@dcg-overseas/number-line 0.1.18 → 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 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
- setDeletedArcIndices(/* @__PURE__ */ new Set());
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,7 +481,8 @@ function NumberLineProvider({
477
481
  onToggleEraser,
478
482
  onDelete,
479
483
  onReset,
480
- onUndo
484
+ onUndo,
485
+ showAllArcs
481
486
  },
482
487
  children
483
488
  }
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
- setDeletedArcIndices(/* @__PURE__ */ new Set());
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,7 +479,8 @@ function NumberLineProvider({
475
479
  onToggleEraser,
476
480
  onDelete,
477
481
  onReset,
478
- onUndo
482
+ onUndo,
483
+ showAllArcs
479
484
  },
480
485
  children
481
486
  }
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@dcg-overseas/number-line",
3
- "version": "0.1.18",
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
- "peerDependencies": {
27
- "react": "^18.0.0",
28
- "react-dom": "^18.0.0"
29
- },
30
- "devDependencies": {
31
- "@types/react": "^18.3.3",
32
- "@types/react-dom": "^18.3.0",
33
- "@vitejs/plugin-react": "^4.3.1",
34
- "vite": "^5.3.1",
35
- "vite-plugin-dts": "^3.9.1"
36
- },
37
- "publishConfig": {
38
- "access": "public",
39
- "registry": "https://registry.npmjs.org/"
40
- },
41
- "scripts": {
42
- "build": "vite build",
43
- "build:watch": "vite build --watch",
44
- "typecheck": "tsc --noEmit",
45
- "clean": "rm -rf dist *.tsbuildinfo"
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
+ }