@dcg-overseas/number-line 1.0.0-beta.2 → 1.0.0-beta.3
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 +9 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -223,6 +223,7 @@ function useNumberLineContext() {
|
|
|
223
223
|
if (!ctx) throw new Error("Must be used inside <NumberLineProvider>");
|
|
224
224
|
return ctx;
|
|
225
225
|
}
|
|
226
|
+
const DEFAULT_DRAWING_STROKE_WIDTH = 2.5;
|
|
226
227
|
function normalizeDomain(lo, hi) {
|
|
227
228
|
const a = Number(lo);
|
|
228
229
|
const b = Number(hi);
|
|
@@ -255,6 +256,7 @@ function NumberLineProvider({
|
|
|
255
256
|
groupSize,
|
|
256
257
|
groupCount,
|
|
257
258
|
tickStep,
|
|
259
|
+
strokeWidth: configuredStrokeWidth,
|
|
258
260
|
arcColors,
|
|
259
261
|
showGroupTicks = true,
|
|
260
262
|
showMajorTicks = true,
|
|
@@ -270,6 +272,7 @@ function NumberLineProvider({
|
|
|
270
272
|
children
|
|
271
273
|
}) {
|
|
272
274
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
275
|
+
const strokeWidth = typeof configuredStrokeWidth === "number" && Number.isFinite(configuredStrokeWidth) && configuredStrokeWidth > 0 ? configuredStrokeWidth : DEFAULT_DRAWING_STROKE_WIDTH;
|
|
273
276
|
const [selectedArcIndices, setSelectedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
274
277
|
const [deletedArcIndices, setDeletedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
275
278
|
const [groupTicksHidden, setGroupTicksHidden] = React.useState(false);
|
|
@@ -551,6 +554,7 @@ function NumberLineProvider({
|
|
|
551
554
|
groupSize,
|
|
552
555
|
groupCount,
|
|
553
556
|
tickStep,
|
|
557
|
+
strokeWidth,
|
|
554
558
|
arcColors,
|
|
555
559
|
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
556
560
|
showMajorTicks,
|
|
@@ -1023,7 +1027,7 @@ const GroupArcsLayer = React.memo(function GroupArcsLayer2({
|
|
|
1023
1027
|
}
|
|
1024
1028
|
return /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nl-arcs-layer", children: arcs });
|
|
1025
1029
|
});
|
|
1026
|
-
function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds, onStrokeClick }) {
|
|
1030
|
+
function DrawingLayer({ strokes, liveStroke, tool, width, height, strokeWidth, eraseHoverIds, onStrokeClick }) {
|
|
1027
1031
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "nl-drawing-layer", transform: `scale(${width} ${height})`, children: [
|
|
1028
1032
|
strokes.map((s) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
1029
1033
|
(s.selected || tool === "eraser" && eraseHoverIds.has(s.id)) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1065,7 +1069,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds,
|
|
|
1065
1069
|
d: s.d,
|
|
1066
1070
|
fill: "none",
|
|
1067
1071
|
stroke: "#7c3aed",
|
|
1068
|
-
strokeWidth
|
|
1072
|
+
strokeWidth,
|
|
1069
1073
|
strokeLinecap: "round",
|
|
1070
1074
|
strokeLinejoin: "round",
|
|
1071
1075
|
vectorEffect: "non-scaling-stroke",
|
|
@@ -1079,7 +1083,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds,
|
|
|
1079
1083
|
d: liveStroke.d,
|
|
1080
1084
|
fill: "none",
|
|
1081
1085
|
stroke: "#7c3aed",
|
|
1082
|
-
strokeWidth
|
|
1086
|
+
strokeWidth,
|
|
1083
1087
|
strokeLinecap: "round",
|
|
1084
1088
|
strokeLinejoin: "round",
|
|
1085
1089
|
vectorEffect: "non-scaling-stroke",
|
|
@@ -1104,6 +1108,7 @@ function NumberLine({ className }) {
|
|
|
1104
1108
|
groupSize,
|
|
1105
1109
|
groupCount,
|
|
1106
1110
|
tickStep,
|
|
1111
|
+
strokeWidth,
|
|
1107
1112
|
arcColors,
|
|
1108
1113
|
showGroupTicks,
|
|
1109
1114
|
showMajorTicks,
|
|
@@ -1355,6 +1360,7 @@ function NumberLine({ className }) {
|
|
|
1355
1360
|
tool,
|
|
1356
1361
|
width: w,
|
|
1357
1362
|
height: h,
|
|
1363
|
+
strokeWidth,
|
|
1358
1364
|
eraseHoverIds,
|
|
1359
1365
|
onStrokeClick
|
|
1360
1366
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare interface NumberLineContextValue {
|
|
|
15
15
|
groupSize: number;
|
|
16
16
|
groupCount: number;
|
|
17
17
|
tickStep: number;
|
|
18
|
+
/** 用户自由绘制笔迹的固定视觉线宽,单位为 CSS 像素。 */
|
|
19
|
+
strokeWidth: number;
|
|
18
20
|
arcColors?: string[];
|
|
19
21
|
showGroupTicks: boolean;
|
|
20
22
|
showMajorTicks: boolean;
|
|
@@ -60,6 +62,8 @@ export declare interface NumberLineProps {
|
|
|
60
62
|
groupSize: number;
|
|
61
63
|
groupCount: number;
|
|
62
64
|
tickStep: number;
|
|
65
|
+
/** 用户自由绘制笔迹的固定视觉线宽,单位为 CSS 像素;默认 2.5。 */
|
|
66
|
+
strokeWidth?: number;
|
|
63
67
|
arcColors?: string[];
|
|
64
68
|
/** show group boundary ticks (tallest). Default: true */
|
|
65
69
|
showGroupTicks?: boolean;
|
|
@@ -87,7 +91,7 @@ export declare interface NumberLineProps {
|
|
|
87
91
|
getShowLabelStep?: (params: unknown) => boolean;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
export declare function NumberLineProvider({ min, max, groupSize, groupCount, tickStep, arcColors, showGroupTicks, showMajorTicks, showMinorTicks, enableZoom, minZoom, maxZoom, showLabelStep, viewMin: controlledViewMin, viewMax: controlledViewMax, getShowLabelStep, onViewChange, children, }: NumberLineProviderProps): JSX_2.Element;
|
|
94
|
+
export declare function NumberLineProvider({ min, max, groupSize, groupCount, tickStep, strokeWidth: configuredStrokeWidth, arcColors, showGroupTicks, showMajorTicks, showMinorTicks, enableZoom, minZoom, maxZoom, showLabelStep, viewMin: controlledViewMin, viewMax: controlledViewMax, getShowLabelStep, onViewChange, children, }: NumberLineProviderProps): JSX_2.Element;
|
|
91
95
|
|
|
92
96
|
declare interface NumberLineProviderProps extends NumberLineProps {
|
|
93
97
|
children: default_2.ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -221,6 +221,7 @@ function useNumberLineContext() {
|
|
|
221
221
|
if (!ctx) throw new Error("Must be used inside <NumberLineProvider>");
|
|
222
222
|
return ctx;
|
|
223
223
|
}
|
|
224
|
+
const DEFAULT_DRAWING_STROKE_WIDTH = 2.5;
|
|
224
225
|
function normalizeDomain(lo, hi) {
|
|
225
226
|
const a = Number(lo);
|
|
226
227
|
const b = Number(hi);
|
|
@@ -253,6 +254,7 @@ function NumberLineProvider({
|
|
|
253
254
|
groupSize,
|
|
254
255
|
groupCount,
|
|
255
256
|
tickStep,
|
|
257
|
+
strokeWidth: configuredStrokeWidth,
|
|
256
258
|
arcColors,
|
|
257
259
|
showGroupTicks = true,
|
|
258
260
|
showMajorTicks = true,
|
|
@@ -268,6 +270,7 @@ function NumberLineProvider({
|
|
|
268
270
|
children
|
|
269
271
|
}) {
|
|
270
272
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
273
|
+
const strokeWidth = typeof configuredStrokeWidth === "number" && Number.isFinite(configuredStrokeWidth) && configuredStrokeWidth > 0 ? configuredStrokeWidth : DEFAULT_DRAWING_STROKE_WIDTH;
|
|
271
274
|
const [selectedArcIndices, setSelectedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
272
275
|
const [deletedArcIndices, setDeletedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
273
276
|
const [groupTicksHidden, setGroupTicksHidden] = useState(false);
|
|
@@ -549,6 +552,7 @@ function NumberLineProvider({
|
|
|
549
552
|
groupSize,
|
|
550
553
|
groupCount,
|
|
551
554
|
tickStep,
|
|
555
|
+
strokeWidth,
|
|
552
556
|
arcColors,
|
|
553
557
|
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
554
558
|
showMajorTicks,
|
|
@@ -1021,7 +1025,7 @@ const GroupArcsLayer = memo(function GroupArcsLayer2({
|
|
|
1021
1025
|
}
|
|
1022
1026
|
return /* @__PURE__ */ jsx("g", { className: "nl-arcs-layer", children: arcs });
|
|
1023
1027
|
});
|
|
1024
|
-
function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds, onStrokeClick }) {
|
|
1028
|
+
function DrawingLayer({ strokes, liveStroke, tool, width, height, strokeWidth, eraseHoverIds, onStrokeClick }) {
|
|
1025
1029
|
return /* @__PURE__ */ jsxs("g", { className: "nl-drawing-layer", transform: `scale(${width} ${height})`, children: [
|
|
1026
1030
|
strokes.map((s) => /* @__PURE__ */ jsxs("g", { children: [
|
|
1027
1031
|
(s.selected || tool === "eraser" && eraseHoverIds.has(s.id)) && /* @__PURE__ */ jsx(
|
|
@@ -1063,7 +1067,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds,
|
|
|
1063
1067
|
d: s.d,
|
|
1064
1068
|
fill: "none",
|
|
1065
1069
|
stroke: "#7c3aed",
|
|
1066
|
-
strokeWidth
|
|
1070
|
+
strokeWidth,
|
|
1067
1071
|
strokeLinecap: "round",
|
|
1068
1072
|
strokeLinejoin: "round",
|
|
1069
1073
|
vectorEffect: "non-scaling-stroke",
|
|
@@ -1077,7 +1081,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, eraseHoverIds,
|
|
|
1077
1081
|
d: liveStroke.d,
|
|
1078
1082
|
fill: "none",
|
|
1079
1083
|
stroke: "#7c3aed",
|
|
1080
|
-
strokeWidth
|
|
1084
|
+
strokeWidth,
|
|
1081
1085
|
strokeLinecap: "round",
|
|
1082
1086
|
strokeLinejoin: "round",
|
|
1083
1087
|
vectorEffect: "non-scaling-stroke",
|
|
@@ -1102,6 +1106,7 @@ function NumberLine({ className }) {
|
|
|
1102
1106
|
groupSize,
|
|
1103
1107
|
groupCount,
|
|
1104
1108
|
tickStep,
|
|
1109
|
+
strokeWidth,
|
|
1105
1110
|
arcColors,
|
|
1106
1111
|
showGroupTicks,
|
|
1107
1112
|
showMajorTicks,
|
|
@@ -1353,6 +1358,7 @@ function NumberLine({ className }) {
|
|
|
1353
1358
|
tool,
|
|
1354
1359
|
width: w,
|
|
1355
1360
|
height: h,
|
|
1361
|
+
strokeWidth,
|
|
1356
1362
|
eraseHoverIds,
|
|
1357
1363
|
onStrokeClick
|
|
1358
1364
|
}
|