fluent-svelte-extra 1.1.5 → 1.1.7

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.
@@ -1,27 +1,37 @@
1
1
  <script >import { createEventDispatcher } from 'svelte';
2
+ const dispatch = createEventDispatcher();
2
3
  import Slider from '@bulatdashiev/svelte-slider';
3
4
  import { TextBlock } from 'fluent-svelte';
4
5
  export let min = 1;
5
6
  export let max = 100;
6
- let values = min + ',' + max;
7
- let range = [min, max];
8
- const dispatch = createEventDispatcher();
7
+ export let step = 1;
8
+ let valuesText = min + ',' + max;
9
+ export let values = [min, max];
10
+ function escapeFloatingPoint(number) {
11
+ return Number(parseFloat(number).toPrecision(12));
12
+ }
13
+ $: {
14
+ if (values.toString() !== valuesText) {
15
+ valuesText = escapeFloatingPoint(values[0]) + "," + escapeFloatingPoint(values[1]);
16
+ }
17
+ }
9
18
  function handleChange(event) {
10
- values = event.detail.toString();
19
+ valuesText = escapeFloatingPoint(event.detail[0]) + "," + escapeFloatingPoint(event.detail[1]);
11
20
  dispatch('change', event.detail);
12
21
  }
13
22
  function handleMouseDown() {
14
23
  document.addEventListener("mouseup", () => {
15
- dispatch('finish', values.toString());
24
+ dispatch('finish', valuesText.toString());
16
25
  }, { once: true });
17
26
  }
18
27
  </script>
19
28
 
20
29
  <div id="sliderComp" {...$$restProps}>
21
30
  <Slider
22
- bind:value={range}
31
+ bind:value={values}
23
32
  {min}
24
33
  {max}
34
+ {step}
25
35
  range
26
36
  order
27
37
  on:input={handleChange}
@@ -38,8 +48,8 @@ function handleMouseDown() {
38
48
  />
39
49
  </Slider>
40
50
  <div id="vals">
41
- <TextBlock>{values.split(',')[0]}</TextBlock>
42
- <TextBlock>{values.split(',')[1]}</TextBlock>
51
+ <TextBlock>{valuesText.split(',')[0]}</TextBlock>
52
+ <TextBlock>{valuesText.split(',')[1]}</TextBlock>
43
53
  </div>
44
54
  </div>
45
55
 
@@ -4,6 +4,8 @@ declare const __propDef: {
4
4
  [x: string]: any;
5
5
  min?: number;
6
6
  max?: number;
7
+ step?: number;
8
+ values?: number[];
7
9
  };
8
10
  events: {
9
11
  change: CustomEvent<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluent-svelte-extra",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "A faithful implementation of Microsoft's Fluent Design System in Svelte.",
5
5
  "homepage": "https://github.com/OpenAnime/fluent-svelte-extra",
6
6
  "license": "MIT",