react-raffle-picker 0.4.0 → 0.4.1
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/index.cjs +66 -57
- package/dist/index.mjs +66 -57
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -909,23 +909,17 @@ function RafflePickWheel({ segments, size = 320, colors = DEFAULT_COLORS, labelC
|
|
|
909
909
|
const pointerStyle = pointer === "right" ? {
|
|
910
910
|
position: "absolute",
|
|
911
911
|
top: "50%",
|
|
912
|
-
right: -2,
|
|
913
|
-
width:
|
|
914
|
-
height:
|
|
915
|
-
transform: "translateY(-50%)"
|
|
916
|
-
borderTop: `${size * .045}px solid transparent`,
|
|
917
|
-
borderBottom: `${size * .045}px solid transparent`,
|
|
918
|
-
borderRight: `${size * .09}px solid currentColor`
|
|
912
|
+
right: "-2%",
|
|
913
|
+
width: "10%",
|
|
914
|
+
height: "14%",
|
|
915
|
+
transform: "translateY(-50%)"
|
|
919
916
|
} : {
|
|
920
917
|
position: "absolute",
|
|
921
918
|
left: "50%",
|
|
922
|
-
top: -2,
|
|
923
|
-
width:
|
|
924
|
-
height:
|
|
925
|
-
transform: "translateX(-50%)"
|
|
926
|
-
borderLeft: `${size * .045}px solid transparent`,
|
|
927
|
-
borderRight: `${size * .045}px solid transparent`,
|
|
928
|
-
borderTop: `${size * .09}px solid currentColor`
|
|
919
|
+
top: "-2%",
|
|
920
|
+
width: "14%",
|
|
921
|
+
height: "10%",
|
|
922
|
+
transform: "translateX(-50%)"
|
|
929
923
|
};
|
|
930
924
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
931
925
|
ref: rootRef,
|
|
@@ -936,59 +930,74 @@ function RafflePickWheel({ segments, size = 320, colors = DEFAULT_COLORS, labelC
|
|
|
936
930
|
lineHeight: 0,
|
|
937
931
|
...style,
|
|
938
932
|
width: size,
|
|
939
|
-
|
|
933
|
+
maxWidth: "100%",
|
|
934
|
+
aspectRatio: "1 / 1"
|
|
940
935
|
},
|
|
941
936
|
"data-phase": phase,
|
|
942
937
|
"data-pointer": pointer,
|
|
943
938
|
"data-resting": "",
|
|
944
939
|
children: [
|
|
945
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
946
|
-
ref: wheelRef,
|
|
947
|
-
className: "rrp-wheel__disc",
|
|
940
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
948
941
|
style: {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
942
|
+
position: "absolute",
|
|
943
|
+
inset: 0,
|
|
944
|
+
overflow: "hidden",
|
|
945
|
+
borderRadius: "50%"
|
|
952
946
|
},
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
947
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
948
|
+
ref: wheelRef,
|
|
949
|
+
className: "rrp-wheel__disc",
|
|
950
|
+
style: {
|
|
951
|
+
display: "block",
|
|
952
|
+
width: "100%",
|
|
953
|
+
height: "100%",
|
|
954
|
+
transformOrigin: "50% 50%",
|
|
955
|
+
willChange: "transform"
|
|
956
|
+
},
|
|
957
|
+
viewBox: `0 0 ${VIEWBOX} ${VIEWBOX}`,
|
|
958
|
+
role: "img",
|
|
959
|
+
"aria-label": `Wheel with ${safeCount} segments`,
|
|
960
|
+
children: [safeCount === 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
961
|
+
cx: CENTER,
|
|
962
|
+
cy: CENTER,
|
|
963
|
+
r: RADIUS,
|
|
964
|
+
fill: paths[0].fill
|
|
965
|
+
}) : paths.map((p, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
966
|
+
d: p.d,
|
|
967
|
+
fill: p.fill,
|
|
968
|
+
stroke: "rgba(0,0,0,0.14)",
|
|
969
|
+
strokeWidth: .3
|
|
970
|
+
}, i)), showLabels && paths.map((p, i) => {
|
|
971
|
+
const pt = rimPoint(p.mid, LABEL_RADIUS);
|
|
972
|
+
const rotate = p.mid > 180 ? p.mid + 90 : p.mid - 90;
|
|
973
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("text", {
|
|
974
|
+
x: pt.x,
|
|
975
|
+
y: pt.y,
|
|
976
|
+
fill: labelColor,
|
|
977
|
+
fontSize,
|
|
978
|
+
fontWeight: 600,
|
|
979
|
+
textAnchor: "middle",
|
|
980
|
+
dominantBaseline: "middle",
|
|
981
|
+
transform: `rotate(${rotate} ${pt.x} ${pt.y})`,
|
|
982
|
+
style: {
|
|
983
|
+
pointerEvents: "none",
|
|
984
|
+
userSelect: "none"
|
|
985
|
+
},
|
|
986
|
+
children: labels[i]
|
|
987
|
+
}, i);
|
|
988
|
+
})]
|
|
989
|
+
})
|
|
987
990
|
}),
|
|
988
|
-
!hidePointer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
991
|
+
!hidePointer && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
989
992
|
className: "rrp-wheel__pointer",
|
|
990
993
|
style: pointerStyle,
|
|
991
|
-
|
|
994
|
+
viewBox: "0 0 10 10",
|
|
995
|
+
preserveAspectRatio: "none",
|
|
996
|
+
"aria-hidden": "true",
|
|
997
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polygon", {
|
|
998
|
+
points: pointer === "right" ? "10,0 10,10 0,5" : "0,0 10,0 5,10",
|
|
999
|
+
fill: "currentColor"
|
|
1000
|
+
})
|
|
992
1001
|
}),
|
|
993
1002
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
994
1003
|
ref: liveRef,
|
package/dist/index.mjs
CHANGED
|
@@ -908,23 +908,17 @@ function RafflePickWheel({ segments, size = 320, colors = DEFAULT_COLORS, labelC
|
|
|
908
908
|
const pointerStyle = pointer === "right" ? {
|
|
909
909
|
position: "absolute",
|
|
910
910
|
top: "50%",
|
|
911
|
-
right: -2,
|
|
912
|
-
width:
|
|
913
|
-
height:
|
|
914
|
-
transform: "translateY(-50%)"
|
|
915
|
-
borderTop: `${size * .045}px solid transparent`,
|
|
916
|
-
borderBottom: `${size * .045}px solid transparent`,
|
|
917
|
-
borderRight: `${size * .09}px solid currentColor`
|
|
911
|
+
right: "-2%",
|
|
912
|
+
width: "10%",
|
|
913
|
+
height: "14%",
|
|
914
|
+
transform: "translateY(-50%)"
|
|
918
915
|
} : {
|
|
919
916
|
position: "absolute",
|
|
920
917
|
left: "50%",
|
|
921
|
-
top: -2,
|
|
922
|
-
width:
|
|
923
|
-
height:
|
|
924
|
-
transform: "translateX(-50%)"
|
|
925
|
-
borderLeft: `${size * .045}px solid transparent`,
|
|
926
|
-
borderRight: `${size * .045}px solid transparent`,
|
|
927
|
-
borderTop: `${size * .09}px solid currentColor`
|
|
918
|
+
top: "-2%",
|
|
919
|
+
width: "14%",
|
|
920
|
+
height: "10%",
|
|
921
|
+
transform: "translateX(-50%)"
|
|
928
922
|
};
|
|
929
923
|
return /* @__PURE__ */ jsxs("div", {
|
|
930
924
|
ref: rootRef,
|
|
@@ -935,59 +929,74 @@ function RafflePickWheel({ segments, size = 320, colors = DEFAULT_COLORS, labelC
|
|
|
935
929
|
lineHeight: 0,
|
|
936
930
|
...style,
|
|
937
931
|
width: size,
|
|
938
|
-
|
|
932
|
+
maxWidth: "100%",
|
|
933
|
+
aspectRatio: "1 / 1"
|
|
939
934
|
},
|
|
940
935
|
"data-phase": phase,
|
|
941
936
|
"data-pointer": pointer,
|
|
942
937
|
"data-resting": "",
|
|
943
938
|
children: [
|
|
944
|
-
/* @__PURE__ */
|
|
945
|
-
ref: wheelRef,
|
|
946
|
-
className: "rrp-wheel__disc",
|
|
939
|
+
/* @__PURE__ */ jsx("span", {
|
|
947
940
|
style: {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
941
|
+
position: "absolute",
|
|
942
|
+
inset: 0,
|
|
943
|
+
overflow: "hidden",
|
|
944
|
+
borderRadius: "50%"
|
|
951
945
|
},
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
946
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
947
|
+
ref: wheelRef,
|
|
948
|
+
className: "rrp-wheel__disc",
|
|
949
|
+
style: {
|
|
950
|
+
display: "block",
|
|
951
|
+
width: "100%",
|
|
952
|
+
height: "100%",
|
|
953
|
+
transformOrigin: "50% 50%",
|
|
954
|
+
willChange: "transform"
|
|
955
|
+
},
|
|
956
|
+
viewBox: `0 0 ${VIEWBOX} ${VIEWBOX}`,
|
|
957
|
+
role: "img",
|
|
958
|
+
"aria-label": `Wheel with ${safeCount} segments`,
|
|
959
|
+
children: [safeCount === 1 ? /* @__PURE__ */ jsx("circle", {
|
|
960
|
+
cx: CENTER,
|
|
961
|
+
cy: CENTER,
|
|
962
|
+
r: RADIUS,
|
|
963
|
+
fill: paths[0].fill
|
|
964
|
+
}) : paths.map((p, i) => /* @__PURE__ */ jsx("path", {
|
|
965
|
+
d: p.d,
|
|
966
|
+
fill: p.fill,
|
|
967
|
+
stroke: "rgba(0,0,0,0.14)",
|
|
968
|
+
strokeWidth: .3
|
|
969
|
+
}, i)), showLabels && paths.map((p, i) => {
|
|
970
|
+
const pt = rimPoint(p.mid, LABEL_RADIUS);
|
|
971
|
+
const rotate = p.mid > 180 ? p.mid + 90 : p.mid - 90;
|
|
972
|
+
return /* @__PURE__ */ jsx("text", {
|
|
973
|
+
x: pt.x,
|
|
974
|
+
y: pt.y,
|
|
975
|
+
fill: labelColor,
|
|
976
|
+
fontSize,
|
|
977
|
+
fontWeight: 600,
|
|
978
|
+
textAnchor: "middle",
|
|
979
|
+
dominantBaseline: "middle",
|
|
980
|
+
transform: `rotate(${rotate} ${pt.x} ${pt.y})`,
|
|
981
|
+
style: {
|
|
982
|
+
pointerEvents: "none",
|
|
983
|
+
userSelect: "none"
|
|
984
|
+
},
|
|
985
|
+
children: labels[i]
|
|
986
|
+
}, i);
|
|
987
|
+
})]
|
|
988
|
+
})
|
|
986
989
|
}),
|
|
987
|
-
!hidePointer && /* @__PURE__ */ jsx("
|
|
990
|
+
!hidePointer && /* @__PURE__ */ jsx("svg", {
|
|
988
991
|
className: "rrp-wheel__pointer",
|
|
989
992
|
style: pointerStyle,
|
|
990
|
-
|
|
993
|
+
viewBox: "0 0 10 10",
|
|
994
|
+
preserveAspectRatio: "none",
|
|
995
|
+
"aria-hidden": "true",
|
|
996
|
+
children: /* @__PURE__ */ jsx("polygon", {
|
|
997
|
+
points: pointer === "right" ? "10,0 10,10 0,5" : "0,0 10,0 5,10",
|
|
998
|
+
fill: "currentColor"
|
|
999
|
+
})
|
|
991
1000
|
}),
|
|
992
1001
|
/* @__PURE__ */ jsx("span", {
|
|
993
1002
|
ref: liveRef,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-raffle-picker",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "React random picker: draw a random winner or number with slot-machine, reel and countdown animations. Headless, typed, zero-dependency.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|