fluent-svelte-extra 1.5.3 → 1.5.5
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/RangeSlider/RangeSlider.svelte +34 -21
- package/TextBox/TextBox.svelte +5 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<script >import { createEventDispatcher } from
|
|
1
|
+
<script >import { createEventDispatcher } from "svelte";
|
|
2
2
|
const dispatch = createEventDispatcher();
|
|
3
|
-
import Slider from
|
|
4
|
-
import { TextBlock } from
|
|
3
|
+
import Slider from "@bulatdashiev/svelte-slider";
|
|
4
|
+
import { TextBlock } from "fluent-svelte";
|
|
5
5
|
export let min = 1;
|
|
6
6
|
export let max = 100;
|
|
7
7
|
export let step = 1;
|
|
8
|
-
let valuesText = min +
|
|
8
|
+
let valuesText = min + "," + max;
|
|
9
9
|
export let values = [min, max];
|
|
10
10
|
function escapeFloatingPoint(number) {
|
|
11
11
|
return Number(parseFloat(number).toPrecision(12));
|
|
@@ -16,29 +16,42 @@ $: {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
function handleChange(event) {
|
|
19
|
-
valuesText =
|
|
20
|
-
|
|
19
|
+
valuesText =
|
|
20
|
+
escapeFloatingPoint(event.detail[0]) + "," + escapeFloatingPoint(event.detail[1]);
|
|
21
|
+
dispatch("change", event.detail);
|
|
21
22
|
}
|
|
22
23
|
function handleMouseDown() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
["touchend", "touchcancel", "mouseup"].forEach(ev => {
|
|
25
|
+
document.addEventListener(ev, () => {
|
|
26
|
+
dispatch("finish", valuesText.toString());
|
|
27
|
+
}, {
|
|
28
|
+
once: true
|
|
29
|
+
});
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
</script>
|
|
30
33
|
|
|
31
34
|
<div id="sliderHolder">
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
<div id="sliderComp" {...$$restProps}>
|
|
36
|
+
<Slider bind:value={values} {min} {max} {step} range order on:input={handleChange}>
|
|
37
|
+
<div
|
|
38
|
+
slot="left"
|
|
39
|
+
class="handle"
|
|
40
|
+
on:mousedown={handleMouseDown}
|
|
41
|
+
on:touchstart={handleMouseDown}
|
|
42
|
+
/>
|
|
43
|
+
<div
|
|
44
|
+
slot="right"
|
|
45
|
+
class="handle"
|
|
46
|
+
on:mousedown={handleMouseDown}
|
|
47
|
+
on:touchstart={handleMouseDown}
|
|
48
|
+
/>
|
|
49
|
+
</Slider>
|
|
50
|
+
<div id="vals">
|
|
51
|
+
<TextBlock>{valuesText.split(",")[0]}</TextBlock>
|
|
52
|
+
<TextBlock>{valuesText.split(",")[1]}</TextBlock>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
42
55
|
</div>
|
|
43
56
|
|
|
44
|
-
<style>#vals{justify-content:space-between}#vals,.handle{align-items:center;display:flex}.handle{background-color:var(--fds-control-solid-fill-default);block-size:20px;border-radius:100%;box-shadow:0 0 0 1px var(--fds-control-stroke-default);inline-size:20px;justify-content:center;z-index:10}.handle:before{background-color:var(--fds-accent-default);block-size:12px;border-radius:100%;content:"";inline-size:12px;transition:var(--fds-control-fast-duration) var(--fds-control-fast-out-slow-in-easing) transform}.handle:hover:before{transform:scale(1.167)}.handle:active:before{background-color:var(--fds-accent-tertiary);transform:scale(.833)}#sliderHolder :global(.thumb-content:before){background:none!important}#sliderHolder :global(.track){background:var(--fds-control-strong-fill-default)!important}#sliderHolder :global(.progress){background:var(--fds-accent-text-primary)!important}</style>
|
|
57
|
+
<style>#vals{justify-content:space-between}#vals,.handle{align-items:center;display:flex}.handle{background-color:var(--fds-control-solid-fill-default);block-size:20px;border-radius:100%;box-shadow:0 0 0 1px var(--fds-control-stroke-default);inline-size:20px;justify-content:center;z-index:10}.handle:before{background-color:var(--fds-accent-default);block-size:12px;border-radius:100%;content:"";inline-size:12px;transition:var(--fds-control-fast-duration) var(--fds-control-fast-out-slow-in-easing) transform}.handle:hover:before{transform:scale(1.167)}.handle:active:before{background-color:var(--fds-accent-tertiary);transform:scale(.833)}#sliderHolder :global(.thumb-content:before){background:none!important}#sliderHolder :global(.track){background:var(--fds-control-strong-fill-default)!important}#sliderHolder :global(.progress){background:var(--fds-accent-text-primary)!important}</style>
|
package/TextBox/TextBox.svelte
CHANGED
|
@@ -64,8 +64,12 @@ function handleReveal(event) {
|
|
|
64
64
|
revealButtonMouseDown = false;
|
|
65
65
|
inputElement.setAttribute("type", "password");
|
|
66
66
|
window.removeEventListener("mouseup", hidePassword);
|
|
67
|
+
window.removeEventListener("touchend", hidePassword);
|
|
68
|
+
window.removeEventListener("touchcancel", hidePassword);
|
|
67
69
|
};
|
|
68
70
|
window.addEventListener("mouseup", hidePassword);
|
|
71
|
+
window.addEventListener("touchend", hidePassword);
|
|
72
|
+
window.addEventListener("touchcancel", hidePassword);
|
|
69
73
|
}
|
|
70
74
|
const inputProps = {
|
|
71
75
|
class: "text-box",
|
|
@@ -171,6 +175,7 @@ The TextBox control lets a user type text into an app. The text displays on the
|
|
|
171
175
|
<TextBoxButton
|
|
172
176
|
aria-label="Reveal password"
|
|
173
177
|
on:mousedown={handleReveal}
|
|
178
|
+
on:touchstart={handleReveal}
|
|
174
179
|
bind:element={revealButtonElement}
|
|
175
180
|
>
|
|
176
181
|
<svg
|
package/package.json
CHANGED