@max-ts/svelte 1.8.4 → 1.9.0
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/assets/src/components/Carousel/Content/{styles.css.ts.vanilla-WeFKZGhD.css → styles.css.ts.vanilla-C9hep06R.css} +4 -1
- package/dist/assets/src/components/RangeInput/{styles.css.ts.vanilla-CoGxbKI0.css → styles.css.ts.vanilla-YtyEUyN4.css} +1 -3
- package/dist/assets/src/components/SliderInput/styles.css.ts.vanilla-D5Ijdd1P.css +66 -0
- package/dist/components/Carousel/Content/styles.css.js +1 -1
- package/dist/components/RangeInput/RangeInput.js +55 -67
- package/dist/components/RangeInput/styles.css.js +1 -1
- package/dist/components/ScalableContainer/store.svelte.d.ts +0 -3
- package/dist/components/ScalableContainer/store.svelte.js +6 -16
- package/dist/components/SliderInput/SliderInput.js +133 -0
- package/dist/components/SliderInput/SliderInput.svelte.d.ts +4 -0
- package/dist/components/SliderInput/index.d.ts +2 -0
- package/dist/components/SliderInput/styles.css.d.ts +12 -0
- package/dist/components/SliderInput/styles.css.js +21 -0
- package/dist/components/SliderInput/types.d.ts +16 -0
- package/dist/components/SliderInput/utils.d.ts +2 -0
- package/dist/components/SliderInput/utils.js +10 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -1
- package/dist/stories/SliderInput.stories.svelte.d.ts +19 -0
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
width: 100%;
|
|
6
6
|
scroll-behavior: smooth;
|
|
7
7
|
-webkit-overflow-scrolling: touch;
|
|
8
|
-
overscroll-behavior: contain;
|
|
9
8
|
scrollbar-width: none;
|
|
10
9
|
}
|
|
11
10
|
.styles_content__ho48de0::-webkit-scrollbar {
|
|
@@ -16,6 +15,8 @@
|
|
|
16
15
|
overflow-y: hidden;
|
|
17
16
|
flex-direction: row;
|
|
18
17
|
scroll-snap-type: x mandatory;
|
|
18
|
+
overscroll-behavior-x: contain;
|
|
19
|
+
overscroll-behavior-y: auto;
|
|
19
20
|
column-gap: var(--spacing-4);
|
|
20
21
|
}
|
|
21
22
|
.styles_orientation_vertical__ho48de2 {
|
|
@@ -23,5 +24,7 @@
|
|
|
23
24
|
overflow-x: hidden;
|
|
24
25
|
flex-direction: column;
|
|
25
26
|
scroll-snap-type: y mandatory;
|
|
27
|
+
overscroll-behavior-y: contain;
|
|
28
|
+
overscroll-behavior-x: auto;
|
|
26
29
|
row-gap: var(--spacing-4);
|
|
27
30
|
}
|
|
@@ -50,11 +50,9 @@
|
|
|
50
50
|
border: none;
|
|
51
51
|
}
|
|
52
52
|
.styles_slider__14rk0zx8 {
|
|
53
|
-
|
|
54
|
-
bottom: -1px;
|
|
53
|
+
bottom: -2px;
|
|
55
54
|
left: 50%;
|
|
56
55
|
transform: translateX(-50%);
|
|
57
|
-
width: calc(100% - 4px);
|
|
58
56
|
}
|
|
59
57
|
.styles_track__14rk0zx9 {
|
|
60
58
|
background-color: transparent;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.styles_container__d42aim0 {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-template-columns: 1fr auto;
|
|
5
|
+
align-items: center;
|
|
6
|
+
column-gap: var(--spacing-1);
|
|
7
|
+
background: var(--colors-background-paper);
|
|
8
|
+
border: 1px solid var(--colors-border);
|
|
9
|
+
border-radius: var(--radius-medium);
|
|
10
|
+
transition: border 0.2s;
|
|
11
|
+
}
|
|
12
|
+
.styles_fullWidth__d42aim1 {
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
.styles_active__d42aim2 {
|
|
16
|
+
border-color: var(--colors-primary);
|
|
17
|
+
}
|
|
18
|
+
.styles_sizes_small__d42aim3 {
|
|
19
|
+
padding: 0.125rem var(--spacing-2);
|
|
20
|
+
height: 28px;
|
|
21
|
+
font-size: var(--fontSize-sm);
|
|
22
|
+
}
|
|
23
|
+
.styles_sizes_medium__d42aim4 {
|
|
24
|
+
padding: var(--spacing-1) var(--spacing-3);
|
|
25
|
+
height: 36px;
|
|
26
|
+
font-size: var(--fontSize-base);
|
|
27
|
+
}
|
|
28
|
+
.styles_sizes_large__d42aim5 {
|
|
29
|
+
padding: var(--spacing-2) var(--spacing-4);
|
|
30
|
+
height: 44px;
|
|
31
|
+
font-size: var(--fontSize-lg);
|
|
32
|
+
}
|
|
33
|
+
.styles_text__d42aim6 {
|
|
34
|
+
font-size: inherit;
|
|
35
|
+
}
|
|
36
|
+
.styles_input__d42aim7 {
|
|
37
|
+
width: 100%;
|
|
38
|
+
min-width: 24px;
|
|
39
|
+
border: none;
|
|
40
|
+
font-size: inherit;
|
|
41
|
+
text-wrap: nowrap;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
outline: none;
|
|
45
|
+
background: transparent;
|
|
46
|
+
color: inherit;
|
|
47
|
+
}
|
|
48
|
+
.styles_input__d42aim7:focus {
|
|
49
|
+
border: none;
|
|
50
|
+
}
|
|
51
|
+
.styles_slider__d42aim8 {
|
|
52
|
+
position: absolute;
|
|
53
|
+
bottom: -2px;
|
|
54
|
+
left: 50%;
|
|
55
|
+
transform: translateX(-50%);
|
|
56
|
+
width: calc(100% - var(--radius-large));
|
|
57
|
+
border-radius: 9999px;
|
|
58
|
+
}
|
|
59
|
+
.styles_track__d42aim9 {
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
}
|
|
62
|
+
@media (max-width: 600px) {
|
|
63
|
+
.styles_container__d42aim0 {
|
|
64
|
+
width: 100%;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./../../../assets/src/theme.css.ts.vanilla-DlH7Hr_5.css";
|
|
2
|
-
import "./../../../assets/src/components/Carousel/Content/styles.css.ts.vanilla-
|
|
2
|
+
import "./../../../assets/src/components/Carousel/Content/styles.css.ts.vanilla-C9hep06R.css";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Carousel/Content/styles.css.ts
|
|
5
5
|
var __default__ = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Typography from "../Typography/Typography.js";
|
|
2
2
|
import { calculateSize } from "../../utils.js";
|
|
3
|
-
import Slider from "../Slider/Slider.js";
|
|
4
3
|
import __default__ from "./styles.css.js";
|
|
5
4
|
import { formatNumber, parseFormattedNumber } from "./utils.js";
|
|
5
|
+
import Slider from "../Slider/Slider.js";
|
|
6
6
|
import "svelte/internal/disclose-version";
|
|
7
7
|
import * as $ from "svelte/internal/client";
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ import * as $ from "svelte/internal/client";
|
|
|
10
10
|
var root = $.from_html(`<div><!> <input type="text" inputmode="numeric" name="min"/> <!> <input type="text" inputmode="numeric" name="max"/> <!> <!></div>`);
|
|
11
11
|
function RangeInput($$anchor, $$props) {
|
|
12
12
|
$.push($$props, true);
|
|
13
|
-
let min = $.prop($$props, "min", 3, 0), max = $.prop($$props, "max", 3, 100), minValue = $.prop($$props, "minValue",
|
|
13
|
+
let min = $.prop($$props, "min", 3, 0), max = $.prop($$props, "max", 3, 100), minValue = $.prop($$props, "minValue", 15), maxValue = $.prop($$props, "maxValue", 15), width = $.prop($$props, "width", 3, 180), step = $.prop($$props, "step", 3, 1), size = $.prop($$props, "size", 3, "medium"), ref = $.prop($$props, "ref", 15, null), restProps = $.rest_props($$props, [
|
|
14
14
|
"$$slots",
|
|
15
15
|
"$$events",
|
|
16
16
|
"$$legacy",
|
|
@@ -27,49 +27,40 @@ function RangeInput($$anchor, $$props) {
|
|
|
27
27
|
"ref",
|
|
28
28
|
"onValueChange"
|
|
29
29
|
]);
|
|
30
|
-
let
|
|
31
|
-
|
|
30
|
+
let timerId;
|
|
31
|
+
const calculatedWidth = $.derived(() => calculateSize(width()));
|
|
32
|
+
let innerValue = $.state($.proxy([minValue() ?? min(), maxValue() ?? max()]));
|
|
33
|
+
let innerDisplayValue = $.derived(() => [formatNumber($.get(innerValue)[0]), formatNumber($.get(innerValue)[1])]);
|
|
32
34
|
$.user_effect(() => {
|
|
33
|
-
$.set(
|
|
34
|
-
$.set(innerMax, maxValue() || max(), true);
|
|
35
|
+
$.set(innerValue, [minValue() || min(), maxValue() || max()], true);
|
|
35
36
|
});
|
|
36
|
-
const calculatedWidth = $.derived(() => calculateSize(width()));
|
|
37
|
-
const innerMinDisplay = $.derived(() => formatNumber($.get(innerMin)));
|
|
38
|
-
const innerMaxDisplay = $.derived(() => formatNumber($.get(innerMax)));
|
|
39
37
|
const adaptiveStep = $.derived(() => {
|
|
40
38
|
const range = max() - min();
|
|
41
39
|
return Math.max(step(), Math.ceil(range / 1e3));
|
|
42
40
|
});
|
|
43
|
-
function applyValues(newMin, newMax) {
|
|
41
|
+
function applyValues([newMin, newMax]) {
|
|
44
42
|
const clampedMin = Math.max(min(), Math.min(newMin, newMax));
|
|
45
43
|
const clampedMax = Math.min(max(), Math.max(newMax, newMin));
|
|
46
|
-
$.set(
|
|
47
|
-
$.set(innerMax, clampedMax, true);
|
|
44
|
+
$.set(innerValue, [clampedMin, clampedMax], true);
|
|
48
45
|
minValue(clampedMin);
|
|
49
46
|
maxValue(clampedMax);
|
|
50
47
|
$$props.onValueChange?.([clampedMin, clampedMax]);
|
|
51
48
|
}
|
|
52
49
|
function handleInput(e) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
clearTimeout(timerId);
|
|
51
|
+
timerId = setTimeout(() => {
|
|
52
|
+
const target = e.target;
|
|
53
|
+
let value = parseFormattedNumber(target.value.replace(/[^\d\s]/g, ""));
|
|
54
|
+
if (Number.isNaN(value)) value = target.name === "min" ? min() : max();
|
|
55
|
+
if (target.name === "min") applyValues([value, $.get(innerValue)[1]]);
|
|
56
|
+
else applyValues([$.get(innerValue)[0], value]);
|
|
57
|
+
}, 700);
|
|
61
58
|
}
|
|
62
59
|
function handleKeyDown(e) {
|
|
63
60
|
if (e.key === "Enter") e.target.blur();
|
|
64
61
|
}
|
|
65
|
-
function handleSliderChange(value) {
|
|
66
|
-
if (value.length === 2) {
|
|
67
|
-
$.set(innerMin, value[0], true);
|
|
68
|
-
$.set(innerMax, value[1], true);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
62
|
function handleSliderCommit(value) {
|
|
72
|
-
if (value.length === 2) applyValues(value
|
|
63
|
+
if (value.length === 2) applyValues(value);
|
|
73
64
|
}
|
|
74
65
|
var div = root();
|
|
75
66
|
$.attribute_effect(div, () => ({
|
|
@@ -87,8 +78,8 @@ function RangeInput($$anchor, $$props) {
|
|
|
87
78
|
get class() {
|
|
88
79
|
return __default__.text;
|
|
89
80
|
},
|
|
90
|
-
color: "
|
|
91
|
-
variant: "
|
|
81
|
+
color: "muted",
|
|
82
|
+
variant: "caption",
|
|
92
83
|
children: ($$anchor, $$slotProps) => {
|
|
93
84
|
$.next();
|
|
94
85
|
var text = $.text("от");
|
|
@@ -103,8 +94,8 @@ function RangeInput($$anchor, $$props) {
|
|
|
103
94
|
get class() {
|
|
104
95
|
return __default__.text;
|
|
105
96
|
},
|
|
106
|
-
color: "
|
|
107
|
-
variant: "
|
|
97
|
+
color: "muted",
|
|
98
|
+
variant: "caption",
|
|
108
99
|
children: ($$anchor, $$slotProps) => {
|
|
109
100
|
$.next();
|
|
110
101
|
var text_1 = $.text("до");
|
|
@@ -119,8 +110,8 @@ function RangeInput($$anchor, $$props) {
|
|
|
119
110
|
get class() {
|
|
120
111
|
return __default__.text;
|
|
121
112
|
},
|
|
122
|
-
color: "
|
|
123
|
-
variant: "
|
|
113
|
+
color: "muted",
|
|
114
|
+
variant: "caption",
|
|
124
115
|
children: ($$anchor, $$slotProps) => {
|
|
125
116
|
$.next();
|
|
126
117
|
var text_2 = $.text();
|
|
@@ -129,49 +120,46 @@ function RangeInput($$anchor, $$props) {
|
|
|
129
120
|
},
|
|
130
121
|
$$slots: { default: true }
|
|
131
122
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
get
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
123
|
+
Slider($.sibling(node_2, 2), {
|
|
124
|
+
get min() {
|
|
125
|
+
return min();
|
|
126
|
+
},
|
|
127
|
+
get max() {
|
|
128
|
+
return max();
|
|
129
|
+
},
|
|
130
|
+
get size() {
|
|
131
|
+
return size();
|
|
132
|
+
},
|
|
133
|
+
get step() {
|
|
134
|
+
return $.get(adaptiveStep);
|
|
135
|
+
},
|
|
136
|
+
get class() {
|
|
137
|
+
return __default__.slider;
|
|
138
|
+
},
|
|
139
|
+
get trackClass() {
|
|
140
|
+
return __default__.track;
|
|
141
|
+
},
|
|
142
|
+
style: "position: absolute;",
|
|
143
|
+
type: "multiple",
|
|
144
|
+
onValueCommit: handleSliderCommit,
|
|
145
|
+
get value() {
|
|
146
|
+
return $.get(innerValue);
|
|
147
|
+
},
|
|
148
|
+
set value($$value) {
|
|
149
|
+
$.set(innerValue, $$value, true);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
162
152
|
$.reset(div);
|
|
163
153
|
$.bind_this(div, ($$value) => ref($$value), () => ref());
|
|
164
154
|
$.template_effect(() => {
|
|
165
155
|
$.set_class(input, 1, $.clsx(__default__.input));
|
|
166
|
-
$.set_value(input, $.get(
|
|
156
|
+
$.set_value(input, $.get(innerDisplayValue)[0]);
|
|
167
157
|
$.set_class(input_1, 1, $.clsx(__default__.input));
|
|
168
|
-
$.set_value(input_1, $.get(
|
|
158
|
+
$.set_value(input_1, $.get(innerDisplayValue)[1]);
|
|
169
159
|
});
|
|
170
160
|
$.delegated("input", input, handleInput);
|
|
171
|
-
$.event("blur", input, handleBlur);
|
|
172
161
|
$.delegated("keydown", input, handleKeyDown);
|
|
173
162
|
$.delegated("input", input_1, handleInput);
|
|
174
|
-
$.event("blur", input_1, handleBlur);
|
|
175
163
|
$.delegated("keydown", input_1, handleKeyDown);
|
|
176
164
|
$.append($$anchor, div);
|
|
177
165
|
$.pop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./../../assets/src/theme.css.ts.vanilla-DlH7Hr_5.css";
|
|
2
|
-
import "./../../assets/src/components/RangeInput/styles.css.ts.vanilla-
|
|
2
|
+
import "./../../assets/src/components/RangeInput/styles.css.ts.vanilla-YtyEUyN4.css";
|
|
3
3
|
|
|
4
4
|
//#region src/components/RangeInput/styles.css.ts
|
|
5
5
|
var __default__ = {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
//#region src/components/ScalableContainer/store.svelte.ts
|
|
2
2
|
var ScalableContainerStore = class {
|
|
3
|
-
|
|
4
|
-
minScale;
|
|
5
|
-
maxScale;
|
|
3
|
+
#props;
|
|
6
4
|
meta;
|
|
7
|
-
#onScaleChanged;
|
|
8
|
-
#onPositionChanged;
|
|
9
5
|
scale = $state(1);
|
|
10
6
|
position = $state({
|
|
11
7
|
x: 0,
|
|
@@ -25,21 +21,16 @@ var ScalableContainerStore = class {
|
|
|
25
21
|
transition = $derived(this.#isDragging ? "none" : "transform 0.1s ease-out");
|
|
26
22
|
cursor = $derived(this.#isDragging ? "grabbing" : "grab");
|
|
27
23
|
constructor(props) {
|
|
28
|
-
this
|
|
29
|
-
this.scale = props.initialScale ?? 1;
|
|
30
|
-
this.minScale = props.minScale ?? .1;
|
|
31
|
-
this.maxScale = props.maxScale ?? 4;
|
|
32
|
-
this.#onScaleChanged = props.onScaleChanged;
|
|
33
|
-
this.#onPositionChanged = props.onPositionChanged;
|
|
24
|
+
this.#props = props;
|
|
34
25
|
this.meta = typeof window !== "undefined" && window.navigator && /Mac/i.test(navigator.userAgent) ? "⌘" : "ctrl";
|
|
35
26
|
}
|
|
36
27
|
#setScale = (value) => {
|
|
37
|
-
this.scale = Math.max(this.minScale, Math.min(this.maxScale, value));
|
|
38
|
-
this.#onScaleChanged?.(this.scale);
|
|
28
|
+
this.scale = Math.max(this.#props.minScale || .1, Math.min(this.#props.maxScale || 4, value));
|
|
29
|
+
this.#props.onScaleChanged?.(this.scale);
|
|
39
30
|
};
|
|
40
31
|
#setPosition = (pos) => {
|
|
41
32
|
this.position = pos;
|
|
42
|
-
this.#onPositionChanged?.(pos);
|
|
33
|
+
this.#props.onPositionChanged?.(pos);
|
|
43
34
|
};
|
|
44
35
|
zoomIn = () => {
|
|
45
36
|
this.#setScale(this.scale * 1.5);
|
|
@@ -48,7 +39,7 @@ var ScalableContainerStore = class {
|
|
|
48
39
|
this.#setScale(this.scale / 1.5);
|
|
49
40
|
};
|
|
50
41
|
reset = () => {
|
|
51
|
-
this.#setScale(this.initialScale);
|
|
42
|
+
this.#setScale(this.#props.initialScale || 1);
|
|
52
43
|
this.#setPosition({
|
|
53
44
|
x: 0,
|
|
54
45
|
y: 0
|
|
@@ -95,7 +86,6 @@ var ScalableContainerStore = class {
|
|
|
95
86
|
movePinch = (t1, t2) => {
|
|
96
87
|
if (this.#initialPinchDistance === 0) return;
|
|
97
88
|
const dist = this.#getDistance(t1, t2);
|
|
98
|
-
console.log({ dist });
|
|
99
89
|
this.#setScale(this.#initialPinchScale * (dist / this.#initialPinchDistance));
|
|
100
90
|
};
|
|
101
91
|
endPinch = () => {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Typography from "../Typography/Typography.js";
|
|
2
|
+
import { calculateSize } from "../../utils.js";
|
|
3
|
+
import Slider from "../Slider/Slider.js";
|
|
4
|
+
import __default__ from "./styles.css.js";
|
|
5
|
+
import { formatNumber, parseFormattedNumber } from "./utils.js";
|
|
6
|
+
import "svelte/internal/disclose-version";
|
|
7
|
+
import * as $ from "svelte/internal/client";
|
|
8
|
+
|
|
9
|
+
//#region src/components/SliderInput/SliderInput.svelte
|
|
10
|
+
var root = $.from_html(`<div><input type="text" inputmode="numeric"/> <!> <!></div>`);
|
|
11
|
+
function SliderInput($$anchor, $$props) {
|
|
12
|
+
$.push($$props, true);
|
|
13
|
+
let min = $.prop($$props, "min", 3, 0), max = $.prop($$props, "max", 3, 100), value = $.prop($$props, "value", 15), width = $.prop($$props, "width", 3, 180), step = $.prop($$props, "step", 3, 1), size = $.prop($$props, "size", 3, "medium"), ref = $.prop($$props, "ref", 15, null), restProps = $.rest_props($$props, [
|
|
14
|
+
"$$slots",
|
|
15
|
+
"$$events",
|
|
16
|
+
"$$legacy",
|
|
17
|
+
"min",
|
|
18
|
+
"max",
|
|
19
|
+
"value",
|
|
20
|
+
"width",
|
|
21
|
+
"step",
|
|
22
|
+
"unit",
|
|
23
|
+
"size",
|
|
24
|
+
"class",
|
|
25
|
+
"name",
|
|
26
|
+
"isActive",
|
|
27
|
+
"ref",
|
|
28
|
+
"onValueChange"
|
|
29
|
+
]);
|
|
30
|
+
let timerId;
|
|
31
|
+
const calculatedWidth = $.derived(() => calculateSize(width()));
|
|
32
|
+
let innerValue = $.state($.proxy(value()));
|
|
33
|
+
let innerDisplayValue = $.derived(() => formatNumber($.get(innerValue) || min()));
|
|
34
|
+
$.user_effect(() => {
|
|
35
|
+
$.set(innerValue, value() || min(), true);
|
|
36
|
+
});
|
|
37
|
+
const adaptiveStep = $.derived(() => {
|
|
38
|
+
const range = max() - min();
|
|
39
|
+
return Math.max(step(), Math.ceil(range / 1e3));
|
|
40
|
+
});
|
|
41
|
+
function applyValues(newValue) {
|
|
42
|
+
const clampedValue = Math.max(min(), Math.min(max(), newValue));
|
|
43
|
+
$.set(innerValue, clampedValue, true);
|
|
44
|
+
value(clampedValue);
|
|
45
|
+
$$props.onValueChange?.(clampedValue);
|
|
46
|
+
}
|
|
47
|
+
function handleInput(e) {
|
|
48
|
+
clearTimeout(timerId);
|
|
49
|
+
timerId = setTimeout(() => {
|
|
50
|
+
const target = e.target;
|
|
51
|
+
let value = parseFormattedNumber(target.value.replace(/[^\d\s]/g, ""));
|
|
52
|
+
if (Number.isNaN(value)) value = min();
|
|
53
|
+
applyValues(value);
|
|
54
|
+
}, 700);
|
|
55
|
+
}
|
|
56
|
+
function handleKeyDown(e) {
|
|
57
|
+
if (e.key === "Enter") applyValues($.get(innerValue) || min());
|
|
58
|
+
}
|
|
59
|
+
function handleSliderCommit(value) {
|
|
60
|
+
applyValues(value);
|
|
61
|
+
}
|
|
62
|
+
var div = root();
|
|
63
|
+
$.attribute_effect(div, () => ({
|
|
64
|
+
class: [
|
|
65
|
+
__default__.container,
|
|
66
|
+
__default__.sizes[size()],
|
|
67
|
+
{ [__default__.active]: $$props.isActive },
|
|
68
|
+
$$props.class
|
|
69
|
+
],
|
|
70
|
+
...restProps,
|
|
71
|
+
[$.STYLE]: { width: $.get(calculatedWidth) }
|
|
72
|
+
}));
|
|
73
|
+
var input = $.child(div);
|
|
74
|
+
$.remove_input_defaults(input);
|
|
75
|
+
var node = $.sibling(input, 2);
|
|
76
|
+
Typography(node, {
|
|
77
|
+
get class() {
|
|
78
|
+
return __default__.text;
|
|
79
|
+
},
|
|
80
|
+
color: "muted",
|
|
81
|
+
variant: "caption",
|
|
82
|
+
children: ($$anchor, $$slotProps) => {
|
|
83
|
+
$.next();
|
|
84
|
+
var text = $.text();
|
|
85
|
+
$.template_effect(() => $.set_text(text, $$props.unit));
|
|
86
|
+
$.append($$anchor, text);
|
|
87
|
+
},
|
|
88
|
+
$$slots: { default: true }
|
|
89
|
+
});
|
|
90
|
+
Slider($.sibling(node, 2), {
|
|
91
|
+
get min() {
|
|
92
|
+
return min();
|
|
93
|
+
},
|
|
94
|
+
get max() {
|
|
95
|
+
return max();
|
|
96
|
+
},
|
|
97
|
+
get size() {
|
|
98
|
+
return size();
|
|
99
|
+
},
|
|
100
|
+
get step() {
|
|
101
|
+
return $.get(adaptiveStep);
|
|
102
|
+
},
|
|
103
|
+
get class() {
|
|
104
|
+
return __default__.slider;
|
|
105
|
+
},
|
|
106
|
+
get trackClass() {
|
|
107
|
+
return __default__.track;
|
|
108
|
+
},
|
|
109
|
+
type: "single",
|
|
110
|
+
onValueCommit: handleSliderCommit,
|
|
111
|
+
get value() {
|
|
112
|
+
return $.get(innerValue);
|
|
113
|
+
},
|
|
114
|
+
set value($$value) {
|
|
115
|
+
$.set(innerValue, $$value, true);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
$.reset(div);
|
|
119
|
+
$.bind_this(div, ($$value) => ref($$value), () => ref());
|
|
120
|
+
$.template_effect(() => {
|
|
121
|
+
$.set_class(input, 1, $.clsx(__default__.input));
|
|
122
|
+
$.set_value(input, $.get(innerDisplayValue));
|
|
123
|
+
$.set_attribute(input, "name", $$props.name);
|
|
124
|
+
});
|
|
125
|
+
$.delegated("input", input, handleInput);
|
|
126
|
+
$.delegated("keydown", input, handleKeyDown);
|
|
127
|
+
$.append($$anchor, div);
|
|
128
|
+
$.pop();
|
|
129
|
+
}
|
|
130
|
+
$.delegate(["input", "keydown"]);
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { SliderInput as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SliderInputSize } from './types';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
container: string;
|
|
4
|
+
active: string;
|
|
5
|
+
sizes: Record<SliderInputSize, string>;
|
|
6
|
+
text: string;
|
|
7
|
+
input: string;
|
|
8
|
+
slider: string;
|
|
9
|
+
fullWidth: string;
|
|
10
|
+
track: string;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./../../assets/src/theme.css.ts.vanilla-DlH7Hr_5.css";
|
|
2
|
+
import "./../../assets/src/components/SliderInput/styles.css.ts.vanilla-D5Ijdd1P.css";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SliderInput/styles.css.ts
|
|
5
|
+
var __default__ = {
|
|
6
|
+
container: "styles_container__d42aim0",
|
|
7
|
+
active: "styles_active__d42aim2",
|
|
8
|
+
sizes: {
|
|
9
|
+
small: "styles_sizes_small__d42aim3",
|
|
10
|
+
medium: "styles_sizes_medium__d42aim4",
|
|
11
|
+
large: "styles_sizes_large__d42aim5"
|
|
12
|
+
},
|
|
13
|
+
text: "styles_text__d42aim6",
|
|
14
|
+
input: "styles_input__d42aim7",
|
|
15
|
+
slider: "styles_slider__d42aim8",
|
|
16
|
+
fullWidth: "styles_fullWidth__d42aim1",
|
|
17
|
+
track: "styles_track__d42aim9"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { __default__ as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { WithElementRef } from '../../types.ts';
|
|
3
|
+
export type SliderInputSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export interface SliderInputProps extends WithElementRef<HTMLAttributes<HTMLDivElement>> {
|
|
5
|
+
value?: number;
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
unit?: string;
|
|
10
|
+
width?: number | string;
|
|
11
|
+
size?: SliderInputSize;
|
|
12
|
+
name?: string;
|
|
13
|
+
isActive?: boolean;
|
|
14
|
+
onValueChange?: (value: number) => void;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/SliderInput/utils.ts
|
|
2
|
+
const formatNumber = (num) => {
|
|
3
|
+
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
|
4
|
+
};
|
|
5
|
+
const parseFormattedNumber = (str) => {
|
|
6
|
+
return parseFloat(str.replace(/\s/g, ""));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { formatNumber, parseFormattedNumber };
|
|
@@ -28,6 +28,7 @@ export { ScalableContainer, type ScalableContainerProps, } from './ScalableConta
|
|
|
28
28
|
export { Select } from './Select';
|
|
29
29
|
export { Separator, type SeparatorProps, } from './Separator';
|
|
30
30
|
export { Slider, type SliderProps } from './Slider';
|
|
31
|
+
export { SliderInput, type SliderInputProps } from './SliderInput';
|
|
31
32
|
export { Spinner, type SpinnerSize } from './Spinner';
|
|
32
33
|
export { Tabs, type TabsProps } from './Tabs';
|
|
33
34
|
export { Tooltip, type TooltipProps } from './Tooltip';
|
package/dist/components/index.js
CHANGED
|
@@ -31,7 +31,8 @@ import Slider from "./Slider/Slider.js";
|
|
|
31
31
|
import RangeInput from "./RangeInput/RangeInput.js";
|
|
32
32
|
import ScalableContainer from "./ScalableContainer/ScalableContainer.js";
|
|
33
33
|
import { Select } from "./Select/index.js";
|
|
34
|
+
import SliderInput from "./SliderInput/SliderInput.js";
|
|
34
35
|
import { Tabs } from "./Tabs/index.js";
|
|
35
36
|
import Tooltip from "./Tooltip/Tooltip.js";
|
|
36
37
|
|
|
37
|
-
export { Accordion, Alert, Badge, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, CircularProgress, ContentState, DataGrid, DataGridSortHeader, Dialog, Drawer, DropdownMenu_exports as DropdownMenu, Empty, Field, Input, InputGroup, Item, Label_1 as Label, Placeholder, Popover, RangeInput, ScalableContainer, Select, Separator, Slider, Spinner, Tabs, Tooltip, Typography, badgeVariants, buttonVariants };
|
|
38
|
+
export { Accordion, Alert, Badge, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, CircularProgress, ContentState, DataGrid, DataGridSortHeader, Dialog, Drawer, DropdownMenu_exports as DropdownMenu, Empty, Field, Input, InputGroup, Item, Label_1 as Label, Placeholder, Popover, RangeInput, ScalableContainer, Select, Separator, Slider, SliderInput, Spinner, Tabs, Tooltip, Typography, badgeVariants, buttonVariants };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SliderInput } from '../components';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const SliderInput: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type SliderInput = InstanceType<typeof SliderInput>;
|
|
19
|
+
export default SliderInput;
|