@dcg-overseas/number-line 0.1.23 → 0.1.25
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/.tsbuildinfo +1 -0
- package/dist/index.cjs +21 -10
- package/dist/index.js +21 -10
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/@types+react@18.3.28/node_modules/@types/react/global.d.ts","../../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts","../../../node_modules/.pnpm/@types+prop-types@15.7.15/node_modules/@types/prop-types/index.d.ts","../../../node_modules/.pnpm/@types+react@18.3.28/node_modules/@types/react/index.d.ts","../../../node_modules/.pnpm/@types+react@18.3.28/node_modules/@types/react/jsx-runtime.d.ts","../src/types.ts","../src/hooks/usehistory.ts","../src/hooks/usedrawing.ts","../src/hooks/usecontainersize.ts","../src/hooks/usezoom.ts","../src/context/numberlinecontext.ts","../src/components/numberlineprovider.tsx","../src/utils/geometry.ts","../src/components/axislayer.tsx","../src/components/grouparcslayer.tsx","../src/components/drawinglayer.tsx","../src/components/numberline.tsx","../src/index.ts"],"fileIdsList":[[48,49,50],[51],[51,52,60],[51,52,53],[51,52,53,60],[51,52,58,60,61,62,63],[51,52,53,54,55,56,57,58],[51,52],[52,53,58,59,64],[52]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb5b19b86227ace1d29ea4cf81387279d04bb34051e944bc53df69f58914b788","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac51dd7d31333793807a6abaa5ae168512b6131bd41d9c5b98477fc3b7800f9f","impliedFormat":1},{"version":"87d9d29dbc745f182683f63187bf3d53fd8673e5fca38ad5eaab69798ed29fbc","impliedFormat":1},{"version":"035312d4945d13efa134ae482f6dc56a1a9346f7ac3be7ccbad5741058ce87f3","affectsGlobalScope":true,"impliedFormat":1},{"version":"42c169fb8c2d42f4f668c624a9a11e719d5d07dacbebb63cbcf7ef365b0a75b3","impliedFormat":1},"497454b2825f0effe921e2f17780f5a5fd702c24b45591b8b4e56ac32e6df498","c3e2589ca80860c4d3b92c8e2d3b0d1068126a971ace2a8a5f9dff7b7d74aabc","b673529a943b4e5b9107755a3d7870991a62eafc0d55227240c8162276b37804","0f788ec0307d841c96c4603d9c60f26b7c66452c69ca6cf2260c4b2bcf30edcb","96d60747aec233ffa35a36551f463a35c71dd44071d001126f372bf4a92316d2","e85e164566025e53fc9270a41d6d8edcdec606525c05ef9b195e21520fc41fcd","5b7af4c67a08f9f8e85183f34952f22a78a5aa25ae4d4b5c0c2d035f23e286cf",{"version":"1b0fad669dfe35c78101ea0bb102ae63d96f92974b21a8713c6e33fb2edfe6ef","signature":"c9932d874e5eae2a6eb66a8a5e7db02dd97d63e97533b41bede73dde47fa46e2"},{"version":"7f438c1fd5c552a1a85118bf537bb1ba5c056f8a46e0838f90bace3b957b54e8","signature":"f53d813558511618a4b866bfb1865b8f91d2b8ac1df5f0efed6416a1604e2831"},"323ad53f5cf18223dca17d5ac77d27f7b02289c705416f5b353545ff56232e6c","7f7c7cab7f72c8783e187e537c9f6a1a14692f391b6921745362cde06928c57b",{"version":"29389865cafab2475cfbfba94ee63c891c2331ea6203ad3e7e8bdb0f64c1220d","signature":"0b10dff05d2ac9cb594c0a2b536f3302a51b20100c523f0a1c0d72c6e96859e7"},"283575d1dd62487ca5ac23be0773c1e8e3a556f3a9ffd65f973eec577a1a5117"],"root":[[53,65]],"options":{"allowImportingTsExtensions":true,"composite":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"jsx":4,"module":99,"noFallthroughCasesInSwitch":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./.tsbuildinfo","useDefineForClassFields":true,"verbatimModuleSyntax":true},"referencedMap":[[51,1],[52,2],[61,3],[63,4],[62,5],[64,6],[59,7],[58,4],[56,8],[55,4],[54,4],[57,8],[65,9],[53,10],[60,10]],"affectedFilesPendingEmit":[[61,51],[63,51],[62,51],[64,51],[59,51],[58,51],[56,51],[55,51],[54,51],[57,51],[65,51],[53,51],[60,51]],"emitSignatures":[53,54,55,56,57,58,59,60,61,62,63,64,65],"version":"6.0.3"}
|
package/dist/index.cjs
CHANGED
|
@@ -492,8 +492,10 @@ function NumberLineProvider({
|
|
|
492
492
|
}
|
|
493
493
|
);
|
|
494
494
|
}
|
|
495
|
+
const ARC_BASELINE_LIFT = 12;
|
|
495
496
|
function buildArcPath({ x1, x2, y, rx, ry }) {
|
|
496
|
-
|
|
497
|
+
const base = y - ARC_BASELINE_LIFT;
|
|
498
|
+
return `M ${x1} ${base} A ${rx} ${ry} 0 0 1 ${x2} ${base}`;
|
|
497
499
|
}
|
|
498
500
|
function computeLabelStep(containerWidth, range) {
|
|
499
501
|
const maxLabels = Math.floor(containerWidth / 40);
|
|
@@ -587,6 +589,7 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
587
589
|
const rawLabelStep = computeLabelStep(containerWidth, range);
|
|
588
590
|
const labelStep = Math.max(step, Math.ceil(rawLabelStep / step) * step);
|
|
589
591
|
const minorStep = showMinorTicks ? computeMinorTickStep(step, containerWidth, range) : 0;
|
|
592
|
+
const halfTickOffset = minorStep > 0 && step === minorStep * 10 ? step / 2 : 0;
|
|
590
593
|
const MAX_TICKS = 500;
|
|
591
594
|
const capStep = Math.max(1, Math.ceil(range / MAX_TICKS));
|
|
592
595
|
const visibleStep = groupSize > 0 ? gcd(step, groupSize) : step;
|
|
@@ -623,6 +626,7 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
623
626
|
if (!visible) return null;
|
|
624
627
|
const renderAsGroup = groupActive;
|
|
625
628
|
const renderAsMajor = !renderAsGroup && majorActive;
|
|
629
|
+
const renderAsHalf = !renderAsGroup && !renderAsMajor && halfTickOffset > 0 && Math.abs(offset % step - halfTickOffset) < 1e-9;
|
|
626
630
|
const showLabel = (renderAsGroup || renderAsMajor) && offset % labelStep === 0;
|
|
627
631
|
const currentShowLabelStep = typeof getShowLabelStep !== "function" ? false : getShowLabelStep == null ? void 0 : getShowLabelStep({
|
|
628
632
|
viewMin,
|
|
@@ -632,9 +636,9 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
632
636
|
length,
|
|
633
637
|
v
|
|
634
638
|
});
|
|
635
|
-
const tickH = renderAsGroup ? 7 : renderAsMajor ? 10 : 6;
|
|
636
|
-
const strokeW = renderAsGroup ? 4 : renderAsMajor ? 2 : 1;
|
|
637
|
-
const color = renderAsGroup || renderAsMajor ? "#374151" : "#4b5563";
|
|
639
|
+
const tickH = renderAsGroup ? 7 : renderAsMajor ? 10 : renderAsHalf ? 8 : 6;
|
|
640
|
+
const strokeW = renderAsGroup ? 4 : renderAsMajor ? 2 : renderAsHalf ? 2 : 1;
|
|
641
|
+
const color = renderAsGroup || renderAsMajor || renderAsHalf ? "#374151" : "#4b5563";
|
|
638
642
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
|
|
639
643
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
640
644
|
"line",
|
|
@@ -693,6 +697,7 @@ function AnimatedArc({
|
|
|
693
697
|
const strokeColor = isSelected ? "#1d4ed8" : color;
|
|
694
698
|
const arrowHeadH = 7;
|
|
695
699
|
const arrowHeadHW = 4;
|
|
700
|
+
const tipY = axisY - ARC_BASELINE_LIFT + 4;
|
|
696
701
|
React.useLayoutEffect(() => {
|
|
697
702
|
var _a;
|
|
698
703
|
const len = ((_a = measureRef.current) == null ? void 0 : _a.getTotalLength()) ?? 0;
|
|
@@ -803,11 +808,14 @@ function AnimatedArc({
|
|
|
803
808
|
x: x2,
|
|
804
809
|
y: textY,
|
|
805
810
|
textAnchor: edgeTextAnchor(),
|
|
806
|
-
fontSize:
|
|
811
|
+
fontSize: 16,
|
|
807
812
|
fill: strokeColor,
|
|
808
813
|
fontWeight: "600",
|
|
809
814
|
pointerEvents: "none",
|
|
810
|
-
style: {
|
|
815
|
+
style: {
|
|
816
|
+
userSelect: "none",
|
|
817
|
+
WebkitUserSelect: "none"
|
|
818
|
+
},
|
|
811
819
|
children: end
|
|
812
820
|
}
|
|
813
821
|
),
|
|
@@ -817,7 +825,7 @@ function AnimatedArc({
|
|
|
817
825
|
x1: x2,
|
|
818
826
|
y1: textY + 5,
|
|
819
827
|
x2,
|
|
820
|
-
y2:
|
|
828
|
+
y2: tipY - arrowHeadH,
|
|
821
829
|
stroke: strokeColor,
|
|
822
830
|
strokeWidth: 1.5,
|
|
823
831
|
pointerEvents: "none"
|
|
@@ -826,7 +834,7 @@ function AnimatedArc({
|
|
|
826
834
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
827
835
|
"polygon",
|
|
828
836
|
{
|
|
829
|
-
points: `${x2},${
|
|
837
|
+
points: `${x2},${tipY} ${x2 - arrowHeadHW},${tipY - arrowHeadH} ${x2 + arrowHeadHW},${tipY - arrowHeadH}`,
|
|
830
838
|
fill: strokeColor,
|
|
831
839
|
pointerEvents: "none"
|
|
832
840
|
}
|
|
@@ -869,7 +877,10 @@ const GroupArcsLayer = React.memo(function GroupArcsLayer2({
|
|
|
869
877
|
const ry = Math.min(rx * ARC_RY_RATIO, arcMaxHeight);
|
|
870
878
|
const color = arcColors[g % arcColors.length];
|
|
871
879
|
const MIN_ARROW_SPAN = 24;
|
|
872
|
-
const textY = Math.min(
|
|
880
|
+
const textY = Math.min(
|
|
881
|
+
axisY - ry - ARC_BASELINE_LIFT - 6,
|
|
882
|
+
axisY - MIN_ARROW_SPAN
|
|
883
|
+
);
|
|
873
884
|
const arcPath = buildArcPath({ x1, x2, y: axisY, rx, ry });
|
|
874
885
|
const isSelected = selectedArcIndices.has(g);
|
|
875
886
|
const hitCursor = tool === "eraser" ? "cell" : tool === "none" ? "pointer" : "default";
|
|
@@ -969,7 +980,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick
|
|
|
969
980
|
] });
|
|
970
981
|
}
|
|
971
982
|
const LABEL_SPACE_BELOW_AXIS = 42;
|
|
972
|
-
const LABEL_ABOVE_AXIS_SLOP =
|
|
983
|
+
const LABEL_ABOVE_AXIS_SLOP = 30;
|
|
973
984
|
const ARC_TOP_PADDING = 16;
|
|
974
985
|
const MIN_ARC_HEIGHT = 24;
|
|
975
986
|
function NumberLine({ className }) {
|
package/dist/index.js
CHANGED
|
@@ -490,8 +490,10 @@ function NumberLineProvider({
|
|
|
490
490
|
}
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
|
+
const ARC_BASELINE_LIFT = 12;
|
|
493
494
|
function buildArcPath({ x1, x2, y, rx, ry }) {
|
|
494
|
-
|
|
495
|
+
const base = y - ARC_BASELINE_LIFT;
|
|
496
|
+
return `M ${x1} ${base} A ${rx} ${ry} 0 0 1 ${x2} ${base}`;
|
|
495
497
|
}
|
|
496
498
|
function computeLabelStep(containerWidth, range) {
|
|
497
499
|
const maxLabels = Math.floor(containerWidth / 40);
|
|
@@ -585,6 +587,7 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
585
587
|
const rawLabelStep = computeLabelStep(containerWidth, range);
|
|
586
588
|
const labelStep = Math.max(step, Math.ceil(rawLabelStep / step) * step);
|
|
587
589
|
const minorStep = showMinorTicks ? computeMinorTickStep(step, containerWidth, range) : 0;
|
|
590
|
+
const halfTickOffset = minorStep > 0 && step === minorStep * 10 ? step / 2 : 0;
|
|
588
591
|
const MAX_TICKS = 500;
|
|
589
592
|
const capStep = Math.max(1, Math.ceil(range / MAX_TICKS));
|
|
590
593
|
const visibleStep = groupSize > 0 ? gcd(step, groupSize) : step;
|
|
@@ -621,6 +624,7 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
621
624
|
if (!visible) return null;
|
|
622
625
|
const renderAsGroup = groupActive;
|
|
623
626
|
const renderAsMajor = !renderAsGroup && majorActive;
|
|
627
|
+
const renderAsHalf = !renderAsGroup && !renderAsMajor && halfTickOffset > 0 && Math.abs(offset % step - halfTickOffset) < 1e-9;
|
|
624
628
|
const showLabel = (renderAsGroup || renderAsMajor) && offset % labelStep === 0;
|
|
625
629
|
const currentShowLabelStep = typeof getShowLabelStep !== "function" ? false : getShowLabelStep == null ? void 0 : getShowLabelStep({
|
|
626
630
|
viewMin,
|
|
@@ -630,9 +634,9 @@ const AxisLayer = React.memo(function AxisLayer2({
|
|
|
630
634
|
length,
|
|
631
635
|
v
|
|
632
636
|
});
|
|
633
|
-
const tickH = renderAsGroup ? 7 : renderAsMajor ? 10 : 6;
|
|
634
|
-
const strokeW = renderAsGroup ? 4 : renderAsMajor ? 2 : 1;
|
|
635
|
-
const color = renderAsGroup || renderAsMajor ? "#374151" : "#4b5563";
|
|
637
|
+
const tickH = renderAsGroup ? 7 : renderAsMajor ? 10 : renderAsHalf ? 8 : 6;
|
|
638
|
+
const strokeW = renderAsGroup ? 4 : renderAsMajor ? 2 : renderAsHalf ? 2 : 1;
|
|
639
|
+
const color = renderAsGroup || renderAsMajor || renderAsHalf ? "#374151" : "#4b5563";
|
|
636
640
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
637
641
|
/* @__PURE__ */ jsx(
|
|
638
642
|
"line",
|
|
@@ -691,6 +695,7 @@ function AnimatedArc({
|
|
|
691
695
|
const strokeColor = isSelected ? "#1d4ed8" : color;
|
|
692
696
|
const arrowHeadH = 7;
|
|
693
697
|
const arrowHeadHW = 4;
|
|
698
|
+
const tipY = axisY - ARC_BASELINE_LIFT + 4;
|
|
694
699
|
useLayoutEffect(() => {
|
|
695
700
|
var _a;
|
|
696
701
|
const len = ((_a = measureRef.current) == null ? void 0 : _a.getTotalLength()) ?? 0;
|
|
@@ -801,11 +806,14 @@ function AnimatedArc({
|
|
|
801
806
|
x: x2,
|
|
802
807
|
y: textY,
|
|
803
808
|
textAnchor: edgeTextAnchor(),
|
|
804
|
-
fontSize:
|
|
809
|
+
fontSize: 16,
|
|
805
810
|
fill: strokeColor,
|
|
806
811
|
fontWeight: "600",
|
|
807
812
|
pointerEvents: "none",
|
|
808
|
-
style: {
|
|
813
|
+
style: {
|
|
814
|
+
userSelect: "none",
|
|
815
|
+
WebkitUserSelect: "none"
|
|
816
|
+
},
|
|
809
817
|
children: end
|
|
810
818
|
}
|
|
811
819
|
),
|
|
@@ -815,7 +823,7 @@ function AnimatedArc({
|
|
|
815
823
|
x1: x2,
|
|
816
824
|
y1: textY + 5,
|
|
817
825
|
x2,
|
|
818
|
-
y2:
|
|
826
|
+
y2: tipY - arrowHeadH,
|
|
819
827
|
stroke: strokeColor,
|
|
820
828
|
strokeWidth: 1.5,
|
|
821
829
|
pointerEvents: "none"
|
|
@@ -824,7 +832,7 @@ function AnimatedArc({
|
|
|
824
832
|
/* @__PURE__ */ jsx(
|
|
825
833
|
"polygon",
|
|
826
834
|
{
|
|
827
|
-
points: `${x2},${
|
|
835
|
+
points: `${x2},${tipY} ${x2 - arrowHeadHW},${tipY - arrowHeadH} ${x2 + arrowHeadHW},${tipY - arrowHeadH}`,
|
|
828
836
|
fill: strokeColor,
|
|
829
837
|
pointerEvents: "none"
|
|
830
838
|
}
|
|
@@ -867,7 +875,10 @@ const GroupArcsLayer = memo(function GroupArcsLayer2({
|
|
|
867
875
|
const ry = Math.min(rx * ARC_RY_RATIO, arcMaxHeight);
|
|
868
876
|
const color = arcColors[g % arcColors.length];
|
|
869
877
|
const MIN_ARROW_SPAN = 24;
|
|
870
|
-
const textY = Math.min(
|
|
878
|
+
const textY = Math.min(
|
|
879
|
+
axisY - ry - ARC_BASELINE_LIFT - 6,
|
|
880
|
+
axisY - MIN_ARROW_SPAN
|
|
881
|
+
);
|
|
871
882
|
const arcPath = buildArcPath({ x1, x2, y: axisY, rx, ry });
|
|
872
883
|
const isSelected = selectedArcIndices.has(g);
|
|
873
884
|
const hitCursor = tool === "eraser" ? "cell" : tool === "none" ? "pointer" : "default";
|
|
@@ -967,7 +978,7 @@ function DrawingLayer({ strokes, liveStroke, tool, width, height, onStrokeClick
|
|
|
967
978
|
] });
|
|
968
979
|
}
|
|
969
980
|
const LABEL_SPACE_BELOW_AXIS = 42;
|
|
970
|
-
const LABEL_ABOVE_AXIS_SLOP =
|
|
981
|
+
const LABEL_ABOVE_AXIS_SLOP = 30;
|
|
971
982
|
const ARC_TOP_PADDING = 16;
|
|
972
983
|
const MIN_ARC_HEIGHT = 24;
|
|
973
984
|
function NumberLine({ className }) {
|