@lowdefy/blocks-basic 0.0.0-experimental-20260928105334 → 0.0.0-experimental-20260929101721
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/blocks/Anchor/Anchor.js +1 -1
- package/dist/blocks/Anchor/gallery.yaml +14 -14
- package/dist/blocks/Anchor/meta.js +4 -2
- package/dist/blocks/Anchor/tests/Anchor.e2e.yaml +1 -1
- package/dist/blocks/Anchor/tests.yaml +6 -6
- package/dist/blocks/Box/Box.js +9 -5
- package/dist/blocks/Box/gallery.yaml +9 -9
- package/dist/blocks/Box/tests/Box.e2e.yaml +62 -0
- package/dist/blocks/ClickableHtml/ClickableHtml.js +9 -28
- package/dist/blocks/ClickableHtml/gallery.yaml +86 -0
- package/dist/blocks/ClickableHtml/meta.js +57 -1
- package/dist/blocks/ClickableHtml/tests/ClickableHtml.e2e.yaml +119 -0
- package/dist/blocks/ClickableHtml/tests.yaml +13 -0
- package/dist/blocks/DangerousHtml/DangerousHtml.js +19 -19
- package/dist/blocks/DangerousHtml/meta.js +13 -1
- package/dist/blocks/Dynamic/Dynamic.js +5 -3
- package/dist/blocks/Dynamic/meta.js +4 -0
- package/dist/blocks/Html/gallery.yaml +28 -0
- package/dist/blocks/Html/meta.js +23 -1
- package/dist/blocks/Html/tests/Html.e2e.yaml +12 -0
- package/dist/blocks/Icon/Icon.js +21 -1
- package/dist/blocks/Icon/gallery.yaml +158 -64
- package/dist/blocks/Icon/meta.js +11 -4
- package/dist/blocks/Icon/tests/Icon.e2e.yaml +3 -3
- package/dist/blocks/Icon/tests.yaml +7 -7
- package/dist/blocks/Img/meta.js +2 -0
- package/dist/blocks/List/gallery.yaml +11 -11
- package/dist/blocks/PollingTimer/PollingTimer.js +120 -0
- package/dist/blocks/PollingTimer/e2e.js +21 -0
- package/dist/blocks/PollingTimer/gallery.yaml +190 -0
- package/dist/blocks/PollingTimer/meta.js +61 -0
- package/dist/blocks/PollingTimer/validateInterval.js +21 -0
- package/dist/blocks/Span/Span.js +5 -3
- package/dist/blocks/Span/gallery.yaml +7 -7
- package/dist/blocks.js +1 -0
- package/dist/e2e.js +1 -0
- package/dist/metas.js +1 -0
- package/package.json +8 -5
|
@@ -17,38 +17,38 @@
|
|
|
17
17
|
- id: properties.icon
|
|
18
18
|
type: Icon
|
|
19
19
|
properties:
|
|
20
|
-
name:
|
|
20
|
+
name: Rocket
|
|
21
21
|
- id: 'properties.disableLoadingIcon: true'
|
|
22
22
|
type: Icon
|
|
23
23
|
properties:
|
|
24
|
-
name:
|
|
24
|
+
name: Rocket
|
|
25
25
|
disableLoadingIcon: true
|
|
26
26
|
- id: 'properties.size: 30'
|
|
27
27
|
type: Icon
|
|
28
28
|
properties:
|
|
29
|
-
name:
|
|
29
|
+
name: Rocket
|
|
30
30
|
size: 30
|
|
31
31
|
- id: 'properties.rotate: 90'
|
|
32
32
|
type: Icon
|
|
33
33
|
properties:
|
|
34
|
-
name:
|
|
34
|
+
name: Rocket
|
|
35
35
|
size: 30
|
|
36
36
|
rotate: 90
|
|
37
37
|
- id: 'properties.spin: true'
|
|
38
38
|
type: Icon
|
|
39
39
|
properties:
|
|
40
|
-
name:
|
|
40
|
+
name: Rocket
|
|
41
41
|
size: 30
|
|
42
42
|
spin: true
|
|
43
43
|
- id: 'properties.color'
|
|
44
44
|
type: Icon
|
|
45
45
|
properties:
|
|
46
|
-
name:
|
|
46
|
+
name: Rocket
|
|
47
47
|
size: 25
|
|
48
48
|
color: '#9c27b0'
|
|
49
49
|
- id: 'properties.style: border: 1px solid red'
|
|
50
50
|
type: Icon
|
|
51
51
|
properties:
|
|
52
|
-
name:
|
|
52
|
+
name: Rocket
|
|
53
53
|
style:
|
|
54
54
|
border: 1px solid red
|
package/dist/blocks/Img/meta.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
properties: {
|
|
29
29
|
src: {
|
|
30
30
|
type: 'string',
|
|
31
|
+
urlKind: 'src',
|
|
31
32
|
description: 'The image URL.'
|
|
32
33
|
},
|
|
33
34
|
alt: {
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
},
|
|
70
71
|
srcSet: {
|
|
71
72
|
type: 'string',
|
|
73
|
+
urlKind: 'srcSet',
|
|
72
74
|
description: 'Possible image sources for the user agent to use, strings separated by commas.',
|
|
73
75
|
docs: {
|
|
74
76
|
displayType: 'text-area'
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
flex: 0 0 auto
|
|
38
38
|
properties:
|
|
39
39
|
title: Add Note
|
|
40
|
-
icon:
|
|
40
|
+
icon: add
|
|
41
41
|
color: primary
|
|
42
42
|
variant: solid
|
|
43
43
|
size: small
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
layout:
|
|
67
67
|
flex: 0 0 auto
|
|
68
68
|
properties:
|
|
69
|
-
icon:
|
|
69
|
+
icon: close
|
|
70
70
|
color: default
|
|
71
71
|
variant: text
|
|
72
72
|
shape: circle
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
flex: 0 0 auto
|
|
136
136
|
properties:
|
|
137
137
|
title: Add Task
|
|
138
|
-
icon:
|
|
138
|
+
icon: add
|
|
139
139
|
color: primary
|
|
140
140
|
variant: solid
|
|
141
141
|
size: small
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
layout:
|
|
210
210
|
flex: 0 0 auto
|
|
211
211
|
properties:
|
|
212
|
-
icon:
|
|
212
|
+
icon: arrow-up
|
|
213
213
|
color: default
|
|
214
214
|
variant: text
|
|
215
215
|
size: small
|
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
layout:
|
|
229
229
|
flex: 0 0 auto
|
|
230
230
|
properties:
|
|
231
|
-
icon:
|
|
231
|
+
icon: arrow-down
|
|
232
232
|
color: default
|
|
233
233
|
variant: text
|
|
234
234
|
size: small
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
layout:
|
|
248
248
|
flex: 0 0 auto
|
|
249
249
|
properties:
|
|
250
|
-
icon:
|
|
250
|
+
icon: delete
|
|
251
251
|
color: danger
|
|
252
252
|
variant: text
|
|
253
253
|
size: small
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
flex: 0 0 auto
|
|
273
273
|
properties:
|
|
274
274
|
title: Save Tasks
|
|
275
|
-
icon:
|
|
275
|
+
icon: save
|
|
276
276
|
color: primary
|
|
277
277
|
variant: solid
|
|
278
278
|
events:
|
|
@@ -315,7 +315,7 @@
|
|
|
315
315
|
flex: 0 0 auto
|
|
316
316
|
properties:
|
|
317
317
|
title: Load Users
|
|
318
|
-
icon:
|
|
318
|
+
icon: CloudDownload
|
|
319
319
|
color: primary
|
|
320
320
|
variant: solid
|
|
321
321
|
size: small
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
flex: 0 0 auto
|
|
409
409
|
properties:
|
|
410
410
|
title: Add Line
|
|
411
|
-
icon:
|
|
411
|
+
icon: add
|
|
412
412
|
color: primary
|
|
413
413
|
variant: dashed
|
|
414
414
|
size: small
|
|
@@ -467,7 +467,7 @@
|
|
|
467
467
|
layout:
|
|
468
468
|
flex: 0 0 auto
|
|
469
469
|
properties:
|
|
470
|
-
icon:
|
|
470
|
+
icon: remove
|
|
471
471
|
color: danger
|
|
472
472
|
variant: text
|
|
473
473
|
size: small
|
|
@@ -507,7 +507,7 @@
|
|
|
507
507
|
flex: 0 0 auto
|
|
508
508
|
properties:
|
|
509
509
|
title: Submit Invoice
|
|
510
|
-
icon:
|
|
510
|
+
icon: send
|
|
511
511
|
color: primary
|
|
512
512
|
variant: solid
|
|
513
513
|
events:
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { useEffect, useRef } from 'react';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
17
|
+
import { withBlockDefaults } from '@lowdefy/block-utils';
|
|
18
|
+
import validateInterval from './validateInterval.js';
|
|
19
|
+
// Headless timer: renders nothing and fires onTick while running. Typically used to poll a
|
|
20
|
+
// request until a background job completes. Each tick is scheduled "interval" ms after the
|
|
21
|
+
// previous onTick actions finish, so a slow chain never overlaps the next tick.
|
|
22
|
+
function PollingTimer({ methods, properties }) {
|
|
23
|
+
// Validated while rendering so an invalid interval reaches the block error boundary, instead
|
|
24
|
+
// of throwing from a timeout or visibility listener where nothing surfaces it.
|
|
25
|
+
validateInterval({
|
|
26
|
+
interval: properties.interval
|
|
27
|
+
});
|
|
28
|
+
const timeoutRef = useRef(null);
|
|
29
|
+
const scheduledIntervalRef = useRef(null);
|
|
30
|
+
const inFlightRef = useRef(false);
|
|
31
|
+
const runningRef = useRef(false);
|
|
32
|
+
const tickRef = useRef(0);
|
|
33
|
+
// Methods are registered once, so property changes are read through a ref.
|
|
34
|
+
const propertiesRef = useRef(properties);
|
|
35
|
+
propertiesRef.current = properties;
|
|
36
|
+
function hiddenAndPaused() {
|
|
37
|
+
if (propertiesRef.current.pauseWhenHidden === false) return false;
|
|
38
|
+
return document.visibilityState === 'hidden';
|
|
39
|
+
}
|
|
40
|
+
function clearScheduledTick() {
|
|
41
|
+
if (timeoutRef.current === null) return;
|
|
42
|
+
clearTimeout(timeoutRef.current);
|
|
43
|
+
timeoutRef.current = null;
|
|
44
|
+
}
|
|
45
|
+
function scheduleTick() {
|
|
46
|
+
if (!runningRef.current) return;
|
|
47
|
+
if (timeoutRef.current !== null) return;
|
|
48
|
+
// A tick in flight schedules the next one when its onTick actions finish.
|
|
49
|
+
if (inFlightRef.current) return;
|
|
50
|
+
if (hiddenAndPaused()) return;
|
|
51
|
+
const { interval } = propertiesRef.current;
|
|
52
|
+
scheduledIntervalRef.current = interval;
|
|
53
|
+
timeoutRef.current = setTimeout(tick, interval);
|
|
54
|
+
}
|
|
55
|
+
async function tick() {
|
|
56
|
+
timeoutRef.current = null;
|
|
57
|
+
tickRef.current += 1;
|
|
58
|
+
const { maxTicks } = propertiesRef.current;
|
|
59
|
+
if (type.isInt(maxTicks) && tickRef.current >= maxTicks) {
|
|
60
|
+
runningRef.current = false;
|
|
61
|
+
}
|
|
62
|
+
inFlightRef.current = true;
|
|
63
|
+
// The engine resolves triggerEvent once the chain finishes, including when an action fails.
|
|
64
|
+
await methods.triggerEvent({
|
|
65
|
+
name: 'onTick',
|
|
66
|
+
event: {
|
|
67
|
+
tick: tickRef.current
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
inFlightRef.current = false;
|
|
71
|
+
scheduleTick();
|
|
72
|
+
}
|
|
73
|
+
function start() {
|
|
74
|
+
if (runningRef.current) return;
|
|
75
|
+
tickRef.current = 0;
|
|
76
|
+
runningRef.current = true;
|
|
77
|
+
scheduleTick();
|
|
78
|
+
}
|
|
79
|
+
function stop() {
|
|
80
|
+
runningRef.current = false;
|
|
81
|
+
clearScheduledTick();
|
|
82
|
+
}
|
|
83
|
+
function toggle() {
|
|
84
|
+
if (runningRef.current) {
|
|
85
|
+
stop();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
start();
|
|
89
|
+
}
|
|
90
|
+
function onVisibilityChange() {
|
|
91
|
+
if (hiddenAndPaused()) {
|
|
92
|
+
clearScheduledTick();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
scheduleTick();
|
|
96
|
+
}
|
|
97
|
+
useEffect(()=>{
|
|
98
|
+
methods.registerMethod('start', start);
|
|
99
|
+
methods.registerMethod('stop', stop);
|
|
100
|
+
methods.registerMethod('toggle', toggle);
|
|
101
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
102
|
+
if (properties.autoStart === true) {
|
|
103
|
+
start();
|
|
104
|
+
}
|
|
105
|
+
return ()=>{
|
|
106
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
107
|
+
stop();
|
|
108
|
+
};
|
|
109
|
+
}, []);
|
|
110
|
+
useEffect(()=>{
|
|
111
|
+
if (timeoutRef.current === null) return;
|
|
112
|
+
if (scheduledIntervalRef.current === properties.interval) return;
|
|
113
|
+
clearScheduledTick();
|
|
114
|
+
scheduleTick();
|
|
115
|
+
}, [
|
|
116
|
+
properties.interval
|
|
117
|
+
]);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
export default withBlockDefaults(PollingTimer);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
|
|
16
|
+
// PollingTimer renders nothing — assert on what onTick does, and use the block wrapper for
|
|
17
|
+
// presence checks.
|
|
18
|
+
const locator = (page, blockId)=>page.locator(`#bl-${escapeId(blockId)}`);
|
|
19
|
+
export default createBlockHelper({
|
|
20
|
+
locator
|
|
21
|
+
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
- title: Poll Until a Job Is Done
|
|
16
|
+
blocks:
|
|
17
|
+
- id: job_timer
|
|
18
|
+
type: PollingTimer
|
|
19
|
+
properties:
|
|
20
|
+
interval: 1000
|
|
21
|
+
events:
|
|
22
|
+
onTick:
|
|
23
|
+
# In an app this is a Request that fetches the job status. Here the job
|
|
24
|
+
# reports done on the fifth tick.
|
|
25
|
+
- id: job_timer_set_status
|
|
26
|
+
type: SetState
|
|
27
|
+
params:
|
|
28
|
+
job_status:
|
|
29
|
+
_if:
|
|
30
|
+
test:
|
|
31
|
+
_gte:
|
|
32
|
+
- _event: tick
|
|
33
|
+
- 5
|
|
34
|
+
then: done
|
|
35
|
+
else: running
|
|
36
|
+
- id: job_timer_stop_when_done
|
|
37
|
+
type: CallMethod
|
|
38
|
+
skip:
|
|
39
|
+
_ne:
|
|
40
|
+
- _state: job_status
|
|
41
|
+
- done
|
|
42
|
+
params:
|
|
43
|
+
blockId: job_timer
|
|
44
|
+
method: stop
|
|
45
|
+
- id: job_timer_controls
|
|
46
|
+
type: Box
|
|
47
|
+
layout:
|
|
48
|
+
gap: 8
|
|
49
|
+
blocks:
|
|
50
|
+
- id: job_timer_start
|
|
51
|
+
type: Button
|
|
52
|
+
properties:
|
|
53
|
+
title: Start Job
|
|
54
|
+
icon: CirclePlay
|
|
55
|
+
events:
|
|
56
|
+
onClick:
|
|
57
|
+
- id: job_timer_set_running
|
|
58
|
+
type: SetState
|
|
59
|
+
params:
|
|
60
|
+
job_status: running
|
|
61
|
+
- id: job_timer_call_start
|
|
62
|
+
type: CallMethod
|
|
63
|
+
params:
|
|
64
|
+
blockId: job_timer
|
|
65
|
+
method: start
|
|
66
|
+
- id: job_timer_status
|
|
67
|
+
type: Span
|
|
68
|
+
properties:
|
|
69
|
+
content:
|
|
70
|
+
_nunjucks:
|
|
71
|
+
template: 'Job status: {{ status }}'
|
|
72
|
+
on:
|
|
73
|
+
status:
|
|
74
|
+
_if_none:
|
|
75
|
+
- _state: job_status
|
|
76
|
+
- not started
|
|
77
|
+
|
|
78
|
+
- title: Start and Stop
|
|
79
|
+
blocks:
|
|
80
|
+
- id: manual_timer
|
|
81
|
+
type: PollingTimer
|
|
82
|
+
properties:
|
|
83
|
+
interval: 1000
|
|
84
|
+
events:
|
|
85
|
+
onTick:
|
|
86
|
+
- id: manual_timer_set_tick
|
|
87
|
+
type: SetState
|
|
88
|
+
params:
|
|
89
|
+
manual_ticks:
|
|
90
|
+
_event: tick
|
|
91
|
+
- id: manual_timer_controls
|
|
92
|
+
type: Box
|
|
93
|
+
layout:
|
|
94
|
+
gap: 8
|
|
95
|
+
blocks:
|
|
96
|
+
- id: manual_timer_start
|
|
97
|
+
type: Button
|
|
98
|
+
properties:
|
|
99
|
+
title: Start
|
|
100
|
+
icon: CirclePlay
|
|
101
|
+
events:
|
|
102
|
+
onClick:
|
|
103
|
+
- id: manual_timer_call_start
|
|
104
|
+
type: CallMethod
|
|
105
|
+
params:
|
|
106
|
+
blockId: manual_timer
|
|
107
|
+
method: start
|
|
108
|
+
- id: manual_timer_stop
|
|
109
|
+
type: Button
|
|
110
|
+
properties:
|
|
111
|
+
title: Stop
|
|
112
|
+
icon: CirclePause
|
|
113
|
+
events:
|
|
114
|
+
onClick:
|
|
115
|
+
- id: manual_timer_call_stop
|
|
116
|
+
type: CallMethod
|
|
117
|
+
params:
|
|
118
|
+
blockId: manual_timer
|
|
119
|
+
method: stop
|
|
120
|
+
- id: manual_timer_toggle
|
|
121
|
+
type: Button
|
|
122
|
+
properties:
|
|
123
|
+
title: Toggle
|
|
124
|
+
icon: ArrowRightLeft
|
|
125
|
+
events:
|
|
126
|
+
onClick:
|
|
127
|
+
- id: manual_timer_call_toggle
|
|
128
|
+
type: CallMethod
|
|
129
|
+
params:
|
|
130
|
+
blockId: manual_timer
|
|
131
|
+
method: toggle
|
|
132
|
+
- id: manual_timer_ticks
|
|
133
|
+
type: Span
|
|
134
|
+
properties:
|
|
135
|
+
content:
|
|
136
|
+
_nunjucks:
|
|
137
|
+
template: 'Ticks: {{ ticks }}'
|
|
138
|
+
on:
|
|
139
|
+
ticks:
|
|
140
|
+
_state: manual_ticks
|
|
141
|
+
|
|
142
|
+
- title: Auto Start with a Tick Limit
|
|
143
|
+
blocks:
|
|
144
|
+
- id: limited_timer
|
|
145
|
+
type: PollingTimer
|
|
146
|
+
properties:
|
|
147
|
+
interval: 1000
|
|
148
|
+
autoStart: true
|
|
149
|
+
maxTicks: 5
|
|
150
|
+
events:
|
|
151
|
+
onTick:
|
|
152
|
+
- id: limited_timer_set_tick
|
|
153
|
+
type: SetState
|
|
154
|
+
params:
|
|
155
|
+
limited_ticks:
|
|
156
|
+
_event: tick
|
|
157
|
+
- id: limited_timer_ticks
|
|
158
|
+
type: Span
|
|
159
|
+
properties:
|
|
160
|
+
content:
|
|
161
|
+
_nunjucks:
|
|
162
|
+
template: 'Ticks: {{ ticks }} of 5'
|
|
163
|
+
on:
|
|
164
|
+
ticks:
|
|
165
|
+
_state: limited_ticks
|
|
166
|
+
|
|
167
|
+
- title: Keep Ticking in a Hidden Tab
|
|
168
|
+
blocks:
|
|
169
|
+
- id: background_timer
|
|
170
|
+
type: PollingTimer
|
|
171
|
+
properties:
|
|
172
|
+
interval: 2000
|
|
173
|
+
autoStart: true
|
|
174
|
+
pauseWhenHidden: false
|
|
175
|
+
events:
|
|
176
|
+
onTick:
|
|
177
|
+
- id: background_timer_set_tick
|
|
178
|
+
type: SetState
|
|
179
|
+
params:
|
|
180
|
+
background_ticks:
|
|
181
|
+
_event: tick
|
|
182
|
+
- id: background_timer_ticks
|
|
183
|
+
type: Span
|
|
184
|
+
properties:
|
|
185
|
+
content:
|
|
186
|
+
_nunjucks:
|
|
187
|
+
template: 'Ticks while this tab was open or hidden: {{ ticks }}'
|
|
188
|
+
on:
|
|
189
|
+
ticks:
|
|
190
|
+
_state: background_ticks
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
category: 'display',
|
|
17
|
+
icons: [],
|
|
18
|
+
valueType: null,
|
|
19
|
+
events: {
|
|
20
|
+
onTick: {
|
|
21
|
+
description: 'Trigger actions on every tick while the timer is running. The next tick is scheduled `interval` ms after the `onTick` actions finish, so ticks never overlap.',
|
|
22
|
+
event: {
|
|
23
|
+
tick: 'The number of ticks since the timer was started, starting at 1.'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
methods: {
|
|
28
|
+
start: 'Start the timer and reset the tick count to zero. The first tick fires after `interval` ms. Does nothing if the timer is already running.',
|
|
29
|
+
stop: 'Stop the timer. If `onTick` actions are running, they finish but no further tick is scheduled. Does nothing if the timer is not running.',
|
|
30
|
+
toggle: 'Start the timer if it is stopped, stop it if it is running.'
|
|
31
|
+
},
|
|
32
|
+
properties: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
properties: {
|
|
36
|
+
interval: {
|
|
37
|
+
type: 'integer',
|
|
38
|
+
minimum: 1,
|
|
39
|
+
description: 'Milliseconds to wait after the `onTick` actions of one tick finish before the next tick fires. Changing it while the timer is waiting restarts the wait.'
|
|
40
|
+
},
|
|
41
|
+
autoStart: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: false,
|
|
44
|
+
description: 'Start ticking when the block mounts. Off by default, so the timer is started with the `start` method.'
|
|
45
|
+
},
|
|
46
|
+
maxTicks: {
|
|
47
|
+
type: 'integer',
|
|
48
|
+
minimum: 1,
|
|
49
|
+
description: 'Stop the timer after this many ticks. The `onTick` event of the last tick is still triggered. Unlimited by default.'
|
|
50
|
+
},
|
|
51
|
+
pauseWhenHidden: {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: true,
|
|
54
|
+
description: 'Pause ticking while the browser tab is hidden (`document.visibilityState`), and resume when it becomes visible again. Ticks missed while hidden are not fired on resume; the next tick fires `interval` ms after the tab is visible.'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: [
|
|
58
|
+
'interval'
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { type } from '@lowdefy/helpers';
|
|
16
|
+
function validateInterval({ interval }) {
|
|
17
|
+
if (!type.isInt(interval) || interval < 1) {
|
|
18
|
+
throw new Error('PollingTimer "interval" should be a positive integer of milliseconds.');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default validateInterval;
|
package/dist/blocks/Span/Span.js
CHANGED
|
@@ -13,13 +13,15 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import React from 'react';
|
|
16
|
-
import { withBlockDefaults } from '@lowdefy/block-utils';
|
|
16
|
+
import { isEventFromDomDescendant, withBlockDefaults } from '@lowdefy/block-utils';
|
|
17
17
|
const Span = ({ blockId, classNames, content, events, methods, properties, styles })=>/*#__PURE__*/ React.createElement("span", {
|
|
18
18
|
id: blockId,
|
|
19
19
|
"data-testid": blockId,
|
|
20
|
-
onClick: ()=>
|
|
20
|
+
onClick: (event)=>{
|
|
21
|
+
if (isEventFromDomDescendant(event)) methods.triggerEvent({
|
|
21
22
|
name: 'onClick'
|
|
22
|
-
})
|
|
23
|
+
});
|
|
24
|
+
},
|
|
23
25
|
className: classNames?.element,
|
|
24
26
|
style: {
|
|
25
27
|
outline: 'none',
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
layout:
|
|
58
58
|
flex: 0 0 auto
|
|
59
59
|
properties:
|
|
60
|
-
name:
|
|
60
|
+
name: info
|
|
61
61
|
size: 14
|
|
62
62
|
color: '#1677ff'
|
|
63
63
|
- id: span_content_area_text
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
layout:
|
|
306
306
|
flex: 0 0 auto
|
|
307
307
|
properties:
|
|
308
|
-
name:
|
|
308
|
+
name: check-circle
|
|
309
309
|
size: 14
|
|
310
310
|
color: '#52c41a'
|
|
311
311
|
- id: span_nested_value_text
|
|
@@ -420,7 +420,7 @@
|
|
|
420
420
|
layout:
|
|
421
421
|
flex: 0 0 auto
|
|
422
422
|
properties:
|
|
423
|
-
name:
|
|
423
|
+
name: FaceSlightlySmiling
|
|
424
424
|
size: 16
|
|
425
425
|
color: '#faad14'
|
|
426
426
|
- id: span_icon_smile_label
|
|
@@ -442,7 +442,7 @@
|
|
|
442
442
|
layout:
|
|
443
443
|
flex: 0 0 auto
|
|
444
444
|
properties:
|
|
445
|
-
name:
|
|
445
|
+
name: check-circle
|
|
446
446
|
size: 16
|
|
447
447
|
color: '#52c41a'
|
|
448
448
|
- id: span_icon_check_label
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
layout:
|
|
465
465
|
flex: 0 0 auto
|
|
466
466
|
properties:
|
|
467
|
-
name:
|
|
467
|
+
name: warning
|
|
468
468
|
size: 16
|
|
469
469
|
color: '#ff4d4f'
|
|
470
470
|
- id: span_icon_warning_label
|
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
layout:
|
|
515
515
|
flex: 0 0 auto
|
|
516
516
|
properties:
|
|
517
|
-
name:
|
|
517
|
+
name: check-circle
|
|
518
518
|
size: 14
|
|
519
519
|
color: '#52c41a'
|
|
520
520
|
- id: span_order_shipped_text
|
|
@@ -616,7 +616,7 @@
|
|
|
616
616
|
layout:
|
|
617
617
|
flex: 0 0 auto
|
|
618
618
|
properties:
|
|
619
|
-
name:
|
|
619
|
+
name: user
|
|
620
620
|
size: 20
|
|
621
621
|
color: '#1677ff'
|
|
622
622
|
- id: span_profile_name
|
package/dist/blocks.js
CHANGED
|
@@ -21,5 +21,6 @@ export { default as Html } from './blocks/Html/Html.js';
|
|
|
21
21
|
export { default as Icon } from './blocks/Icon/Icon.js';
|
|
22
22
|
export { default as Img } from './blocks/Img/Img.js';
|
|
23
23
|
export { default as List } from './blocks/List/List.js';
|
|
24
|
+
export { default as PollingTimer } from './blocks/PollingTimer/PollingTimer.js';
|
|
24
25
|
export { default as Span } from './blocks/Span/Span.js';
|
|
25
26
|
export { default as Throw } from './blocks/Throw/Throw.js';
|
package/dist/e2e.js
CHANGED
|
@@ -21,5 +21,6 @@ export { default as Html } from './blocks/Html/e2e.js';
|
|
|
21
21
|
export { default as Icon } from './blocks/Icon/e2e.js';
|
|
22
22
|
export { default as Img } from './blocks/Img/e2e.js';
|
|
23
23
|
export { default as List } from './blocks/List/e2e.js';
|
|
24
|
+
export { default as PollingTimer } from './blocks/PollingTimer/e2e.js';
|
|
24
25
|
export { default as Span } from './blocks/Span/e2e.js';
|
|
25
26
|
export { default as Throw } from './blocks/Throw/e2e.js';
|
package/dist/metas.js
CHANGED
|
@@ -21,5 +21,6 @@ export { default as Html } from './blocks/Html/meta.js';
|
|
|
21
21
|
export { default as Icon } from './blocks/Icon/meta.js';
|
|
22
22
|
export { default as Img } from './blocks/Img/meta.js';
|
|
23
23
|
export { default as List } from './blocks/List/meta.js';
|
|
24
|
+
export { default as PollingTimer } from './blocks/PollingTimer/meta.js';
|
|
24
25
|
export { default as Span } from './blocks/Span/meta.js';
|
|
25
26
|
export { default as Throw } from './blocks/Throw/meta.js';
|