@operato/event-view 10.29.76 → 10.29.79
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 +10 -0
- package/dist/src/calendar-monthly-styles.js +7 -0
- package/dist/src/calendar-monthly-styles.js.map +1 -1
- package/dist/src/calendar-monthly.d.ts +2 -0
- package/dist/src/calendar-monthly.js +8 -0
- package/dist/src/calendar-monthly.js.map +1 -1
- package/dist/src/calendar-weekly-styles.js +7 -0
- package/dist/src/calendar-weekly-styles.js.map +1 -1
- package/dist/src/calendar-weekly.d.ts +2 -0
- package/dist/src/calendar-weekly.js +9 -2
- package/dist/src/calendar-weekly.js.map +1 -1
- package/dist/src/ox-event-view.d.ts +8 -0
- package/dist/src/ox-event-view.js +13 -2
- package/dist/src/ox-event-view.js.map +1 -1
- package/dist/test/calendar-layout.test.d.ts +1 -0
- package/dist/test/calendar-layout.test.js +211 -0
- package/dist/test/calendar-layout.test.js.map +1 -0
- package/dist/test/dark-theme.test.d.ts +1 -0
- package/dist/test/dark-theme.test.js +68 -0
- package/dist/test/dark-theme.test.js.map +1 -0
- package/dist/test/day-overflow.test.d.ts +1 -0
- package/dist/test/day-overflow.test.js +81 -0
- package/dist/test/day-overflow.test.js.map +1 -0
- package/dist/test/day-state.test.d.ts +1 -0
- package/dist/test/day-state.test.js +115 -0
- package/dist/test/day-state.test.js.map +1 -0
- package/dist/test/selectable.test.d.ts +1 -0
- package/dist/test/selectable.test.js +49 -0
- package/dist/test/selectable.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/test/dark-theme.test.ts +84 -0
- package/test/selectable.test.ts +62 -0
- package/themes/calendar-theme.css +7 -6
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { html, fixture, expect } from '@open-wc/testing'
|
|
2
|
+
|
|
3
|
+
import '../src/ox-event-view.js'
|
|
4
|
+
import { OxEventView } from '../src/ox-event-view.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A calendar picks dates only when the host says it is a picker.
|
|
8
|
+
*
|
|
9
|
+
* Every calendar used to take a press or drag over its days as a range selection, and set
|
|
10
|
+
* touch-action: none on them so the browser would not read the drag as a scroll. On a phone that
|
|
11
|
+
* left screens which only show a calendar unable to scroll past it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
async function grid(mode: 'monthly' | 'weekly', selectable: boolean) {
|
|
15
|
+
const el = (await fixture(
|
|
16
|
+
html`<ox-event-view mode=${mode} ?selectable=${selectable}></ox-event-view>`
|
|
17
|
+
)) as OxEventView
|
|
18
|
+
await el.updateComplete
|
|
19
|
+
await new Promise(resolve => setTimeout(resolve, 50))
|
|
20
|
+
|
|
21
|
+
const view = el.renderRoot.querySelector(mode === 'monthly' ? 'calendar-monthly' : 'calendar-weekly')!
|
|
22
|
+
const days = Array.from(view.shadowRoot!.querySelectorAll('li[date]')) as HTMLElement[]
|
|
23
|
+
return { el, days }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function drag(from: HTMLElement, to: HTMLElement) {
|
|
27
|
+
const init = { bubbles: true, composed: true, cancelable: true, pointerId: 1, pointerType: 'touch' }
|
|
28
|
+
const down = new PointerEvent('pointerdown', init)
|
|
29
|
+
from.dispatchEvent(down)
|
|
30
|
+
to.dispatchEvent(new PointerEvent('pointermove', init))
|
|
31
|
+
to.dispatchEvent(new PointerEvent('pointerup', init))
|
|
32
|
+
return down
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
for (const mode of ['monthly', 'weekly'] as const) {
|
|
36
|
+
describe(`${mode} calendar selection`, () => {
|
|
37
|
+
it('a calendar that only shows leaves touch to the page and selects nothing', async () => {
|
|
38
|
+
const { el, days } = await grid(mode, false)
|
|
39
|
+
let selected = 0
|
|
40
|
+
el.addEventListener('select-date', () => selected++)
|
|
41
|
+
|
|
42
|
+
expect(getComputedStyle(days[1]).touchAction).to.equal('auto')
|
|
43
|
+
|
|
44
|
+
const down = drag(days[1], days[3])
|
|
45
|
+
expect(down.defaultPrevented).to.be.false
|
|
46
|
+
expect(selected).to.equal(0)
|
|
47
|
+
expect(days.some(day => day.hasAttribute('selected'))).to.be.false
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('a picker takes touch and reports the dragged range', async () => {
|
|
51
|
+
const { el, days } = await grid(mode, true)
|
|
52
|
+
let detail: Date[] | undefined
|
|
53
|
+
el.addEventListener('select-date', e => (detail = (e as CustomEvent).detail))
|
|
54
|
+
|
|
55
|
+
expect(getComputedStyle(days[1]).touchAction).to.equal('none')
|
|
56
|
+
|
|
57
|
+
const down = drag(days[3], days[1])
|
|
58
|
+
expect(down.defaultPrevented).to.be.true
|
|
59
|
+
expect(detail).to.deep.equal([(days[1] as any).date, (days[3] as any).date])
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}
|
|
@@ -3,7 +3,7 @@ body {
|
|
|
3
3
|
|
|
4
4
|
/* monthly common color */
|
|
5
5
|
--calendar-monthly-text-color: var(--md-sys-color-secondary);
|
|
6
|
-
--calendar-monthly-border: 1px solid
|
|
6
|
+
--calendar-monthly-border: 1px solid var(--md-sys-color-outline-variant);
|
|
7
7
|
--calendar-monthly-border-width: 0 1px 1px 0px;
|
|
8
8
|
|
|
9
9
|
/* monthly layout */
|
|
@@ -21,16 +21,17 @@ body {
|
|
|
21
21
|
--calendar-monthly-date-label-color: var(--md-sys-color-on-primary);
|
|
22
22
|
--calendar-monthly-date-min-height: 120px;
|
|
23
23
|
|
|
24
|
-
--calendar-monthly-background-color:
|
|
24
|
+
--calendar-monthly-background-color: var(--md-sys-color-surface-container-low);
|
|
25
|
+
--calendar-monthly-color: var(--md-sys-color-on-surface);
|
|
25
26
|
--calendar-monthly-event-border-radius: var(--border-radius);
|
|
26
27
|
--calendar-monthly-event-margin: var(--padding-narrow) 0 0 0;
|
|
27
28
|
--calendar-monthly-event-padding: 2px var(--padding-default);
|
|
28
|
-
--calendar-monthly-event-border: 3px solid
|
|
29
|
+
--calendar-monthly-event-border: 3px solid var(--md-sys-color-outline);
|
|
29
30
|
--calendar-monthly-event-border-width: 0 0 0 3px;
|
|
30
31
|
|
|
31
32
|
/* weekly common color */
|
|
32
33
|
--calendar-weekly-text-color: var(--md-sys-color-secondary);
|
|
33
|
-
--calendar-weekly-border: 1px solid
|
|
34
|
+
--calendar-weekly-border: 1px solid var(--md-sys-color-outline-variant);
|
|
34
35
|
--calendar-weekly-border-width: 0 1px 1px 0px;
|
|
35
36
|
|
|
36
37
|
/* weekly layout */
|
|
@@ -47,11 +48,11 @@ body {
|
|
|
47
48
|
--calendar-weekly-date-label-padding: 0px 6px;
|
|
48
49
|
--calendar-weekly-date-label-color: var(--md-sys-color-on-primary);
|
|
49
50
|
|
|
50
|
-
--calendar-weekly-background-color:
|
|
51
|
+
--calendar-weekly-background-color: var(--md-sys-color-surface-container-low);
|
|
51
52
|
--calendar-weekly-event-border-radius: var(--border-radius);
|
|
52
53
|
--calendar-weekly-event-margin: var(--padding-narrow) 0 0 0;
|
|
53
54
|
--calendar-weekly-event-padding: 2px var(--padding-default);
|
|
54
|
-
--calendar-weekly-event-border: 3px solid
|
|
55
|
+
--calendar-weekly-event-border: 3px solid var(--md-sys-color-outline);
|
|
55
56
|
--calendar-weekly-event-border-width: 0 0 0 3px;
|
|
56
57
|
}
|
|
57
58
|
|