@operato/event-view 1.0.0-beta.12 → 1.0.0-beta.13

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.0-beta.13](https://github.com/hatiolab/operato/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2022-05-19)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * add calenadar-weekly ([fbb5a4c](https://github.com/hatiolab/operato/commit/fbb5a4c3499a7a2cd53c5d3a394d8cadd4fb6370))
12
+ * add calendar-weekly ([0e1ad3c](https://github.com/hatiolab/operato/commit/0e1ad3c5bc8b2637c7a68471dfd13534c7f6ac39))
13
+
14
+
15
+ ### :bug: Bug Fix
16
+
17
+ * incorrect package.json scripts for storybooks ([8c8c405](https://github.com/hatiolab/operato/commit/8c8c405443247108b9c411b8161c008d9b6a2261))
18
+ * storybook for event-view ([8c17c66](https://github.com/hatiolab/operato/commit/8c17c66f5d7049afcb8823a170b6c8551fd38898))
19
+ * storybook for event-view ([2f65f70](https://github.com/hatiolab/operato/commit/2f65f701a14989596e01ab8837be7523f20ebaca))
20
+ * storybook for event-view ([de92485](https://github.com/hatiolab/operato/commit/de924859e7987915ea2d402179600a91ce1baa74))
21
+
22
+
23
+
6
24
  ## [1.0.0-beta.12](https://github.com/hatiolab/operato/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2022-05-13)
7
25
 
8
26
 
package/demo/index.html CHANGED
@@ -16,13 +16,12 @@
16
16
  </head>
17
17
  <body>
18
18
  <div id="demo"></div>
19
-
20
19
  <script type="module">
21
20
  import { html, render } from 'lit'
22
21
  import '../dist/src/event-view.js'
23
22
 
24
23
  const title = 'Hello owc World!'
25
- render(html` <event-view> </event-view> `, document.querySelector('#demo'))
24
+ render(html` <event-view .monthly=${false}> </event-view> `, document.querySelector('#demo'))
26
25
  </script>
27
26
  </body>
28
27
  </html>
@@ -2,4 +2,5 @@ export declare type BizEvent = {
2
2
  due?: string;
3
3
  title: string;
4
4
  color: string;
5
+ clickEvent?: any;
5
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"biz-event.js","sourceRoot":"","sources":["../../src/biz-event.ts"],"names":[],"mappings":"","sourcesContent":["import { property } from 'lit/decorators.js'\n\nexport type BizEvent = {\n due?: string\n title: string\n color: string\n}\n"]}
1
+ {"version":3,"file":"biz-event.js","sourceRoot":"","sources":["../../src/biz-event.ts"],"names":[],"mappings":"","sourcesContent":["export type BizEvent = {\n due?: string\n title: string\n color: string\n clickEvent?: any\n}\n"]}
@@ -20,6 +20,7 @@ let CalendarMonthly = class CalendarMonthly extends LitElement {
20
20
  this.year = dayjs().year();
21
21
  this.month = dayjs().month();
22
22
  }
23
+ static { this.styles = [CalendarMonthlyStyles]; }
23
24
  render() {
24
25
  const currentMonth = this.createDaysForCurrentMonth(this.year, this.month);
25
26
  const calendar = [
@@ -69,8 +70,7 @@ let CalendarMonthly = class CalendarMonthly extends LitElement {
69
70
  }
70
71
  updated(changes) { }
71
72
  findEvents(date) {
72
- var _a;
73
- return ((_a = this.eventProvider) === null || _a === void 0 ? void 0 : _a.fetchEventsForDate(date, {})) || [];
73
+ return this.eventProvider?.fetchEventsForDate(date, {}) || [];
74
74
  }
75
75
  moveTo(month) {
76
76
  this.year = month.year();
@@ -119,7 +119,6 @@ let CalendarMonthly = class CalendarMonthly extends LitElement {
119
119
  });
120
120
  }
121
121
  };
122
- CalendarMonthly.styles = [CalendarMonthlyStyles];
123
122
  __decorate([
124
123
  property({ type: Number })
125
124
  ], CalendarMonthly.prototype, "year", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"calendar-monthly.js","sourceRoot":"","sources":["../../src/calendar-monthly.ts"],"names":[],"mappings":";AAAA,OAAO,KAAgB,MAAM,iBAAiB,CAAA;AAC9C,OAAO,OAAO,MA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AAE,KAAK,EAAE,EAAE;YACrE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;YACrE,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAChF,OAAO;gBACL,IAAI;gBACJ,KAAK;gBACL,SAAS,EAAE,KAAK;gBAChB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;aACrB,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAxHQ,sBAAM,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgC;AAChC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;sDAA8B;AAL7C,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAyH3B;SAzHY,eAAe","sourcesContent":["import dayjs, { Dayjs } from 'dayjs/esm/index'\nimport weekday from 'dayjs/esm/plugin/weekday'\nimport weekOfYear from 'dayjs/esm/plugin/weekOfYear'\nimport { html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { BizEvent } from './biz-event'\nimport { CalendarMonthlyStyles } from './calendar-monthly-styles'\nimport { EventProvider } from './event-provider'\n\ndayjs.extend(weekday)\ndayjs.extend(weekOfYear)\n\nconst WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n\nfunction isToday(date: Date) {\n const today = new Date()\n return (\n date.getDate() == today.getDate() &&\n date.getMonth() == today.getMonth() &&\n date.getFullYear() == today.getFullYear()\n )\n}\n\ntype CALENDAR = {\n label: string\n date: Date\n thisMonth: boolean\n today?: boolean\n}[]\n\n@customElement('calendar-monthly')\nexport class CalendarMonthly extends LitElement {\n static styles = [CalendarMonthlyStyles]\n\n @property({ type: Number }) year: number = dayjs().year()\n @property({ type: Number }) month: number = dayjs().month()\n @property({ type: Array }) eventProvider?: EventProvider\n\n render() {\n const currentMonth = this.createDaysForCurrentMonth(this.year, this.month)\n\n const calendar = [\n ...this.createDaysForPreviousMonth(this.year, this.month, currentMonth),\n ...currentMonth,\n ...this.createDaysForNextMonth(this.year, this.month, currentMonth)\n ]\n\n return html`\n <div head>\n <div this-month><b>${dayjs(new Date(this.year, this.month)).format('MMMM')}</b> ${this.year}</div>\n\n <div nav>\n <mwc-button\n outlined\n @click=${() => {\n this.moveTo(dayjs(new Date(this.year, this.month, 1)).subtract(1, 'month'))\n }}\n ><</mwc-button\n >\n <mwc-button\n @click=${() => {\n this.moveTo(dayjs(new Date(dayjs().year(), dayjs().month(), 1)))\n }}\n >Today</mwc-button\n >\n <mwc-button\n @click=${() => {\n this.moveTo(dayjs(new Date(this.year, this.month, 1)).add(1, 'month'))\n }}\n >></mwc-button\n >\n </div>\n </div>\n\n <ol>\n ${WEEKDAYS.map(date => html` <li day-of-week>${date}</li> `)}\n ${calendar.map(\n date => html`\n <li ?today=${date.today} ?current-month=${date.thisMonth} date>\n <span date-label>${date.label}</span>\n <div>\n ${this.findEvents(date.date).map(\n event => html`<span event .style=\"border-color: ${event.color};\">${event.title}</span>`\n )}\n </div>\n </li>\n `\n )}\n </ol>\n `\n }\n\n updated(changes: PropertyValues<this>) {}\n\n findEvents(date: Date): BizEvent[] {\n return this.eventProvider?.fetchEventsForDate(date, {}) || []\n }\n\n moveTo(month: Dayjs) {\n this.year = month.year()\n this.month = month.month()\n }\n\n createDaysForCurrentMonth(year: number, month: number): CALENDAR {\n return [...Array(dayjs(new Date(year, month, 1)).daysInMonth())].map((day, index) => {\n const date = new Date(year, month, index + 1)\n const label = index == 0 ? dayjs(date).format('MMM D') : dayjs(date).format('D')\n return {\n date,\n label,\n thisMonth: true,\n today: isToday(date)\n }\n })\n }\n\n createDaysForPreviousMonth(year: number, month: number, currentMonth: CALENDAR): CALENDAR {\n const previousMonth = dayjs(new Date(year, month, 1)).subtract(1, 'month')\n\n const visibleNumberOfDaysFromPreviousMonth = (dayjs(currentMonth[0].date) as any).weekday()\n\n const previousMonthLastMondayDayOfMonth = dayjs(currentMonth[0].date)\n .subtract(visibleNumberOfDaysFromPreviousMonth, 'day')\n .date()\n\n return [...Array(visibleNumberOfDaysFromPreviousMonth)].map((day, index) => {\n const date = new Date(previousMonth.year(), previousMonth.month(), previousMonthLastMondayDayOfMonth + index)\n return {\n date,\n label: dayjs(date).format('D'),\n thisMonth: false,\n today: isToday(date)\n }\n })\n }\n\n createDaysForNextMonth(year: number, month: number, currentMonth: CALENDAR): CALENDAR {\n const nextMonth = dayjs(new Date(year, month, 1)).add(1, 'month')\n\n const visibleNumberOfDaysFromNextMonth = 6 - (dayjs(new Date(year, month, currentMonth.length)) as any).weekday()\n\n return [...Array(visibleNumberOfDaysFromNextMonth)].map((day, index) => {\n const date = new Date(nextMonth.year(), nextMonth.month(), index + 1)\n const label = index == 0 ? dayjs(date).format('MMM D') : dayjs(date).format('D')\n return {\n date,\n label,\n thisMonth: false,\n today: isToday(date)\n }\n })\n }\n}\n"]}
1
+ {"version":3,"file":"calendar-monthly.js","sourceRoot":"","sources":["../../src/calendar-monthly.ts"],"names":[],"mappings":";AAAA,OAAO,KAAgB,MAAM,iBAAiB,CAAA;AAC9C,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,QA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EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;YACrE,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAChF,OAAO;gBACL,IAAI;gBACJ,KAAK;gBACL,SAAS,EAAE,KAAK;gBAChB,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;aACrB,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAtH6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgC;AAChC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;sDAA8B;AAL7C,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAyH3B;SAzHY,eAAe","sourcesContent":["import dayjs, { Dayjs } from 'dayjs/esm/index'\nimport weekday from 'dayjs/esm/plugin/weekday'\nimport weekOfYear from 'dayjs/esm/plugin/weekOfYear'\nimport { html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { BizEvent } from './biz-event'\nimport { CalendarMonthlyStyles } from './calendar-monthly-styles'\nimport { EventProvider } from './event-provider'\n\ndayjs.extend(weekday)\ndayjs.extend(weekOfYear)\n\nconst WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n\nfunction isToday(date: Date) {\n const today = new Date()\n return (\n date.getDate() == today.getDate() &&\n date.getMonth() == today.getMonth() &&\n date.getFullYear() == today.getFullYear()\n )\n}\n\ntype CALENDAR = {\n label: string\n date: Date\n thisMonth: boolean\n today?: boolean\n}[]\n\n@customElement('calendar-monthly')\nexport class CalendarMonthly extends LitElement {\n static styles = [CalendarMonthlyStyles]\n\n @property({ type: Number }) year: number = dayjs().year()\n @property({ type: Number }) month: number = dayjs().month()\n @property({ type: Array }) eventProvider?: EventProvider\n\n render() {\n const currentMonth = this.createDaysForCurrentMonth(this.year, this.month)\n\n const calendar = [\n ...this.createDaysForPreviousMonth(this.year, this.month, currentMonth),\n ...currentMonth,\n ...this.createDaysForNextMonth(this.year, this.month, currentMonth)\n ]\n\n return html`\n <div head>\n <div this-month><b>${dayjs(new Date(this.year, this.month)).format('MMMM')}</b> ${this.year}</div>\n\n <div nav>\n <mwc-button\n outlined\n @click=${() => {\n this.moveTo(dayjs(new Date(this.year, this.month, 1)).subtract(1, 'month'))\n }}\n ><</mwc-button\n >\n <mwc-button\n @click=${() => {\n this.moveTo(dayjs(new Date(dayjs().year(), dayjs().month(), 1)))\n }}\n >Today</mwc-button\n >\n <mwc-button\n @click=${() => {\n this.moveTo(dayjs(new Date(this.year, this.month, 1)).add(1, 'month'))\n }}\n >></mwc-button\n >\n </div>\n </div>\n\n <ol>\n ${WEEKDAYS.map(date => html` <li day-of-week>${date}</li> `)}\n ${calendar.map(\n date => html`\n <li ?today=${date.today} ?current-month=${date.thisMonth} date>\n <span date-label>${date.label}</span>\n <div>\n ${this.findEvents(date.date).map(\n event => html`<span event .style=\"border-color: ${event.color};\">${event.title}</span>`\n )}\n </div>\n </li>\n `\n )}\n </ol>\n `\n }\n\n updated(changes: PropertyValues<this>) {}\n\n findEvents(date: Date): BizEvent[] {\n return this.eventProvider?.fetchEventsForDate(date, {}) || []\n }\n\n moveTo(month: Dayjs) {\n this.year = month.year()\n this.month = month.month()\n }\n\n createDaysForCurrentMonth(year: number, month: number): CALENDAR {\n return [...Array(dayjs(new Date(year, month, 1)).daysInMonth())].map((day, index) => {\n const date = new Date(year, month, index + 1)\n const label = index == 0 ? dayjs(date).format('MMM D') : dayjs(date).format('D')\n return {\n date,\n label,\n thisMonth: true,\n today: isToday(date)\n }\n })\n }\n\n createDaysForPreviousMonth(year: number, month: number, currentMonth: CALENDAR): CALENDAR {\n const previousMonth = dayjs(new Date(year, month, 1)).subtract(1, 'month')\n\n const visibleNumberOfDaysFromPreviousMonth = (dayjs(currentMonth[0].date) as any).weekday()\n\n const previousMonthLastMondayDayOfMonth = dayjs(currentMonth[0].date)\n .subtract(visibleNumberOfDaysFromPreviousMonth, 'day')\n .date()\n\n return [...Array(visibleNumberOfDaysFromPreviousMonth)].map((day, index) => {\n const date = new Date(previousMonth.year(), previousMonth.month(), previousMonthLastMondayDayOfMonth + index)\n return {\n date,\n label: dayjs(date).format('D'),\n thisMonth: false,\n today: isToday(date)\n }\n })\n }\n\n createDaysForNextMonth(year: number, month: number, currentMonth: CALENDAR): CALENDAR {\n const nextMonth = dayjs(new Date(year, month, 1)).add(1, 'month')\n\n const visibleNumberOfDaysFromNextMonth = 6 - (dayjs(new Date(year, month, currentMonth.length)) as any).weekday()\n\n return [...Array(visibleNumberOfDaysFromNextMonth)].map((day, index) => {\n const date = new Date(nextMonth.year(), nextMonth.month(), index + 1)\n const label = index == 0 ? dayjs(date).format('MMM D') : dayjs(date).format('D')\n return {\n date,\n label,\n thisMonth: false,\n today: isToday(date)\n }\n })\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const CalendarWeeklyStyles: import("lit").CSSResult;
@@ -0,0 +1,94 @@
1
+ import { css } from 'lit';
2
+ export const CalendarWeeklyStyles = css `
3
+ :host {
4
+ display: flex;
5
+ flex-direction: column;
6
+ color: var(--calendar-weekly-text-color, #585858);
7
+ }
8
+
9
+ [head] {
10
+ display: flex;
11
+ align-items: center;
12
+ }
13
+
14
+ [head-week] {
15
+ display: flex;
16
+ align-items: left;
17
+ }
18
+
19
+ [this-week] {
20
+ font-size: x-large;
21
+ }
22
+
23
+ [nav] {
24
+ margin-left: auto;
25
+ }
26
+
27
+ ol {
28
+ flex: 1;
29
+
30
+ display: grid;
31
+ grid-template-columns: repeat(7, 1fr);
32
+ grid-template-rows: max-content;
33
+
34
+ padding: 0;
35
+ margin: var(--calendar-weekly-ol-margin, 9px 0);
36
+ border-top: var(--calendar-weekly-ol-top-border, 3px solid #999);
37
+ }
38
+
39
+ li {
40
+ position: relative;
41
+
42
+ list-style: none;
43
+ border: var(--calendar-weekly-border, 1px solid rgba(0, 0, 0, 0.1));
44
+ border-width: var(--calendar-weekly-border-width, 0 1px 1px 0px);
45
+ opacity: var(--calendar-weekly-opacity);
46
+ }
47
+ li:nth-child(7n + 1) {
48
+ border-left-width: 1px;
49
+ }
50
+
51
+ li[day-of-week] {
52
+ opacity: 1;
53
+ background-color: var(--calendar-current-week-background-color, #fff);
54
+ padding: var(--calendar-weekly-label-padding);
55
+ color: rgba(var(--secondary-color-rgb), 0.8);
56
+ text-align: center;
57
+ }
58
+
59
+ li[current-week] {
60
+ background-color: var(--calendar-current-monthly-background-color, #fff);
61
+ opacity: 1;
62
+ }
63
+
64
+ span[date-label] {
65
+ display: block;
66
+ margin: var(--calendar-weekly-date-label-margin);
67
+ text-align: var(--calendar-weekly-label-align, center);
68
+ }
69
+
70
+ li[today] > span[date-label] {
71
+ display: inline-block;
72
+ background-color: var(--calendar-weekly-date-label-background-color, #cc3300);
73
+ padding: var(--calendar-weekly-date-label-padding);
74
+ border-radius: var(--calendar-weekly-date-label-border-radius, 50%);
75
+ color: var(--calendar-weekly-date-label-color, #fff);
76
+ min-width: 16px;
77
+ text-align: center;
78
+ }
79
+
80
+ [date] div {
81
+ display: block;
82
+ font-size: small;
83
+ }
84
+
85
+ [event] {
86
+ display: block;
87
+ background-color: var(--calendar-weekly-background-color);
88
+ border: var(--calendar-weekly-event-border);
89
+ border-width: var(--calendar-weekly-event-border-width);
90
+ margin: var(--calendar-weekly-event-margin, 0 0 4px 0);
91
+ padding: var(--calendar-weekly-event-padding, 2px 4px 2px 4px);
92
+ }
93
+ `;
94
+ //# sourceMappingURL=calendar-weekly-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-weekly-styles.js","sourceRoot":"","sources":["../../src/calendar-weekly-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2FtC,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport const CalendarWeeklyStyles = css`\n :host {\n display: flex;\n flex-direction: column;\n color: var(--calendar-weekly-text-color, #585858);\n }\n\n [head] {\n display: flex;\n align-items: center;\n }\n\n [head-week] {\n display: flex;\n align-items: left;\n }\n\n [this-week] {\n font-size: x-large;\n }\n\n [nav] {\n margin-left: auto;\n }\n\n ol {\n flex: 1;\n\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n grid-template-rows: max-content;\n\n padding: 0;\n margin: var(--calendar-weekly-ol-margin, 9px 0);\n border-top: var(--calendar-weekly-ol-top-border, 3px solid #999);\n }\n\n li {\n position: relative;\n\n list-style: none;\n border: var(--calendar-weekly-border, 1px solid rgba(0, 0, 0, 0.1));\n border-width: var(--calendar-weekly-border-width, 0 1px 1px 0px);\n opacity: var(--calendar-weekly-opacity);\n }\n li:nth-child(7n + 1) {\n border-left-width: 1px;\n }\n\n li[day-of-week] {\n opacity: 1;\n background-color: var(--calendar-current-week-background-color, #fff);\n padding: var(--calendar-weekly-label-padding);\n color: rgba(var(--secondary-color-rgb), 0.8);\n text-align: center;\n }\n\n li[current-week] {\n background-color: var(--calendar-current-monthly-background-color, #fff);\n opacity: 1;\n }\n\n span[date-label] {\n display: block;\n margin: var(--calendar-weekly-date-label-margin);\n text-align: var(--calendar-weekly-label-align, center);\n }\n\n li[today] > span[date-label] {\n display: inline-block;\n background-color: var(--calendar-weekly-date-label-background-color, #cc3300);\n padding: var(--calendar-weekly-date-label-padding);\n border-radius: var(--calendar-weekly-date-label-border-radius, 50%);\n color: var(--calendar-weekly-date-label-color, #fff);\n min-width: 16px;\n text-align: center;\n }\n\n [date] div {\n display: block;\n font-size: small;\n }\n\n [event] {\n display: block;\n background-color: var(--calendar-weekly-background-color);\n border: var(--calendar-weekly-event-border);\n border-width: var(--calendar-weekly-event-border-width);\n margin: var(--calendar-weekly-event-margin, 0 0 4px 0);\n padding: var(--calendar-weekly-event-padding, 2px 4px 2px 4px);\n }\n`\n"]}
@@ -0,0 +1,24 @@
1
+ import { Dayjs } from 'dayjs/esm/index';
2
+ import { LitElement, PropertyValues } from 'lit';
3
+ import { BizEvent } from './biz-event';
4
+ import { EventProvider } from './event-provider';
5
+ declare type CALENDAR = {
6
+ label: string;
7
+ date: Date;
8
+ thisWeek: boolean;
9
+ today?: boolean;
10
+ }[];
11
+ export declare class CalendarWeekly extends LitElement {
12
+ static styles: import("lit").CSSResult[];
13
+ year: number;
14
+ month: number;
15
+ week: number;
16
+ eventProvider?: EventProvider;
17
+ render(): import("lit-html").TemplateResult<1>;
18
+ updated(changes: PropertyValues<this>): void;
19
+ findEvents(date: Date): BizEvent[];
20
+ moveTo(year: number, month: number, week: number): void;
21
+ getLastDateOfWeek(year: number, week: number): Dayjs;
22
+ createDaysForCurrentWeek(year: number, week: number): CALENDAR;
23
+ }
24
+ export {};
@@ -0,0 +1,129 @@
1
+ import { __decorate } from "tslib";
2
+ import dayjs from 'dayjs/esm/index';
3
+ import weekday from 'dayjs/esm/plugin/weekday';
4
+ import weekOfYear from 'dayjs/esm/plugin/weekOfYear';
5
+ import { html, LitElement } from 'lit';
6
+ import { customElement, property } from 'lit/decorators.js';
7
+ import { CalendarWeeklyStyles } from './calendar-weekly-styles';
8
+ dayjs.extend(weekday);
9
+ dayjs.extend(weekOfYear);
10
+ const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
11
+ function isToday(date) {
12
+ const today = new Date();
13
+ return (date.getDate() == today.getDate() &&
14
+ date.getMonth() == today.getMonth() &&
15
+ date.getFullYear() == today.getFullYear());
16
+ }
17
+ let CalendarWeekly = class CalendarWeekly extends LitElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.year = dayjs().year();
21
+ this.month = dayjs().month();
22
+ this.week = dayjs().week();
23
+ }
24
+ static { this.styles = [CalendarWeeklyStyles]; }
25
+ render() {
26
+ const calendar = this.createDaysForCurrentWeek(this.year, this.week);
27
+ return html `
28
+ <div head>
29
+ <div this-week><b>${dayjs(new Date(this.year, this.month)).format('MMMM')}</b> ${this.year}</div>
30
+
31
+ <div nav>
32
+ <mwc-button
33
+ outlined
34
+ @click=${() => {
35
+ const dayJs = this.getLastDateOfWeek(this.year, this.week);
36
+ const prevWeek = dayJs.subtract(1, 'week');
37
+ this.moveTo(prevWeek.year(), prevWeek.month(), prevWeek.week());
38
+ }}
39
+ ><</mwc-button
40
+ >
41
+ <mwc-button
42
+ @click=${() => {
43
+ this.moveTo(dayjs().year(), dayjs().month(), dayjs().week());
44
+ }}
45
+ >Today</mwc-button
46
+ >
47
+ <mwc-button
48
+ @click=${() => {
49
+ const dayJs = this.getLastDateOfWeek(this.year, this.week);
50
+ const nextWeek = dayJs.add(1, 'week');
51
+ this.moveTo(nextWeek.year(), nextWeek.month(), nextWeek.week());
52
+ }}
53
+ >></mwc-button
54
+ >
55
+ </div>
56
+ </div>
57
+ <div head-week>
58
+ <div this-week><b>Week ${this.week}</b></div>
59
+ </div>
60
+
61
+ <ol>
62
+ ${calendar.map((date, index) => {
63
+ return html `
64
+ <li ?today=${date.today} day-of-week><span date-label>${date.label}(${WEEKDAYS[index]})</span></li>
65
+ `;
66
+ })}
67
+ ${calendar.map(date => {
68
+ return html `<li day-task>
69
+ <div>
70
+ ${this.findEvents(date.date).map(event => html `<span
71
+ @click=${() => event.clickEvent(event.title, event.due)}
72
+ event
73
+ .style="border-color: ${event.color};"
74
+ >${event.title}</span
75
+ >`)}
76
+ </div>
77
+ </li>`;
78
+ })}
79
+ </ol>
80
+ `;
81
+ }
82
+ updated(changes) { }
83
+ findEvents(date) {
84
+ return this.eventProvider?.fetchEventsForDate(date, {}) || [];
85
+ }
86
+ moveTo(year, month, week) {
87
+ this.year = year;
88
+ this.month = month;
89
+ this.week = week;
90
+ }
91
+ getLastDateOfWeek(year, week) {
92
+ const firstWeekLastDay = dayjs(new Date(year, 0, 1)).endOf('w');
93
+ week -= 1; // one-based week, so need the minus-one
94
+ return firstWeekLastDay.add(week, 'w');
95
+ }
96
+ createDaysForCurrentWeek(year, week) {
97
+ const lastDayjs = this.getLastDateOfWeek(year, week);
98
+ const weekDays = 7;
99
+ return [...Array(weekDays)]
100
+ .map((day, index) => {
101
+ const date = new Date(lastDayjs.year(), lastDayjs.month(), lastDayjs.date() - index);
102
+ const label = dayjs(date).format('MM-DD');
103
+ return {
104
+ date,
105
+ label,
106
+ thisWeek: true,
107
+ today: isToday(date)
108
+ };
109
+ })
110
+ .reverse();
111
+ }
112
+ };
113
+ __decorate([
114
+ property({ type: Number })
115
+ ], CalendarWeekly.prototype, "year", void 0);
116
+ __decorate([
117
+ property({ type: Number })
118
+ ], CalendarWeekly.prototype, "month", void 0);
119
+ __decorate([
120
+ property({ type: Number })
121
+ ], CalendarWeekly.prototype, "week", void 0);
122
+ __decorate([
123
+ property({ type: Array })
124
+ ], CalendarWeekly.prototype, "eventProvider", void 0);
125
+ CalendarWeekly = __decorate([
126
+ customElement('calendar-weekly')
127
+ ], CalendarWeekly);
128
+ export { CalendarWeekly };
129
+ //# sourceMappingURL=calendar-weekly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-weekly.js","sourceRoot":"","sources":["../../src/calendar-weekly.ts"],"names":[],"mappings":";AAAA,OAAO,KAAgB,MAAM,iBAAiB,CAAA;AAC9C,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AACtD,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S,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAA;YACpF,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YACzC,OAAO;gBACL,IAAI;gBACJ,KAAK;gBACL,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC;aACrB,CAAA;QACH,CAAC,CAAC;aACD,OAAO,EAAE,CAAA;IACd,CAAC;CACF,CAAA;AAtG6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAC9B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAA8B;AAN7C,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAyG1B;SAzGY,cAAc","sourcesContent":["import dayjs, { Dayjs } from 'dayjs/esm/index'\nimport weekday from 'dayjs/esm/plugin/weekday'\nimport weekOfYear from 'dayjs/esm/plugin/weekOfYear'\nimport { html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { BizEvent } from './biz-event'\nimport { CalendarWeeklyStyles } from './calendar-weekly-styles'\nimport { EventProvider } from './event-provider'\n\ndayjs.extend(weekday)\ndayjs.extend(weekOfYear)\n\nconst WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n\nfunction isToday(date: Date) {\n const today = new Date()\n return (\n date.getDate() == today.getDate() &&\n date.getMonth() == today.getMonth() &&\n date.getFullYear() == today.getFullYear()\n )\n}\n\ntype CALENDAR = {\n label: string\n date: Date\n thisWeek: boolean\n today?: boolean\n}[]\n\n@customElement('calendar-weekly')\nexport class CalendarWeekly extends LitElement {\n static styles = [CalendarWeeklyStyles]\n\n @property({ type: Number }) year: number = dayjs().year()\n @property({ type: Number }) month: number = dayjs().month()\n @property({ type: Number }) week: number = dayjs().week()\n @property({ type: Array }) eventProvider?: EventProvider\n\n render() {\n const calendar = this.createDaysForCurrentWeek(this.year, this.week)\n\n return html`\n <div head>\n <div this-week><b>${dayjs(new Date(this.year, this.month)).format('MMMM')}</b> ${this.year}</div>\n\n <div nav>\n <mwc-button\n outlined\n @click=${() => {\n const dayJs = this.getLastDateOfWeek(this.year, this.week)\n const prevWeek = dayJs.subtract(1, 'week')\n this.moveTo(prevWeek.year(), prevWeek.month(), prevWeek.week())\n }}\n ><</mwc-button\n >\n <mwc-button\n @click=${() => {\n this.moveTo(dayjs().year(), dayjs().month(), dayjs().week())\n }}\n >Today</mwc-button\n >\n <mwc-button\n @click=${() => {\n const dayJs = this.getLastDateOfWeek(this.year, this.week)\n const nextWeek = dayJs.add(1, 'week')\n this.moveTo(nextWeek.year(), nextWeek.month(), nextWeek.week())\n }}\n >></mwc-button\n >\n </div>\n </div>\n <div head-week>\n <div this-week><b>Week ${this.week}</b></div>\n </div>\n\n <ol>\n ${calendar.map((date, index) => {\n return html`\n <li ?today=${date.today} day-of-week><span date-label>${date.label}(${WEEKDAYS[index]})</span></li>\n `\n })}\n ${calendar.map(date => {\n return html`<li day-task>\n <div>\n ${this.findEvents(date.date).map(\n event =>\n html`<span\n @click=${() => event.clickEvent(event.title, event.due)}\n event\n .style=\"border-color: ${event.color};\"\n >${event.title}</span\n >`\n )}\n </div>\n </li>`\n })}\n </ol>\n `\n }\n\n updated(changes: PropertyValues<this>) {}\n\n findEvents(date: Date): BizEvent[] {\n return this.eventProvider?.fetchEventsForDate(date, {}) || []\n }\n\n moveTo(year: number, month: number, week: number) {\n this.year = year\n this.month = month\n this.week = week\n }\n\n getLastDateOfWeek(year: number, week: number): Dayjs {\n const firstWeekLastDay = dayjs(new Date(year, 0, 1)).endOf('w')\n week -= 1 // one-based week, so need the minus-one\n return firstWeekLastDay.add(week, 'w')\n }\n\n createDaysForCurrentWeek(year: number, week: number): CALENDAR {\n const lastDayjs = this.getLastDateOfWeek(year, week)\n const weekDays = 7\n\n return [...Array(weekDays)]\n .map((day, index) => {\n const date = new Date(lastDayjs.year(), lastDayjs.month(), lastDayjs.date() - index)\n const label = dayjs(date).format('MM-DD')\n return {\n date,\n label,\n thisWeek: true,\n today: isToday(date)\n }\n })\n .reverse()\n }\n}\n"]}
@@ -1,6 +1,8 @@
1
1
  import './calendar-monthly';
2
+ import './calendar-weekly';
2
3
  import { LitElement } from 'lit';
3
4
  export declare class EventView extends LitElement {
4
5
  static styles: import("lit").CSSResult;
6
+ format: string;
5
7
  render(): import("lit-html").TemplateResult<1>;
6
8
  }
@@ -1,26 +1,36 @@
1
1
  import { __decorate } from "tslib";
2
2
  import './calendar-monthly';
3
- import { LitElement, css, html } from 'lit';
4
- import { customElement } from 'lit/decorators.js';
5
- import { SampleEventProvider } from './sample-event-provider';
3
+ import './calendar-weekly';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { customElement, property } from 'lit/decorators.js';
6
+ import { SampleMonthlyEventProvider, SampleWeeklyEventProvider } from './sample-event-provider';
6
7
  let EventView = class EventView extends LitElement {
7
- render() {
8
- return html ` <calendar-monthly .eventProvider=${new SampleEventProvider()}></calendar-monthly> `;
8
+ constructor() {
9
+ super(...arguments);
10
+ this.format = 'monthly';
9
11
  }
10
- };
11
- EventView.styles = css `
12
+ static { this.styles = css `
12
13
  :host {
13
14
  display: flex;
14
15
  flex-direction: column;
15
16
  }
16
17
 
17
- calendar-monthly {
18
+ calendar-weekly {
18
19
  flex: 1;
19
20
 
20
21
  padding: 0;
21
22
  margin: 0;
22
23
  }
23
- `;
24
+ `; }
25
+ render() {
26
+ return this.format == 'weekly'
27
+ ? html ` <calendar-weekly .eventProvider=${new SampleWeeklyEventProvider()}></calendar-weekly> `
28
+ : html ` <calendar-monthly .eventProvider=${new SampleMonthlyEventProvider()}></calendar-monthly> `;
29
+ }
30
+ };
31
+ __decorate([
32
+ property({ type: String })
33
+ ], EventView.prototype, "format", void 0);
24
34
  EventView = __decorate([
25
35
  customElement('event-view')
26
36
  ], EventView);
@@ -1 +1 @@
1
- {"version":3,"file":"event-view.js","sourceRoot":"","sources":["../../src/event-view.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAY,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAG7D,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAevC,MAAM;QACJ,OAAO,IAAI,CAAA,qCAAqC,IAAI,mBAAmB,EAAE,uBAAuB,CAAA;IAClG,CAAC;CACF,CAAA;AAjBQ,gBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;GAYlB,CAAA;AAbU,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAkBrB;SAlBY,SAAS","sourcesContent":["import './calendar-monthly'\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { SampleEventProvider } from './sample-event-provider'\n\n@customElement('event-view')\nexport class EventView extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n }\n\n calendar-monthly {\n flex: 1;\n\n padding: 0;\n margin: 0;\n }\n `\n\n render() {\n return html` <calendar-monthly .eventProvider=${new SampleEventProvider()}></calendar-monthly> `\n }\n}\n"]}
1
+ {"version":3,"file":"event-view.js","sourceRoot":"","sources":["../../src/event-view.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,mBAAmB,CAAA;AAE1B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAG/F,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAAzC;;QAe8B,WAAM,GAAW,SAAS,CAAA;IAOxD,CAAC;aArBQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;GAYlB,CAAA;IAID,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,IAAI,QAAQ;YAC5B,CAAC,CAAC,IAAI,CAAA,oCAAoC,IAAI,yBAAyB,EAAE,sBAAsB;YAC/F,CAAC,CAAC,IAAI,CAAA,qCAAqC,IAAI,0BAA0B,EAAE,uBAAuB,CAAA;IACtG,CAAC;CACF,CAAA;AAP6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAA2B;AAf3C,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAsBrB;SAtBY,SAAS","sourcesContent":["import './calendar-monthly'\nimport './calendar-weekly'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { SampleMonthlyEventProvider, SampleWeeklyEventProvider } from './sample-event-provider'\n\n@customElement('event-view')\nexport class EventView extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n }\n\n calendar-weekly {\n flex: 1;\n\n padding: 0;\n margin: 0;\n }\n `\n\n @property({ type: String }) format: string = 'monthly'\n\n render() {\n return this.format == 'weekly'\n ? html` <calendar-weekly .eventProvider=${new SampleWeeklyEventProvider()}></calendar-weekly> `\n : html` <calendar-monthly .eventProvider=${new SampleMonthlyEventProvider()}></calendar-monthly> `\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { EventProvider } from './event-provider';
2
- export declare class SampleEventProvider implements EventProvider {
2
+ export declare class SampleMonthlyEventProvider implements EventProvider {
3
3
  fetchEventsForDate(date: Date, options: any): {
4
4
  due: string;
5
5
  title: string;
@@ -7,3 +7,17 @@ export declare class SampleEventProvider implements EventProvider {
7
7
  }[];
8
8
  fetchEventsForDuration(from: Date, to: Date, options: any): never[];
9
9
  }
10
+ export declare class SampleWeeklyEventProvider implements EventProvider {
11
+ fetchEventsForDate(date: Date, options: any): ({
12
+ due: string;
13
+ title: string;
14
+ color: string;
15
+ clickEvent: (title: string, due: string) => void;
16
+ } | {
17
+ due: string;
18
+ title: string;
19
+ color: string;
20
+ clickEvent?: undefined;
21
+ })[];
22
+ fetchEventsForDuration(from: Date, to: Date, options: any): never[];
23
+ }
@@ -1,4 +1,4 @@
1
- export class SampleEventProvider {
1
+ export class SampleMonthlyEventProvider {
2
2
  fetchEventsForDate(date, options) {
3
3
  return [
4
4
  {
@@ -52,4 +52,61 @@ export class SampleEventProvider {
52
52
  return [];
53
53
  }
54
54
  }
55
+ export class SampleWeeklyEventProvider {
56
+ fetchEventsForDate(date, options) {
57
+ return [
58
+ {
59
+ due: '2021-08-21',
60
+ title: 'HAHAHA',
61
+ color: 'yellow',
62
+ clickEvent: function (title, due) {
63
+ console.log('clicked...', title, due);
64
+ }
65
+ },
66
+ {
67
+ due: '2021-08-21',
68
+ title: 'HOHOHO',
69
+ color: 'lime'
70
+ },
71
+ {
72
+ due: '2021-08-21',
73
+ title: 'HIHIHI',
74
+ color: 'yellow'
75
+ },
76
+ {
77
+ due: '2021-08-21',
78
+ title: 'HEHEHE',
79
+ color: 'white'
80
+ },
81
+ {
82
+ due: '2021-08-21',
83
+ title: 'KEKEKE',
84
+ color: 'yellow'
85
+ },
86
+ {
87
+ due: '2021-08-21',
88
+ title: 'MEMEME',
89
+ color: 'orange'
90
+ },
91
+ {
92
+ due: '2021-08-21',
93
+ title: 'MOMOMO',
94
+ color: 'lime'
95
+ },
96
+ {
97
+ due: '2021-08-21',
98
+ title: 'QUOQUO',
99
+ color: 'navy'
100
+ },
101
+ {
102
+ due: '2021-08-21',
103
+ title: 'ZZXXCC',
104
+ color: 'gray'
105
+ }
106
+ ];
107
+ }
108
+ fetchEventsForDuration(from, to, options) {
109
+ return [];
110
+ }
111
+ }
55
112
  //# sourceMappingURL=sample-event-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sample-event-provider.js","sourceRoot":"","sources":["../../src/sample-event-provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,mBAAmB;IAC9B,kBAAkB,CAAC,IAAU,EAAE,OAAY;QACzC,OAAO;YACL;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,OAAO;aACf;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;SACF,CAAA;IACH,CAAC;IAED,sBAAsB,CAAC,IAAU,EAAE,EAAQ,EAAE,OAAY;QACvD,OAAO,EAAE,CAAA;IACX,CAAC;CACF","sourcesContent":["import { EventProvider } from './event-provider'\n\nexport class SampleEventProvider implements EventProvider {\n fetchEventsForDate(date: Date, options: any) {\n return [\n {\n due: '2021-08-21',\n title: 'HAHAHA',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'HOHOHO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'HIHIHI',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'HEHEHE',\n color: 'white'\n },\n {\n due: '2021-08-21',\n title: 'KEKEKE',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'MEMEME',\n color: 'orange'\n },\n {\n due: '2021-08-21',\n title: 'MOMOMO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'QUOQUO',\n color: 'navy'\n },\n {\n due: '2021-08-21',\n title: 'ZZXXCC',\n color: 'gray'\n }\n ]\n }\n\n fetchEventsForDuration(from: Date, to: Date, options: any) {\n return []\n }\n}\n"]}
1
+ {"version":3,"file":"sample-event-provider.js","sourceRoot":"","sources":["../../src/sample-event-provider.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,0BAA0B;IACrC,kBAAkB,CAAC,IAAU,EAAE,OAAY;QACzC,OAAO;YACL;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,OAAO;aACf;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,QAAQ;aAChB;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,K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K,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;YACD;gBACE,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,QAAQ;gBACf,KAAK,EAAE,MAAM;aACd;SACF,CAAA;IACH,CAAC;IAED,sBAAsB,CAAC,IAAU,EAAE,EAAQ,EAAE,OAAY;QACvD,OAAO,EAAE,CAAA;IACX,CAAC;CACF","sourcesContent":["import { EventProvider } from './event-provider'\n\nexport class SampleMonthlyEventProvider implements EventProvider {\n fetchEventsForDate(date: Date, options: any) {\n return [\n {\n due: '2021-08-21',\n title: 'HAHAHA',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'HOHOHO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'HIHIHI',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'HEHEHE',\n color: 'white'\n },\n {\n due: '2021-08-21',\n title: 'KEKEKE',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'MEMEME',\n color: 'orange'\n },\n {\n due: '2021-08-21',\n title: 'MOMOMO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'QUOQUO',\n color: 'navy'\n },\n {\n due: '2021-08-21',\n title: 'ZZXXCC',\n color: 'gray'\n }\n ]\n }\n\n fetchEventsForDuration(from: Date, to: Date, options: any) {\n return []\n }\n}\n\nexport class SampleWeeklyEventProvider implements EventProvider {\n fetchEventsForDate(date: Date, options: any) {\n return [\n {\n due: '2021-08-21',\n title: 'HAHAHA',\n color: 'yellow',\n clickEvent: function (title: string, due: string) {\n console.log('clicked...', title, due)\n }\n },\n {\n due: '2021-08-21',\n title: 'HOHOHO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'HIHIHI',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'HEHEHE',\n color: 'white'\n },\n {\n due: '2021-08-21',\n title: 'KEKEKE',\n color: 'yellow'\n },\n {\n due: '2021-08-21',\n title: 'MEMEME',\n color: 'orange'\n },\n {\n due: '2021-08-21',\n title: 'MOMOMO',\n color: 'lime'\n },\n {\n due: '2021-08-21',\n title: 'QUOQUO',\n color: 'navy'\n },\n {\n due: '2021-08-21',\n title: 'ZZXXCC',\n color: 'gray'\n }\n ]\n }\n\n fetchEventsForDuration(from: Date, to: Date, options: any) {\n return []\n }\n}\n"]}
@@ -1,17 +1,13 @@
1
- import { TemplateResult } from 'lit';
2
1
  import '../src/event-view.js';
2
+ import { TemplateResult } from 'lit';
3
3
  declare const _default: {
4
4
  title: string;
5
5
  component: string;
6
6
  argTypes: {
7
- title: {
8
- control: string;
9
- };
10
- counter: {
11
- control: string;
12
- };
13
- textColor: {
7
+ format: {
14
8
  control: string;
9
+ options: string[];
10
+ description: string;
15
11
  };
16
12
  };
17
13
  };
@@ -22,12 +18,7 @@ interface Story<T> {
22
18
  argTypes?: Record<string, unknown>;
23
19
  }
24
20
  interface ArgTypes {
25
- title?: string;
26
- counter?: number;
27
- textColor?: string;
28
- slot?: TemplateResult;
21
+ format?: string;
29
22
  }
30
23
  export declare const Regular: Story<ArgTypes>;
31
- export declare const CustomTitle: Story<ArgTypes>;
32
- export declare const CustomCounter: Story<ArgTypes>;
33
- export declare const SlottedContent: Story<ArgTypes>;
24
+ export declare const WeeklyEventView: Story<ArgTypes>;