@vonage/vivid 3.0.0 → 3.1.0
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/README.md +176 -4
- package/accordion/index.js +22 -61
- package/accordion-item/index.js +16 -118
- package/action-group/index.js +5 -0
- package/avatar/index.js +11 -0
- package/badge/index.js +9 -53
- package/banner/index.js +20 -210
- package/breadcrumb/index.js +7 -96
- package/breadcrumb-item/index.js +15 -46
- package/button/index.js +19 -751
- package/calendar/index.js +6 -1520
- package/calendar-event/index.js +9 -0
- package/card/index.js +10 -133
- package/checkbox/index.js +16 -0
- package/combobox/index.js +35 -0
- package/custom-elements.json +6214 -0
- package/data-grid/index.js +1104 -0
- package/dialog/index.js +24 -0
- package/divider/index.js +6 -0
- package/elevation/index.js +4 -30
- package/fab/index.js +22 -0
- package/focus/index.js +4 -2
- package/header/index.js +6 -0
- package/icon/index.js +8 -36
- package/index.js +77 -26
- package/layout/index.js +4 -52
- package/lib/accordion/accordion.d.ts +3 -7
- package/lib/accordion/accordion.template.d.ts +1 -2
- package/lib/accordion/definition.d.ts +1 -0
- package/lib/accordion/index.d.ts +1 -2
- package/lib/accordion-item/accordion-item.d.ts +2 -6
- package/lib/accordion-item/accordion-item.template.d.ts +4 -4
- package/lib/accordion-item/definition.d.ts +1 -0
- package/lib/accordion-item/index.d.ts +1 -3
- package/lib/action-group/action-group.d.ts +10 -0
- package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
- package/lib/action-group/definition.d.ts +1 -0
- package/lib/action-group/index.d.ts +1 -0
- package/lib/avatar/avatar.d.ts +15 -0
- package/lib/avatar/avatar.template.d.ts +4 -0
- package/lib/avatar/definition.d.ts +1 -0
- package/lib/avatar/index.d.ts +1 -0
- package/lib/badge/badge.d.ts +2 -4
- package/lib/badge/definition.d.ts +3 -0
- package/lib/badge/index.d.ts +1 -3
- package/lib/banner/banner.d.ts +1 -1
- package/lib/banner/banner.template.d.ts +0 -2
- package/lib/banner/definition.d.ts +1 -0
- package/lib/banner/index.d.ts +1 -2
- package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
- package/lib/breadcrumb/definition.d.ts +1 -0
- package/lib/breadcrumb/index.d.ts +1 -2
- package/lib/breadcrumb-item/definition.d.ts +1 -0
- package/lib/breadcrumb-item/index.d.ts +1 -3
- package/lib/button/button.d.ts +3 -2
- package/lib/button/definition.d.ts +1 -0
- package/lib/button/index.d.ts +1 -21
- package/lib/calendar/calendar.d.ts +3 -1
- package/lib/calendar/definition.d.ts +1 -0
- package/lib/calendar/index.d.ts +1 -3
- package/lib/calendar-event/calendar-event.d.ts +14 -0
- package/lib/calendar-event/calendar-event.template.d.ts +4 -0
- package/lib/calendar-event/definition.d.ts +1 -0
- package/lib/calendar-event/index.d.ts +1 -0
- package/lib/card/card.d.ts +2 -2
- package/lib/card/definition.d.ts +1 -0
- package/lib/card/index.d.ts +1 -5
- package/lib/checkbox/checkbox.d.ts +5 -0
- package/lib/checkbox/checkbox.template.d.ts +4 -0
- package/lib/checkbox/definition.d.ts +1 -0
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/combobox/combobox.d.ts +14 -0
- package/lib/combobox/combobox.template.d.ts +4 -0
- package/lib/combobox/definition.d.ts +3 -0
- package/lib/combobox/index.d.ts +1 -0
- package/lib/components.d.ts +44 -16
- package/lib/data-grid/data-grid-cell.d.ts +5 -0
- package/lib/data-grid/data-grid-cell.template.d.ts +4 -0
- package/lib/data-grid/data-grid-row.d.ts +3 -0
- package/lib/data-grid/data-grid-row.template.d.ts +3 -0
- package/lib/data-grid/data-grid.d.ts +3 -0
- package/lib/data-grid/data-grid.options.d.ts +31 -0
- package/lib/data-grid/data-grid.template.d.ts +3 -0
- package/lib/data-grid/definition.d.ts +6 -0
- package/lib/data-grid/index.d.ts +1 -0
- package/lib/dialog/definition.d.ts +1 -0
- package/lib/dialog/dialog.d.ts +23 -0
- package/lib/dialog/dialog.template.d.ts +4 -0
- package/lib/dialog/index.d.ts +1 -0
- package/lib/divider/definition.d.ts +1 -0
- package/lib/divider/divider.d.ts +3 -0
- package/lib/divider/divider.template.d.ts +4 -0
- package/lib/divider/index.d.ts +1 -0
- package/lib/elevation/definition.d.ts +1 -0
- package/lib/elevation/elevation.d.ts +1 -0
- package/lib/elevation/index.d.ts +1 -2
- package/lib/enums.d.ts +19 -6
- package/lib/fab/definition.d.ts +3 -0
- package/lib/fab/fab.d.ts +13 -0
- package/lib/fab/fab.template.d.ts +4 -0
- package/lib/fab/index.d.ts +1 -0
- package/lib/focus/definition.d.ts +3 -0
- package/lib/focus/index.d.ts +1 -2
- package/lib/{sidenav-item/index.d.ts → header/definition.d.ts} +2 -2
- package/lib/header/header.d.ts +5 -0
- package/lib/header/header.template.d.ts +4 -0
- package/lib/header/index.d.ts +1 -0
- package/lib/icon/definition.d.ts +3 -0
- package/lib/icon/icon.d.ts +5 -6
- package/lib/icon/index.d.ts +1 -2
- package/lib/layout/definition.d.ts +3 -0
- package/lib/layout/index.d.ts +1 -2
- package/lib/layout/layout.d.ts +4 -4
- package/lib/listbox/definition.d.ts +3 -0
- package/lib/listbox/index.d.ts +1 -0
- package/lib/listbox/listbox.d.ts +6 -0
- package/lib/listbox/listbox.template.d.ts +4 -0
- package/lib/menu/definition.d.ts +11 -0
- package/lib/menu/index.d.ts +1 -0
- package/lib/menu/menu.d.ts +10 -0
- package/lib/menu/menu.template.d.ts +3 -0
- package/lib/menu-item/definition.d.ts +3 -0
- package/lib/menu-item/index.d.ts +1 -0
- package/lib/menu-item/menu-item.d.ts +8 -0
- package/lib/menu-item/menu-item.template.d.ts +5 -0
- package/lib/nav/definition.d.ts +3 -0
- package/lib/nav/index.d.ts +1 -0
- package/lib/nav/nav.d.ts +3 -0
- package/lib/nav/nav.template.d.ts +4 -0
- package/lib/nav-disclosure/definition.d.ts +3 -0
- package/lib/nav-disclosure/index.d.ts +1 -0
- package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
- package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
- package/lib/nav-item/definition.d.ts +3 -0
- package/lib/nav-item/index.d.ts +1 -0
- package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
- package/lib/nav-item/nav-item.template.d.ts +4 -0
- package/lib/note/definition.d.ts +3 -0
- package/lib/note/index.d.ts +1 -0
- package/lib/note/note.d.ts +10 -0
- package/lib/{text/text.template.d.ts → note/note.template.d.ts} +2 -2
- package/lib/number-field/definition.d.ts +4 -0
- package/lib/number-field/index.d.ts +1 -0
- package/lib/number-field/number-field.d.ts +14 -0
- package/lib/number-field/number-field.template.d.ts +4 -0
- package/lib/option/definition.d.ts +3 -0
- package/lib/option/index.d.ts +1 -0
- package/lib/option/option.d.ts +9 -0
- package/lib/option/option.template.d.ts +4 -0
- package/lib/popup/definition.d.ts +3 -0
- package/lib/popup/index.d.ts +1 -4
- package/lib/popup/popup.d.ts +8 -4
- package/lib/progress/definition.d.ts +3 -0
- package/lib/progress/index.d.ts +1 -2
- package/lib/progress/progress.d.ts +1 -1
- package/lib/progress-ring/definition.d.ts +3 -0
- package/lib/progress-ring/index.d.ts +1 -2
- package/lib/progress-ring/progress-ring.d.ts +2 -1
- package/lib/radio/definition.d.ts +3 -0
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/radio.d.ts +4 -0
- package/lib/radio/radio.template.d.ts +4 -0
- package/lib/radio-group/definition.d.ts +11 -0
- package/lib/radio-group/index.d.ts +1 -0
- package/lib/radio-group/radio-group.d.ts +4 -0
- package/lib/radio-group/radio-group.template.d.ts +4 -0
- package/lib/select/definition.d.ts +3 -0
- package/lib/select/index.d.ts +1 -0
- package/lib/select/select.d.ts +17 -0
- package/lib/select/select.template.d.ts +4 -0
- package/lib/side-drawer/definition.d.ts +3 -0
- package/lib/side-drawer/index.d.ts +1 -2
- package/lib/side-drawer/side-drawer.d.ts +3 -2
- package/lib/slider/definition.d.ts +3 -0
- package/lib/slider/index.d.ts +1 -0
- package/lib/slider/slider.d.ts +4 -0
- package/lib/slider/slider.template.d.ts +4 -0
- package/lib/switch/definition.d.ts +3 -0
- package/lib/switch/index.d.ts +1 -0
- package/lib/switch/switch.d.ts +7 -0
- package/lib/switch/switch.template.d.ts +4 -0
- package/lib/tab/definition.d.ts +3 -0
- package/lib/tab/index.d.ts +1 -0
- package/lib/tab/tab.d.ts +9 -0
- package/lib/tab/tab.template.d.ts +3 -0
- package/lib/tab-panel/definition.d.ts +3 -0
- package/lib/tab-panel/index.d.ts +1 -0
- package/lib/tab-panel/tab-panel.d.ts +3 -0
- package/lib/tab-panel/tab-panel.template.d.ts +2 -0
- package/lib/tabs/definition.d.ts +3 -0
- package/lib/tabs/index.d.ts +1 -0
- package/lib/tabs/tabs.d.ts +10 -0
- package/lib/tabs/tabs.template.d.ts +2 -0
- package/lib/text-anchor/definition.d.ts +3 -0
- package/lib/text-anchor/index.d.ts +1 -2
- package/lib/text-area/definition.d.ts +3 -0
- package/lib/text-area/index.d.ts +1 -0
- package/lib/text-area/text-area.d.ts +9 -0
- package/lib/text-area/text-area.template.d.ts +4 -0
- package/lib/text-field/definition.d.ts +3 -0
- package/lib/text-field/index.d.ts +1 -0
- package/lib/text-field/text-field.d.ts +14 -0
- package/lib/text-field/text-field.template.d.ts +4 -0
- package/lib/tooltip/definition.d.ts +3 -0
- package/lib/tooltip/index.d.ts +1 -3
- package/lib/tooltip/tooltip.d.ts +6 -6
- package/listbox/index.js +27 -0
- package/menu/index.js +30 -0
- package/menu-item/index.js +20 -0
- package/nav/index.js +4 -0
- package/nav-disclosure/index.js +17 -0
- package/nav-item/index.js +22 -0
- package/note/index.js +15 -0
- package/number-field/index.js +459 -0
- package/option/index.js +21 -0
- package/package.json +21 -11
- package/popup/index.js +21 -2062
- package/progress/index.js +6 -98
- package/progress-ring/index.js +6 -75
- package/radio/index.js +12 -0
- package/radio-group/index.js +11 -0
- package/select/index.js +34 -0
- package/shared/affix.js +2 -8
- package/shared/anchor.js +10 -2
- package/shared/apply-mixins.js +5 -4
- package/shared/aria-global.js +2 -86
- package/shared/aria.js +9 -0
- package/shared/base-progress.js +5 -0
- package/shared/breadcrumb-item.js +1 -1
- package/shared/button.js +200 -0
- package/shared/calendar-event.js +19 -0
- package/shared/definition.js +225 -0
- package/shared/definition10.js +99 -0
- package/shared/definition11.js +48 -0
- package/shared/definition12.js +763 -0
- package/shared/definition13.js +111 -0
- package/shared/definition14.js +114 -0
- package/shared/definition15.js +32 -0
- package/shared/definition16.js +172 -0
- package/shared/definition17.js +727 -0
- package/shared/definition18.js +1531 -0
- package/shared/definition19.js +261 -0
- package/shared/definition2.js +150 -0
- package/shared/definition20.js +221 -0
- package/shared/definition21.js +78 -0
- package/shared/definition22.js +87 -0
- package/shared/definition23.js +58 -0
- package/shared/definition24.js +44 -0
- package/shared/definition25.js +58 -0
- package/shared/definition26.js +348 -0
- package/shared/definition27.js +363 -0
- package/shared/definition28.js +21 -0
- package/shared/definition29.js +75 -0
- package/shared/definition3.js +29 -0
- package/shared/definition30.js +31 -0
- package/shared/definition31.js +49 -0
- package/shared/definition32.js +94 -0
- package/shared/definition33.js +77 -0
- package/shared/definition34.js +45 -0
- package/shared/definition35.js +435 -0
- package/shared/definition36.js +634 -0
- package/shared/definition37.js +86 -0
- package/shared/definition38.js +592 -0
- package/shared/definition39.js +147 -0
- package/shared/definition4.js +19 -0
- package/shared/definition40.js +67 -0
- package/shared/definition41.js +32 -0
- package/shared/definition42.js +440 -0
- package/shared/definition43.js +282 -0
- package/shared/definition44.js +119 -0
- package/shared/definition45.js +77 -0
- package/shared/definition5.js +38 -0
- package/shared/definition6.js +60 -0
- package/shared/definition7.js +45 -0
- package/shared/definition8.js +113 -0
- package/shared/definition9.js +107 -0
- package/shared/design-system/index.d.ts +1 -1
- package/shared/dialog-polyfill.esm.js +858 -0
- package/shared/direction.js +20 -0
- package/shared/dom.js +8 -0
- package/shared/enums.js +70 -0
- package/shared/es.object.assign.js +2 -3
- package/shared/es.regexp.to-string.js +59 -0
- package/shared/focus.js +5 -0
- package/shared/focus2.js +11 -0
- package/shared/form-associated.js +466 -0
- package/shared/form-elements.js +127 -0
- package/shared/icon.js +538 -567
- package/shared/index.js +1664 -83
- package/shared/key-codes.js +100 -0
- package/shared/listbox.js +995 -0
- package/shared/numbers.js +34 -0
- package/shared/patterns/affix.d.ts +1 -1
- package/shared/patterns/focus.d.ts +3 -0
- package/shared/patterns/form-elements/form-elements.d.ts +43 -0
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/index.d.ts +2 -0
- package/shared/radio.js +127 -0
- package/shared/ref.js +41 -0
- package/shared/repeat.js +764 -0
- package/shared/select.options.js +10 -0
- package/shared/slotted.js +1 -1
- package/shared/start-end.js +50 -0
- package/shared/string-trim.js +40 -0
- package/shared/strings.js +9 -0
- package/shared/text-anchor.js +0 -2
- package/shared/text-anchor.template.js +6 -5
- package/shared/text-field.js +3 -0
- package/shared/text-field2.js +225 -0
- package/shared/to-string.js +51 -0
- package/side-drawer/index.js +5 -81
- package/slider/index.js +17 -0
- package/styles/core/all.css +83 -0
- package/styles/core/theme.css +11 -0
- package/styles/core/typography.css +77 -0
- package/styles/tokens/theme-dark.css +228 -0
- package/styles/tokens/theme-light.css +228 -0
- package/switch/index.js +18 -0
- package/tab/index.js +16 -0
- package/tab-panel/index.js +4 -0
- package/tabs/index.js +24 -0
- package/text-anchor/index.js +11 -6
- package/text-area/index.js +23 -0
- package/text-field/index.js +24 -0
- package/tooltip/index.js +18 -55
- package/vivid.api.json +3695 -0
- package/lib/text/index.d.ts +0 -2
- package/lib/text/text.d.ts +0 -10
- package/shared/index2.js +0 -21
- package/shared/object-set-prototype-of.js +0 -1009
- package/shared/style-inject.es.js +0 -28
- package/shared/web.dom-collections.iterator.js +0 -473
- package/sidenav-item/index.js +0 -39
- package/styles/fonts/spezia.css +0 -23
- package/styles/themes/dark.css +0 -205
- package/styles/themes/light.css +0 -205
- package/text/index.js +0 -46
package/calendar/index.js
CHANGED
|
@@ -1,1522 +1,8 @@
|
|
|
1
|
-
import '../
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import '../shared/web.dom-collections.iterator.js';
|
|
1
|
+
import { r as registerCalendar } from '../shared/definition12.js';
|
|
2
|
+
import '../shared/index.js';
|
|
3
|
+
import '../shared/calendar-event.js';
|
|
5
4
|
import '../shared/es.object.assign.js';
|
|
6
|
-
import
|
|
7
|
-
import '../shared/
|
|
8
|
-
import '../shared/object-set-prototype-of.js';
|
|
5
|
+
import '../shared/_has.js';
|
|
6
|
+
import '../shared/repeat.js';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
function newSplice(index, removed, addedCount) {
|
|
12
|
-
return {
|
|
13
|
-
index: index,
|
|
14
|
-
removed: removed,
|
|
15
|
-
addedCount: addedCount,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const EDIT_LEAVE = 0;
|
|
19
|
-
const EDIT_UPDATE = 1;
|
|
20
|
-
const EDIT_ADD = 2;
|
|
21
|
-
const EDIT_DELETE = 3;
|
|
22
|
-
// Note: This function is *based* on the computation of the Levenshtein
|
|
23
|
-
// "edit" distance. The one change is that "updates" are treated as two
|
|
24
|
-
// edits - not one. With Array splices, an update is really a delete
|
|
25
|
-
// followed by an add. By retaining this, we optimize for "keeping" the
|
|
26
|
-
// maximum array items in the original array. For example:
|
|
27
|
-
//
|
|
28
|
-
// 'xxxx123' -> '123yyyy'
|
|
29
|
-
//
|
|
30
|
-
// With 1-edit updates, the shortest path would be just to update all seven
|
|
31
|
-
// characters. With 2-edit updates, we delete 4, leave 3, and add 4. This
|
|
32
|
-
// leaves the substring '123' intact.
|
|
33
|
-
function calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
|
34
|
-
// "Deletion" columns
|
|
35
|
-
const rowCount = oldEnd - oldStart + 1;
|
|
36
|
-
const columnCount = currentEnd - currentStart + 1;
|
|
37
|
-
const distances = new Array(rowCount);
|
|
38
|
-
let north;
|
|
39
|
-
let west;
|
|
40
|
-
// "Addition" rows. Initialize null column.
|
|
41
|
-
for (let i = 0; i < rowCount; ++i) {
|
|
42
|
-
distances[i] = new Array(columnCount);
|
|
43
|
-
distances[i][0] = i;
|
|
44
|
-
}
|
|
45
|
-
// Initialize null row
|
|
46
|
-
for (let j = 0; j < columnCount; ++j) {
|
|
47
|
-
distances[0][j] = j;
|
|
48
|
-
}
|
|
49
|
-
for (let i = 1; i < rowCount; ++i) {
|
|
50
|
-
for (let j = 1; j < columnCount; ++j) {
|
|
51
|
-
if (current[currentStart + j - 1] === old[oldStart + i - 1]) {
|
|
52
|
-
distances[i][j] = distances[i - 1][j - 1];
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
north = distances[i - 1][j] + 1;
|
|
56
|
-
west = distances[i][j - 1] + 1;
|
|
57
|
-
distances[i][j] = north < west ? north : west;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return distances;
|
|
62
|
-
}
|
|
63
|
-
// This starts at the final weight, and walks "backward" by finding
|
|
64
|
-
// the minimum previous weight recursively until the origin of the weight
|
|
65
|
-
// matrix.
|
|
66
|
-
function spliceOperationsFromEditDistances(distances) {
|
|
67
|
-
let i = distances.length - 1;
|
|
68
|
-
let j = distances[0].length - 1;
|
|
69
|
-
let current = distances[i][j];
|
|
70
|
-
const edits = [];
|
|
71
|
-
while (i > 0 || j > 0) {
|
|
72
|
-
if (i === 0) {
|
|
73
|
-
edits.push(EDIT_ADD);
|
|
74
|
-
j--;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (j === 0) {
|
|
78
|
-
edits.push(EDIT_DELETE);
|
|
79
|
-
i--;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const northWest = distances[i - 1][j - 1];
|
|
83
|
-
const west = distances[i - 1][j];
|
|
84
|
-
const north = distances[i][j - 1];
|
|
85
|
-
let min;
|
|
86
|
-
if (west < north) {
|
|
87
|
-
min = west < northWest ? west : northWest;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
min = north < northWest ? north : northWest;
|
|
91
|
-
}
|
|
92
|
-
if (min === northWest) {
|
|
93
|
-
if (northWest === current) {
|
|
94
|
-
edits.push(EDIT_LEAVE);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
edits.push(EDIT_UPDATE);
|
|
98
|
-
current = northWest;
|
|
99
|
-
}
|
|
100
|
-
i--;
|
|
101
|
-
j--;
|
|
102
|
-
}
|
|
103
|
-
else if (min === west) {
|
|
104
|
-
edits.push(EDIT_DELETE);
|
|
105
|
-
i--;
|
|
106
|
-
current = west;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
edits.push(EDIT_ADD);
|
|
110
|
-
j--;
|
|
111
|
-
current = north;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
edits.reverse();
|
|
115
|
-
return edits;
|
|
116
|
-
}
|
|
117
|
-
function sharedPrefix(current, old, searchLength) {
|
|
118
|
-
for (let i = 0; i < searchLength; ++i) {
|
|
119
|
-
if (current[i] !== old[i]) {
|
|
120
|
-
return i;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return searchLength;
|
|
124
|
-
}
|
|
125
|
-
function sharedSuffix(current, old, searchLength) {
|
|
126
|
-
let index1 = current.length;
|
|
127
|
-
let index2 = old.length;
|
|
128
|
-
let count = 0;
|
|
129
|
-
while (count < searchLength && current[--index1] === old[--index2]) {
|
|
130
|
-
count++;
|
|
131
|
-
}
|
|
132
|
-
return count;
|
|
133
|
-
}
|
|
134
|
-
function intersect(start1, end1, start2, end2) {
|
|
135
|
-
// Disjoint
|
|
136
|
-
if (end1 < start2 || end2 < start1) {
|
|
137
|
-
return -1;
|
|
138
|
-
}
|
|
139
|
-
// Adjacent
|
|
140
|
-
if (end1 === start2 || end2 === start1) {
|
|
141
|
-
return 0;
|
|
142
|
-
}
|
|
143
|
-
// Non-zero intersect, span1 first
|
|
144
|
-
if (start1 < start2) {
|
|
145
|
-
if (end1 < end2) {
|
|
146
|
-
return end1 - start2; // Overlap
|
|
147
|
-
}
|
|
148
|
-
return end2 - start2; // Contained
|
|
149
|
-
}
|
|
150
|
-
// Non-zero intersect, span2 first
|
|
151
|
-
if (end2 < end1) {
|
|
152
|
-
return end2 - start1; // Overlap
|
|
153
|
-
}
|
|
154
|
-
return end1 - start1; // Contained
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Splice Projection functions:
|
|
158
|
-
*
|
|
159
|
-
* A splice map is a representation of how a previous array of items
|
|
160
|
-
* was transformed into a new array of items. Conceptually it is a list of
|
|
161
|
-
* tuples of
|
|
162
|
-
*
|
|
163
|
-
* <index, removed, addedCount>
|
|
164
|
-
*
|
|
165
|
-
* which are kept in ascending index order of. The tuple represents that at
|
|
166
|
-
* the |index|, |removed| sequence of items were removed, and counting forward
|
|
167
|
-
* from |index|, |addedCount| items were added.
|
|
168
|
-
*/
|
|
169
|
-
/**
|
|
170
|
-
* @internal
|
|
171
|
-
* @remarks
|
|
172
|
-
* Lacking individual splice mutation information, the minimal set of
|
|
173
|
-
* splices can be synthesized given the previous state and final state of an
|
|
174
|
-
* array. The basic approach is to calculate the edit distance matrix and
|
|
175
|
-
* choose the shortest path through it.
|
|
176
|
-
*
|
|
177
|
-
* Complexity: O(l * p)
|
|
178
|
-
* l: The length of the current array
|
|
179
|
-
* p: The length of the old array
|
|
180
|
-
*/
|
|
181
|
-
function calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
|
182
|
-
let prefixCount = 0;
|
|
183
|
-
let suffixCount = 0;
|
|
184
|
-
const minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
|
|
185
|
-
if (currentStart === 0 && oldStart === 0) {
|
|
186
|
-
prefixCount = sharedPrefix(current, old, minLength);
|
|
187
|
-
}
|
|
188
|
-
if (currentEnd === current.length && oldEnd === old.length) {
|
|
189
|
-
suffixCount = sharedSuffix(current, old, minLength - prefixCount);
|
|
190
|
-
}
|
|
191
|
-
currentStart += prefixCount;
|
|
192
|
-
oldStart += prefixCount;
|
|
193
|
-
currentEnd -= suffixCount;
|
|
194
|
-
oldEnd -= suffixCount;
|
|
195
|
-
if (currentEnd - currentStart === 0 && oldEnd - oldStart === 0) {
|
|
196
|
-
return emptyArray;
|
|
197
|
-
}
|
|
198
|
-
if (currentStart === currentEnd) {
|
|
199
|
-
const splice = newSplice(currentStart, [], 0);
|
|
200
|
-
while (oldStart < oldEnd) {
|
|
201
|
-
splice.removed.push(old[oldStart++]);
|
|
202
|
-
}
|
|
203
|
-
return [splice];
|
|
204
|
-
}
|
|
205
|
-
else if (oldStart === oldEnd) {
|
|
206
|
-
return [newSplice(currentStart, [], currentEnd - currentStart)];
|
|
207
|
-
}
|
|
208
|
-
const ops = spliceOperationsFromEditDistances(calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
|
|
209
|
-
const splices = [];
|
|
210
|
-
let splice = void 0;
|
|
211
|
-
let index = currentStart;
|
|
212
|
-
let oldIndex = oldStart;
|
|
213
|
-
for (let i = 0; i < ops.length; ++i) {
|
|
214
|
-
switch (ops[i]) {
|
|
215
|
-
case EDIT_LEAVE:
|
|
216
|
-
if (splice !== void 0) {
|
|
217
|
-
splices.push(splice);
|
|
218
|
-
splice = void 0;
|
|
219
|
-
}
|
|
220
|
-
index++;
|
|
221
|
-
oldIndex++;
|
|
222
|
-
break;
|
|
223
|
-
case EDIT_UPDATE:
|
|
224
|
-
if (splice === void 0) {
|
|
225
|
-
splice = newSplice(index, [], 0);
|
|
226
|
-
}
|
|
227
|
-
splice.addedCount++;
|
|
228
|
-
index++;
|
|
229
|
-
splice.removed.push(old[oldIndex]);
|
|
230
|
-
oldIndex++;
|
|
231
|
-
break;
|
|
232
|
-
case EDIT_ADD:
|
|
233
|
-
if (splice === void 0) {
|
|
234
|
-
splice = newSplice(index, [], 0);
|
|
235
|
-
}
|
|
236
|
-
splice.addedCount++;
|
|
237
|
-
index++;
|
|
238
|
-
break;
|
|
239
|
-
case EDIT_DELETE:
|
|
240
|
-
if (splice === void 0) {
|
|
241
|
-
splice = newSplice(index, [], 0);
|
|
242
|
-
}
|
|
243
|
-
splice.removed.push(old[oldIndex]);
|
|
244
|
-
oldIndex++;
|
|
245
|
-
break;
|
|
246
|
-
// no default
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (splice !== void 0) {
|
|
250
|
-
splices.push(splice);
|
|
251
|
-
}
|
|
252
|
-
return splices;
|
|
253
|
-
}
|
|
254
|
-
const $push = Array.prototype.push;
|
|
255
|
-
function mergeSplice(splices, index, removed, addedCount) {
|
|
256
|
-
const splice = newSplice(index, removed, addedCount);
|
|
257
|
-
let inserted = false;
|
|
258
|
-
let insertionOffset = 0;
|
|
259
|
-
for (let i = 0; i < splices.length; i++) {
|
|
260
|
-
const current = splices[i];
|
|
261
|
-
current.index += insertionOffset;
|
|
262
|
-
if (inserted) {
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
const intersectCount = intersect(splice.index, splice.index + splice.removed.length, current.index, current.index + current.addedCount);
|
|
266
|
-
if (intersectCount >= 0) {
|
|
267
|
-
// Merge the two splices
|
|
268
|
-
splices.splice(i, 1);
|
|
269
|
-
i--;
|
|
270
|
-
insertionOffset -= current.addedCount - current.removed.length;
|
|
271
|
-
splice.addedCount += current.addedCount - intersectCount;
|
|
272
|
-
const deleteCount = splice.removed.length + current.removed.length - intersectCount;
|
|
273
|
-
if (!splice.addedCount && !deleteCount) {
|
|
274
|
-
// merged splice is a noop. discard.
|
|
275
|
-
inserted = true;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
let currentRemoved = current.removed;
|
|
279
|
-
if (splice.index < current.index) {
|
|
280
|
-
// some prefix of splice.removed is prepended to current.removed.
|
|
281
|
-
const prepend = splice.removed.slice(0, current.index - splice.index);
|
|
282
|
-
$push.apply(prepend, currentRemoved);
|
|
283
|
-
currentRemoved = prepend;
|
|
284
|
-
}
|
|
285
|
-
if (splice.index + splice.removed.length >
|
|
286
|
-
current.index + current.addedCount) {
|
|
287
|
-
// some suffix of splice.removed is appended to current.removed.
|
|
288
|
-
const append = splice.removed.slice(current.index + current.addedCount - splice.index);
|
|
289
|
-
$push.apply(currentRemoved, append);
|
|
290
|
-
}
|
|
291
|
-
splice.removed = currentRemoved;
|
|
292
|
-
if (current.index < splice.index) {
|
|
293
|
-
splice.index = current.index;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else if (splice.index < current.index) {
|
|
298
|
-
// Insert splice here.
|
|
299
|
-
inserted = true;
|
|
300
|
-
splices.splice(i, 0, splice);
|
|
301
|
-
i++;
|
|
302
|
-
const offset = splice.addedCount - splice.removed.length;
|
|
303
|
-
current.index += offset;
|
|
304
|
-
insertionOffset += offset;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (!inserted) {
|
|
308
|
-
splices.push(splice);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function createInitialSplices(changeRecords) {
|
|
312
|
-
const splices = [];
|
|
313
|
-
for (let i = 0, ii = changeRecords.length; i < ii; i++) {
|
|
314
|
-
const record = changeRecords[i];
|
|
315
|
-
mergeSplice(splices, record.index, record.removed, record.addedCount);
|
|
316
|
-
}
|
|
317
|
-
return splices;
|
|
318
|
-
}
|
|
319
|
-
/** @internal */
|
|
320
|
-
function projectArraySplices(array, changeRecords) {
|
|
321
|
-
let splices = [];
|
|
322
|
-
const initialSplices = createInitialSplices(changeRecords);
|
|
323
|
-
for (let i = 0, ii = initialSplices.length; i < ii; ++i) {
|
|
324
|
-
const splice = initialSplices[i];
|
|
325
|
-
if (splice.addedCount === 1 && splice.removed.length === 1) {
|
|
326
|
-
if (splice.removed[0] !== array[splice.index]) {
|
|
327
|
-
splices.push(splice);
|
|
328
|
-
}
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
splices = splices.concat(calcSplices(array, splice.index, splice.index + splice.addedCount, splice.removed, 0, splice.removed.length));
|
|
332
|
-
}
|
|
333
|
-
return splices;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
let arrayObservationEnabled = false;
|
|
337
|
-
function adjustIndex(changeRecord, array) {
|
|
338
|
-
let index = changeRecord.index;
|
|
339
|
-
const arrayLength = array.length;
|
|
340
|
-
if (index > arrayLength) {
|
|
341
|
-
index = arrayLength - changeRecord.addedCount;
|
|
342
|
-
}
|
|
343
|
-
else if (index < 0) {
|
|
344
|
-
index =
|
|
345
|
-
arrayLength + changeRecord.removed.length + index - changeRecord.addedCount;
|
|
346
|
-
}
|
|
347
|
-
if (index < 0) {
|
|
348
|
-
index = 0;
|
|
349
|
-
}
|
|
350
|
-
changeRecord.index = index;
|
|
351
|
-
return changeRecord;
|
|
352
|
-
}
|
|
353
|
-
class ArrayObserver extends SubscriberSet {
|
|
354
|
-
constructor(source) {
|
|
355
|
-
super(source);
|
|
356
|
-
this.oldCollection = void 0;
|
|
357
|
-
this.splices = void 0;
|
|
358
|
-
this.needsQueue = true;
|
|
359
|
-
this.call = this.flush;
|
|
360
|
-
Reflect.defineProperty(source, "$fastController", {
|
|
361
|
-
value: this,
|
|
362
|
-
enumerable: false,
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
addSplice(splice) {
|
|
366
|
-
if (this.splices === void 0) {
|
|
367
|
-
this.splices = [splice];
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
this.splices.push(splice);
|
|
371
|
-
}
|
|
372
|
-
if (this.needsQueue) {
|
|
373
|
-
this.needsQueue = false;
|
|
374
|
-
DOM.queueUpdate(this);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
reset(oldCollection) {
|
|
378
|
-
this.oldCollection = oldCollection;
|
|
379
|
-
if (this.needsQueue) {
|
|
380
|
-
this.needsQueue = false;
|
|
381
|
-
DOM.queueUpdate(this);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
flush() {
|
|
385
|
-
const splices = this.splices;
|
|
386
|
-
const oldCollection = this.oldCollection;
|
|
387
|
-
if (splices === void 0 && oldCollection === void 0) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
this.needsQueue = true;
|
|
391
|
-
this.splices = void 0;
|
|
392
|
-
this.oldCollection = void 0;
|
|
393
|
-
const finalSplices = oldCollection === void 0
|
|
394
|
-
? projectArraySplices(this.source, splices)
|
|
395
|
-
: calcSplices(this.source, 0, this.source.length, oldCollection, 0, oldCollection.length);
|
|
396
|
-
this.notify(finalSplices);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
/* eslint-disable prefer-rest-params */
|
|
400
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
401
|
-
/**
|
|
402
|
-
* Enables the array observation mechanism.
|
|
403
|
-
* @remarks
|
|
404
|
-
* Array observation is enabled automatically when using the
|
|
405
|
-
* {@link RepeatDirective}, so calling this API manually is
|
|
406
|
-
* not typically necessary.
|
|
407
|
-
* @public
|
|
408
|
-
*/
|
|
409
|
-
function enableArrayObservation() {
|
|
410
|
-
if (arrayObservationEnabled) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
arrayObservationEnabled = true;
|
|
414
|
-
Observable.setArrayObserverFactory((collection) => {
|
|
415
|
-
return new ArrayObserver(collection);
|
|
416
|
-
});
|
|
417
|
-
const proto = Array.prototype;
|
|
418
|
-
// Don't patch Array if it has already been patched
|
|
419
|
-
// by another copy of fast-element.
|
|
420
|
-
if (proto.$fastPatch) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
Reflect.defineProperty(proto, "$fastPatch", {
|
|
424
|
-
value: 1,
|
|
425
|
-
enumerable: false,
|
|
426
|
-
});
|
|
427
|
-
const pop = proto.pop;
|
|
428
|
-
const push = proto.push;
|
|
429
|
-
const reverse = proto.reverse;
|
|
430
|
-
const shift = proto.shift;
|
|
431
|
-
const sort = proto.sort;
|
|
432
|
-
const splice = proto.splice;
|
|
433
|
-
const unshift = proto.unshift;
|
|
434
|
-
proto.pop = function () {
|
|
435
|
-
const notEmpty = this.length > 0;
|
|
436
|
-
const methodCallResult = pop.apply(this, arguments);
|
|
437
|
-
const o = this.$fastController;
|
|
438
|
-
if (o !== void 0 && notEmpty) {
|
|
439
|
-
o.addSplice(newSplice(this.length, [methodCallResult], 0));
|
|
440
|
-
}
|
|
441
|
-
return methodCallResult;
|
|
442
|
-
};
|
|
443
|
-
proto.push = function () {
|
|
444
|
-
const methodCallResult = push.apply(this, arguments);
|
|
445
|
-
const o = this.$fastController;
|
|
446
|
-
if (o !== void 0) {
|
|
447
|
-
o.addSplice(adjustIndex(newSplice(this.length - arguments.length, [], arguments.length), this));
|
|
448
|
-
}
|
|
449
|
-
return methodCallResult;
|
|
450
|
-
};
|
|
451
|
-
proto.reverse = function () {
|
|
452
|
-
let oldArray;
|
|
453
|
-
const o = this.$fastController;
|
|
454
|
-
if (o !== void 0) {
|
|
455
|
-
o.flush();
|
|
456
|
-
oldArray = this.slice();
|
|
457
|
-
}
|
|
458
|
-
const methodCallResult = reverse.apply(this, arguments);
|
|
459
|
-
if (o !== void 0) {
|
|
460
|
-
o.reset(oldArray);
|
|
461
|
-
}
|
|
462
|
-
return methodCallResult;
|
|
463
|
-
};
|
|
464
|
-
proto.shift = function () {
|
|
465
|
-
const notEmpty = this.length > 0;
|
|
466
|
-
const methodCallResult = shift.apply(this, arguments);
|
|
467
|
-
const o = this.$fastController;
|
|
468
|
-
if (o !== void 0 && notEmpty) {
|
|
469
|
-
o.addSplice(newSplice(0, [methodCallResult], 0));
|
|
470
|
-
}
|
|
471
|
-
return methodCallResult;
|
|
472
|
-
};
|
|
473
|
-
proto.sort = function () {
|
|
474
|
-
let oldArray;
|
|
475
|
-
const o = this.$fastController;
|
|
476
|
-
if (o !== void 0) {
|
|
477
|
-
o.flush();
|
|
478
|
-
oldArray = this.slice();
|
|
479
|
-
}
|
|
480
|
-
const methodCallResult = sort.apply(this, arguments);
|
|
481
|
-
if (o !== void 0) {
|
|
482
|
-
o.reset(oldArray);
|
|
483
|
-
}
|
|
484
|
-
return methodCallResult;
|
|
485
|
-
};
|
|
486
|
-
proto.splice = function () {
|
|
487
|
-
const methodCallResult = splice.apply(this, arguments);
|
|
488
|
-
const o = this.$fastController;
|
|
489
|
-
if (o !== void 0) {
|
|
490
|
-
o.addSplice(adjustIndex(newSplice(+arguments[0], methodCallResult, arguments.length > 2 ? arguments.length - 2 : 0), this));
|
|
491
|
-
}
|
|
492
|
-
return methodCallResult;
|
|
493
|
-
};
|
|
494
|
-
proto.unshift = function () {
|
|
495
|
-
const methodCallResult = unshift.apply(this, arguments);
|
|
496
|
-
const o = this.$fastController;
|
|
497
|
-
if (o !== void 0) {
|
|
498
|
-
o.addSplice(adjustIndex(newSplice(0, [], arguments.length), this));
|
|
499
|
-
}
|
|
500
|
-
return methodCallResult;
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
/* eslint-enable prefer-rest-params */
|
|
504
|
-
/* eslint-enable @typescript-eslint/explicit-function-return-type */
|
|
505
|
-
|
|
506
|
-
const defaultRepeatOptions = Object.freeze({
|
|
507
|
-
positioning: false,
|
|
508
|
-
recycle: true,
|
|
509
|
-
});
|
|
510
|
-
function bindWithoutPositioning(view, items, index, context) {
|
|
511
|
-
view.bind(items[index], context);
|
|
512
|
-
}
|
|
513
|
-
function bindWithPositioning(view, items, index, context) {
|
|
514
|
-
const childContext = Object.create(context);
|
|
515
|
-
childContext.index = index;
|
|
516
|
-
childContext.length = items.length;
|
|
517
|
-
view.bind(items[index], childContext);
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* A behavior that renders a template for each item in an array.
|
|
521
|
-
* @public
|
|
522
|
-
*/
|
|
523
|
-
class RepeatBehavior {
|
|
524
|
-
/**
|
|
525
|
-
* Creates an instance of RepeatBehavior.
|
|
526
|
-
* @param location - The location in the DOM to render the repeat.
|
|
527
|
-
* @param itemsBinding - The array to render.
|
|
528
|
-
* @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
|
|
529
|
-
* @param templateBinding - The template to render for each item.
|
|
530
|
-
* @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
|
|
531
|
-
* @param options - Options used to turn on special repeat features.
|
|
532
|
-
*/
|
|
533
|
-
constructor(location, itemsBinding, isItemsBindingVolatile, templateBinding, isTemplateBindingVolatile, options) {
|
|
534
|
-
this.location = location;
|
|
535
|
-
this.itemsBinding = itemsBinding;
|
|
536
|
-
this.templateBinding = templateBinding;
|
|
537
|
-
this.options = options;
|
|
538
|
-
this.source = null;
|
|
539
|
-
this.views = [];
|
|
540
|
-
this.items = null;
|
|
541
|
-
this.itemsObserver = null;
|
|
542
|
-
this.originalContext = void 0;
|
|
543
|
-
this.childContext = void 0;
|
|
544
|
-
this.bindView = bindWithoutPositioning;
|
|
545
|
-
this.itemsBindingObserver = Observable.binding(itemsBinding, this, isItemsBindingVolatile);
|
|
546
|
-
this.templateBindingObserver = Observable.binding(templateBinding, this, isTemplateBindingVolatile);
|
|
547
|
-
if (options.positioning) {
|
|
548
|
-
this.bindView = bindWithPositioning;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Bind this behavior to the source.
|
|
553
|
-
* @param source - The source to bind to.
|
|
554
|
-
* @param context - The execution context that the binding is operating within.
|
|
555
|
-
*/
|
|
556
|
-
bind(source, context) {
|
|
557
|
-
this.source = source;
|
|
558
|
-
this.originalContext = context;
|
|
559
|
-
this.childContext = Object.create(context);
|
|
560
|
-
this.childContext.parent = source;
|
|
561
|
-
this.childContext.parentContext = this.originalContext;
|
|
562
|
-
this.items = this.itemsBindingObserver.observe(source, this.originalContext);
|
|
563
|
-
this.template = this.templateBindingObserver.observe(source, this.originalContext);
|
|
564
|
-
this.observeItems(true);
|
|
565
|
-
this.refreshAllViews();
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Unbinds this behavior from the source.
|
|
569
|
-
* @param source - The source to unbind from.
|
|
570
|
-
*/
|
|
571
|
-
unbind() {
|
|
572
|
-
this.source = null;
|
|
573
|
-
this.items = null;
|
|
574
|
-
if (this.itemsObserver !== null) {
|
|
575
|
-
this.itemsObserver.unsubscribe(this);
|
|
576
|
-
}
|
|
577
|
-
this.unbindAllViews();
|
|
578
|
-
this.itemsBindingObserver.disconnect();
|
|
579
|
-
this.templateBindingObserver.disconnect();
|
|
580
|
-
}
|
|
581
|
-
/** @internal */
|
|
582
|
-
handleChange(source, args) {
|
|
583
|
-
if (source === this.itemsBinding) {
|
|
584
|
-
this.items = this.itemsBindingObserver.observe(this.source, this.originalContext);
|
|
585
|
-
this.observeItems();
|
|
586
|
-
this.refreshAllViews();
|
|
587
|
-
}
|
|
588
|
-
else if (source === this.templateBinding) {
|
|
589
|
-
this.template = this.templateBindingObserver.observe(this.source, this.originalContext);
|
|
590
|
-
this.refreshAllViews(true);
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
this.updateViews(args);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
observeItems(force = false) {
|
|
597
|
-
if (!this.items) {
|
|
598
|
-
this.items = emptyArray;
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
const oldObserver = this.itemsObserver;
|
|
602
|
-
const newObserver = (this.itemsObserver = Observable.getNotifier(this.items));
|
|
603
|
-
const hasNewObserver = oldObserver !== newObserver;
|
|
604
|
-
if (hasNewObserver && oldObserver !== null) {
|
|
605
|
-
oldObserver.unsubscribe(this);
|
|
606
|
-
}
|
|
607
|
-
if (hasNewObserver || force) {
|
|
608
|
-
newObserver.subscribe(this);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
updateViews(splices) {
|
|
612
|
-
const childContext = this.childContext;
|
|
613
|
-
const views = this.views;
|
|
614
|
-
const totalRemoved = [];
|
|
615
|
-
const bindView = this.bindView;
|
|
616
|
-
let removeDelta = 0;
|
|
617
|
-
for (let i = 0, ii = splices.length; i < ii; ++i) {
|
|
618
|
-
const splice = splices[i];
|
|
619
|
-
const removed = splice.removed;
|
|
620
|
-
totalRemoved.push(...views.splice(splice.index + removeDelta, removed.length));
|
|
621
|
-
removeDelta -= splice.addedCount;
|
|
622
|
-
}
|
|
623
|
-
const items = this.items;
|
|
624
|
-
const template = this.template;
|
|
625
|
-
for (let i = 0, ii = splices.length; i < ii; ++i) {
|
|
626
|
-
const splice = splices[i];
|
|
627
|
-
let addIndex = splice.index;
|
|
628
|
-
const end = addIndex + splice.addedCount;
|
|
629
|
-
for (; addIndex < end; ++addIndex) {
|
|
630
|
-
const neighbor = views[addIndex];
|
|
631
|
-
const location = neighbor ? neighbor.firstChild : this.location;
|
|
632
|
-
const view = this.options.recycle && totalRemoved.length > 0
|
|
633
|
-
? totalRemoved.shift()
|
|
634
|
-
: template.create();
|
|
635
|
-
views.splice(addIndex, 0, view);
|
|
636
|
-
bindView(view, items, addIndex, childContext);
|
|
637
|
-
view.insertBefore(location);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
for (let i = 0, ii = totalRemoved.length; i < ii; ++i) {
|
|
641
|
-
totalRemoved[i].dispose();
|
|
642
|
-
}
|
|
643
|
-
if (this.options.positioning) {
|
|
644
|
-
for (let i = 0, ii = views.length; i < ii; ++i) {
|
|
645
|
-
const currentContext = views[i].context;
|
|
646
|
-
currentContext.length = ii;
|
|
647
|
-
currentContext.index = i;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
refreshAllViews(templateChanged = false) {
|
|
652
|
-
const items = this.items;
|
|
653
|
-
const childContext = this.childContext;
|
|
654
|
-
const template = this.template;
|
|
655
|
-
const location = this.location;
|
|
656
|
-
const bindView = this.bindView;
|
|
657
|
-
let itemsLength = items.length;
|
|
658
|
-
let views = this.views;
|
|
659
|
-
let viewsLength = views.length;
|
|
660
|
-
if (itemsLength === 0 || templateChanged) {
|
|
661
|
-
// all views need to be removed
|
|
662
|
-
HTMLView.disposeContiguousBatch(views);
|
|
663
|
-
viewsLength = 0;
|
|
664
|
-
}
|
|
665
|
-
if (viewsLength === 0) {
|
|
666
|
-
// all views need to be created
|
|
667
|
-
this.views = views = new Array(itemsLength);
|
|
668
|
-
for (let i = 0; i < itemsLength; ++i) {
|
|
669
|
-
const view = template.create();
|
|
670
|
-
bindView(view, items, i, childContext);
|
|
671
|
-
views[i] = view;
|
|
672
|
-
view.insertBefore(location);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
// attempt to reuse existing views with new data
|
|
677
|
-
let i = 0;
|
|
678
|
-
for (; i < itemsLength; ++i) {
|
|
679
|
-
if (i < viewsLength) {
|
|
680
|
-
const view = views[i];
|
|
681
|
-
bindView(view, items, i, childContext);
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
const view = template.create();
|
|
685
|
-
bindView(view, items, i, childContext);
|
|
686
|
-
views.push(view);
|
|
687
|
-
view.insertBefore(location);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
const removed = views.splice(i, viewsLength - i);
|
|
691
|
-
for (i = 0, itemsLength = removed.length; i < itemsLength; ++i) {
|
|
692
|
-
removed[i].dispose();
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
unbindAllViews() {
|
|
697
|
-
const views = this.views;
|
|
698
|
-
for (let i = 0, ii = views.length; i < ii; ++i) {
|
|
699
|
-
views[i].unbind();
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* A directive that configures list rendering.
|
|
705
|
-
* @public
|
|
706
|
-
*/
|
|
707
|
-
class RepeatDirective extends HTMLDirective {
|
|
708
|
-
/**
|
|
709
|
-
* Creates an instance of RepeatDirective.
|
|
710
|
-
* @param itemsBinding - The binding that provides the array to render.
|
|
711
|
-
* @param templateBinding - The template binding used to obtain a template to render for each item in the array.
|
|
712
|
-
* @param options - Options used to turn on special repeat features.
|
|
713
|
-
*/
|
|
714
|
-
constructor(itemsBinding, templateBinding, options) {
|
|
715
|
-
super();
|
|
716
|
-
this.itemsBinding = itemsBinding;
|
|
717
|
-
this.templateBinding = templateBinding;
|
|
718
|
-
this.options = options;
|
|
719
|
-
/**
|
|
720
|
-
* Creates a placeholder string based on the directive's index within the template.
|
|
721
|
-
* @param index - The index of the directive within the template.
|
|
722
|
-
*/
|
|
723
|
-
this.createPlaceholder = DOM.createBlockPlaceholder;
|
|
724
|
-
enableArrayObservation();
|
|
725
|
-
this.isItemsBindingVolatile = Observable.isVolatileBinding(itemsBinding);
|
|
726
|
-
this.isTemplateBindingVolatile = Observable.isVolatileBinding(templateBinding);
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Creates a behavior for the provided target node.
|
|
730
|
-
* @param target - The node instance to create the behavior for.
|
|
731
|
-
*/
|
|
732
|
-
createBehavior(target) {
|
|
733
|
-
return new RepeatBehavior(target, this.itemsBinding, this.isItemsBindingVolatile, this.templateBinding, this.isTemplateBindingVolatile, this.options);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* A directive that enables list rendering.
|
|
738
|
-
* @param itemsBinding - The array to render.
|
|
739
|
-
* @param templateOrTemplateBinding - The template or a template binding used obtain a template
|
|
740
|
-
* to render for each item in the array.
|
|
741
|
-
* @param options - Options used to turn on special repeat features.
|
|
742
|
-
* @public
|
|
743
|
-
*/
|
|
744
|
-
function repeat(itemsBinding, templateOrTemplateBinding, options = defaultRepeatOptions) {
|
|
745
|
-
const templateBinding = typeof templateOrTemplateBinding === "function"
|
|
746
|
-
? templateOrTemplateBinding
|
|
747
|
-
: () => templateOrTemplateBinding;
|
|
748
|
-
return new RepeatDirective(itemsBinding, templateBinding, options);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
* Tests whether or not an object is an array.
|
|
753
|
-
*
|
|
754
|
-
* @private
|
|
755
|
-
* @param {*} val The object to test.
|
|
756
|
-
* @return {Boolean} `true` if `val` is an array, `false` otherwise.
|
|
757
|
-
* @example
|
|
758
|
-
*
|
|
759
|
-
* _isArray([]); //=> true
|
|
760
|
-
* _isArray(null); //=> false
|
|
761
|
-
* _isArray({}); //=> false
|
|
762
|
-
*/
|
|
763
|
-
var _isArray = Array.isArray || function _isArray(val) {
|
|
764
|
-
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
function _isString(x) {
|
|
768
|
-
return Object.prototype.toString.call(x) === '[object String]';
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
var toString = Object.prototype.toString;
|
|
772
|
-
|
|
773
|
-
var _isArguments =
|
|
774
|
-
/*#__PURE__*/
|
|
775
|
-
function () {
|
|
776
|
-
return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
|
|
777
|
-
return toString.call(x) === '[object Arguments]';
|
|
778
|
-
} : function _isArguments(x) {
|
|
779
|
-
return _has('callee', x);
|
|
780
|
-
};
|
|
781
|
-
}();
|
|
782
|
-
|
|
783
|
-
var _isArguments$1 = _isArguments;
|
|
784
|
-
|
|
785
|
-
var hasEnumBug = !
|
|
786
|
-
/*#__PURE__*/
|
|
787
|
-
{
|
|
788
|
-
toString: null
|
|
789
|
-
}.propertyIsEnumerable('toString');
|
|
790
|
-
var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug
|
|
791
|
-
|
|
792
|
-
var hasArgsEnumBug =
|
|
793
|
-
/*#__PURE__*/
|
|
794
|
-
function () {
|
|
795
|
-
|
|
796
|
-
return arguments.propertyIsEnumerable('length');
|
|
797
|
-
}();
|
|
798
|
-
|
|
799
|
-
var contains = function contains(list, item) {
|
|
800
|
-
var idx = 0;
|
|
801
|
-
|
|
802
|
-
while (idx < list.length) {
|
|
803
|
-
if (list[idx] === item) {
|
|
804
|
-
return true;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
idx += 1;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
return false;
|
|
811
|
-
};
|
|
812
|
-
/**
|
|
813
|
-
* Returns a list containing the names of all the enumerable own properties of
|
|
814
|
-
* the supplied object.
|
|
815
|
-
* Note that the order of the output array is not guaranteed to be consistent
|
|
816
|
-
* across different JS platforms.
|
|
817
|
-
*
|
|
818
|
-
* @func
|
|
819
|
-
* @memberOf R
|
|
820
|
-
* @since v0.1.0
|
|
821
|
-
* @category Object
|
|
822
|
-
* @sig {k: v} -> [k]
|
|
823
|
-
* @param {Object} obj The object to extract properties from
|
|
824
|
-
* @return {Array} An array of the object's own properties.
|
|
825
|
-
* @see R.keysIn, R.values
|
|
826
|
-
* @example
|
|
827
|
-
*
|
|
828
|
-
* R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
|
|
829
|
-
*/
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?
|
|
833
|
-
/*#__PURE__*/
|
|
834
|
-
_curry1(function keys(obj) {
|
|
835
|
-
return Object(obj) !== obj ? [] : Object.keys(obj);
|
|
836
|
-
}) :
|
|
837
|
-
/*#__PURE__*/
|
|
838
|
-
_curry1(function keys(obj) {
|
|
839
|
-
if (Object(obj) !== obj) {
|
|
840
|
-
return [];
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
var prop, nIdx;
|
|
844
|
-
var ks = [];
|
|
845
|
-
|
|
846
|
-
var checkArgsLength = hasArgsEnumBug && _isArguments$1(obj);
|
|
847
|
-
|
|
848
|
-
for (prop in obj) {
|
|
849
|
-
if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
|
|
850
|
-
ks[ks.length] = prop;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
if (hasEnumBug) {
|
|
855
|
-
nIdx = nonEnumerableProps.length - 1;
|
|
856
|
-
|
|
857
|
-
while (nIdx >= 0) {
|
|
858
|
-
prop = nonEnumerableProps[nIdx];
|
|
859
|
-
|
|
860
|
-
if (_has(prop, obj) && !contains(ks, prop)) {
|
|
861
|
-
ks[ks.length] = prop;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
nIdx -= 1;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
return ks;
|
|
869
|
-
});
|
|
870
|
-
var keys$1 = keys;
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Gives a single-word string description of the (native) type of a value,
|
|
874
|
-
* returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
|
|
875
|
-
* attempt to distinguish user Object types any further, reporting them all as
|
|
876
|
-
* 'Object'.
|
|
877
|
-
*
|
|
878
|
-
* @func
|
|
879
|
-
* @memberOf R
|
|
880
|
-
* @since v0.8.0
|
|
881
|
-
* @category Type
|
|
882
|
-
* @sig (* -> {*}) -> String
|
|
883
|
-
* @param {*} val The value to test
|
|
884
|
-
* @return {String}
|
|
885
|
-
* @example
|
|
886
|
-
*
|
|
887
|
-
* R.type({}); //=> "Object"
|
|
888
|
-
* R.type(1); //=> "Number"
|
|
889
|
-
* R.type(false); //=> "Boolean"
|
|
890
|
-
* R.type('s'); //=> "String"
|
|
891
|
-
* R.type(null); //=> "Null"
|
|
892
|
-
* R.type([]); //=> "Array"
|
|
893
|
-
* R.type(/[A-z]/); //=> "RegExp"
|
|
894
|
-
* R.type(() => {}); //=> "Function"
|
|
895
|
-
* R.type(undefined); //=> "Undefined"
|
|
896
|
-
*/
|
|
897
|
-
|
|
898
|
-
var type =
|
|
899
|
-
/*#__PURE__*/
|
|
900
|
-
_curry1(function type(val) {
|
|
901
|
-
return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
|
|
902
|
-
});
|
|
903
|
-
|
|
904
|
-
var type$1 = type;
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* A function that returns the `!` of its argument. It will return `true` when
|
|
908
|
-
* passed false-y value, and `false` when passed a truth-y one.
|
|
909
|
-
*
|
|
910
|
-
* @func
|
|
911
|
-
* @memberOf R
|
|
912
|
-
* @since v0.1.0
|
|
913
|
-
* @category Logic
|
|
914
|
-
* @sig * -> Boolean
|
|
915
|
-
* @param {*} a any value
|
|
916
|
-
* @return {Boolean} the logical inverse of passed argument.
|
|
917
|
-
* @see R.complement
|
|
918
|
-
* @example
|
|
919
|
-
*
|
|
920
|
-
* R.not(true); //=> false
|
|
921
|
-
* R.not(false); //=> true
|
|
922
|
-
* R.not(0); //=> true
|
|
923
|
-
* R.not(1); //=> false
|
|
924
|
-
*/
|
|
925
|
-
|
|
926
|
-
var not =
|
|
927
|
-
/*#__PURE__*/
|
|
928
|
-
_curry1(function not(a) {
|
|
929
|
-
return !a;
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
var not$1 = not;
|
|
933
|
-
|
|
934
|
-
function _arrayFromIterator(iter) {
|
|
935
|
-
var list = [];
|
|
936
|
-
var next;
|
|
937
|
-
|
|
938
|
-
while (!(next = iter.next()).done) {
|
|
939
|
-
list.push(next.value);
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
return list;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
function _includesWith(pred, x, list) {
|
|
946
|
-
var idx = 0;
|
|
947
|
-
var len = list.length;
|
|
948
|
-
|
|
949
|
-
while (idx < len) {
|
|
950
|
-
if (pred(x, list[idx])) {
|
|
951
|
-
return true;
|
|
952
|
-
}
|
|
953
|
-
|
|
954
|
-
idx += 1;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
return false;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
function _functionName(f) {
|
|
961
|
-
// String(x => x) evaluates to "x => x", so the pattern may not match.
|
|
962
|
-
var match = String(f).match(/^function (\w*)/);
|
|
963
|
-
return match == null ? '' : match[1];
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
967
|
-
function _objectIs(a, b) {
|
|
968
|
-
// SameValue algorithm
|
|
969
|
-
if (a === b) {
|
|
970
|
-
// Steps 1-5, 7-10
|
|
971
|
-
// Steps 6.b-6.e: +0 != -0
|
|
972
|
-
return a !== 0 || 1 / a === 1 / b;
|
|
973
|
-
} else {
|
|
974
|
-
// Step 6.a: NaN == NaN
|
|
975
|
-
return a !== a && b !== b;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
* private _uniqContentEquals function.
|
|
983
|
-
* That function is checking equality of 2 iterator contents with 2 assumptions
|
|
984
|
-
* - iterators lengths are the same
|
|
985
|
-
* - iterators values are unique
|
|
986
|
-
*
|
|
987
|
-
* false-positive result will be returned for comparision of, e.g.
|
|
988
|
-
* - [1,2,3] and [1,2,3,4]
|
|
989
|
-
* - [1,1,1] and [1,2,3]
|
|
990
|
-
* */
|
|
991
|
-
|
|
992
|
-
function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
|
|
993
|
-
var a = _arrayFromIterator(aIterator);
|
|
994
|
-
|
|
995
|
-
var b = _arrayFromIterator(bIterator);
|
|
996
|
-
|
|
997
|
-
function eq(_a, _b) {
|
|
998
|
-
return _equals(_a, _b, stackA.slice(), stackB.slice());
|
|
999
|
-
} // if *a* array contains any element that is not included in *b*
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
return !_includesWith(function (b, aItem) {
|
|
1003
|
-
return !_includesWith(eq, aItem, b);
|
|
1004
|
-
}, b, a);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
function _equals(a, b, stackA, stackB) {
|
|
1008
|
-
if (_objectIs$1(a, b)) {
|
|
1009
|
-
return true;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
var typeA = type$1(a);
|
|
1013
|
-
|
|
1014
|
-
if (typeA !== type$1(b)) {
|
|
1015
|
-
return false;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
if (a == null || b == null) {
|
|
1019
|
-
return false;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
|
|
1023
|
-
return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
if (typeof a.equals === 'function' || typeof b.equals === 'function') {
|
|
1027
|
-
return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
switch (typeA) {
|
|
1031
|
-
case 'Arguments':
|
|
1032
|
-
case 'Array':
|
|
1033
|
-
case 'Object':
|
|
1034
|
-
if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
|
|
1035
|
-
return a === b;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
break;
|
|
1039
|
-
|
|
1040
|
-
case 'Boolean':
|
|
1041
|
-
case 'Number':
|
|
1042
|
-
case 'String':
|
|
1043
|
-
if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
break;
|
|
1048
|
-
|
|
1049
|
-
case 'Date':
|
|
1050
|
-
if (!_objectIs$1(a.valueOf(), b.valueOf())) {
|
|
1051
|
-
return false;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
break;
|
|
1055
|
-
|
|
1056
|
-
case 'Error':
|
|
1057
|
-
return a.name === b.name && a.message === b.message;
|
|
1058
|
-
|
|
1059
|
-
case 'RegExp':
|
|
1060
|
-
if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
|
|
1061
|
-
return false;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
break;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
var idx = stackA.length - 1;
|
|
1068
|
-
|
|
1069
|
-
while (idx >= 0) {
|
|
1070
|
-
if (stackA[idx] === a) {
|
|
1071
|
-
return stackB[idx] === b;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
idx -= 1;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
switch (typeA) {
|
|
1078
|
-
case 'Map':
|
|
1079
|
-
if (a.size !== b.size) {
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
|
|
1084
|
-
|
|
1085
|
-
case 'Set':
|
|
1086
|
-
if (a.size !== b.size) {
|
|
1087
|
-
return false;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
|
|
1091
|
-
|
|
1092
|
-
case 'Arguments':
|
|
1093
|
-
case 'Array':
|
|
1094
|
-
case 'Object':
|
|
1095
|
-
case 'Boolean':
|
|
1096
|
-
case 'Number':
|
|
1097
|
-
case 'String':
|
|
1098
|
-
case 'Date':
|
|
1099
|
-
case 'Error':
|
|
1100
|
-
case 'RegExp':
|
|
1101
|
-
case 'Int8Array':
|
|
1102
|
-
case 'Uint8Array':
|
|
1103
|
-
case 'Uint8ClampedArray':
|
|
1104
|
-
case 'Int16Array':
|
|
1105
|
-
case 'Uint16Array':
|
|
1106
|
-
case 'Int32Array':
|
|
1107
|
-
case 'Uint32Array':
|
|
1108
|
-
case 'Float32Array':
|
|
1109
|
-
case 'Float64Array':
|
|
1110
|
-
case 'ArrayBuffer':
|
|
1111
|
-
break;
|
|
1112
|
-
|
|
1113
|
-
default:
|
|
1114
|
-
// Values of other types are only equal if identical.
|
|
1115
|
-
return false;
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
var keysA = keys$1(a);
|
|
1119
|
-
|
|
1120
|
-
if (keysA.length !== keys$1(b).length) {
|
|
1121
|
-
return false;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
var extendedStackA = stackA.concat([a]);
|
|
1125
|
-
var extendedStackB = stackB.concat([b]);
|
|
1126
|
-
idx = keysA.length - 1;
|
|
1127
|
-
|
|
1128
|
-
while (idx >= 0) {
|
|
1129
|
-
var key = keysA[idx];
|
|
1130
|
-
|
|
1131
|
-
if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
|
|
1132
|
-
return false;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
idx -= 1;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
return true;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* Returns `true` if its arguments are equivalent, `false` otherwise. Handles
|
|
1143
|
-
* cyclical data structures.
|
|
1144
|
-
*
|
|
1145
|
-
* Dispatches symmetrically to the `equals` methods of both arguments, if
|
|
1146
|
-
* present.
|
|
1147
|
-
*
|
|
1148
|
-
* @func
|
|
1149
|
-
* @memberOf R
|
|
1150
|
-
* @since v0.15.0
|
|
1151
|
-
* @category Relation
|
|
1152
|
-
* @sig a -> b -> Boolean
|
|
1153
|
-
* @param {*} a
|
|
1154
|
-
* @param {*} b
|
|
1155
|
-
* @return {Boolean}
|
|
1156
|
-
* @example
|
|
1157
|
-
*
|
|
1158
|
-
* R.equals(1, 1); //=> true
|
|
1159
|
-
* R.equals(1, '1'); //=> false
|
|
1160
|
-
* R.equals([1, 2, 3], [1, 2, 3]); //=> true
|
|
1161
|
-
*
|
|
1162
|
-
* const a = {}; a.v = a;
|
|
1163
|
-
* const b = {}; b.v = b;
|
|
1164
|
-
* R.equals(a, b); //=> true
|
|
1165
|
-
*/
|
|
1166
|
-
|
|
1167
|
-
var equals =
|
|
1168
|
-
/*#__PURE__*/
|
|
1169
|
-
_curry2(function equals(a, b) {
|
|
1170
|
-
return _equals(a, b, [], []);
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
var equals$1 = equals;
|
|
1174
|
-
|
|
1175
|
-
function _isObject(x) {
|
|
1176
|
-
return Object.prototype.toString.call(x) === '[object Object]';
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* Returns the empty value of its argument's type. Ramda defines the empty
|
|
1181
|
-
* value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
|
|
1182
|
-
* types are supported if they define `<Type>.empty`,
|
|
1183
|
-
* `<Type>.prototype.empty` or implement the
|
|
1184
|
-
* [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
|
|
1185
|
-
*
|
|
1186
|
-
* Dispatches to the `empty` method of the first argument, if present.
|
|
1187
|
-
*
|
|
1188
|
-
* @func
|
|
1189
|
-
* @memberOf R
|
|
1190
|
-
* @since v0.3.0
|
|
1191
|
-
* @category Function
|
|
1192
|
-
* @sig a -> a
|
|
1193
|
-
* @param {*} x
|
|
1194
|
-
* @return {*}
|
|
1195
|
-
* @example
|
|
1196
|
-
*
|
|
1197
|
-
* R.empty(Just(42)); //=> Nothing()
|
|
1198
|
-
* R.empty([1, 2, 3]); //=> []
|
|
1199
|
-
* R.empty('unicorns'); //=> ''
|
|
1200
|
-
* R.empty({x: 1, y: 2}); //=> {}
|
|
1201
|
-
*/
|
|
1202
|
-
|
|
1203
|
-
var empty =
|
|
1204
|
-
/*#__PURE__*/
|
|
1205
|
-
_curry1(function empty(x) {
|
|
1206
|
-
return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments$1(x) ? function () {
|
|
1207
|
-
return arguments;
|
|
1208
|
-
}() : void 0 // else
|
|
1209
|
-
;
|
|
1210
|
-
});
|
|
1211
|
-
|
|
1212
|
-
var empty$1 = empty;
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
* Returns `true` if the given value is its type's empty value; `false`
|
|
1216
|
-
* otherwise.
|
|
1217
|
-
*
|
|
1218
|
-
* @func
|
|
1219
|
-
* @memberOf R
|
|
1220
|
-
* @since v0.1.0
|
|
1221
|
-
* @category Logic
|
|
1222
|
-
* @sig a -> Boolean
|
|
1223
|
-
* @param {*} x
|
|
1224
|
-
* @return {Boolean}
|
|
1225
|
-
* @see R.empty
|
|
1226
|
-
* @example
|
|
1227
|
-
*
|
|
1228
|
-
* R.isEmpty([1, 2, 3]); //=> false
|
|
1229
|
-
* R.isEmpty([]); //=> true
|
|
1230
|
-
* R.isEmpty(''); //=> true
|
|
1231
|
-
* R.isEmpty(null); //=> false
|
|
1232
|
-
* R.isEmpty({}); //=> true
|
|
1233
|
-
* R.isEmpty({length: 0}); //=> false
|
|
1234
|
-
*/
|
|
1235
|
-
|
|
1236
|
-
var isEmpty =
|
|
1237
|
-
/*#__PURE__*/
|
|
1238
|
-
_curry1(function isEmpty(x) {
|
|
1239
|
-
return x != null && equals$1(x, empty$1(x));
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
var isEmpty$1 = isEmpty;
|
|
1243
|
-
|
|
1244
|
-
var css_248z = "/*\n Do not edit directly\n Generated on Wed, 27 Apr 2022 11:58:36 GMT\n*/\nol {\n padding: 0;\n margin: 0;\n list-style: none;\n}\n\n[role=grid i] {\n position: relative;\n z-index: 0;\n display: grid;\n margin: auto;\n grid-template-areas: \". column-headers\" \"row-headers calendar\";\n grid-template-columns: min-content auto;\n inline-size: max(100%, 500px);\n min-inline-size: 880px;\n}\n\n.row-headers {\n display: grid;\n grid-area: row-headers;\n grid-template-rows: repeat(24, 1fr);\n margin-inline-end: 2px;\n}\n.row-headers > [role=rowheader i] {\n display: flex;\n align-items: flex-end;\n justify-content: flex-end;\n}\n.row-headers > [role=rowheader i] > time {\n font: 400 ultra-condensed 12px / 16px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n font-size: small;\n line-height: 1;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n.calendar-row {\n display: contents;\n}\n\n.calendar-grid-presentation {\n display: grid;\n overflow: hidden;\n background-color: var(--vvd-color-surface-2dp);\n border-radius: 6px;\n counter-reset: listing;\n filter: var(--vvd-shadow-surface-2dp);\n gap: 1px;\n grid-area: calendar;\n grid-auto-flow: column;\n grid-template: repeat(24, 1fr)/repeat(7, 1fr);\n}\n\n.hours {\n display: contents;\n}\n.hours > [role=listitem i] {\n position: relative;\n grid-column: 1/8;\n grid-row: var(--row);\n min-block-size: 48px;\n pointer-events: none;\n}\n.hours > [role=listitem i]:not(:first-child)::after {\n position: absolute;\n border-block-end: var(--vvd-color-neutral-20) 1px solid;\n content: \"\";\n inline-size: 100%;\n margin-block-start: -1px;\n}\n.hours > [role=listitem i]:nth-child(24n+1) {\n --row: 1;\n}\n.hours > [role=listitem i]:nth-child(24n+2) {\n --row: 2;\n}\n.hours > [role=listitem i]:nth-child(24n+3) {\n --row: 3;\n}\n.hours > [role=listitem i]:nth-child(24n+4) {\n --row: 4;\n}\n.hours > [role=listitem i]:nth-child(24n+5) {\n --row: 5;\n}\n.hours > [role=listitem i]:nth-child(24n+6) {\n --row: 6;\n}\n.hours > [role=listitem i]:nth-child(24n+7) {\n --row: 7;\n}\n.hours > [role=listitem i]:nth-child(24n+8) {\n --row: 8;\n}\n.hours > [role=listitem i]:nth-child(24n+9) {\n --row: 9;\n}\n.hours > [role=listitem i]:nth-child(24n+10) {\n --row: 10;\n}\n.hours > [role=listitem i]:nth-child(24n+11) {\n --row: 11;\n}\n.hours > [role=listitem i]:nth-child(24n+12) {\n --row: 12;\n}\n.hours > [role=listitem i]:nth-child(24n+13) {\n --row: 13;\n}\n.hours > [role=listitem i]:nth-child(24n+14) {\n --row: 14;\n}\n.hours > [role=listitem i]:nth-child(24n+15) {\n --row: 15;\n}\n.hours > [role=listitem i]:nth-child(24n+16) {\n --row: 16;\n}\n.hours > [role=listitem i]:nth-child(24n+17) {\n --row: 17;\n}\n.hours > [role=listitem i]:nth-child(24n+18) {\n --row: 18;\n}\n.hours > [role=listitem i]:nth-child(24n+19) {\n --row: 19;\n}\n.hours > [role=listitem i]:nth-child(24n+20) {\n --row: 20;\n}\n.hours > [role=listitem i]:nth-child(24n+21) {\n --row: 21;\n}\n.hours > [role=listitem i]:nth-child(24n+22) {\n --row: 22;\n}\n.hours > [role=listitem i]:nth-child(24n+23) {\n --row: 23;\n}\n.hours > [role=listitem i]:nth-child(24n+24) {\n --row: 24;\n}\n\n[role=gridcell i] {\n display: grid;\n gap: 1px;\n grid-auto-flow: column;\n}\n\n[role=gridcell i],\n[role=columnheader i],\n[role=columnheader i] [role=button i] {\n position: relative;\n}\n[role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n position: absolute;\n z-index: -1;\n background-color: var(--vvd-color-info-10);\n content: \"\";\n}\n@supports (inset: 0) {\n [role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n inset: 0;\n }\n}\n@supports not (inset: 0) {\n [role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n}\n[role=gridcell i]:focus,\n[role=columnheader i]:focus,\n[role=columnheader i] [role=button i]:focus {\n outline: none;\n}\n[role=gridcell i]:not(:focus)::before,\n[role=columnheader i]:not(:focus)::before,\n[role=columnheader i] [role=button i]:not(:focus)::before {\n display: none;\n}\n\n.columns {\n display: contents;\n}\n.columns > [role=gridcell i] {\n position: relative;\n grid-column: var(--column);\n grid-row: 1/25;\n}\n.columns > [role=gridcell i]:nth-child(1) {\n --column: 1;\n}\n.columns > [role=gridcell i]:nth-child(2) {\n --column: 2;\n}\n.columns > [role=gridcell i]:nth-child(3) {\n --column: 3;\n}\n.columns > [role=gridcell i]:nth-child(4) {\n --column: 4;\n}\n.columns > [role=gridcell i]:nth-child(5) {\n --column: 5;\n}\n.columns > [role=gridcell i]:nth-child(6) {\n --column: 6;\n}\n.columns > [role=gridcell i]:nth-child(7) {\n --column: 7;\n}\n.columns > [role=gridcell i]:not(:first-child)::after {\n position: absolute;\n block-size: 100%;\n border-inline-end: var(--vvd-color-neutral-20) 1px solid;\n content: \"\";\n margin-inline-start: -1px;\n}\n\n.column-headers {\n display: grid;\n grid-area: column-headers;\n grid-template-columns: repeat(7, 1fr);\n}\n.column-headers [role=columnheader i] h2 {\n font: 500 condensed 20px / 28px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n display: grid;\n align-items: baseline;\n margin: 0;\n grid-template-columns: 1fr auto 1fr;\n}\n.column-headers [role=columnheader i] h2 > em {\n font: inherit;\n inline-size: min-content;\n}\n@supports (inset: 0) {\n .column-headers [role=columnheader i] h2 > em {\n inset-inline-start: 0;\n }\n}\n@supports not (inset: 0) {\n .column-headers [role=columnheader i] h2 > em {\n left: 0;\n }\n}\n.column-headers [role=columnheader i] h2 > small {\n font: 400 ultra-condensed 12px / 16px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n text-transform: uppercase;\n}";
|
|
1245
|
-
styleInject(css_248z);
|
|
1246
|
-
|
|
1247
|
-
const ARROW_UP = 'ArrowUp';
|
|
1248
|
-
const ARROW_RIGHT = 'ArrowRight';
|
|
1249
|
-
const ARROW_DOWN = 'ArrowDown';
|
|
1250
|
-
const ARROW_LEFT = 'ArrowLeft';
|
|
1251
|
-
function isCellOrHeader(el) {
|
|
1252
|
-
return el instanceof HTMLElement && (el.matches('[role="gridcell"i]') || el.matches('[role="columnheader"i]'));
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
const getCellOrHeader = f => f.matches('[role="columnheader"i]') ? '[role="gridcell"i]' : '[role="columnheader"i]';
|
|
1256
|
-
|
|
1257
|
-
function getNextFocusableGridElement(key, activeElement) {
|
|
1258
|
-
if (activeElement.parentNode instanceof HTMLElement) {
|
|
1259
|
-
switch (key) {
|
|
1260
|
-
case ARROW_RIGHT:
|
|
1261
|
-
return activeElement.nextElementSibling || activeElement.parentNode.firstElementChild;
|
|
1262
|
-
|
|
1263
|
-
case ARROW_LEFT:
|
|
1264
|
-
return activeElement.previousElementSibling || activeElement.parentNode.lastElementChild;
|
|
1265
|
-
|
|
1266
|
-
case ARROW_UP:
|
|
1267
|
-
case ARROW_DOWN:
|
|
1268
|
-
{
|
|
1269
|
-
const {
|
|
1270
|
-
children
|
|
1271
|
-
} = activeElement.parentNode;
|
|
1272
|
-
const i = Array.from(children).indexOf(activeElement);
|
|
1273
|
-
return this.shadowRoot.querySelector(`${getCellOrHeader(activeElement)}:nth-child(${i + 1})`);
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
function getHeaderDescendantGridCell(key, activeElement) {
|
|
1279
|
-
if (key !== ARROW_DOWN) {
|
|
1280
|
-
return;
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
const header = activeElement.closest('[role="columnheader"i]');
|
|
1284
|
-
const columnHeaders = this.shadowRoot.querySelectorAll('[role="columnheader"i]');
|
|
1285
|
-
const i = Array.from(columnHeaders).indexOf(header);
|
|
1286
|
-
return this.shadowRoot.querySelector(`[role="gridcell"i]:nth-child(${i + 1})`);
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
function getDay(el) {
|
|
1290
|
-
const cellOrHeader = el.closest('[role="gridcell"i], [role="columnheader"i]');
|
|
1291
|
-
|
|
1292
|
-
if (cellOrHeader) {
|
|
1293
|
-
const {
|
|
1294
|
-
parentElement
|
|
1295
|
-
} = cellOrHeader;
|
|
1296
|
-
|
|
1297
|
-
if (parentElement) {
|
|
1298
|
-
return parentElement.children && Array.from(parentElement.children).indexOf(cellOrHeader);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
function getHour(e, el, hours) {
|
|
1304
|
-
const rowHeaderOrCell = el.closest('[role="rowheader"], [role="gridcell"i]');
|
|
1305
|
-
|
|
1306
|
-
if (rowHeaderOrCell) {
|
|
1307
|
-
const DOMRect = rowHeaderOrCell.getBoundingClientRect();
|
|
1308
|
-
const offsetY = e.clientY - DOMRect.y;
|
|
1309
|
-
const hourHeight = DOMRect.height / hours;
|
|
1310
|
-
const hour = offsetY / hourHeight;
|
|
1311
|
-
return Math.round((hour + Number.EPSILON) * 100) / 100;
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
const getEventContext = function getEventContext(e) {
|
|
1316
|
-
if (!(e instanceof KeyboardEvent || e instanceof MouseEvent)) {
|
|
1317
|
-
throw new Error('Invalid event. Event must be instance of KeyboardEvent or MouseEvent');
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
const [el] = e.composedPath();
|
|
1321
|
-
|
|
1322
|
-
if (!(el && el instanceof HTMLElement && this.shadowRoot.contains(el))) {
|
|
1323
|
-
throw new Error('Invalid event. Event must contain a target object which is a direct descendant of calendar');
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
const day = getDay(el);
|
|
1327
|
-
let hour;
|
|
1328
|
-
|
|
1329
|
-
if (e instanceof MouseEvent) {
|
|
1330
|
-
hour = getHour(e, el, this._hours);
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
const context = Object.assign(Object.assign({}, day != undefined && {
|
|
1334
|
-
day
|
|
1335
|
-
}), hour != undefined && {
|
|
1336
|
-
hour
|
|
1337
|
-
});
|
|
1338
|
-
return not$1(isEmpty$1(context)) ? context : null;
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
class Calendar extends FoundationElement {
|
|
1342
|
-
constructor() {
|
|
1343
|
-
super(...arguments);
|
|
1344
|
-
this.hour12 = false;
|
|
1345
|
-
this._hours = 24;
|
|
1346
|
-
this._days = 7;
|
|
1347
|
-
this.hoursAsDatetime = Array.from({
|
|
1348
|
-
length: this._hours - 1
|
|
1349
|
-
}).fill(new Date(new Date().setHours(0, 0, 0))).map((d, i) => new Date(d.setHours(++i)));
|
|
1350
|
-
|
|
1351
|
-
this._generateDaysArr = dateArr => {
|
|
1352
|
-
if (dateArr.length == this._days) {
|
|
1353
|
-
return dateArr;
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
const lastDate = new Date(dateArr[dateArr.length - 1]);
|
|
1357
|
-
lastDate.setDate(lastDate.getDate() + 1);
|
|
1358
|
-
return this._generateDaysArr([...dateArr, lastDate]);
|
|
1359
|
-
};
|
|
1360
|
-
|
|
1361
|
-
this.getEventContext = getEventContext;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
arrowKeysInteractions(key) {
|
|
1365
|
-
const activeElement = this.shadowRoot.activeElement;
|
|
1366
|
-
let focusNext;
|
|
1367
|
-
|
|
1368
|
-
if (isCellOrHeader(activeElement)) {
|
|
1369
|
-
focusNext = getNextFocusableGridElement.call(this, key, activeElement);
|
|
1370
|
-
} else if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.matches('em[role="button"i]')) {
|
|
1371
|
-
focusNext = getHeaderDescendantGridCell.call(this, key, activeElement);
|
|
1372
|
-
} else {
|
|
1373
|
-
focusNext = this.shadowRoot.querySelector('[role="columnheader"i]');
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
this.moveTo(focusNext);
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
moveTo(el) {
|
|
1380
|
-
const onBlur = ({
|
|
1381
|
-
target
|
|
1382
|
-
}) => target.setAttribute('tabindex', '-1');
|
|
1383
|
-
|
|
1384
|
-
el === null || el === void 0 ? void 0 : el.addEventListener('blur', onBlur, {
|
|
1385
|
-
once: true
|
|
1386
|
-
});
|
|
1387
|
-
el === null || el === void 0 ? void 0 : el.setAttribute('tabindex', '0');
|
|
1388
|
-
el === null || el === void 0 ? void 0 : el.focus();
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
onKeydown({
|
|
1392
|
-
key
|
|
1393
|
-
}) {
|
|
1394
|
-
const isArrow = [ARROW_UP, ARROW_RIGHT, ARROW_DOWN, ARROW_LEFT].some(predefinedKey => predefinedKey == key);
|
|
1395
|
-
|
|
1396
|
-
if (isArrow) {
|
|
1397
|
-
this.arrowKeysInteractions(key);
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
return !isArrow;
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
__decorate([attr, __metadata("design:type", Object)], Calendar.prototype, "datetime", void 0);
|
|
1406
|
-
|
|
1407
|
-
__decorate([attr({
|
|
1408
|
-
attribute: 'start-day'
|
|
1409
|
-
}), __metadata("design:type", String)], Calendar.prototype, "startDay", void 0);
|
|
1410
|
-
|
|
1411
|
-
__decorate([attr, __metadata("design:type", Object)], Calendar.prototype, "locales", void 0);
|
|
1412
|
-
|
|
1413
|
-
__decorate([attr({
|
|
1414
|
-
mode: 'boolean'
|
|
1415
|
-
}), __metadata("design:type", Object)], Calendar.prototype, "hour12", void 0);
|
|
1416
|
-
|
|
1417
|
-
function getValidDateString(date) {
|
|
1418
|
-
const twoDigit = num => `0${num}`.slice(-2);
|
|
1419
|
-
|
|
1420
|
-
return `${date.getFullYear()}-${twoDigit(date.getMonth() + 1)}-${twoDigit(date.getDate())}`;
|
|
1421
|
-
}
|
|
1422
|
-
const weekdaysMap = new Map([['sunday', 0], ['monday', 1]]);
|
|
1423
|
-
function getFirstDateOfTheWeek(date = new Date(), startDay) {
|
|
1424
|
-
date = new Date(date);
|
|
1425
|
-
let num = weekdaysMap.get(startDay);
|
|
1426
|
-
num !== null && num !== void 0 ? num : num = 1;
|
|
1427
|
-
const day = date.getDate() - (date.getDay() + 7 - num) % 7;
|
|
1428
|
-
return new Date(date.setDate(day));
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
let _2 = t => t,
|
|
1432
|
-
_t,
|
|
1433
|
-
_t2,
|
|
1434
|
-
_t3,
|
|
1435
|
-
_t4,
|
|
1436
|
-
_t5,
|
|
1437
|
-
_t6,
|
|
1438
|
-
_t7;
|
|
1439
|
-
|
|
1440
|
-
const HoursTemplate = () => {
|
|
1441
|
-
return html(_t || (_t = _2`
|
|
1442
|
-
<div class="row-headers" role="presentation">
|
|
1443
|
-
${0}
|
|
1444
|
-
</div>`), repeat(x => x.hoursAsDatetime, html(_t2 || (_t2 = _2`<span role="rowheader">
|
|
1445
|
-
<time datetime="${0}">
|
|
1446
|
-
${0}
|
|
1447
|
-
</time>
|
|
1448
|
-
</span>`), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
|
|
1449
|
-
hour: 'numeric',
|
|
1450
|
-
minute: 'numeric',
|
|
1451
|
-
hour12: false
|
|
1452
|
-
}).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
|
|
1453
|
-
hour: 'numeric',
|
|
1454
|
-
hour12: c.parent.hour12
|
|
1455
|
-
}).format(x))));
|
|
1456
|
-
};
|
|
1457
|
-
|
|
1458
|
-
const DaysTemplate = () => {
|
|
1459
|
-
return html(_t3 || (_t3 = _2`
|
|
1460
|
-
<div class="column-headers" role="row">
|
|
1461
|
-
${0}
|
|
1462
|
-
</div>`), repeat(x => x._generateDaysArr([getFirstDateOfTheWeek(x.datetime, x.startDay)]), html(_t4 || (_t4 = _2`
|
|
1463
|
-
<div role="columnheader" tabindex="-1">
|
|
1464
|
-
<time datetime=${0}>
|
|
1465
|
-
<h2>
|
|
1466
|
-
<!-- TODO add to column aria-labelledby or describedby to count
|
|
1467
|
-
events and related day e.g. "3 events, Sunday, March 8" -->
|
|
1468
|
-
<em tabindex="0" role="button" aria-label=${0}>
|
|
1469
|
-
${0}
|
|
1470
|
-
</em>
|
|
1471
|
-
<small aria-hidden="true">
|
|
1472
|
-
${0}
|
|
1473
|
-
</small>
|
|
1474
|
-
</h2>
|
|
1475
|
-
</time>
|
|
1476
|
-
</div>`), x => getValidDateString(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
|
|
1477
|
-
weekday: 'long',
|
|
1478
|
-
month: 'long',
|
|
1479
|
-
day: 'numeric'
|
|
1480
|
-
}).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
|
|
1481
|
-
day: '2-digit'
|
|
1482
|
-
}).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
|
|
1483
|
-
weekday: 'short'
|
|
1484
|
-
}).format(x))));
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
|
-
const ColumnTemplate = html(_t5 || (_t5 = _2`
|
|
1488
|
-
<div role="gridcell" tabindex="-1">
|
|
1489
|
-
<slot name="day-${0}"></slot>
|
|
1490
|
-
</div>
|
|
1491
|
-
`), (_, c) => c.index);
|
|
1492
|
-
const CalendarTemplate = () => html(_t6 || (_t6 = _2`
|
|
1493
|
-
<div role="grid" @keydown=${0}>
|
|
1494
|
-
${0}
|
|
1495
|
-
<div role="row" class="calendar-row">
|
|
1496
|
-
${0}
|
|
1497
|
-
<div class="calendar-grid-presentation" role="presentation">
|
|
1498
|
-
<div class="hours" role="list">
|
|
1499
|
-
${0}
|
|
1500
|
-
</div>
|
|
1501
|
-
<div class="columns" role="presentation">
|
|
1502
|
-
${0}
|
|
1503
|
-
</div>
|
|
1504
|
-
<slot></slot>
|
|
1505
|
-
</div>
|
|
1506
|
-
</div>
|
|
1507
|
-
</div>
|
|
1508
|
-
`), (x, c) => x.onKeydown(c.event), DaysTemplate, HoursTemplate, repeat(x => Array.from({
|
|
1509
|
-
length: x.hoursAsDatetime.length + 1
|
|
1510
|
-
}), html(_t7 || (_t7 = _2`
|
|
1511
|
-
<div role="listitem"></div>`))), repeat(x => Array.from(Array(x._days)), ColumnTemplate, {
|
|
1512
|
-
positioning: true
|
|
1513
|
-
}));
|
|
1514
|
-
|
|
1515
|
-
const vividCalendar = Calendar.compose({
|
|
1516
|
-
baseName: 'calendar',
|
|
1517
|
-
template: CalendarTemplate,
|
|
1518
|
-
styles: css_248z
|
|
1519
|
-
});
|
|
1520
|
-
designSystem.register(vividCalendar());
|
|
1521
|
-
|
|
1522
|
-
export { vividCalendar };
|
|
8
|
+
registerCalendar();
|