@dcg-overseas/number-line 0.1.17 → 0.1.19
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 +2 -1
- package/dist/index.cjs +9 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -4
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -212,8 +212,9 @@ function App() {
|
|
|
212
212
|
| `onTogglePen` | `() => void` | 切换画笔工具 |
|
|
213
213
|
| `onToggleEraser` | `() => void` | 切换橡皮擦 |
|
|
214
214
|
| `onDelete` | `() => void` | 删除当前选中 |
|
|
215
|
-
| `onReset` | `() => void` |
|
|
215
|
+
| `onReset` | `() => void` | 清空所有笔迹与选中,并隐藏全部跳数弧线(重新设置 `groupSize/groupCount/min/max` 后弧线恢复) |
|
|
216
216
|
| `onUndo` | `() => void` | 撤销上一步操作 |
|
|
217
|
+
| `showAllArcs` | `() => void` | 重新显示全部跳数弧线(清空删除记录)。即使参数未变、或刚 `onReset` 隐藏后,也能强制把弧线显示出来,且不影响笔迹 |
|
|
217
218
|
|
|
218
219
|
#### 缩放 API(仅 `enableZoom=true` 时有效)
|
|
219
220
|
| 字段 | 类型 | 说明 |
|
package/dist/index.cjs
CHANGED
|
@@ -382,9 +382,13 @@ function NumberLineProvider({
|
|
|
382
382
|
const onReset = React.useCallback(() => {
|
|
383
383
|
drawing.resetStrokes();
|
|
384
384
|
history.clear();
|
|
385
|
-
|
|
385
|
+
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
386
|
+
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
386
387
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
387
|
-
}, [drawing, history]);
|
|
388
|
+
}, [drawing, history, groupCount]);
|
|
389
|
+
const showAllArcs = React.useCallback(() => {
|
|
390
|
+
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
391
|
+
}, []);
|
|
388
392
|
const onUndo = React.useCallback(() => {
|
|
389
393
|
const result = history.undo(drawing.strokes);
|
|
390
394
|
if (result.strokes !== null) drawing.restoreStrokes(result.strokes);
|
|
@@ -477,14 +481,15 @@ function NumberLineProvider({
|
|
|
477
481
|
onToggleEraser,
|
|
478
482
|
onDelete,
|
|
479
483
|
onReset,
|
|
480
|
-
onUndo
|
|
484
|
+
onUndo,
|
|
485
|
+
showAllArcs
|
|
481
486
|
},
|
|
482
487
|
children
|
|
483
488
|
}
|
|
484
489
|
);
|
|
485
490
|
}
|
|
486
491
|
function buildArcPath({ x1, x2, y, rx, ry }) {
|
|
487
|
-
return `M ${x1} ${y -
|
|
492
|
+
return `M ${x1} ${y - 20} A ${rx} ${ry} 0 0 1 ${x2} ${y - 20}`;
|
|
488
493
|
}
|
|
489
494
|
function computeLabelStep(containerWidth, range) {
|
|
490
495
|
const maxLabels = Math.floor(containerWidth / 40);
|
package/dist/index.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare interface NumberLineContextValue {
|
|
|
43
43
|
onDelete: () => void;
|
|
44
44
|
onReset: () => void;
|
|
45
45
|
onUndo: () => void;
|
|
46
|
+
/** restore (re-show) every arc by clearing the deleted-arc record */
|
|
47
|
+
showAllArcs: () => void;
|
|
46
48
|
getShowLabelStep?: (params: unknown) => boolean;
|
|
47
49
|
}
|
|
48
50
|
|
package/dist/index.js
CHANGED
|
@@ -380,9 +380,13 @@ function NumberLineProvider({
|
|
|
380
380
|
const onReset = useCallback(() => {
|
|
381
381
|
drawing.resetStrokes();
|
|
382
382
|
history.clear();
|
|
383
|
-
|
|
383
|
+
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
384
|
+
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
384
385
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
385
|
-
}, [drawing, history]);
|
|
386
|
+
}, [drawing, history, groupCount]);
|
|
387
|
+
const showAllArcs = useCallback(() => {
|
|
388
|
+
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
389
|
+
}, []);
|
|
386
390
|
const onUndo = useCallback(() => {
|
|
387
391
|
const result = history.undo(drawing.strokes);
|
|
388
392
|
if (result.strokes !== null) drawing.restoreStrokes(result.strokes);
|
|
@@ -475,14 +479,15 @@ function NumberLineProvider({
|
|
|
475
479
|
onToggleEraser,
|
|
476
480
|
onDelete,
|
|
477
481
|
onReset,
|
|
478
|
-
onUndo
|
|
482
|
+
onUndo,
|
|
483
|
+
showAllArcs
|
|
479
484
|
},
|
|
480
485
|
children
|
|
481
486
|
}
|
|
482
487
|
);
|
|
483
488
|
}
|
|
484
489
|
function buildArcPath({ x1, x2, y, rx, ry }) {
|
|
485
|
-
return `M ${x1} ${y -
|
|
490
|
+
return `M ${x1} ${y - 20} A ${rx} ${ry} 0 0 1 ${x2} ${y - 20}`;
|
|
486
491
|
}
|
|
487
492
|
function computeLabelStep(containerWidth, range) {
|
|
488
493
|
const maxLabels = Math.floor(containerWidth / 40);
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dcg-overseas/number-line",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Interactive number line component with group arcs and freehand drawing",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"main": "./dist/index.cjs",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"import": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"require": {
|
|
17
|
-
"types": "./dist/index.d.cts",
|
|
18
|
-
"default": "./dist/index.cjs"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
|
-
"sideEffects": false,
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dcg-overseas/number-line",
|
|
3
|
+
"version": "0.1.19",
|
|
4
|
+
"description": "Interactive number line component with group arcs and freehand drawing",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"build:watch": "vite build --watch",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "^18.0.0",
|
|
34
|
+
"react-dom": "^18.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/react": "^18.3.3",
|
|
38
|
+
"@types/react-dom": "^18.3.0",
|
|
39
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
40
|
+
"vite": "^5.3.1",
|
|
41
|
+
"vite-plugin-dts": "^3.9.1"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org/"
|
|
46
|
+
}
|
|
47
|
+
}
|