fluent-svelte-extra 1.1.6 → 1.1.8

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.
@@ -4,48 +4,39 @@ import Slider from '@bulatdashiev/svelte-slider';
4
4
  import { TextBlock } from 'fluent-svelte';
5
5
  export let min = 1;
6
6
  export let max = 100;
7
+ export let step = 1;
7
8
  let valuesText = min + ',' + max;
8
9
  export let values = [min, max];
10
+ function escapeFloatingPoint(number) {
11
+ return Number(parseFloat(number).toPrecision(12));
12
+ }
9
13
  $: {
10
14
  if (values.toString() !== valuesText) {
11
- valuesText = values[0] + "," + values[1];
15
+ valuesText = escapeFloatingPoint(values[0]) + "," + escapeFloatingPoint(values[1]);
12
16
  }
13
17
  }
14
18
  function handleChange(event) {
15
- valuesText = event.detail.toString();
19
+ valuesText = escapeFloatingPoint(event.detail[0]) + "," + escapeFloatingPoint(event.detail[1]);
16
20
  dispatch('change', event.detail);
17
21
  }
18
22
  function handleMouseDown() {
19
23
  document.addEventListener("mouseup", () => {
20
24
  dispatch('finish', valuesText.toString());
21
- }, { once: true });
25
+ }, {
26
+ once: true
27
+ });
22
28
  }
23
29
  </script>
24
30
 
25
31
  <div id="sliderComp" {...$$restProps}>
26
- <Slider
27
- bind:value={values}
28
- {min}
29
- {max}
30
- range
31
- order
32
- on:input={handleChange}
33
- >
34
- <div
35
- slot="left"
36
- class="handle"
37
- on:mousedown={handleMouseDown}
38
- />
39
- <div
40
- slot="right"
41
- class="handle"
42
- on:mousedown={handleMouseDown}
43
- />
44
- </Slider>
45
- <div id="vals">
46
- <TextBlock>{valuesText.split(',')[0]}</TextBlock>
47
- <TextBlock>{valuesText.split(',')[1]}</TextBlock>
48
- </div>
32
+ <Slider bind:value={values} {min} {max} {step} range order on:input={handleChange}>
33
+ <div slot="left" class="handle" on:mousedown={handleMouseDown} />
34
+ <div slot="right" class="handle" on:mousedown={handleMouseDown} />
35
+ </Slider>
36
+ <div id="vals">
37
+ <TextBlock>{valuesText.split(',')[0]}</TextBlock>
38
+ <TextBlock>{valuesText.split(',')[1]}</TextBlock>
39
+ </div>
49
40
  </div>
50
41
 
51
- <style>#vals{justify-content:space-between}#vals,.handle{align-items:center;display:flex}.handle{height:0;justify-content:center;width:0}.handle:after{background-color:#62cdfe;border:5px solid #4d4d4d;border-radius:50%;box-sizing:border-box;content:" ";height:20px;position:absolute;transition:all .1s linear!important;width:20px}.handle:hover:after{border:4px solid #4d4d4d}.handle:active:after{border:6px solid #4d4d4d;box-shadow:0 0 10px rgba(0,0,0,.4)}#sliderComp{--fds-thumb-bg:transparent;--fds-progress-bg:#62cdfe;--fds-track-bg:#454545}</style>
42
+ <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)}#sliderComp{--fds-thumb-bg:transparent;--fds-progress-bg:var(--fds-accent-text-primary);--fds-track-bg:var(--fds-control-strong-fill-default)}</style>
@@ -4,6 +4,7 @@ declare const __propDef: {
4
4
  [x: string]: any;
5
5
  min?: number;
6
6
  max?: number;
7
+ step?: number;
7
8
  values?: number[];
8
9
  };
9
10
  events: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluent-svelte-extra",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
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",