@vnejs/uis.react.range-with-text 0.1.3 → 0.1.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/package.json +12 -18
- package/src/RangeWithText.stories.tsx +59 -0
- package/src/RangeWithText.tsx +49 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +18 -0
package/package.json
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/uis.react.range-with-text",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"publish:major:
|
|
9
|
-
"publish:minor:
|
|
10
|
-
"publish:patch:
|
|
11
|
-
"publish:major": "
|
|
12
|
-
"publish:minor": "
|
|
13
|
-
"publish:patch": "
|
|
7
|
+
"build": "npx @vnejs/monorepo package",
|
|
8
|
+
"publish:major:uis:react": "npm run publish:major",
|
|
9
|
+
"publish:minor:uis:react": "npm run publish:minor",
|
|
10
|
+
"publish:patch:uis:react": "npm run publish:patch",
|
|
11
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
12
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
13
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@vnejs/uis.utils": "~0.1.0",
|
|
18
|
-
"react": "19.2.4",
|
|
19
|
-
"react-dom": "19.2.4",
|
|
20
|
-
"@vnejs/uis.react": "~0.1.0"
|
|
16
|
+
"@vnejs/uis.utils": "~0.1.0"
|
|
21
17
|
},
|
|
22
18
|
"devDependencies": {
|
|
23
|
-
"@vnejs/uis.react": "~0.1.0"
|
|
24
|
-
"typescript": "^6.0.3",
|
|
25
|
-
"@types/react": "^19.0.10",
|
|
26
|
-
"@types/react-dom": "^19.0.4"
|
|
19
|
+
"@vnejs/uis.react": "~0.1.0"
|
|
27
20
|
},
|
|
28
21
|
"files": [
|
|
29
22
|
"dist",
|
|
30
|
-
"
|
|
23
|
+
"src",
|
|
24
|
+
"tsconfig.json"
|
|
31
25
|
]
|
|
32
26
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { renderWithVneWrap, VneWrap } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import { RangeWithText } from "@vnejs/uis.react";
|
|
6
|
+
|
|
7
|
+
export const Common = {
|
|
8
|
+
args: {
|
|
9
|
+
...VneWrap.DEFAULT_ARGS,
|
|
10
|
+
|
|
11
|
+
gap: 120,
|
|
12
|
+
isSelected: false,
|
|
13
|
+
|
|
14
|
+
textWidth: 240,
|
|
15
|
+
textSize: 72,
|
|
16
|
+
rangeWidth: 1200,
|
|
17
|
+
rangeHeight: 48,
|
|
18
|
+
valuePostfix: "x",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const VALUE_INFO = {
|
|
23
|
+
["%"]: { defaultValue: 50, min: 0, max: 100, step: 1 },
|
|
24
|
+
["ms"]: { defaultValue: 500, min: 0, max: 2000, step: 20 },
|
|
25
|
+
["s"]: { defaultValue: 0.5, min: 0, max: 1.5, step: 0.05 },
|
|
26
|
+
["x"]: { defaultValue: 1, min: 0.5, max: 1.5, step: 0.05 },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
title: "Base/RangeWithText",
|
|
31
|
+
render: renderWithVneWrap(({ valuePostfix, ...args }) => {
|
|
32
|
+
const [value, setValue] = useState(0);
|
|
33
|
+
|
|
34
|
+
useEffect(() => setValue(VALUE_INFO[valuePostfix].defaultValue), [valuePostfix, setValue]);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<RangeWithText
|
|
38
|
+
value={value}
|
|
39
|
+
valuePostfix={valuePostfix}
|
|
40
|
+
onChange={setValue}
|
|
41
|
+
{...args}
|
|
42
|
+
{...VALUE_INFO[valuePostfix]}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}),
|
|
46
|
+
argTypes: {
|
|
47
|
+
// engine
|
|
48
|
+
...VneWrap.ARGS,
|
|
49
|
+
|
|
50
|
+
gap: { control: { type: "number", min: 12, max: 240, step: 12 } },
|
|
51
|
+
|
|
52
|
+
textWidth: { control: { type: "number", min: 360, max: 2400, step: 60 } },
|
|
53
|
+
textSize: { control: { type: "number", min: 36, max: 120, step: 12 } },
|
|
54
|
+
rangeWidth: { control: { type: "number", min: 600, max: 1800, step: 60 } },
|
|
55
|
+
rangeHeight: { control: { type: "number", min: 24, max: 120, step: 12 } },
|
|
56
|
+
|
|
57
|
+
valuePostfix: { control: { type: "select" }, options: Object.keys(VALUE_INFO) },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { Text, Flex, Range } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
export const RangeWithText = ({
|
|
6
|
+
isSelected = false,
|
|
7
|
+
gap = 120,
|
|
8
|
+
textSize = 72,
|
|
9
|
+
textWidth = 240,
|
|
10
|
+
rangeWidth = 1200,
|
|
11
|
+
rangeHeight = 48,
|
|
12
|
+
min,
|
|
13
|
+
max,
|
|
14
|
+
step,
|
|
15
|
+
value,
|
|
16
|
+
valuePostfix = "",
|
|
17
|
+
valueMap = null,
|
|
18
|
+
onChange,
|
|
19
|
+
}) => {
|
|
20
|
+
const valueText = useMemo(() => (valueMap ? valueMap(value) : value), [valueMap, value]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Flex
|
|
24
|
+
align={Flex.ALIGN.CENTER}
|
|
25
|
+
justify={Flex.JUSTIFY.CENTER}
|
|
26
|
+
direction={Flex.DIRECTION.ROW}
|
|
27
|
+
gap={gap}
|
|
28
|
+
>
|
|
29
|
+
<Range
|
|
30
|
+
className="TextHoverSibling"
|
|
31
|
+
isSelected={isSelected}
|
|
32
|
+
width={rangeWidth}
|
|
33
|
+
height={rangeHeight}
|
|
34
|
+
min={min}
|
|
35
|
+
max={max}
|
|
36
|
+
step={step}
|
|
37
|
+
value={value}
|
|
38
|
+
onChange={onChange}
|
|
39
|
+
/>
|
|
40
|
+
<Text
|
|
41
|
+
text={`${valueText}${valuePostfix}`}
|
|
42
|
+
width={textWidth}
|
|
43
|
+
isSelected={isSelected}
|
|
44
|
+
size={textSize}
|
|
45
|
+
align={Text.ALIGNS.RIGHT}
|
|
46
|
+
/>
|
|
47
|
+
</Flex>
|
|
48
|
+
);
|
|
49
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./RangeWithText";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.react.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "src"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts",
|
|
9
|
+
"src/**/*.tsx",
|
|
10
|
+
"../../../globals.d.ts",
|
|
11
|
+
"../../../peer-modules.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"exclude": [
|
|
14
|
+
"dist",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"src/**/*.stories.tsx"
|
|
17
|
+
]
|
|
18
|
+
}
|