@drayman/elements 1.58.0 → 1.60.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/dist/nebula/main.js +3 -3
- package/dist/table/main.js +1 -1
- package/dist/types/year-calendar/src/app/models/year-calendar-options.d.ts +17 -0
- package/dist/year-calendar/3rdpartylicenses.txt +271 -0
- package/dist/year-calendar/favicon.ico +0 -0
- package/dist/year-calendar/main.js +1 -0
- package/dist/year-calendar/polyfills.js +1 -0
- package/dist/year-calendar/styles.css +0 -0
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
- package/dist/types/year-calendar/options.d.ts +0 -24
- package/dist/year-calendar/index.js +0 -128
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drayman/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"description": "A collection of web components for Drayman.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"build:ngx-charts": "ng build ngx-charts --configuration production --single-bundle --output-hashing=none",
|
|
37
37
|
"build:ngx-graph": "ng build ngx-graph --configuration production --single-bundle --output-hashing=none",
|
|
38
38
|
"build:menu": "ng build menu --configuration production --single-bundle --output-hashing=none",
|
|
39
|
-
"build:year-calendar": "
|
|
39
|
+
"build:year-calendar": "ng build year-calendar --configuration production --single-bundle --output-hashing=none",
|
|
40
40
|
"create-element": "./element-generator/create.sh",
|
|
41
41
|
"e2e": "ng e2e"
|
|
42
42
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"script": "./dist/calendar/main.js"
|
|
56
56
|
},
|
|
57
57
|
"drayman-year-calendar": {
|
|
58
|
-
"script": "./dist/year-calendar/
|
|
58
|
+
"script": "./dist/year-calendar/main.js"
|
|
59
59
|
},
|
|
60
60
|
"drayman-code-editor": {
|
|
61
61
|
"script": "./dist/code-editor/main.js"
|
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DraymanClavizCharts } from '../dist/types/claviz-charts/src/app/models/
|
|
|
3
3
|
import { DraymanDatepicker } from '../dist/types/datepicker/src/app/models/datepicker-options';
|
|
4
4
|
import { DraymanGauge } from '../dist/types/gauge/src/app/models/gauge-options';
|
|
5
5
|
import { DraymanFileUploader } from '../dist/types/file-uploader/src/app/models/file-uploader-options';
|
|
6
|
-
import { DraymanYearCalendar } from '../dist/types/year-calendar/options';
|
|
6
|
+
import { DraymanYearCalendar } from '../dist/types/year-calendar/src/app/models/year-calendar-options';
|
|
7
7
|
import { DraymanMenu } from '../dist/types/menu/src/app/models/menu-options';
|
|
8
8
|
import { DraymanNgxCharts } from '../dist/types/ngx-charts/src/app/models/ngx-charts-options';
|
|
9
9
|
import { DraymanNgxGraph } from '../dist/types/ngx-graph/src/app/models/ngx-graph-options';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface DraymanYearCalendar {
|
|
2
|
-
/**
|
|
3
|
-
* Array of events to be displayed in the calendar.
|
|
4
|
-
*/
|
|
5
|
-
events?: {
|
|
6
|
-
title: string;
|
|
7
|
-
id: any;
|
|
8
|
-
color: string;
|
|
9
|
-
start: string;
|
|
10
|
-
end?: string;
|
|
11
|
-
}[];
|
|
12
|
-
/**
|
|
13
|
-
* Executed when user clicks on an event.
|
|
14
|
-
*/
|
|
15
|
-
onEventClick?: ElementEvent<{
|
|
16
|
-
id: any;
|
|
17
|
-
}>;
|
|
18
|
-
/**
|
|
19
|
-
* Executed when user clicks on a day.
|
|
20
|
-
*/
|
|
21
|
-
onDayClick?: ElementEvent<{
|
|
22
|
-
date: string;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
class CalendarGrid extends HTMLElement {
|
|
2
|
-
constructor() {
|
|
3
|
-
super();
|
|
4
|
-
this.attachShadow({ mode: 'open' });
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
connectedCallback() {
|
|
8
|
-
this.render();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
render() {
|
|
12
|
-
const blocksPerRow = 4;
|
|
13
|
-
const blocksPerCol = 3;
|
|
14
|
-
const blockWidth = 7;
|
|
15
|
-
const blockHeight = 8;
|
|
16
|
-
const gap = 1;
|
|
17
|
-
const cellWidth = 40;
|
|
18
|
-
const cellHeight = 20;
|
|
19
|
-
const megaColumns = blocksPerRow * blockWidth + (blocksPerRow - 1) * gap;
|
|
20
|
-
const megaRows = blocksPerCol * blockHeight + (blocksPerCol - 1) * gap;
|
|
21
|
-
|
|
22
|
-
this.shadowRoot.innerHTML = '';
|
|
23
|
-
|
|
24
|
-
const style = document.createElement('style');
|
|
25
|
-
style.textContent = `
|
|
26
|
-
.calendar {
|
|
27
|
-
display: grid;
|
|
28
|
-
grid-template-columns: repeat(${megaColumns}, ${cellWidth}px);
|
|
29
|
-
grid-template-rows: repeat(${megaRows}, ${cellHeight}px);
|
|
30
|
-
gap: ${gap}px;
|
|
31
|
-
}
|
|
32
|
-
.cell {
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
justify-content: center;
|
|
36
|
-
}
|
|
37
|
-
.cell.clickable {
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
40
|
-
.cell.header {
|
|
41
|
-
font-weight: bold;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
text-align: center;
|
|
44
|
-
white-space: nowrap;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
text-overflow: ellipsis;
|
|
47
|
-
}
|
|
48
|
-
.cell.weekday {
|
|
49
|
-
font-weight: bold;
|
|
50
|
-
background-color: #f0f0f0;
|
|
51
|
-
border-bottom: 1px solid #000;
|
|
52
|
-
}
|
|
53
|
-
.cell.selected {
|
|
54
|
-
background-color: red;
|
|
55
|
-
}
|
|
56
|
-
`;
|
|
57
|
-
this.shadowRoot.appendChild(style);
|
|
58
|
-
|
|
59
|
-
const container = document.createElement('div');
|
|
60
|
-
container.classList.add('calendar');
|
|
61
|
-
this.shadowRoot.appendChild(container);
|
|
62
|
-
|
|
63
|
-
const daysOfWeek = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
64
|
-
|
|
65
|
-
for (let m = 1; m <= 12; m++) {
|
|
66
|
-
const monthIdx = m - 1;
|
|
67
|
-
const baseCol = (monthIdx % blocksPerRow) * (blockWidth + gap);
|
|
68
|
-
const baseRow = Math.floor(monthIdx / blocksPerRow) * (blockHeight + gap);
|
|
69
|
-
|
|
70
|
-
const firstDate = new Date(this.year, m - 1, 1);
|
|
71
|
-
const monthName = firstDate.toLocaleString('default', { month: 'long' });
|
|
72
|
-
const headerCell = this._createCell(container, baseRow, baseCol, '', monthName, ['cell', 'header']);
|
|
73
|
-
headerCell.style.gridColumnStart = baseCol + 1;
|
|
74
|
-
headerCell.style.gridColumnEnd = baseCol + 1 + blockWidth;
|
|
75
|
-
|
|
76
|
-
daysOfWeek.forEach((day, di) => {
|
|
77
|
-
this._createCell(container, baseRow + 1, baseCol + di, '', day, ['cell', 'weekday']);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
for (let i = 0; i < 42; i++) {
|
|
81
|
-
const dayNum = i - ((firstDate.getDay() + 6) % 7) + 1;
|
|
82
|
-
const r = baseRow + 2 + Math.floor(i / 7);
|
|
83
|
-
const c = baseCol + (i % 7);
|
|
84
|
-
let dateStr = '';
|
|
85
|
-
let txt = '';
|
|
86
|
-
if (dayNum > 0 && dayNum <= new Date(this.year, m, 0).getDate()) {
|
|
87
|
-
const yyyy = this.year;
|
|
88
|
-
const mm = String(m).padStart(2, '0');
|
|
89
|
-
const dd = String(dayNum).padStart(2, '0');
|
|
90
|
-
dateStr = `${yyyy}-${mm}-${dd}`;
|
|
91
|
-
txt = String(dayNum);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const classes = ['cell'];
|
|
95
|
-
if (dateStr) classes.push('clickable');
|
|
96
|
-
if (this.selectedDates.includes(dateStr)) classes.push('selected');
|
|
97
|
-
|
|
98
|
-
const cell = this._createCell(container, r, c, dateStr, txt, classes);
|
|
99
|
-
if (dateStr) {
|
|
100
|
-
cell.addEventListener('click', () => {
|
|
101
|
-
const idx = this.selectedDates.indexOf(dateStr);
|
|
102
|
-
if (idx > -1) {
|
|
103
|
-
this.selectedDates.splice(idx, 1);
|
|
104
|
-
cell.classList.remove('selected');
|
|
105
|
-
} else {
|
|
106
|
-
this.selectedDates.push(dateStr);
|
|
107
|
-
cell.classList.add('selected');
|
|
108
|
-
}
|
|
109
|
-
this.onDayClick?.({ date: dateStr });
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
_createCell(container, row, col, date, content, classes) {
|
|
117
|
-
const cell = document.createElement('div');
|
|
118
|
-
cell.textContent = content;
|
|
119
|
-
cell.dataset.date = date;
|
|
120
|
-
cell.classList.add(...classes);
|
|
121
|
-
cell.style.gridRowStart = row + 1;
|
|
122
|
-
cell.style.gridColumnStart = col + 1;
|
|
123
|
-
container.appendChild(cell);
|
|
124
|
-
return cell;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
customElements.define('drayman-year-calendar', CalendarGrid);
|