@openremote/or-timeline 1.0.1 → 1.2.0-snapshot.20240512155407

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/src/index.ts DELETED
@@ -1,254 +0,0 @@
1
- import {html, LitElement, property} from 'lit-element';
2
-
3
- import moment from 'moment';
4
-
5
- class OrTimeline extends LitElement {
6
- protected render() {
7
- if(this.shadowRoot){
8
- const range:any = this.shadowRoot.getElementById('or-timeline-slider');
9
- if(range) {
10
- range.value = Math.round(this.current);
11
- this.moveBubble(range);
12
- }
13
- }
14
-
15
- return html`
16
- <style>
17
- :host {
18
- position: relative;
19
- }
20
- .timeline-container {
21
- display: block;
22
- height: 52px;
23
- background-color: var(--app-white, #FFFFFF);
24
-
25
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
26
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
27
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
28
-
29
- padding-top: 20px;
30
- }
31
- .slidecontainer {
32
- position: relative;
33
- margin: -5px 50px 0 30px;
34
- }
35
-
36
- /* The slider itself */
37
- .slider {
38
- box-sizing: border-box;
39
- -webkit-appearance: none; /* Override default CSS styles */
40
- appearance: none;
41
- width: calc(100% + 20px);
42
- margin-left: -10px;
43
- height: 12px;
44
- background: #bdbdbd; /* Grey background */
45
- outline: none; /* Remove outline */
46
- opacity: 1; /* Set transparency (for mouse-over effects on hover) */
47
- -webkit-transition: .2s; /* 0.2 seconds transition on hover */
48
- transition: opacity .2s;
49
-
50
- border-radius: 6px;
51
- cursor: pointer;
52
- }
53
-
54
- /* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
55
- .slider::-webkit-slider-thumb {
56
- -webkit-appearance: none;
57
- appearance: none;
58
- width: 18px;
59
- height: 18px;
60
- margin: 0;
61
- border-radius: 50%;
62
- cursor: pointer;
63
- border: 0 !important;
64
- background-color: var(--timeline-accent, blue); /* Green background */
65
- }
66
-
67
- .slider::-ms-thumb,
68
- .slider::-moz-range-thumb,
69
- .slider::-webkit-slider-thumb {
70
- width: 18px;
71
- height: 18px;
72
- margin: 0;
73
- border-radius: 50%;
74
- cursor: pointer;
75
- border: 0 !important;
76
- background-color: var(--timeline-accent, blue); /* Green background */
77
- }
78
-
79
- #timelineHourMarkers {
80
- position: relative;
81
- display: -webkit-box;
82
- display: -moz-box;
83
- display: -ms-flexbox;
84
- display: -webkit-flex;
85
- display: flex;
86
- -webkit-box-orient: horizontal;
87
- -moz-box-orient: horizontal;
88
- -webkit-box-direction: normal;
89
- -moz-box-direction: normal;
90
- -webkit-flex-direction: row;
91
- -ms-flex-direction: row;
92
- flex-direction: row;
93
-
94
- margin: 0 50px 0 30px;
95
- }
96
-
97
- #timelineHourMarkers > .timelineHourMark{
98
- display: flex;
99
- flex: 1 100%;
100
- flex-grow: 1;
101
- flex-shrink: 1;
102
- flex-basis: 100%;
103
-
104
- overflow: visible;
105
- color: var(--timeline-grey, darkgrey);
106
- border-left: 1px solid var(--timeline-grey, darkgrey);
107
- font-size: 12px;
108
- -webkit-user-select: none;
109
- -moz-user-select: none;
110
- -ms-user-select: none;
111
- user-select: none;
112
- padding-left: 4px;
113
- padding-bottom: 4px;
114
- }
115
- #timelineHourMarkers .timelineHourMark:last-child {
116
- position: absolute;
117
- right: -25px;
118
- }
119
-
120
- #range-value {
121
- position: absolute;
122
- background-color: var(--timeline-accent, blue);
123
- height: 30px;
124
- width: 60px;
125
- margin-left: -30px;
126
- text-align: center;
127
- color: white;
128
- display: inline-block;
129
- left: 0;
130
- font-size: 12px;
131
- font-weight: bold;
132
- line-height: 30px;
133
- }
134
-
135
- .time-value-container {
136
- width: calc(100% - 80px);
137
- display: block;
138
- position: relative;
139
- height: 30px;
140
- margin: 0 50px 0 30px;
141
- }
142
- </style>
143
-
144
-
145
- <div class="time-value-container">
146
- <div id="range-value">${this.current === 0 ? 'LIVE' : moment().add(this.current, 'minutes').format('HH:mm')}</div>
147
- </div>
148
- <div class="timeline-container">
149
- <div id="timelineHourMarkers" class="layout horizontal justified style-scope controller-timeline">
150
- ${new Array((this.maxRange/60)+1).fill(0).map((_, idx) => {
151
- return html`
152
- ${idx === 0 ? html`
153
- <div class="timelineHourMark style-scope controller-timeline">Nu</div>
154
- ` : html`
155
- <div class="timelineHourMark style-scope controller-timeline">+${idx}u</div>
156
- `}
157
- `})}
158
- </div>
159
-
160
- <div class="slidecontainer">
161
- <input id="or-timeline-slider" class="slider" type="range" @input="${this.moveBubble}" @change="${this.valueChange}" value="${this.current}" min="${this.minRange}" max="${this.maxRange}" step="${this.step}">
162
- </div>
163
- </div>
164
-
165
- `;
166
- }
167
- // default value in minutes
168
- @property({type: Function})
169
- private onChange: any;
170
-
171
- // default value in minutes
172
- @property({type: Number})
173
- private value: number = 0;
174
-
175
- // default value in minutes
176
- @property({type: Number})
177
- public current: number = 0;
178
-
179
- // maxRange in minutes
180
- @property({type: Number})
181
- private maxRange: number = 360;
182
-
183
- // minRange in minutes
184
- @property({type: Number})
185
- private minRange: number = 0;
186
-
187
- // Steps in minutes
188
- @property({type: Number})
189
- private step: number = 5;
190
-
191
- moveBubble(e:any=null, value:string|null=null) {
192
- let el;
193
- if(e){
194
- el = e.target;
195
- } else {
196
- if(this.shadowRoot){
197
- el = this.shadowRoot.getElementById('or-timeline-slider');
198
- }
199
- }
200
-
201
- if(el) {
202
- if(value){
203
- this.current = parseInt(value);
204
- } else {
205
- this.current = parseInt(el.value);
206
- }
207
- // Measure width of range input
208
- const width = el.offsetWidth;
209
- const v = this.current;
210
-
211
- // Figure out placement percentage between left and right of input
212
- const newPoint = v / this.maxRange;
213
- // Janky value to get pointer to line up better
214
- let offset = 30;
215
- let newPlace;
216
-
217
- // Prevent bubble from going beyond left or right (unsupported browsers)
218
- if (newPoint < 0) {
219
- newPlace = 0;
220
- } else if (newPoint > 1) {
221
- newPlace = width - offset;
222
- } else {
223
- newPlace = (width - offset) * newPoint;
224
-
225
- if(newPlace < 0 ) {
226
- newPlace = 0;
227
- }
228
-
229
- }
230
-
231
- // Move bubble
232
- if(this.shadowRoot) {
233
- const range:HTMLElement | null = this.shadowRoot.getElementById('range-value');
234
- if(range){
235
- range.style.left = newPlace + "px";
236
- }
237
- }
238
- }
239
-
240
- }
241
-
242
- valueChange (e:any) {
243
- this.moveBubble(e);
244
- this.onChange();
245
- }
246
-
247
- constructor() {
248
- super();
249
- }
250
-
251
-
252
- }
253
-
254
- window.customElements.define('or-timeline', OrTimeline);
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "../../tsconfig",
3
- "compilerOptions": {
4
- "outDir": "./dist/",
5
- "rootDir": "src"
6
- },
7
- "include": [
8
- "./src"
9
- ],
10
- "references": [
11
- { "path": "../core" },
12
- { "path": "../rest" }
13
- ]
14
- }
File without changes