@operato/event-view 7.1.15 → 7.1.32
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 +24 -0
- package/dist/src/calendar-monthly-styles.js +16 -4
- package/dist/src/calendar-monthly-styles.js.map +1 -1
- package/dist/src/calendar-monthly.d.ts +5 -0
- package/dist/src/calendar-monthly.js +68 -5
- package/dist/src/calendar-monthly.js.map +1 -1
- package/dist/src/calendar-weekly-styles.js +14 -3
- package/dist/src/calendar-weekly-styles.js.map +1 -1
- package/dist/src/calendar-weekly.d.ts +12 -0
- package/dist/src/calendar-weekly.js +83 -4
- package/dist/src/calendar-weekly.js.map +1 -1
- package/dist/src/ox-event-view.js +2 -1
- package/dist/src/ox-event-view.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/stories/index.stories.d.ts +1 -1
- package/dist/stories/index.stories.js +9 -2
- package/dist/stories/index.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/themes/calendar-theme.css +3 -1
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/index.html +0 -40
- package/src/calendar-monthly-styles.ts +0 -101
- package/src/calendar-monthly.ts +0 -138
- package/src/calendar-weekly-styles.ts +0 -102
- package/src/calendar-weekly.ts +0 -114
- package/src/index.ts +0 -2
- package/src/ox-event-view.ts +0 -46
- package/src/types.ts +0 -38
- package/stories/index.stories.ts +0 -116
- package/tsconfig.json +0 -25
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { css } from 'lit'
|
|
2
|
-
|
|
3
|
-
export const CalendarWeeklyStyles = css`
|
|
4
|
-
:host {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
color: var(--calendar-weekly-text-color, #585858);
|
|
8
|
-
|
|
9
|
-
--md-text-button-container-height: 24px;
|
|
10
|
-
--md-sys-color-primary: rgba(var(--secondary-color-rgb), 0.8);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
[head] {
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
[head-week] {
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: left;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
[this-week] {
|
|
24
|
-
font-size: x-large;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
[nav] {
|
|
28
|
-
margin-left: auto;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
::slotted(*) {
|
|
32
|
-
color: var(--md-sys-color-primary);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
ol {
|
|
36
|
-
flex: 1;
|
|
37
|
-
|
|
38
|
-
display: grid;
|
|
39
|
-
grid-template-columns: repeat(7, 1fr);
|
|
40
|
-
grid-template-rows: max-content;
|
|
41
|
-
|
|
42
|
-
padding: 0;
|
|
43
|
-
margin: var(--calendar-weekly-ol-margin, 9px 0);
|
|
44
|
-
border-top: var(--calendar-weekly-ol-top-border, 3px solid #999);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
li {
|
|
48
|
-
position: relative;
|
|
49
|
-
|
|
50
|
-
list-style: none;
|
|
51
|
-
border: var(--calendar-weekly-border, 1px solid rgba(0, 0, 0, 0.1));
|
|
52
|
-
border-width: var(--calendar-weekly-border-width, 0 1px 1px 0px);
|
|
53
|
-
opacity: var(--calendar-weekly-opacity);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
li:nth-child(7n + 1) {
|
|
57
|
-
border-left-width: 1px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
li[day-of-week] {
|
|
61
|
-
opacity: 1;
|
|
62
|
-
background-color: var(--calendar-current-week-background-color, #fff);
|
|
63
|
-
padding: var(--calendar-weekly-label-padding);
|
|
64
|
-
color: rgba(var(--secondary-color-rgb), 0.8);
|
|
65
|
-
text-align: center;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
li[current-week] {
|
|
69
|
-
background-color: var(--calendar-current-monthly-background-color, #fff);
|
|
70
|
-
opacity: 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
span[date-label] {
|
|
74
|
-
display: block;
|
|
75
|
-
margin: var(--calendar-weekly-date-label-margin);
|
|
76
|
-
text-align: var(--calendar-weekly-label-align, center);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
li[today] > span[date-label] {
|
|
80
|
-
display: inline-block;
|
|
81
|
-
background-color: var(--calendar-weekly-date-label-background-color, #cc3300);
|
|
82
|
-
padding: var(--calendar-weekly-date-label-padding);
|
|
83
|
-
border-radius: var(--calendar-weekly-date-label-border-radius, 999em);
|
|
84
|
-
color: var(--calendar-weekly-date-label-color, #fff);
|
|
85
|
-
min-width: 16px;
|
|
86
|
-
text-align: center;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
[date] div {
|
|
90
|
-
display: block;
|
|
91
|
-
font-size: small;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
[event] {
|
|
95
|
-
display: block;
|
|
96
|
-
background-color: var(--calendar-weekly-background-color);
|
|
97
|
-
border: var(--calendar-weekly-event-border);
|
|
98
|
-
border-width: var(--calendar-weekly-event-border-width);
|
|
99
|
-
margin: var(--calendar-weekly-event-margin, 0 0 4px 0);
|
|
100
|
-
padding: var(--calendar-weekly-event-padding, 2px 4px 2px 4px);
|
|
101
|
-
}
|
|
102
|
-
`
|
package/src/calendar-weekly.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import '@material/web/button/text-button.js'
|
|
2
|
-
|
|
3
|
-
import dayjs, { Dayjs } from 'dayjs/esm/index'
|
|
4
|
-
import { html, LitElement, PropertyValues } from 'lit'
|
|
5
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
6
|
-
|
|
7
|
-
import { CalendarWeeklyStyles } from './calendar-weekly-styles'
|
|
8
|
-
import { BizEvent, CALENDAR, WEEKDAYS, EventProvider, isToday } from './types'
|
|
9
|
-
|
|
10
|
-
@customElement('calendar-weekly')
|
|
11
|
-
export class CalendarWeekly extends LitElement {
|
|
12
|
-
static styles = [CalendarWeeklyStyles]
|
|
13
|
-
|
|
14
|
-
@property({ type: Object }) eventProvider?: EventProvider
|
|
15
|
-
|
|
16
|
-
@state() year: number = dayjs().year()
|
|
17
|
-
@state() month: number = dayjs().month()
|
|
18
|
-
@state() week: number = dayjs().week()
|
|
19
|
-
@state() calendar?: CALENDAR
|
|
20
|
-
@state() eventMap?: Map<Date, BizEvent[]>
|
|
21
|
-
|
|
22
|
-
render() {
|
|
23
|
-
return html`
|
|
24
|
-
<div head>
|
|
25
|
-
<div this-week>
|
|
26
|
-
<b>${dayjs(new Date(this.year, this.month)).format('MMMM')}</b> ${this.year} <b>Week ${this.week}</b>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div nav>
|
|
30
|
-
<md-text-button
|
|
31
|
-
@click=${() => {
|
|
32
|
-
const dayJs = this.getLastDateOfWeek(this.year, this.week)
|
|
33
|
-
const prevWeek = dayJs.subtract(1, 'week')
|
|
34
|
-
this.moveTo(prevWeek.year(), prevWeek.month(), prevWeek.week())
|
|
35
|
-
}}
|
|
36
|
-
><</md-text-button
|
|
37
|
-
>
|
|
38
|
-
<md-text-button
|
|
39
|
-
@click=${() => {
|
|
40
|
-
this.moveTo(dayjs().year(), dayjs().month(), dayjs().week())
|
|
41
|
-
}}
|
|
42
|
-
>Today</md-text-button
|
|
43
|
-
>
|
|
44
|
-
<md-text-button
|
|
45
|
-
@click=${() => {
|
|
46
|
-
const dayJs = this.getLastDateOfWeek(this.year, this.week)
|
|
47
|
-
const nextWeek = dayJs.add(1, 'week')
|
|
48
|
-
this.moveTo(nextWeek.year(), nextWeek.month(), nextWeek.week())
|
|
49
|
-
}}
|
|
50
|
-
>></md-text-button
|
|
51
|
-
>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<slot></slot>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<ol>
|
|
58
|
-
${this.calendar?.map((date, index) => {
|
|
59
|
-
return html`
|
|
60
|
-
<li ?today=${date.today} day-of-week><span date-label>${date.label}(${WEEKDAYS[index]})</span></li>
|
|
61
|
-
`
|
|
62
|
-
})}
|
|
63
|
-
${this.calendar?.map(date => {
|
|
64
|
-
return html`<li date>
|
|
65
|
-
<div>
|
|
66
|
-
${(this.eventMap?.get(date?.date) || []).map(({ title, color, template }) =>
|
|
67
|
-
template ? template : html`<span event .style="border-color: ${color};">${title}</span>`
|
|
68
|
-
)}
|
|
69
|
-
</div>
|
|
70
|
-
</li>`
|
|
71
|
-
})}
|
|
72
|
-
</ol>
|
|
73
|
-
`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async updated(changes: PropertyValues<this>) {
|
|
77
|
-
if (changes.has('year') || changes.has('month') || changes.has('week')) {
|
|
78
|
-
const calendar = this.createDaysForCurrentWeek(this.year, this.week)
|
|
79
|
-
|
|
80
|
-
this.eventMap = await this.eventProvider?.fetchEventsForCalendar(calendar)
|
|
81
|
-
this.calendar = calendar
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
moveTo(year: number, month: number, week: number) {
|
|
86
|
-
this.year = year
|
|
87
|
-
this.month = month
|
|
88
|
-
this.week = week
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getLastDateOfWeek(year: number, week: number): Dayjs {
|
|
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
|
-
|
|
97
|
-
createDaysForCurrentWeek(year: number, week: number): CALENDAR {
|
|
98
|
-
const lastDayjs = this.getLastDateOfWeek(year, week)
|
|
99
|
-
const weekDays = 7
|
|
100
|
-
|
|
101
|
-
return [...Array(weekDays)]
|
|
102
|
-
.map((day, index) => {
|
|
103
|
-
const date = new Date(lastDayjs.year(), lastDayjs.month(), lastDayjs.date() - index)
|
|
104
|
-
const label = dayjs(date).format('MM-DD')
|
|
105
|
-
return {
|
|
106
|
-
date,
|
|
107
|
-
label,
|
|
108
|
-
thisWeek: true,
|
|
109
|
-
today: isToday(date)
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
.reverse()
|
|
113
|
-
}
|
|
114
|
-
}
|
package/src/index.ts
DELETED
package/src/ox-event-view.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import '@material/web/icon/icon.js'
|
|
2
|
-
|
|
3
|
-
import './calendar-monthly'
|
|
4
|
-
import './calendar-weekly'
|
|
5
|
-
|
|
6
|
-
import { css, html, LitElement } from 'lit'
|
|
7
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
8
|
-
|
|
9
|
-
import { EventProvider } from './types'
|
|
10
|
-
|
|
11
|
-
@customElement('ox-event-view')
|
|
12
|
-
export class OxEventView extends LitElement {
|
|
13
|
-
static styles = css`
|
|
14
|
-
:host {
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
|
|
18
|
-
background-color: var(--md-sys-color-background);
|
|
19
|
-
color: var(--md-sys-color-on-background);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
calendar-weekly {
|
|
23
|
-
flex: 1;
|
|
24
|
-
|
|
25
|
-
padding: 0;
|
|
26
|
-
margin: 0;
|
|
27
|
-
}
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
@property({ type: String }) mode: 'monthly' | 'weekly' = 'monthly'
|
|
31
|
-
@property({ type: Object }) eventProvider?: EventProvider
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
return this.mode == 'weekly'
|
|
35
|
-
? html`
|
|
36
|
-
<calendar-weekly .eventProvider=${this.eventProvider}>
|
|
37
|
-
<md-icon @click=${(e: Event) => (this.mode = 'monthly')}>calendar_month</md-icon>
|
|
38
|
-
</calendar-weekly>
|
|
39
|
-
`
|
|
40
|
-
: html`
|
|
41
|
-
<calendar-monthly .eventProvider=${this.eventProvider}>
|
|
42
|
-
<md-icon @click=${(e: Event) => (this.mode = 'weekly')}>calendar_view_week</md-icon>
|
|
43
|
-
</calendar-monthly>
|
|
44
|
-
`
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit'
|
|
2
|
-
import dayjs from 'dayjs/esm/index'
|
|
3
|
-
import weekday from 'dayjs/esm/plugin/weekday'
|
|
4
|
-
import weekOfYear from 'dayjs/esm/plugin/weekOfYear'
|
|
5
|
-
|
|
6
|
-
dayjs.extend(weekday)
|
|
7
|
-
dayjs.extend(weekOfYear)
|
|
8
|
-
|
|
9
|
-
export type BizEvent = {
|
|
10
|
-
due?: string
|
|
11
|
-
title: string
|
|
12
|
-
color: string
|
|
13
|
-
clickEvent?: any
|
|
14
|
-
template?: TemplateResult
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type CALENDAR = {
|
|
18
|
-
label: string
|
|
19
|
-
date: Date
|
|
20
|
-
thisMonth?: boolean
|
|
21
|
-
thisWeek?: boolean
|
|
22
|
-
today?: boolean
|
|
23
|
-
}[]
|
|
24
|
-
|
|
25
|
-
export interface EventProvider {
|
|
26
|
-
fetchEventsForCalendar(calendar: CALENDAR): Map<Date, BizEvent[]>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
30
|
-
|
|
31
|
-
export function isToday(date: Date) {
|
|
32
|
-
const today = new Date()
|
|
33
|
-
return (
|
|
34
|
-
date.getDate() == today.getDate() &&
|
|
35
|
-
date.getMonth() == today.getMonth() &&
|
|
36
|
-
date.getFullYear() == today.getFullYear()
|
|
37
|
-
)
|
|
38
|
-
}
|
package/stories/index.stories.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import '../src/ox-event-view.js'
|
|
2
|
-
import { html, TemplateResult } from 'lit'
|
|
3
|
-
import { BizEvent, CALENDAR, EventProvider } from '../src/types.js'
|
|
4
|
-
|
|
5
|
-
class SampleEventProvider implements EventProvider {
|
|
6
|
-
fetchEventsForCalendar(calendar: CALENDAR) {
|
|
7
|
-
const map = new Map<Date, BizEvent[]>()
|
|
8
|
-
|
|
9
|
-
calendar.forEach(({ date }) =>
|
|
10
|
-
map.set(date, [
|
|
11
|
-
{
|
|
12
|
-
due: '2021-08-21',
|
|
13
|
-
title: 'HAHAHA',
|
|
14
|
-
color: 'yellow'
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
due: '2021-08-21',
|
|
18
|
-
title: 'HOHOHO',
|
|
19
|
-
color: 'lime'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
due: '2021-08-21',
|
|
23
|
-
title: 'HIHIHI',
|
|
24
|
-
color: 'yellow'
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
due: '2021-08-21',
|
|
28
|
-
title: 'HEHEHE',
|
|
29
|
-
color: 'white'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
due: '2021-08-21',
|
|
33
|
-
title: 'KEKEKE',
|
|
34
|
-
color: 'yellow'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
due: '2021-08-21',
|
|
38
|
-
title: 'MEMEME',
|
|
39
|
-
color: 'orange'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
due: '2021-08-21',
|
|
43
|
-
title: 'MOMOMO',
|
|
44
|
-
color: 'lime'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
due: '2021-08-21',
|
|
48
|
-
title: 'QUOQUO',
|
|
49
|
-
color: 'navy'
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
due: '2021-08-21',
|
|
53
|
-
title: 'ZZXXCC',
|
|
54
|
-
color: 'gray'
|
|
55
|
-
}
|
|
56
|
-
])
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return map
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default {
|
|
64
|
-
title: 'EventView',
|
|
65
|
-
component: 'ox-event-view',
|
|
66
|
-
argTypes: {
|
|
67
|
-
mode: { control: 'select', options: ['monthly', 'weekly'], description: 'set event view mode' }
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface Story<T> {
|
|
72
|
-
(args: T): TemplateResult
|
|
73
|
-
args?: Partial<T>
|
|
74
|
-
argTypes?: Record<string, unknown>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
interface ArgTypes {
|
|
78
|
-
mode?: string
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const Template: Story<ArgTypes> = ({ mode = 'monthly' }: ArgTypes) => html`
|
|
82
|
-
<link rel="stylesheet" href="/themes/material-theme.css" />
|
|
83
|
-
<link rel="stylesheet" href="/themes/calendar-theme.css" />
|
|
84
|
-
|
|
85
|
-
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
86
|
-
<link href="/themes/light.css" rel="stylesheet" />
|
|
87
|
-
<link href="/themes/dark.css" rel="stylesheet" />
|
|
88
|
-
<link href="/themes/spacing.css" rel="stylesheet" />
|
|
89
|
-
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
|
90
|
-
<link href="/themes/form-theme.css" rel="stylesheet" />
|
|
91
|
-
|
|
92
|
-
<link
|
|
93
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
|
94
|
-
rel="stylesheet"
|
|
95
|
-
/>
|
|
96
|
-
<link
|
|
97
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
|
98
|
-
rel="stylesheet"
|
|
99
|
-
/>
|
|
100
|
-
<link
|
|
101
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
|
102
|
-
rel="stylesheet"
|
|
103
|
-
/>
|
|
104
|
-
|
|
105
|
-
<ox-event-view mode=${mode} .eventProvider=${new SampleEventProvider()}> </ox-event-view>
|
|
106
|
-
`
|
|
107
|
-
|
|
108
|
-
export const Regular = Template.bind({})
|
|
109
|
-
Regular.args = {
|
|
110
|
-
mode: 'monthly'
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export const WeeklyEventView = Template.bind({})
|
|
114
|
-
WeeklyEventView.args = {
|
|
115
|
-
mode: 'weekly'
|
|
116
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "esnext",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"resolveJsonModule": true,
|
|
7
|
-
"noEmitOnError": true,
|
|
8
|
-
"lib": ["es2017", "dom"],
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": false,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"experimentalDecorators": true,
|
|
13
|
-
"useDefineForClassFields": false,
|
|
14
|
-
"importHelpers": true,
|
|
15
|
-
"outDir": "dist",
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"inlineSources": true,
|
|
18
|
-
"rootDir": "./",
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"incremental": true,
|
|
21
|
-
"skipLibCheck": true,
|
|
22
|
-
"types": ["node", "mocha"]
|
|
23
|
-
},
|
|
24
|
-
"include": ["**/*.ts", "*.d.ts"]
|
|
25
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
-
|
|
3
|
-
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
-
const hmr = process.argv.includes('--hmr');
|
|
5
|
-
|
|
6
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
-
open: '/demo/',
|
|
8
|
-
/** Use regular watch mode if HMR is not enabled. */
|
|
9
|
-
watch: !hmr,
|
|
10
|
-
/** Resolve bare module imports */
|
|
11
|
-
nodeResolve: {
|
|
12
|
-
exportConditions: ['browser', 'development'],
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
16
|
-
// esbuildTarget: 'auto'
|
|
17
|
-
|
|
18
|
-
/** Set appIndex to enable SPA routing */
|
|
19
|
-
// appIndex: 'demo/index.html',
|
|
20
|
-
|
|
21
|
-
plugins: [
|
|
22
|
-
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
23
|
-
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
24
|
-
],
|
|
25
|
-
|
|
26
|
-
// See documentation for all available options
|
|
27
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
-
|
|
3
|
-
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
-
|
|
5
|
-
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
-
/** Test files to run */
|
|
7
|
-
files: 'dist/test/**/*.test.js',
|
|
8
|
-
|
|
9
|
-
/** Resolve bare module imports */
|
|
10
|
-
nodeResolve: {
|
|
11
|
-
exportConditions: ['browser', 'development'],
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
/** Filter out lit dev mode logs */
|
|
15
|
-
filterBrowserLogs(log) {
|
|
16
|
-
for (const arg of log.args) {
|
|
17
|
-
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
-
// esbuildTarget: 'auto',
|
|
26
|
-
|
|
27
|
-
/** Amount of browsers to run concurrently */
|
|
28
|
-
// concurrentBrowsers: 2,
|
|
29
|
-
|
|
30
|
-
/** Amount of test files per browser to test concurrently */
|
|
31
|
-
// concurrency: 1,
|
|
32
|
-
|
|
33
|
-
/** Browsers to run tests on */
|
|
34
|
-
// browsers: [
|
|
35
|
-
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
-
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
-
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
-
// ],
|
|
39
|
-
|
|
40
|
-
// See documentation for all available options
|
|
41
|
-
});
|