@tremolo-ui/functions 0.0.4
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/README.md +11 -0
- package/dist/cjs/components/NumberInput/type.js +82 -0
- package/dist/cjs/components/NumberInput/type.js.map +1 -0
- package/dist/cjs/components/NumberInput/types/components/NumberInput/type.d.ts +14 -0
- package/dist/cjs/components/NumberInput/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/cjs/components/NumberInput/types/components/Slider/type.d.ts +32 -0
- package/dist/cjs/components/NumberInput/types/components/Slider/type.d.ts.map +1 -0
- package/dist/cjs/components/NumberInput/types/index.d.ts +4 -0
- package/dist/cjs/components/NumberInput/types/index.d.ts.map +1 -0
- package/dist/cjs/components/NumberInput/types/math.d.ts +12 -0
- package/dist/cjs/components/NumberInput/types/math.d.ts.map +1 -0
- package/dist/cjs/components/NumberInput/types/types.d.ts +2 -0
- package/dist/cjs/components/NumberInput/types/types.d.ts.map +1 -0
- package/dist/cjs/components/NumberInput/types/util.d.ts +6 -0
- package/dist/cjs/components/NumberInput/types/util.d.ts.map +1 -0
- package/dist/cjs/components/Slider/type.js +50 -0
- package/dist/cjs/components/Slider/type.js.map +1 -0
- package/dist/cjs/components/Slider/types/components/NumberInput/type.d.ts +14 -0
- package/dist/cjs/components/Slider/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/cjs/components/Slider/types/components/Slider/type.d.ts +32 -0
- package/dist/cjs/components/Slider/types/components/Slider/type.d.ts.map +1 -0
- package/dist/cjs/components/Slider/types/index.d.ts +4 -0
- package/dist/cjs/components/Slider/types/index.d.ts.map +1 -0
- package/dist/cjs/components/Slider/types/math.d.ts +12 -0
- package/dist/cjs/components/Slider/types/math.d.ts.map +1 -0
- package/dist/cjs/components/Slider/types/types.d.ts +2 -0
- package/dist/cjs/components/Slider/types/types.d.ts.map +1 -0
- package/dist/cjs/components/Slider/types/util.d.ts +6 -0
- package/dist/cjs/components/Slider/types/util.d.ts.map +1 -0
- package/dist/cjs/index.js +96 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/components/NumberInput/type.d.ts +14 -0
- package/dist/cjs/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/cjs/types/components/Slider/type.d.ts +32 -0
- package/dist/cjs/types/components/Slider/type.d.ts.map +1 -0
- package/dist/cjs/types/index.d.ts +4 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/math.d.ts +12 -0
- package/dist/cjs/types/math.d.ts.map +1 -0
- package/dist/cjs/types/types.d.ts +2 -0
- package/dist/cjs/types/types.d.ts.map +1 -0
- package/dist/cjs/types/util.d.ts +6 -0
- package/dist/cjs/types/util.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/type.js +78 -0
- package/dist/esm/components/NumberInput/type.js.map +1 -0
- package/dist/esm/components/NumberInput/types/components/NumberInput/type.d.ts +14 -0
- package/dist/esm/components/NumberInput/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/types/components/Slider/type.d.ts +32 -0
- package/dist/esm/components/NumberInput/types/components/Slider/type.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/types/index.d.ts +4 -0
- package/dist/esm/components/NumberInput/types/index.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/types/math.d.ts +12 -0
- package/dist/esm/components/NumberInput/types/math.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/types/types.d.ts +2 -0
- package/dist/esm/components/NumberInput/types/types.d.ts.map +1 -0
- package/dist/esm/components/NumberInput/types/util.d.ts +6 -0
- package/dist/esm/components/NumberInput/types/util.d.ts.map +1 -0
- package/dist/esm/components/Slider/type.js +44 -0
- package/dist/esm/components/Slider/type.js.map +1 -0
- package/dist/esm/components/Slider/types/components/NumberInput/type.d.ts +14 -0
- package/dist/esm/components/Slider/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/esm/components/Slider/types/components/Slider/type.d.ts +32 -0
- package/dist/esm/components/Slider/types/components/Slider/type.d.ts.map +1 -0
- package/dist/esm/components/Slider/types/index.d.ts +4 -0
- package/dist/esm/components/Slider/types/index.d.ts.map +1 -0
- package/dist/esm/components/Slider/types/math.d.ts +12 -0
- package/dist/esm/components/Slider/types/math.d.ts.map +1 -0
- package/dist/esm/components/Slider/types/types.d.ts +2 -0
- package/dist/esm/components/Slider/types/types.d.ts.map +1 -0
- package/dist/esm/components/Slider/types/util.d.ts +6 -0
- package/dist/esm/components/Slider/types/util.d.ts.map +1 -0
- package/dist/esm/components/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/index.js +82 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/NumberInput/type.d.ts +14 -0
- package/dist/esm/types/components/NumberInput/type.d.ts.map +1 -0
- package/dist/esm/types/components/Slider/type.d.ts +32 -0
- package/dist/esm/types/components/Slider/type.d.ts.map +1 -0
- package/dist/esm/types/index.d.ts +4 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/math.d.ts +12 -0
- package/dist/esm/types/math.d.ts.map +1 -0
- package/dist/esm/types/types.d.ts +2 -0
- package/dist/esm/types/types.d.ts.map +1 -0
- package/dist/esm/types/util.d.ts +6 -0
- package/dist/esm/types/util.d.ts.map +1 -0
- package/package.json +68 -0
- package/src/components/NumberInput/type.ts +82 -0
- package/src/components/Slider/type.ts +82 -0
- package/src/index.ts +3 -0
- package/src/math.ts +71 -0
- package/src/types.ts +1 -0
- package/src/util.ts +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function toFixed(x, fractionDigits) {
|
|
4
|
+
return Number(x.toFixed(fractionDigits));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function selectUnit(units, value) {
|
|
8
|
+
if (typeof units == 'string')
|
|
9
|
+
return [units, 1];
|
|
10
|
+
let i = 0;
|
|
11
|
+
for (; i < units.length; i++) {
|
|
12
|
+
if (Math.abs(units[i][1]) > Math.abs(value))
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
return units[Math.max(0, i - 1)];
|
|
16
|
+
}
|
|
17
|
+
function parseValue(inputString, units, digit, defaultValue = 0) {
|
|
18
|
+
let str = inputString.trim();
|
|
19
|
+
if (str == '')
|
|
20
|
+
str = String(defaultValue);
|
|
21
|
+
if (!units) {
|
|
22
|
+
return {
|
|
23
|
+
rawValue: Number(str) || defaultValue,
|
|
24
|
+
formatValue: str,
|
|
25
|
+
unit: '',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else if (typeof units == 'string') {
|
|
29
|
+
return {
|
|
30
|
+
rawValue: Number(str) || defaultValue,
|
|
31
|
+
formatValue: `${str}${units}`,
|
|
32
|
+
unit: units,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const unitList = units.map(([u, _s]) => u);
|
|
36
|
+
const scaleList = units.map(([_u, s]) => s);
|
|
37
|
+
let rawValue = defaultValue;
|
|
38
|
+
let formatValue = `${scaleList[0]}`;
|
|
39
|
+
let unit = unitList[0];
|
|
40
|
+
const m = str.match(/^(-?\d+(\.\d+)?)\s*(\w*)$/);
|
|
41
|
+
if (m) {
|
|
42
|
+
rawValue = Number(m[1]) || 0;
|
|
43
|
+
const inputUnit = m[3];
|
|
44
|
+
if (inputUnit != '' && unitList.indexOf(inputUnit) != -1) {
|
|
45
|
+
rawValue *= scaleList[unitList.indexOf(inputUnit)];
|
|
46
|
+
const s = selectUnit(units, rawValue);
|
|
47
|
+
const v = rawValue / s[1];
|
|
48
|
+
formatValue = `${digit != undefined ? toFixed(v, digit) : v}${s[0]}`;
|
|
49
|
+
unit = s[0];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const [u, scale] = selectUnit(units, rawValue);
|
|
53
|
+
const v = rawValue / scale;
|
|
54
|
+
formatValue = `${digit != undefined ? toFixed(v, digit) : v}${u}`;
|
|
55
|
+
unit = u;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
rawValue: rawValue,
|
|
60
|
+
formatValue: formatValue,
|
|
61
|
+
unit: unit,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// TODO: toFixed 以外のフォーマット手法
|
|
65
|
+
// e.g. 小数点第n位
|
|
66
|
+
function formatValue(value, units) {
|
|
67
|
+
if (!units) {
|
|
68
|
+
return `${value}`;
|
|
69
|
+
}
|
|
70
|
+
else if (typeof units == 'string') {
|
|
71
|
+
return `${value}${units}`;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const [unit, scale] = selectUnit(units, value);
|
|
75
|
+
return `${toFixed(value / scale)}${unit}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.formatValue = formatValue;
|
|
80
|
+
exports.parseValue = parseValue;
|
|
81
|
+
exports.selectUnit = selectUnit;
|
|
82
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sources":["../../../../../../../src/math.ts","../../../../../../../src/components/NumberInput/type.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAgDgB,SAAA,OAAO,CAAC,CAAS,EAAE,cAAuB,EAAA;IACxD,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC1C;;ACzCgB,SAAA,UAAU,CAAC,KAAY,EAAE,KAAa,EAAA;IACpD,IAAI,OAAO,KAAK,IAAI,QAAQ;AAAE,QAAA,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAE/C,IAAI,CAAC,GAAG,CAAC;IACT,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC5B,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE;;AAE/C,IAAA,OAAO,KAAK,CA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CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC;QAC9C,OAAO,CAAA,EAAG,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA,EAAG,IAAI,CAAA,CAAE;;AAE7C;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [unit, scale][]
|
|
3
|
+
* @example
|
|
4
|
+
* [['Hz', 1], ['kHz', 1000]]
|
|
5
|
+
*/
|
|
6
|
+
export type Units = [string, number][];
|
|
7
|
+
export declare function selectUnit(units: Units, value: number): [string, number];
|
|
8
|
+
export declare function parseValue(inputString: string, units?: string | Units, digit?: number, defaultValue?: number): {
|
|
9
|
+
rawValue: number;
|
|
10
|
+
formatValue: string;
|
|
11
|
+
unit: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function formatValue(value: number, units?: string | Units): string;
|
|
14
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/NumberInput/type.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;AAEtC,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxE;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,EACtB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,SAAI;;;;EA6CjB;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,UAShE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Horizontal = 'right' | 'left';
|
|
2
|
+
export type Vertical = 'up' | 'down';
|
|
3
|
+
export type Direction = Horizontal | Vertical;
|
|
4
|
+
export declare function isHorizontal(d: Direction): d is "right" | "left";
|
|
5
|
+
export declare function isVertical(d: Direction): d is "up" | "down";
|
|
6
|
+
export declare function isReversed(d: Direction): d is "left" | "up";
|
|
7
|
+
export declare function gradientDirection(d: Direction): "right" | "left" | "top" | "bottom" | undefined;
|
|
8
|
+
export type ScaleType = 'mark' | 'mark-number' | 'number';
|
|
9
|
+
export type ScaleOrderList = {
|
|
10
|
+
at: number;
|
|
11
|
+
type?: ScaleType;
|
|
12
|
+
text?: string;
|
|
13
|
+
style?: {
|
|
14
|
+
markColor?: string;
|
|
15
|
+
labelColor?: string;
|
|
16
|
+
length?: number | string;
|
|
17
|
+
thickness?: number | string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function parseScaleOrderList(scale: ['step', ScaleType] | [number, ScaleType] | ScaleOrderList[] | undefined, min: number, max: number, step: number): ScaleOrderList[];
|
|
21
|
+
export type ScaleOption = {
|
|
22
|
+
/**
|
|
23
|
+
* @default 'mark-number'
|
|
24
|
+
*/
|
|
25
|
+
defaultType?: ScaleType;
|
|
26
|
+
markColor?: string;
|
|
27
|
+
labelColor?: string;
|
|
28
|
+
gap?: number | string;
|
|
29
|
+
labelWidth?: number | string;
|
|
30
|
+
style?: unknown;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Slider/type.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;AACzC,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAA;AACpC,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE7C,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,yBAExC;AAED,wBAAgB,UAAU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CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
2
|
+
export declare function normalizeValue(rawValue: number, min: number, max: number, skew?: number): number;
|
|
3
|
+
export declare function rawValue(normalizedValue: number, min: number, max: number, skew?: number): number;
|
|
4
|
+
export declare function skewWithCenterValue(centerValue: number, min: number, max: number): number;
|
|
5
|
+
export declare function stepValue(value: number, step: number): number;
|
|
6
|
+
export declare function toFixed(x: number, fractionDigits?: number): number;
|
|
7
|
+
export declare function decimalPart(x: number | string): string | undefined;
|
|
8
|
+
export declare function radian(degree: number): number;
|
|
9
|
+
export declare function degree(radian: number): number;
|
|
10
|
+
export declare function dbToGain(db: number): number;
|
|
11
|
+
export declare function gainToDb(gain: number): number;
|
|
12
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../../src/math.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5D;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAKT;AAED,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAQT;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,UAKZ;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAOpD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,UAEzD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,UAElC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Operator = '+' | '-' | '*' | '/';
|
|
2
|
+
export declare function styleHelper(value: string | number): string;
|
|
3
|
+
export declare function styleHelper(value: string | number, op: Operator, influencer?: number): string;
|
|
4
|
+
export declare function isEmpty(obj: object): boolean;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/util.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAErC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC3D,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EAAE,EAAE,QAAQ,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAA;AAwBT,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,WAElC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function toFixed(x, fractionDigits) {
|
|
4
|
+
return Number(x.toFixed(fractionDigits));
|
|
5
|
+
}
|
|
6
|
+
function decimalPart(x) {
|
|
7
|
+
return String(x).split('.')[1];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isHorizontal(d) {
|
|
11
|
+
return d == 'right' || d == 'left';
|
|
12
|
+
}
|
|
13
|
+
function isVertical(d) {
|
|
14
|
+
return d == 'up' || d == 'down';
|
|
15
|
+
}
|
|
16
|
+
function isReversed(d) {
|
|
17
|
+
return d == 'left' || d == 'up';
|
|
18
|
+
}
|
|
19
|
+
function gradientDirection(d) {
|
|
20
|
+
if (d == 'left' || d == 'right')
|
|
21
|
+
return d;
|
|
22
|
+
if (d == 'up')
|
|
23
|
+
return 'top';
|
|
24
|
+
if (d == 'down')
|
|
25
|
+
return 'bottom';
|
|
26
|
+
}
|
|
27
|
+
function parseScaleOrderList(scale, min, max, step) {
|
|
28
|
+
var _a;
|
|
29
|
+
let scalesList = [];
|
|
30
|
+
if (!scale) ;
|
|
31
|
+
else if (typeof scale[0] == 'object') {
|
|
32
|
+
scalesList = scale;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const per = scale[0] == 'step' ? step : scale[0];
|
|
36
|
+
const count = Math.floor(max / per) - Math.ceil(min / per) + 1;
|
|
37
|
+
for (let i = 0; i < count; i++) {
|
|
38
|
+
const at = toFixed(per * (Math.ceil(min / per) + i), (_a = decimalPart(per)) === null || _a === void 0 ? void 0 : _a.length);
|
|
39
|
+
scalesList.push({ at: at, type: scale[1] });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return scalesList;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.gradientDirection = gradientDirection;
|
|
46
|
+
exports.isHorizontal = isHorizontal;
|
|
47
|
+
exports.isReversed = isReversed;
|
|
48
|
+
exports.isVertical = isVertical;
|
|
49
|
+
exports.parseScaleOrderList = parseScaleOrderList;
|
|
50
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sources":["../../../../../../../src/math.ts","../../../../../../../src/components/Slider/type.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAgDgB,SAAA,OAAO,CAAC,CAAS,EAAE,cAAuB,EAAA;IACxD,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC1C;AAEM,SAAU,WAAW,CAAC,CAAkB,EAAA;AAC5C,IAAA,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAChC;;AChDM,SAAU,YAAY,CAAC,CAAY,EAAA;AACvC,IAAA,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,MAAM;AACpC;AAEM,SAAU,UAAU,CAAC,CAAY,EAAA;AACrC,IAAA,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,MAAM;AACjC;AAEM,SAAU,UAAU,CAAC,CAAY,EAAA;AACrC,IAAA,OAAO,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,IAAI;AACjC;AAEM,SAAU,iBAAiB,CAAC,CAAY,EAAA;AAC5C,IAAA,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,OAAO;AAAE,QAAA,OAAO,CAAC;IACzC,IAAI,CAAC,IAAI,IAAI;AAAE,QAAA,OAAO,KAAK;IAC3B,IAAI,CAAC,IAAI,MAAM;AAAE,QAAA,OAAO,QAAQ;AAClC;AAiBM,SAAU,mBAAmB,CACjC,KAIa,EACb,GAAW,EACX,GAAW,EACX,IAAY,EAAA;;IAEZ,IAAI,UAAU,GAAqB,EAAE;IACrC,IAAI,CAAC,KAAK,EAAE;SAEL,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE;QACtC,UAAU,GAAG,KAAK;;SACb;AACL,QAAA,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;AAC9D,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,MAAM,EAAE,GAAG,OAAO,CAChB,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,EAChC,CAAA,EAAA,GAAA,WAAW,CAAC,GAAG,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,MAAM,CACzB;AACD,YAAA,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;;;AAG/C,IAAA,OAAO,UAAU;AACnB;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [unit, scale][]
|
|
3
|
+
* @example
|
|
4
|
+
* [['Hz', 1], ['kHz', 1000]]
|
|
5
|
+
*/
|
|
6
|
+
export type Units = [string, number][];
|
|
7
|
+
export declare function selectUnit(units: Units, value: number): [string, number];
|
|
8
|
+
export declare function parseValue(inputString: string, units?: string | Units, digit?: number, defaultValue?: number): {
|
|
9
|
+
rawValue: number;
|
|
10
|
+
formatValue: string;
|
|
11
|
+
unit: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function formatValue(value: number, units?: string | Units): string;
|
|
14
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/NumberInput/type.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;AAEtC,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxE;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,EACtB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,SAAI;;;;EA6CjB;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,UAShE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Horizontal = 'right' | 'left';
|
|
2
|
+
export type Vertical = 'up' | 'down';
|
|
3
|
+
export type Direction = Horizontal | Vertical;
|
|
4
|
+
export declare function isHorizontal(d: Direction): d is "right" | "left";
|
|
5
|
+
export declare function isVertical(d: Direction): d is "up" | "down";
|
|
6
|
+
export declare function isReversed(d: Direction): d is "left" | "up";
|
|
7
|
+
export declare function gradientDirection(d: Direction): "right" | "left" | "top" | "bottom" | undefined;
|
|
8
|
+
export type ScaleType = 'mark' | 'mark-number' | 'number';
|
|
9
|
+
export type ScaleOrderList = {
|
|
10
|
+
at: number;
|
|
11
|
+
type?: ScaleType;
|
|
12
|
+
text?: string;
|
|
13
|
+
style?: {
|
|
14
|
+
markColor?: string;
|
|
15
|
+
labelColor?: string;
|
|
16
|
+
length?: number | string;
|
|
17
|
+
thickness?: number | string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function parseScaleOrderList(scale: ['step', ScaleType] | [number, ScaleType] | ScaleOrderList[] | undefined, min: number, max: number, step: number): ScaleOrderList[];
|
|
21
|
+
export type ScaleOption = {
|
|
22
|
+
/**
|
|
23
|
+
* @default 'mark-number'
|
|
24
|
+
*/
|
|
25
|
+
defaultType?: ScaleType;
|
|
26
|
+
markColor?: string;
|
|
27
|
+
labelColor?: string;
|
|
28
|
+
gap?: number | string;
|
|
29
|
+
labelWidth?: number | string;
|
|
30
|
+
style?: unknown;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Slider/type.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;AACzC,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAA;AACpC,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE7C,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,yBAExC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,sBAEtC;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,sBAEtC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,SAAS,mDAI7C;AAID,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAA;AACzD,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACxB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAC5B,CAAA;CACF,CAAA;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EACD,CAAC,MAAM,EAAE,SAAS,CAAC,GACnB,CAAC,MAAM,EAAE,SAAS,CAAC,GACnB,cAAc,EAAE,GAChB,SAAS,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,oBAmBb;AAKD,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
2
|
+
export declare function normalizeValue(rawValue: number, min: number, max: number, skew?: number): number;
|
|
3
|
+
export declare function rawValue(normalizedValue: number, min: number, max: number, skew?: number): number;
|
|
4
|
+
export declare function skewWithCenterValue(centerValue: number, min: number, max: number): number;
|
|
5
|
+
export declare function stepValue(value: number, step: number): number;
|
|
6
|
+
export declare function toFixed(x: number, fractionDigits?: number): number;
|
|
7
|
+
export declare function decimalPart(x: number | string): string | undefined;
|
|
8
|
+
export declare function radian(degree: number): number;
|
|
9
|
+
export declare function degree(radian: number): number;
|
|
10
|
+
export declare function dbToGain(db: number): number;
|
|
11
|
+
export declare function gainToDb(gain: number): number;
|
|
12
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../../../src/math.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5D;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAKT;AAED,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAQT;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,UAKZ;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAOpD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,UAEzD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,UAElC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Operator = '+' | '-' | '*' | '/';
|
|
2
|
+
export declare function styleHelper(value: string | number): string;
|
|
3
|
+
export declare function styleHelper(value: string | number, op: Operator, influencer?: number): string;
|
|
4
|
+
export declare function isEmpty(obj: object): boolean;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../src/util.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAErC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC3D,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EAAE,EAAE,QAAQ,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAA;AAwBT,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,WAElC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function clamp(value, min, max) {
|
|
4
|
+
return Math.max(min, Math.min(value, max));
|
|
5
|
+
}
|
|
6
|
+
function normalizeValue(rawValue, min, max, skew = 1) {
|
|
7
|
+
if (min >= max)
|
|
8
|
+
throw new RangeError('requirements: min < max');
|
|
9
|
+
const v = clamp((rawValue - min) / (max - min), 0, 1);
|
|
10
|
+
return Math.pow(v, skew);
|
|
11
|
+
}
|
|
12
|
+
function rawValue(normalizedValue, min, max, skew = 1) {
|
|
13
|
+
if (min >= max)
|
|
14
|
+
throw new RangeError('requirements: min < max');
|
|
15
|
+
const v = skew == 1
|
|
16
|
+
? clamp(normalizedValue, 0, 1)
|
|
17
|
+
: Math.exp(Math.log(clamp(normalizedValue, 0, 1)) / skew);
|
|
18
|
+
return min + v * (max - min);
|
|
19
|
+
}
|
|
20
|
+
function skewWithCenterValue(centerValue, min, max) {
|
|
21
|
+
if (!(min <= centerValue && centerValue <= max))
|
|
22
|
+
throw new RangeError('requirements: min <= centerValue <= max');
|
|
23
|
+
return Math.log(0.5) / Math.log((centerValue - min) / (max - min));
|
|
24
|
+
}
|
|
25
|
+
function stepValue(value, step) {
|
|
26
|
+
var _a;
|
|
27
|
+
if (step <= 0)
|
|
28
|
+
throw new RangeError('requirements: step > 0');
|
|
29
|
+
const quotient = Math.floor(value / step);
|
|
30
|
+
const decimalDigits = (_a = decimalPart(step)) === null || _a === void 0 ? void 0 : _a.length;
|
|
31
|
+
const v = toFixed(quotient * step, decimalDigits);
|
|
32
|
+
const next = toFixed((quotient + 1) * step, decimalDigits);
|
|
33
|
+
return Math.abs(value - v) < Math.abs(value - next) ? v : next;
|
|
34
|
+
}
|
|
35
|
+
function toFixed(x, fractionDigits) {
|
|
36
|
+
return Number(x.toFixed(fractionDigits));
|
|
37
|
+
}
|
|
38
|
+
function decimalPart(x) {
|
|
39
|
+
return String(x).split('.')[1];
|
|
40
|
+
}
|
|
41
|
+
function radian(degree) {
|
|
42
|
+
return (Math.PI * degree) / 180;
|
|
43
|
+
}
|
|
44
|
+
function degree(radian) {
|
|
45
|
+
return (180 * radian) / Math.PI;
|
|
46
|
+
}
|
|
47
|
+
function dbToGain(db) {
|
|
48
|
+
return Math.pow(10, db / 20);
|
|
49
|
+
}
|
|
50
|
+
function gainToDb(gain) {
|
|
51
|
+
return 20 * (Math.log(gain) / Math.LN10);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function styleHelper(value, op, influencer) {
|
|
55
|
+
if (op && influencer) {
|
|
56
|
+
if (typeof value == 'number') {
|
|
57
|
+
if (op == '+')
|
|
58
|
+
return `${value + influencer}px`;
|
|
59
|
+
if (op == '-')
|
|
60
|
+
return `${value - influencer}px`;
|
|
61
|
+
if (op == '*')
|
|
62
|
+
return `${value * influencer}px`;
|
|
63
|
+
if (op == '/')
|
|
64
|
+
return `${value / influencer}px`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return `calc(${value}px ${op} ${influencer})`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (typeof value == 'number') {
|
|
72
|
+
return `${value}px`;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function isEmpty(obj) {
|
|
80
|
+
return Object.keys(obj).length == 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.clamp = clamp;
|
|
84
|
+
exports.dbToGain = dbToGain;
|
|
85
|
+
exports.decimalPart = decimalPart;
|
|
86
|
+
exports.degree = degree;
|
|
87
|
+
exports.gainToDb = gainToDb;
|
|
88
|
+
exports.isEmpty = isEmpty;
|
|
89
|
+
exports.normalizeValue = normalizeValue;
|
|
90
|
+
exports.radian = radian;
|
|
91
|
+
exports.rawValue = rawValue;
|
|
92
|
+
exports.skewWithCenterValue = skewWithCenterValue;
|
|
93
|
+
exports.stepValue = stepValue;
|
|
94
|
+
exports.styleHelper = styleHelper;
|
|
95
|
+
exports.toFixed = toFixed;
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/math.ts","../../../src/util.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;SAAgB,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAA;AAC3D,IAAA,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC5C;AAEM,SAAU,cAAc,CAC5B,QAAgB,EAChB,GAAW,EACX,GAAW,EACX,IAAI,GAAG,CAAC,EAAA;IAER,IAAI,GAAG,IAAI,GAAG;AAAE,QAAA,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC;IAC/D,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC;AAC1B;AAEM,SAAU,QAAQ,CACtB,eAAuB,EACvB,GAAW,EACX,GAAW,EACX,IAAI,GAAG,CAAC,EAAA;IAER,IAAI,GAAG,IAAI,GAAG;AAAE,QAAA,MAAM,IAAI,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GAAG;AAAE,gBAAA,OAAO,CAAG,EAAA,KAAK,GAAG,UAAU,IAAI;;aAC1C;AACL,YAAA,OAAO,QAAQ,KAAK,CAAA,GAAA,EAAM,EAAE,CAAI,CAAA,EAAA,UAAU,GAAG;;;SAE1C;AACL,QAAA,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE;YAC5B,OAAO,CAAA,EAAG,KAAK,CAAA,EAAA,CAAI;;aACd;AACL,YAAA,OAAO,KAAK;;;AAGlB;AAEM,SAAU,OAAO,CAAC,GAAW,EAAA;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC;AACrC;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [unit, scale][]
|
|
3
|
+
* @example
|
|
4
|
+
* [['Hz', 1], ['kHz', 1000]]
|
|
5
|
+
*/
|
|
6
|
+
export type Units = [string, number][];
|
|
7
|
+
export declare function selectUnit(units: Units, value: number): [string, number];
|
|
8
|
+
export declare function parseValue(inputString: string, units?: string | Units, digit?: number, defaultValue?: number): {
|
|
9
|
+
rawValue: number;
|
|
10
|
+
formatValue: string;
|
|
11
|
+
unit: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function formatValue(value: number, units?: string | Units): string;
|
|
14
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/NumberInput/type.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;AAEtC,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxE;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,EACtB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,SAAI;;;;EA6CjB;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,UAShE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type Horizontal = 'right' | 'left';
|
|
2
|
+
export type Vertical = 'up' | 'down';
|
|
3
|
+
export type Direction = Horizontal | Vertical;
|
|
4
|
+
export declare function isHorizontal(d: Direction): d is "right" | "left";
|
|
5
|
+
export declare function isVertical(d: Direction): d is "up" | "down";
|
|
6
|
+
export declare function isReversed(d: Direction): d is "left" | "up";
|
|
7
|
+
export declare function gradientDirection(d: Direction): "right" | "left" | "top" | "bottom" | undefined;
|
|
8
|
+
export type ScaleType = 'mark' | 'mark-number' | 'number';
|
|
9
|
+
export type ScaleOrderList = {
|
|
10
|
+
at: number;
|
|
11
|
+
type?: ScaleType;
|
|
12
|
+
text?: string;
|
|
13
|
+
style?: {
|
|
14
|
+
markColor?: string;
|
|
15
|
+
labelColor?: string;
|
|
16
|
+
length?: number | string;
|
|
17
|
+
thickness?: number | string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function parseScaleOrderList(scale: ['step', ScaleType] | [number, ScaleType] | ScaleOrderList[] | undefined, min: number, max: number, step: number): ScaleOrderList[];
|
|
21
|
+
export type ScaleOption = {
|
|
22
|
+
/**
|
|
23
|
+
* @default 'mark-number'
|
|
24
|
+
*/
|
|
25
|
+
defaultType?: ScaleType;
|
|
26
|
+
markColor?: string;
|
|
27
|
+
labelColor?: string;
|
|
28
|
+
gap?: number | string;
|
|
29
|
+
labelWidth?: number | string;
|
|
30
|
+
style?: unknown;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../../src/components/Slider/type.ts"],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AE,MAAM,GAAG,MAAM,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
2
|
+
export declare function normalizeValue(rawValue: number, min: number, max: number, skew?: number): number;
|
|
3
|
+
export declare function rawValue(normalizedValue: number, min: number, max: number, skew?: number): number;
|
|
4
|
+
export declare function skewWithCenterValue(centerValue: number, min: number, max: number): number;
|
|
5
|
+
export declare function stepValue(value: number, step: number): number;
|
|
6
|
+
export declare function toFixed(x: number, fractionDigits?: number): number;
|
|
7
|
+
export declare function decimalPart(x: number | string): string | undefined;
|
|
8
|
+
export declare function radian(degree: number): number;
|
|
9
|
+
export declare function degree(radian: number): number;
|
|
10
|
+
export declare function dbToGain(db: number): number;
|
|
11
|
+
export declare function gainToDb(gain: number): number;
|
|
12
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../../src/math.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAE5D;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAKT;AAED,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,IAAI,SAAI,UAQT;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,UAKZ;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAOpD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,UAEzD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,UAEpC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,UAElC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,UAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,YAAY,GAAG,KAAK,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Operator = '+' | '-' | '*' | '/';
|
|
2
|
+
export declare function styleHelper(value: string | number): string;
|
|
3
|
+
export declare function styleHelper(value: string | number, op: Operator, influencer?: number): string;
|
|
4
|
+
export declare function isEmpty(obj: object): boolean;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAErC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC3D,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,EAAE,EAAE,QAAQ,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAAA;AAwBT,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,WAElC"}
|