@dcg-overseas/number-line 0.1.18 → 0.1.20
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 +13 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -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
|
@@ -270,6 +270,7 @@ function NumberLineProvider({
|
|
|
270
270
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
271
271
|
const [selectedArcIndices, setSelectedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
272
272
|
const [deletedArcIndices, setDeletedArcIndices] = React.useState(/* @__PURE__ */ new Set());
|
|
273
|
+
const [groupTicksHidden, setGroupTicksHidden] = React.useState(false);
|
|
273
274
|
const { ref: svgRef, width: containerWidth, height: containerHeight } = useContainerSize();
|
|
274
275
|
const history = useHistory();
|
|
275
276
|
const drawing = useDrawing();
|
|
@@ -287,6 +288,7 @@ function NumberLineProvider({
|
|
|
287
288
|
React.useEffect(() => {
|
|
288
289
|
setDeletedArcIndices(/* @__PURE__ */ new Set());
|
|
289
290
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
291
|
+
setGroupTicksHidden(false);
|
|
290
292
|
}, [domainMin, domainMax, groupSize, groupCount]);
|
|
291
293
|
const getLocalCoords = React.useCallback(
|
|
292
294
|
(e) => {
|
|
@@ -382,9 +384,15 @@ function NumberLineProvider({
|
|
|
382
384
|
const onReset = React.useCallback(() => {
|
|
383
385
|
drawing.resetStrokes();
|
|
384
386
|
history.clear();
|
|
385
|
-
|
|
387
|
+
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
388
|
+
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
386
389
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
387
|
-
|
|
390
|
+
setGroupTicksHidden(true);
|
|
391
|
+
}, [drawing, history, groupCount]);
|
|
392
|
+
const showAllArcs = React.useCallback(() => {
|
|
393
|
+
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
394
|
+
setGroupTicksHidden(false);
|
|
395
|
+
}, []);
|
|
388
396
|
const onUndo = React.useCallback(() => {
|
|
389
397
|
const result = history.undo(drawing.strokes);
|
|
390
398
|
if (result.strokes !== null) drawing.restoreStrokes(result.strokes);
|
|
@@ -450,7 +458,7 @@ function NumberLineProvider({
|
|
|
450
458
|
groupCount,
|
|
451
459
|
tickStep,
|
|
452
460
|
arcColors,
|
|
453
|
-
showGroupTicks,
|
|
461
|
+
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
454
462
|
showMajorTicks,
|
|
455
463
|
showMinorTicks,
|
|
456
464
|
showLabelStep,
|
|
@@ -477,7 +485,8 @@ function NumberLineProvider({
|
|
|
477
485
|
onToggleEraser,
|
|
478
486
|
onDelete,
|
|
479
487
|
onReset,
|
|
480
|
-
onUndo
|
|
488
|
+
onUndo,
|
|
489
|
+
showAllArcs
|
|
481
490
|
},
|
|
482
491
|
children
|
|
483
492
|
}
|
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
|
@@ -268,6 +268,7 @@ function NumberLineProvider({
|
|
|
268
268
|
const { min: domainMin, max: domainMax } = normalizeDomain(min, max);
|
|
269
269
|
const [selectedArcIndices, setSelectedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
270
270
|
const [deletedArcIndices, setDeletedArcIndices] = useState(/* @__PURE__ */ new Set());
|
|
271
|
+
const [groupTicksHidden, setGroupTicksHidden] = useState(false);
|
|
271
272
|
const { ref: svgRef, width: containerWidth, height: containerHeight } = useContainerSize();
|
|
272
273
|
const history = useHistory();
|
|
273
274
|
const drawing = useDrawing();
|
|
@@ -285,6 +286,7 @@ function NumberLineProvider({
|
|
|
285
286
|
useEffect(() => {
|
|
286
287
|
setDeletedArcIndices(/* @__PURE__ */ new Set());
|
|
287
288
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
289
|
+
setGroupTicksHidden(false);
|
|
288
290
|
}, [domainMin, domainMax, groupSize, groupCount]);
|
|
289
291
|
const getLocalCoords = useCallback(
|
|
290
292
|
(e) => {
|
|
@@ -380,9 +382,15 @@ function NumberLineProvider({
|
|
|
380
382
|
const onReset = useCallback(() => {
|
|
381
383
|
drawing.resetStrokes();
|
|
382
384
|
history.clear();
|
|
383
|
-
|
|
385
|
+
const arcCount = Math.max(0, Math.ceil(Number(groupCount) || 0));
|
|
386
|
+
setDeletedArcIndices(new Set(Array.from({ length: arcCount }, (_, i) => i)));
|
|
384
387
|
setSelectedArcIndices(/* @__PURE__ */ new Set());
|
|
385
|
-
|
|
388
|
+
setGroupTicksHidden(true);
|
|
389
|
+
}, [drawing, history, groupCount]);
|
|
390
|
+
const showAllArcs = useCallback(() => {
|
|
391
|
+
setDeletedArcIndices((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
392
|
+
setGroupTicksHidden(false);
|
|
393
|
+
}, []);
|
|
386
394
|
const onUndo = useCallback(() => {
|
|
387
395
|
const result = history.undo(drawing.strokes);
|
|
388
396
|
if (result.strokes !== null) drawing.restoreStrokes(result.strokes);
|
|
@@ -448,7 +456,7 @@ function NumberLineProvider({
|
|
|
448
456
|
groupCount,
|
|
449
457
|
tickStep,
|
|
450
458
|
arcColors,
|
|
451
|
-
showGroupTicks,
|
|
459
|
+
showGroupTicks: showGroupTicks && !groupTicksHidden,
|
|
452
460
|
showMajorTicks,
|
|
453
461
|
showMinorTicks,
|
|
454
462
|
showLabelStep,
|
|
@@ -475,7 +483,8 @@ function NumberLineProvider({
|
|
|
475
483
|
onToggleEraser,
|
|
476
484
|
onDelete,
|
|
477
485
|
onReset,
|
|
478
|
-
onUndo
|
|
486
|
+
onUndo,
|
|
487
|
+
showAllArcs
|
|
479
488
|
},
|
|
480
489
|
children
|
|
481
490
|
}
|
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.20",
|
|
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
|
+
}
|