@budibase/bbui 3.37.5 → 3.38.1
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/bbui",
|
|
3
3
|
"description": "A UI solution used in the different Budibase projects.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.38.1",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"module": "dist/bbui.mjs",
|
|
7
7
|
"exports": {
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "5c558700d0c4dbc554a935b71b9ac99ec263a654"
|
|
107
107
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
3
|
import "@spectrum-css/actionbutton/dist/index-vars.css"
|
|
4
4
|
import "@spectrum-css/stepper/dist/index-vars.css"
|
|
5
|
-
import { createEventDispatcher } from "svelte"
|
|
5
|
+
import { createEventDispatcher, onDestroy } from "svelte"
|
|
6
6
|
import Icon from "../../Icon/Icon.svelte"
|
|
7
7
|
|
|
8
8
|
export let value = null
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
export let min
|
|
16
16
|
export let max
|
|
17
17
|
export let step
|
|
18
|
+
export let hideButtons = false
|
|
18
19
|
|
|
19
20
|
const dispatch = createEventDispatcher()
|
|
20
21
|
let focus = false
|
|
22
|
+
let holdTimeout
|
|
23
|
+
let holdInterval
|
|
21
24
|
|
|
22
25
|
// We need to keep the field value bound to a different variable in order
|
|
23
26
|
// to properly handle erroneous values. If we don't do this then it is
|
|
@@ -79,6 +82,9 @@
|
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
const stepUp = () => {
|
|
85
|
+
if (readonly || disabled) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
82
88
|
if (value == null || isNaN(value)) {
|
|
83
89
|
updateValue(step)
|
|
84
90
|
} else {
|
|
@@ -87,12 +93,47 @@
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
const stepDown = () => {
|
|
96
|
+
if (readonly || disabled) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
90
99
|
if (value == null || isNaN(value)) {
|
|
91
100
|
updateValue(step)
|
|
92
101
|
} else {
|
|
93
102
|
updateValue(value - step)
|
|
94
103
|
}
|
|
95
104
|
}
|
|
105
|
+
|
|
106
|
+
const stopHold = () => {
|
|
107
|
+
if (holdTimeout) {
|
|
108
|
+
clearTimeout(holdTimeout)
|
|
109
|
+
holdTimeout = undefined
|
|
110
|
+
}
|
|
111
|
+
if (holdInterval) {
|
|
112
|
+
clearInterval(holdInterval)
|
|
113
|
+
holdInterval = undefined
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const startHold = stepFn => {
|
|
118
|
+
if (readonly || disabled) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
stepFn()
|
|
122
|
+
holdTimeout = setTimeout(() => {
|
|
123
|
+
holdInterval = setInterval(stepFn, 75)
|
|
124
|
+
}, 300)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const onStepButtonClick = (event, stepFn) => {
|
|
128
|
+
if (event.detail !== 0) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
stepFn()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onDestroy(() => {
|
|
135
|
+
stopHold()
|
|
136
|
+
})
|
|
96
137
|
</script>
|
|
97
138
|
|
|
98
139
|
<div
|
|
@@ -109,6 +150,9 @@
|
|
|
109
150
|
bind:value={fieldValue}
|
|
110
151
|
placeholder={placeholder || ""}
|
|
111
152
|
type="number"
|
|
153
|
+
{min}
|
|
154
|
+
{max}
|
|
155
|
+
{step}
|
|
112
156
|
class="spectrum-Textfield-input spectrum-Stepper-input"
|
|
113
157
|
on:click
|
|
114
158
|
on:blur
|
|
@@ -121,22 +165,40 @@
|
|
|
121
165
|
on:keyup={updateValueOnEnter}
|
|
122
166
|
/>
|
|
123
167
|
</div>
|
|
124
|
-
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
168
|
+
{#if !hideButtons}
|
|
169
|
+
<span class="spectrum-Stepper-buttons">
|
|
170
|
+
<button
|
|
171
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-Stepper-stepUp"
|
|
172
|
+
type="button"
|
|
173
|
+
{disabled}
|
|
174
|
+
tabindex="-1"
|
|
175
|
+
on:mousedown|preventDefault={() => startHold(stepUp)}
|
|
176
|
+
on:mouseup={stopHold}
|
|
177
|
+
on:mouseleave={stopHold}
|
|
178
|
+
on:touchstart|preventDefault={() => startHold(stepUp)}
|
|
179
|
+
on:touchend={stopHold}
|
|
180
|
+
on:touchcancel={stopHold}
|
|
181
|
+
on:click={event => onStepButtonClick(event, stepUp)}
|
|
182
|
+
>
|
|
183
|
+
<Icon name="caret-up" size="XS" />
|
|
184
|
+
</button>
|
|
185
|
+
<button
|
|
186
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-Stepper-stepDown"
|
|
187
|
+
type="button"
|
|
188
|
+
{disabled}
|
|
189
|
+
tabindex="-1"
|
|
190
|
+
on:mousedown|preventDefault={() => startHold(stepDown)}
|
|
191
|
+
on:mouseup={stopHold}
|
|
192
|
+
on:mouseleave={stopHold}
|
|
193
|
+
on:touchstart|preventDefault={() => startHold(stepDown)}
|
|
194
|
+
on:touchend={stopHold}
|
|
195
|
+
on:touchcancel={stopHold}
|
|
196
|
+
on:click={event => onStepButtonClick(event, stepDown)}
|
|
197
|
+
>
|
|
198
|
+
<Icon name="caret-down" size="XS" />
|
|
199
|
+
</button>
|
|
200
|
+
</span>
|
|
201
|
+
{/if}
|
|
140
202
|
</div>
|
|
141
203
|
|
|
142
204
|
<style>
|
package/src/Form/Stepper.svelte
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
export let min = null
|
|
16
16
|
export let max = null
|
|
17
17
|
export let step = 1
|
|
18
|
+
export let hideButtons = true
|
|
18
19
|
export let helpText = null
|
|
19
20
|
|
|
20
21
|
const dispatch = createEventDispatcher()
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
{min}
|
|
37
38
|
{max}
|
|
38
39
|
{step}
|
|
40
|
+
{hideButtons}
|
|
39
41
|
on:change={onChange}
|
|
40
42
|
on:click
|
|
41
43
|
on:input
|