freewind-ts-utils 0.18.2
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 +60 -0
- package/antd/CopyButton/CopyButton.d.ts +7 -0
- package/antd/CopyButton/CopyButton.js +29 -0
- package/antd/CopyButton/index.d.ts +1 -0
- package/antd/CopyButton/index.js +2 -0
- package/antd/FloatLabel/FloatLabel.css +18 -0
- package/antd/FloatLabel/FloatLabel.d.ts +8 -0
- package/antd/FloatLabel/FloatLabel.js +50 -0
- package/antd/FloatLabel/index.d.ts +1 -0
- package/antd/FloatLabel/index.js +2 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.d.ts +17 -0
- package/antd/FuzzyAutoComplete/FuzzyAutoComplete.js +73 -0
- package/antd/FuzzyAutoComplete/index.d.ts +1 -0
- package/antd/FuzzyAutoComplete/index.js +2 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.d.ts +8 -0
- package/antd/FuzzyPathSelect/FuzzyPathSelect.js +48 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.d.ts +1 -0
- package/antd/FuzzyPathSelect/defaultIgnoreNames.js +28 -0
- package/antd/FuzzyPathSelect/index.d.ts +1 -0
- package/antd/FuzzyPathSelect/index.js +2 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.d.ts +6 -0
- package/antd/FuzzyStringSelect/FuzzyStringSelect.js +12 -0
- package/antd/FuzzyStringSelect/index.d.ts +1 -0
- package/antd/FuzzyStringSelect/index.js +2 -0
- package/antd/HoverSwap/HoverSwap.css +3 -0
- package/antd/HoverSwap/HoverSwap.d.ts +8 -0
- package/antd/HoverSwap/HoverSwap.js +18 -0
- package/antd/HoverSwap/index.d.ts +1 -0
- package/antd/HoverSwap/index.js +2 -0
- package/antd/InputLabel/InputLabel.css +10 -0
- package/antd/InputLabel/InputLabel.d.ts +4 -0
- package/antd/InputLabel/InputLabel.js +11 -0
- package/antd/InputLabel/index.d.ts +1 -0
- package/antd/InputLabel/index.js +2 -0
- package/antd/JsonPreviewer/JsonPreviewer.css +74 -0
- package/antd/JsonPreviewer/JsonPreviewer.d.ts +11 -0
- package/antd/JsonPreviewer/JsonPreviewer.js +69 -0
- package/antd/JsonPreviewer/index.d.ts +1 -0
- package/antd/JsonPreviewer/index.js +2 -0
- package/antd/_internal/HighlightParts.d.ts +6 -0
- package/antd/_internal/HighlightParts.js +12 -0
- package/antd/index.d.ts +8 -0
- package/antd/index.js +17 -0
- package/common/SimpleType.d.ts +2 -0
- package/common/SimpleType.js +0 -0
- package/common/_internal/createObjectReferenceTracker.d.ts +5 -0
- package/common/_internal/createObjectReferenceTracker.js +11 -0
- package/common/anyToString/anyToString.d.ts +27 -0
- package/common/anyToString/anyToString.js +23 -0
- package/common/anyToString/createCircularStackTracker.d.ts +5 -0
- package/common/anyToString/createCircularStackTracker.js +14 -0
- package/common/anyToString/formatters/formatArray.d.ts +2 -0
- package/common/anyToString/formatters/formatArray.js +11 -0
- package/common/anyToString/formatters/formatArrayBufferView.d.ts +2 -0
- package/common/anyToString/formatters/formatArrayBufferView.js +14 -0
- package/common/anyToString/formatters/formatDocumentObject.d.ts +1 -0
- package/common/anyToString/formatters/formatDocumentObject.js +7 -0
- package/common/anyToString/formatters/formatElementObject.d.ts +1 -0
- package/common/anyToString/formatters/formatElementObject.js +15 -0
- package/common/anyToString/formatters/formatError.d.ts +1 -0
- package/common/anyToString/formatters/formatError.js +7 -0
- package/common/anyToString/formatters/formatFunction.d.ts +1 -0
- package/common/anyToString/formatters/formatFunction.js +6 -0
- package/common/anyToString/formatters/formatMap.d.ts +2 -0
- package/common/anyToString/formatters/formatMap.js +17 -0
- package/common/anyToString/formatters/formatObject.d.ts +2 -0
- package/common/anyToString/formatters/formatObject.js +44 -0
- package/common/anyToString/formatters/formatObjectKey.d.ts +1 -0
- package/common/anyToString/formatters/formatObjectKey.js +8 -0
- package/common/anyToString/formatters/formatRecordLike.d.ts +2 -0
- package/common/anyToString/formatters/formatRecordLike.js +39 -0
- package/common/anyToString/formatters/formatSet.d.ts +2 -0
- package/common/anyToString/formatters/formatSet.js +17 -0
- package/common/anyToString/formatters/formatString.d.ts +1 -0
- package/common/anyToString/formatters/formatString.js +8 -0
- package/common/anyToString/formatters/formatValue.d.ts +11 -0
- package/common/anyToString/formatters/formatValue.js +20 -0
- package/common/anyToString/formatters/formatWindowObject.d.ts +1 -0
- package/common/anyToString/formatters/formatWindowObject.js +6 -0
- package/common/anyToString/formatters/getConstructorName.d.ts +1 -0
- package/common/anyToString/formatters/getConstructorName.js +7 -0
- package/common/anyToString/formatters/joinBlock.d.ts +1 -0
- package/common/anyToString/formatters/joinBlock.js +9 -0
- package/common/anyToString/formatters/withCircularGuard.d.ts +2 -0
- package/common/anyToString/formatters/withCircularGuard.js +11 -0
- package/common/anyToString/index.d.ts +1 -0
- package/common/anyToString/index.js +2 -0
- package/common/assertsType.d.ts +12 -0
- package/common/assertsType.js +4 -0
- package/common/buildSequence.d.ts +6 -0
- package/common/buildSequence.js +8 -0
- package/common/deepClone.d.ts +12 -0
- package/common/deepClone.js +55 -0
- package/common/deepEqual.d.ts +12 -0
- package/common/deepEqual.js +46 -0
- package/common/deepParseJsonStrings.d.ts +1 -0
- package/common/deepParseJsonStrings.js +22 -0
- package/common/dependsOn.d.ts +12 -0
- package/common/dependsOn.js +4 -0
- package/common/doExpr.d.ts +14 -0
- package/common/doExpr.js +6 -0
- package/common/flatChildren.d.ts +1 -0
- package/common/flatChildren.js +14 -0
- package/common/formatDecimal.d.ts +12 -0
- package/common/formatDecimal.js +11 -0
- package/common/formatFriendlyTime.d.ts +1 -0
- package/common/formatFriendlyTime.js +10 -0
- package/common/formatSize.d.ts +13 -0
- package/common/formatSize.js +19 -0
- package/common/fuzzy/fuzzyMatch.d.ts +25 -0
- package/common/fuzzy/fuzzyMatch.js +19 -0
- package/common/fuzzy/fuzzyMatchPath.d.ts +23 -0
- package/common/fuzzy/fuzzyMatchPath.js +102 -0
- package/common/fuzzy/types.d.ts +10 -0
- package/common/fuzzy/types.js +0 -0
- package/common/fuzzy/utils/buildHighlightParts.d.ts +4 -0
- package/common/fuzzy/utils/buildHighlightParts.js +21 -0
- package/common/fuzzy/utils/buildHighlightRanges.d.ts +1 -0
- package/common/fuzzy/utils/buildHighlightRanges.js +20 -0
- package/common/fuzzy/utils/index.d.ts +5 -0
- package/common/fuzzy/utils/index.js +6 -0
- package/common/fuzzy/utils/normalizePathSeparators.d.ts +1 -0
- package/common/fuzzy/utils/normalizePathSeparators.js +7 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.d.ts +2 -0
- package/common/fuzzy/utils/rankFuzzyCandidates.js +26 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.d.ts +2 -0
- package/common/fuzzy/utils/scoreLooseFuzzyMatch.js +126 -0
- package/common/getEnumerableOwnDescriptors.d.ts +1 -0
- package/common/getEnumerableOwnDescriptors.js +11 -0
- package/common/index.d.ts +49 -0
- package/common/index.js +48 -0
- package/common/isEmptyRecord.d.ts +10 -0
- package/common/isEmptyRecord.js +7 -0
- package/common/isNil.d.ts +13 -0
- package/common/isNil.js +6 -0
- package/common/isNonNil.d.ts +11 -0
- package/common/isNonNil.js +6 -0
- package/common/isRecord.d.ts +12 -0
- package/common/isRecord.js +8 -0
- package/common/jsonRecord/filterJsonRecord.d.ts +16 -0
- package/common/jsonRecord/filterJsonRecord.js +19 -0
- package/common/jsonRecord/isJsonRecord.d.ts +16 -0
- package/common/jsonRecord/isJsonRecord.js +16 -0
- package/common/jsonRecord/jsonRecordDiff.d.ts +13 -0
- package/common/jsonRecord/jsonRecordDiff.js +26 -0
- package/common/jsonRecord/mapJsonRecord.d.ts +13 -0
- package/common/jsonRecord/mapJsonRecord.js +14 -0
- package/common/jsonRecord/modifyJsonRecord.d.ts +14 -0
- package/common/jsonRecord/modifyJsonRecord.js +24 -0
- package/common/jsonRecord/walkJsonRecord.d.ts +15 -0
- package/common/jsonRecord/walkJsonRecord.js +16 -0
- package/common/onlyUnique.d.ts +10 -0
- package/common/onlyUnique.js +6 -0
- package/common/pipe.d.ts +9 -0
- package/common/pipe.js +6 -0
- package/common/pipeNonNil.d.ts +16 -0
- package/common/pipeNonNil.js +7 -0
- package/common/safeJsonStringify.d.ts +28 -0
- package/common/safeJsonStringify.js +105 -0
- package/common/simpleInt/isSimpleInt.d.ts +6 -0
- package/common/simpleInt/isSimpleInt.js +6 -0
- package/common/simpleInt/isSimpleIntInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleIntInputing.js +7 -0
- package/common/simpleInt/isSimpleNumber.d.ts +10 -0
- package/common/simpleInt/isSimpleNumber.js +6 -0
- package/common/simpleInt/isSimpleNumberInputing.d.ts +6 -0
- package/common/simpleInt/isSimpleNumberInputing.js +7 -0
- package/common/simpleInt/parseSimpleInt.d.ts +6 -0
- package/common/simpleInt/parseSimpleInt.js +11 -0
- package/common/simpleInt/parseSimpleIntOrNil.d.ts +6 -0
- package/common/simpleInt/parseSimpleIntOrNil.js +9 -0
- package/common/simpleInt/parseSimpleNumber.d.ts +6 -0
- package/common/simpleInt/parseSimpleNumber.js +11 -0
- package/common/simpleInt/parseSimpleNumberOrNil.d.ts +4 -0
- package/common/simpleInt/parseSimpleNumberOrNil.js +7 -0
- package/common/tap.d.ts +9 -0
- package/common/tap.js +6 -0
- package/common/tree/buildTree.d.ts +6 -0
- package/common/tree/buildTree.js +13 -0
- package/common/tree/flatTree.d.ts +2 -0
- package/common/tree/flatTree.js +7 -0
- package/common/tree/mapTree.d.ts +2 -0
- package/common/tree/mapTree.js +11 -0
- package/common/tree/pruneTree.d.ts +2 -0
- package/common/tree/pruneTree.js +15 -0
- package/common/tree/sortTree.d.ts +2 -0
- package/common/tree/sortTree.js +11 -0
- package/common/tree/treeToArray.d.ts +2 -0
- package/common/tree/treeToArray.js +12 -0
- package/common/tree/treeToRows.d.ts +5 -0
- package/common/tree/treeToRows.js +19 -0
- package/common/tree/treeTypes.d.ts +7 -0
- package/common/tree/treeTypes.js +0 -0
- package/common/tree/walkTree.d.ts +2 -0
- package/common/tree/walkTree.js +13 -0
- package/common/truncateJsonStrings.d.ts +14 -0
- package/common/truncateJsonStrings.js +7 -0
- package/common/truncateString.d.ts +13 -0
- package/common/truncateString.js +7 -0
- package/common/tryParsePartialJson.d.ts +11 -0
- package/common/tryParsePartialJson.js +156 -0
- package/eslint-config/eslintPreset.d.ts +2 -0
- package/eslint-config/eslintPreset.js +36 -0
- package/eslint-config/index.d.ts +14 -0
- package/eslint-config/index.js +20 -0
- package/eslint-config/layers/configLayer.d.ts +2 -0
- package/eslint-config/layers/configLayer.js +16 -0
- package/eslint-config/layers/jsLayer.d.ts +2 -0
- package/eslint-config/layers/jsLayer.js +20 -0
- package/eslint-config/layers/prettierLayer.d.ts +5 -0
- package/eslint-config/layers/prettierLayer.js +5 -0
- package/eslint-config/layers/reactHookLayer.d.ts +2 -0
- package/eslint-config/layers/reactHookLayer.js +16 -0
- package/eslint-config/layers/testLayer.d.ts +2 -0
- package/eslint-config/layers/testLayer.js +46 -0
- package/eslint-config/layers/tsLayer.d.ts +2 -0
- package/eslint-config/layers/tsLayer.js +70 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.d.ts +2 -0
- package/eslint-config/plugins/freewindSingleExportPlugin.js +47 -0
- package/eslint-config/utils/withRuleOverrides.d.ts +2 -0
- package/eslint-config/utils/withRuleOverrides.js +9 -0
- package/index.d.ts +1 -0
- package/index.js +49 -0
- package/node/index.d.ts +2 -0
- package/node/index.js +3 -0
- package/node/md5.d.ts +11 -0
- package/node/md5.js +7 -0
- package/node/uuid.d.ts +11 -0
- package/node/uuid.js +7 -0
- package/package.json +115 -0
- package/prettier-config/freewindPrettierPreset.d.ts +2 -0
- package/prettier-config/freewindPrettierPreset.js +4 -0
- package/prettier-config/index.d.ts +1 -0
- package/prettier-config/index.js +2 -0
- package/react/hooks/useCopyToClipboard.d.ts +10 -0
- package/react/hooks/useCopyToClipboard.js +28 -0
- package/react/hooks/useDeepCompareSelector.d.ts +23 -0
- package/react/hooks/useDeepCompareSelector.js +14 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.d.ts +2 -0
- package/react/hooks/useInputEvent/_internal/ink-input/index.js +3 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.d.ts +6 -0
- package/react/hooks/useInputEvent/_internal/ink-input/input-parser.js +98 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.d.ts +19 -0
- package/react/hooks/useInputEvent/_internal/ink-input/kitty-keyboard.js +13 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.d.ts +33 -0
- package/react/hooks/useInputEvent/_internal/ink-input/parse-keypress.js +319 -0
- package/react/hooks/useInputEvent/formatInputEvent.d.ts +2 -0
- package/react/hooks/useInputEvent/formatInputEvent.js +25 -0
- package/react/hooks/useInputEvent/index.d.ts +4 -0
- package/react/hooks/useInputEvent/index.js +4 -0
- package/react/hooks/useInputEvent/inputEventTypes.d.ts +51 -0
- package/react/hooks/useInputEvent/inputEventTypes.js +0 -0
- package/react/hooks/useInputEvent/parseInputEvent.d.ts +4 -0
- package/react/hooks/useInputEvent/parseInputEvent.js +100 -0
- package/react/hooks/useInputEvent/useInputEvent.d.ts +7 -0
- package/react/hooks/useInputEvent/useInputEvent.js +57 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.d.ts +2 -0
- package/react/hooks/useOverlayStack/_internal/overlayStackId.js +6 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.d.ts +2 -0
- package/react/hooks/useOverlayStack/createOverlayStackItem.js +10 -0
- package/react/hooks/useOverlayStack/index.d.ts +3 -0
- package/react/hooks/useOverlayStack/index.js +3 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.d.ts +13 -0
- package/react/hooks/useOverlayStack/overlayStackTypes.js +0 -0
- package/react/hooks/useOverlayStack/useOverlayStack.d.ts +2 -0
- package/react/hooks/useOverlayStack/useOverlayStack.js +24 -0
- package/react/index.d.ts +4 -0
- package/react/index.js +10 -0
- package/react/ink-components/InkModal/InkModal.d.ts +3 -0
- package/react/ink-components/InkModal/InkModal.js +101 -0
- package/react/ink-components/InkModal/index.d.ts +4 -0
- package/react/ink-components/InkModal/index.js +4 -0
- package/react/ink-components/InkModal/types.d.ts +24 -0
- package/react/ink-components/InkModal/types.js +0 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.d.ts +1 -0
- package/react/ink-components/InkModal/utils/computeInkModalBodyMaxHeight.js +4 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.d.ts +6 -0
- package/react/ink-components/InkModal/utils/resolveInkModalSize.js +7 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.d.ts +22 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelect.js +94 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/InkMultiSelectRow.js +35 -0
- package/react/ink-components/InkMultiSelect/index.d.ts +8 -0
- package/react/ink-components/InkMultiSelect/index.js +9 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.d.ts +17 -0
- package/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.js +19 -0
- package/react/ink-components/InkMultiSelect/types.d.ts +20 -0
- package/react/ink-components/InkMultiSelect/types.js +18 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.d.ts +10 -0
- package/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.js +40 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/clampListScrollOffset.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.d.ts +1 -0
- package/react/ink-components/InkMultiSelect/utils/formatMoreLabel.js +6 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.d.ts +2 -0
- package/react/ink-components/InkMultiSelect/utils/inkMultiSelectVisibleCount.js +7 -0
- package/react/ink-components/InkScrollView/InkScrollView.d.ts +19 -0
- package/react/ink-components/InkScrollView/InkScrollView.js +103 -0
- package/react/ink-components/InkScrollView/Scrollbar.d.ts +7 -0
- package/react/ink-components/InkScrollView/Scrollbar.js +16 -0
- package/react/ink-components/InkScrollView/index.d.ts +9 -0
- package/react/ink-components/InkScrollView/index.js +18 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/applyInkScrollInput.js +57 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.d.ts +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.js +19 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.d.ts +3 -0
- package/react/ink-components/InkScrollView/utils/bounds/index.js +4 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/isInside.js +7 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/bounds/rowInViewport.js +4 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.d.ts +11 -0
- package/react/ink-components/InkScrollView/utils/inkScrollInputTarget.js +0 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.d.ts +6 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.js +29 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/clampOffset.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.d.ts +5 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.js +14 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/index.js +11 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.js +12 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.d.ts +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.js +10 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.js +15 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.d.ts +9 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.js +7 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.d.ts +2 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.js +8 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.d.ts +1 -0
- package/react/ink-components/InkScrollView/utils/scrollMath/stickToBottomOffset.js +4 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.d.ts +10 -0
- package/react/ink-components/InkScrollView/utils/useInkScrollInput.js +17 -0
- package/react/ink-components/InkTimer/InkTimer.d.ts +9 -0
- package/react/ink-components/InkTimer/InkTimer.js +26 -0
- package/react/ink-components/InkTimer/index.d.ts +1 -0
- package/react/ink-components/InkTimer/index.js +2 -0
- package/react/ink-components/index.d.ts +4 -0
- package/react/ink-components/index.js +34 -0
- package/vite-plugins/fileLinePlaceholderPlugin.d.ts +26 -0
- package/vite-plugins/fileLinePlaceholderPlugin.js +57 -0
- package/vite-plugins/index.d.ts +1 -0
- package/vite-plugins/index.js +2 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { clampOffset as e } from "./utils/scrollMath/clampOffset.js";
|
|
2
|
+
import { resolveNextStickToBottomOffset as t } from "./utils/scrollMath/resolveNextStickToBottomOffset.js";
|
|
3
|
+
import { Scrollbar as n } from "./Scrollbar.js";
|
|
4
|
+
import { useInkScrollInput as r } from "./utils/useInkScrollInput.js";
|
|
5
|
+
import { Children as i, useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
|
+
import { Box as f, Text as p } from "ink";
|
|
8
|
+
//#region src/react/ink-components/InkScrollView/InkScrollView.tsx
|
|
9
|
+
var m = ({ maxHeight: m, children: h, scrollOffset: g, defaultScrollOffset: _ = 0, onScrollOffsetChange: v, stickToBottom: y = !1, enableInput: b = !1, focused: x = !1, showScrollbar: S = !1, title: C, viewportRef: w, scrollbarRef: T }) => {
|
|
10
|
+
let E = g !== void 0, [D, O] = l(_), k = c(null), A = c(null), j = w ?? k, M = T ?? A, N = s(() => i.toArray(h), [h]), P = N.length, F = m, I = c(P), L = c(F), R = F + 2, z = E ? g : D, B = a((t) => {
|
|
11
|
+
let n = e(t, P, F);
|
|
12
|
+
E || O(n), v?.(n);
|
|
13
|
+
}, [
|
|
14
|
+
F,
|
|
15
|
+
E,
|
|
16
|
+
P,
|
|
17
|
+
v
|
|
18
|
+
]), V = e(z, P, F), H = N.slice(V, V + F);
|
|
19
|
+
o(() => {
|
|
20
|
+
V !== z && B(z);
|
|
21
|
+
}, [
|
|
22
|
+
V,
|
|
23
|
+
z,
|
|
24
|
+
B
|
|
25
|
+
]), o(() => {
|
|
26
|
+
if (y === !1) return;
|
|
27
|
+
let e = I.current, n = L.current;
|
|
28
|
+
if (I.current = P, L.current = F, P === e && F === n) return;
|
|
29
|
+
let r = t({
|
|
30
|
+
mode: y,
|
|
31
|
+
offset: z,
|
|
32
|
+
prevLineCount: e,
|
|
33
|
+
lineCount: P,
|
|
34
|
+
viewportHeight: F
|
|
35
|
+
});
|
|
36
|
+
r !== void 0 && B(r);
|
|
37
|
+
}, [
|
|
38
|
+
F,
|
|
39
|
+
P,
|
|
40
|
+
z,
|
|
41
|
+
B,
|
|
42
|
+
y
|
|
43
|
+
]);
|
|
44
|
+
let U = s(() => !b || !x ? null : {
|
|
45
|
+
lineCount: P,
|
|
46
|
+
viewportHeight: F,
|
|
47
|
+
offset: V,
|
|
48
|
+
onOffsetChange: B,
|
|
49
|
+
viewportRef: j,
|
|
50
|
+
...S ? { scrollbarRef: M } : {}
|
|
51
|
+
}, [
|
|
52
|
+
V,
|
|
53
|
+
F,
|
|
54
|
+
b,
|
|
55
|
+
x,
|
|
56
|
+
P,
|
|
57
|
+
M,
|
|
58
|
+
j,
|
|
59
|
+
B,
|
|
60
|
+
S
|
|
61
|
+
]);
|
|
62
|
+
return r({
|
|
63
|
+
enabled: b && x,
|
|
64
|
+
keyboardTarget: U,
|
|
65
|
+
mouseTargets: U ? [U] : []
|
|
66
|
+
}), /* @__PURE__ */ d(f, {
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
flexGrow: 1,
|
|
69
|
+
minHeight: R,
|
|
70
|
+
children: [C ? /* @__PURE__ */ d(p, {
|
|
71
|
+
bold: !0,
|
|
72
|
+
...x ? { color: "cyan" } : {},
|
|
73
|
+
children: [C, x ? " ◀" : ""]
|
|
74
|
+
}) : null, /* @__PURE__ */ d(f, {
|
|
75
|
+
flexDirection: "row",
|
|
76
|
+
height: R,
|
|
77
|
+
borderStyle: "single",
|
|
78
|
+
borderColor: x ? "cyan" : "gray",
|
|
79
|
+
children: [/* @__PURE__ */ u(f, {
|
|
80
|
+
ref: j,
|
|
81
|
+
flexDirection: "column",
|
|
82
|
+
height: F,
|
|
83
|
+
overflow: "hidden",
|
|
84
|
+
flexGrow: 1,
|
|
85
|
+
paddingX: 1,
|
|
86
|
+
children: H.length === 0 ? /* @__PURE__ */ u(p, {
|
|
87
|
+
dimColor: !0,
|
|
88
|
+
children: "(empty)"
|
|
89
|
+
}) : H.map((e, t) => /* @__PURE__ */ u(f, { children: e }, `line-${V + t}`))
|
|
90
|
+
}), S ? /* @__PURE__ */ u(f, {
|
|
91
|
+
ref: M,
|
|
92
|
+
paddingRight: 1,
|
|
93
|
+
children: /* @__PURE__ */ u(n, {
|
|
94
|
+
viewportHeight: F,
|
|
95
|
+
lineCount: P,
|
|
96
|
+
offset: V
|
|
97
|
+
})
|
|
98
|
+
}) : null]
|
|
99
|
+
})]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
export { m as InkScrollView };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computeScrollbarThumb as e } from "./utils/scrollMath/computeScrollbarThumb.js";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import { Box as n, Text as r } from "ink";
|
|
4
|
+
//#region src/react/ink-components/InkScrollView/Scrollbar.tsx
|
|
5
|
+
var i = ({ viewportHeight: i, lineCount: a, offset: o }) => {
|
|
6
|
+
let { thumbStart: s, thumbSize: c } = e(a, i, o), l = a > i;
|
|
7
|
+
return /* @__PURE__ */ t(n, {
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
children: Array.from({ length: i }, (e, t) => l && t >= s && t < s + c ? "▓" : "░").map((e, n) => /* @__PURE__ */ t(r, {
|
|
10
|
+
dimColor: !0,
|
|
11
|
+
children: e
|
|
12
|
+
}, `scrollbar-${n}`))
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as Scrollbar };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { InkScrollView } from './InkScrollView.js';
|
|
2
|
+
export type { InkScrollViewProps } from './InkScrollView.js';
|
|
3
|
+
export { Scrollbar } from './Scrollbar.js';
|
|
4
|
+
export type { ScrollbarProps } from './Scrollbar.js';
|
|
5
|
+
export { useInkScrollInput } from './utils/useInkScrollInput.js';
|
|
6
|
+
export { applyInkScrollInput } from './utils/applyInkScrollInput.js';
|
|
7
|
+
export type { InkScrollInputTarget } from './utils/inkScrollInputTarget.js';
|
|
8
|
+
export * from './utils/scrollMath/index.js';
|
|
9
|
+
export * from './utils/bounds/index.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { allocateHeights as e } from "./utils/scrollMath/allocateHeights.js";
|
|
2
|
+
import { clampOffset as t } from "./utils/scrollMath/clampOffset.js";
|
|
3
|
+
import { computeScrollbarThumb as n } from "./utils/scrollMath/computeScrollbarThumb.js";
|
|
4
|
+
import { offsetFromScrollbarClick as r } from "./utils/scrollMath/offsetFromScrollbarClick.js";
|
|
5
|
+
import { offsetFromScrollbarDrag as i } from "./utils/scrollMath/offsetFromScrollbarDrag.js";
|
|
6
|
+
import { scrollByKey as a } from "./utils/scrollMath/scrollByKey.js";
|
|
7
|
+
import { scrollByInputEventKey as o } from "./utils/scrollMath/scrollByInputEventKey.js";
|
|
8
|
+
import { scrollByWheel as s } from "./utils/scrollMath/scrollByWheel.js";
|
|
9
|
+
import { stickToBottomOffset as c } from "./utils/scrollMath/stickToBottomOffset.js";
|
|
10
|
+
import { resolveNextStickToBottomOffset as l } from "./utils/scrollMath/resolveNextStickToBottomOffset.js";
|
|
11
|
+
import { Scrollbar as u } from "./Scrollbar.js";
|
|
12
|
+
import { getAbsoluteBounds as d } from "./utils/bounds/getAbsoluteBounds.js";
|
|
13
|
+
import { isInside as f } from "./utils/bounds/isInside.js";
|
|
14
|
+
import { rowInViewport as p } from "./utils/bounds/rowInViewport.js";
|
|
15
|
+
import { applyInkScrollInput as m } from "./utils/applyInkScrollInput.js";
|
|
16
|
+
import { useInkScrollInput as h } from "./utils/useInkScrollInput.js";
|
|
17
|
+
import { InkScrollView as g } from "./InkScrollView.js";
|
|
18
|
+
export { g as InkScrollView, u as Scrollbar, e as allocateHeights, m as applyInkScrollInput, t as clampOffset, n as computeScrollbarThumb, d as getAbsoluteBounds, f as isInside, r as offsetFromScrollbarClick, i as offsetFromScrollbarDrag, l as resolveNextStickToBottomOffset, p as rowInViewport, o as scrollByInputEventKey, a as scrollByKey, s as scrollByWheel, c as stickToBottomOffset, h as useInkScrollInput };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { InputEvent } from '../../../hooks/useInputEvent/inputEventTypes.js';
|
|
3
|
+
import { InkScrollInputTarget } from './inkScrollInputTarget.js';
|
|
4
|
+
type ApplyInkScrollInputOptions = {
|
|
5
|
+
keyboardTarget: InkScrollInputTarget | null;
|
|
6
|
+
mouseTargets: InkScrollInputTarget[];
|
|
7
|
+
draggingTargetIdRef: RefObject<string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
export declare const applyInkScrollInput: (event: InputEvent, options: ApplyInkScrollInputOptions) => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { offsetFromScrollbarClick as e } from "./scrollMath/offsetFromScrollbarClick.js";
|
|
2
|
+
import { offsetFromScrollbarDrag as t } from "./scrollMath/offsetFromScrollbarDrag.js";
|
|
3
|
+
import { scrollByInputEventKey as n } from "./scrollMath/scrollByInputEventKey.js";
|
|
4
|
+
import { scrollByWheel as r } from "./scrollMath/scrollByWheel.js";
|
|
5
|
+
import { getAbsoluteBounds as i } from "./bounds/getAbsoluteBounds.js";
|
|
6
|
+
import { isInside as a } from "./bounds/isInside.js";
|
|
7
|
+
import { rowInViewport as o } from "./bounds/rowInViewport.js";
|
|
8
|
+
//#region src/react/ink-components/InkScrollView/utils/applyInkScrollInput.ts
|
|
9
|
+
var s = (e, t, n) => {
|
|
10
|
+
for (let r of n) {
|
|
11
|
+
let n = i(r.viewportRef.current);
|
|
12
|
+
if (n && a(e, t, n)) return r;
|
|
13
|
+
}
|
|
14
|
+
}, c = (e, t, n) => {
|
|
15
|
+
for (let r of n) {
|
|
16
|
+
let n = i(r.scrollbarRef?.current);
|
|
17
|
+
if (n && a(e, t, n)) return r;
|
|
18
|
+
}
|
|
19
|
+
}, l = (a, l) => {
|
|
20
|
+
let { keyboardTarget: u, mouseTargets: d, draggingTargetIdRef: f } = l;
|
|
21
|
+
if (a.type === "key" && u) {
|
|
22
|
+
let e = n(u.offset, u.lineCount, u.viewportHeight, a.name);
|
|
23
|
+
e !== u.offset && u.onOffsetChange(e);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (a.type === "mouse") {
|
|
27
|
+
if (a.button === "wheel-up") {
|
|
28
|
+
let e = s(a.column, a.row, d);
|
|
29
|
+
e && e.onOffsetChange(r(e.offset, e.lineCount, e.viewportHeight, "up"));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (a.button === "wheel-down") {
|
|
33
|
+
let e = s(a.column, a.row, d);
|
|
34
|
+
e && e.onOffsetChange(r(e.offset, e.lineCount, e.viewportHeight, "down"));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (a.button === "left" && a.action === "press") {
|
|
38
|
+
let t = c(a.column, a.row, d), n = t ? i(t.scrollbarRef?.current) : void 0;
|
|
39
|
+
if (t && n) {
|
|
40
|
+
let r = o(a.row, n);
|
|
41
|
+
t.onOffsetChange(e(t.lineCount, t.viewportHeight, r)), f.current = t.id;
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (a.button === "left" && a.action === "move" && f.current) {
|
|
46
|
+
let e = d.find((e) => e.id === f.current), n = e ? i(e.scrollbarRef?.current) : void 0;
|
|
47
|
+
if (e && n) {
|
|
48
|
+
let r = o(a.row, n);
|
|
49
|
+
e.onOffsetChange(t(e.lineCount, e.viewportHeight, r));
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
a.button === "left" && a.action === "release" && (f.current = void 0);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { l as applyInkScrollInput };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/bounds/getAbsoluteBounds.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
if (!e) return;
|
|
4
|
+
let t = e.yogaNode?.getComputedLayout();
|
|
5
|
+
if (!t) return;
|
|
6
|
+
let n = t.left, r = t.top, i = e.parentNode;
|
|
7
|
+
for (; i && i.nodeName !== "ink-root";) {
|
|
8
|
+
let e = i.yogaNode?.getComputedLayout();
|
|
9
|
+
e && (n += e.left, r += e.top), i = i.parentNode;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
left: n,
|
|
13
|
+
top: r,
|
|
14
|
+
width: t.width,
|
|
15
|
+
height: t.height
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { e as getAbsoluteBounds };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/bounds/isInside.ts
|
|
2
|
+
var e = (e, t, n) => {
|
|
3
|
+
let r = n.left + 1, i = n.left + n.width, a = n.top + 1, o = n.top + n.height;
|
|
4
|
+
return e >= r && e <= i && t >= a && t <= o;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as isInside };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DOMElement } from 'ink';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
export type InkScrollInputTarget = {
|
|
4
|
+
id?: string;
|
|
5
|
+
lineCount: number;
|
|
6
|
+
viewportHeight: number;
|
|
7
|
+
offset: number;
|
|
8
|
+
onOffsetChange: (offset: number) => void;
|
|
9
|
+
viewportRef: RefObject<DOMElement | null>;
|
|
10
|
+
scrollbarRef?: RefObject<DOMElement | null>;
|
|
11
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/allocateHeights.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
let n = t.reduce((e, t) => e + t.weight, 0), r = t.map((t) => {
|
|
4
|
+
let r = Math.floor(e * t.weight / n), i = t.minHeight ?? 1, a = t.maxHeight ?? e;
|
|
5
|
+
return Math.min(a, Math.max(i, r));
|
|
6
|
+
}), i = r.reduce((e, t) => e + t, 0);
|
|
7
|
+
for (; i > e;) {
|
|
8
|
+
let e = 0;
|
|
9
|
+
for (let t = 1; t < r.length; t += 1) (r[t] ?? 0) > (r[e] ?? 0) && (e = t);
|
|
10
|
+
let n = t[e]?.minHeight ?? 1, a = r[e] ?? 0;
|
|
11
|
+
if (a <= n) break;
|
|
12
|
+
r[e] = a - 1, --i;
|
|
13
|
+
}
|
|
14
|
+
for (; i < e;) {
|
|
15
|
+
let n = -1;
|
|
16
|
+
for (let i = 0; i < r.length; i += 1) {
|
|
17
|
+
let a = t[i]?.maxHeight ?? e;
|
|
18
|
+
if ((r[i] ?? 0) < a) {
|
|
19
|
+
n = i;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (n === -1) break;
|
|
24
|
+
r[n] = (r[n] ?? 0) + 1, i += 1;
|
|
25
|
+
}
|
|
26
|
+
return r;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { e as allocateHeights };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clampOffset: (offset: number, lineCount: number, viewportHeight: number) => number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/computeScrollbarThumb.ts
|
|
2
|
+
var e = (e, t, n) => {
|
|
3
|
+
if (e <= t) return {
|
|
4
|
+
thumbStart: 0,
|
|
5
|
+
thumbSize: t
|
|
6
|
+
};
|
|
7
|
+
let r = e - t, i = Math.max(1, Math.round(t * t / e)), a = Math.max(0, t - i);
|
|
8
|
+
return {
|
|
9
|
+
thumbStart: r === 0 ? 0 : Math.round(n / r * a),
|
|
10
|
+
thumbSize: i
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { e as computeScrollbarThumb };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './allocateHeights.js';
|
|
2
|
+
export * from './clampOffset.js';
|
|
3
|
+
export * from './computeScrollbarThumb.js';
|
|
4
|
+
export * from './offsetFromScrollbarClick.js';
|
|
5
|
+
export * from './offsetFromScrollbarDrag.js';
|
|
6
|
+
export * from './scrollByInputEventKey.js';
|
|
7
|
+
export * from './scrollByKey.js';
|
|
8
|
+
export * from './scrollByWheel.js';
|
|
9
|
+
export * from './stickToBottomOffset.js';
|
|
10
|
+
export * from './resolveNextStickToBottomOffset.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { allocateHeights as e } from "./allocateHeights.js";
|
|
2
|
+
import { clampOffset as t } from "./clampOffset.js";
|
|
3
|
+
import { computeScrollbarThumb as n } from "./computeScrollbarThumb.js";
|
|
4
|
+
import { offsetFromScrollbarClick as r } from "./offsetFromScrollbarClick.js";
|
|
5
|
+
import { offsetFromScrollbarDrag as i } from "./offsetFromScrollbarDrag.js";
|
|
6
|
+
import { scrollByKey as a } from "./scrollByKey.js";
|
|
7
|
+
import { scrollByInputEventKey as o } from "./scrollByInputEventKey.js";
|
|
8
|
+
import { scrollByWheel as s } from "./scrollByWheel.js";
|
|
9
|
+
import { stickToBottomOffset as c } from "./stickToBottomOffset.js";
|
|
10
|
+
import { resolveNextStickToBottomOffset as l } from "./resolveNextStickToBottomOffset.js";
|
|
11
|
+
export { e as allocateHeights, t as clampOffset, n as computeScrollbarThumb, r as offsetFromScrollbarClick, i as offsetFromScrollbarDrag, l as resolveNextStickToBottomOffset, o as scrollByInputEventKey, a as scrollByKey, s as scrollByWheel, c as stickToBottomOffset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const offsetFromScrollbarClick: (lineCount: number, viewportHeight: number, clickRowInViewport: number) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { computeScrollbarThumb as e } from "./computeScrollbarThumb.js";
|
|
2
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarClick.ts
|
|
3
|
+
var t = (t, n, r) => {
|
|
4
|
+
if (t <= n) return 0;
|
|
5
|
+
let { thumbStart: i, thumbSize: a } = e(t, n, 0), o = t - n, s = Math.max(0, n - a);
|
|
6
|
+
if (r < i) return Math.max(0, Math.round(r / n * o) - n);
|
|
7
|
+
if (r >= i + a) return Math.min(o, Math.round(r / n * o) + n);
|
|
8
|
+
let c = s === 0 ? 0 : (r - i) / s;
|
|
9
|
+
return Math.round(c * o);
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as offsetFromScrollbarClick };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const offsetFromScrollbarDrag: (lineCount: number, viewportHeight: number, dragRowInViewport: number) => number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/offsetFromScrollbarDrag.ts
|
|
2
|
+
var e = (e, t, n) => {
|
|
3
|
+
if (e <= t) return 0;
|
|
4
|
+
let r = Math.max(1, Math.round(t * t / e)), i = n, a = Math.max(0, Math.min(t - r, i - Math.floor(r / 2))), o = Math.max(0, t - r), s = e - t, c = o === 0 ? 0 : a / o;
|
|
5
|
+
return Math.round(c * s);
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as offsetFromScrollbarDrag };
|
package/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type StickToBottomMode = boolean | "always" | "whenAtBottom";
|
|
2
|
+
export declare const resolveNextStickToBottomOffset: ({ mode, offset, prevLineCount, lineCount, viewportHeight, }: {
|
|
3
|
+
mode: StickToBottomMode;
|
|
4
|
+
offset: number;
|
|
5
|
+
prevLineCount: number;
|
|
6
|
+
lineCount: number;
|
|
7
|
+
viewportHeight: number;
|
|
8
|
+
}) => number | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { stickToBottomOffset as e } from "./stickToBottomOffset.js";
|
|
2
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/resolveNextStickToBottomOffset.ts
|
|
3
|
+
var t = ({ mode: t, offset: n, prevLineCount: r, lineCount: i, viewportHeight: a }) => {
|
|
4
|
+
if (t === !1) return;
|
|
5
|
+
let o = e(i, a);
|
|
6
|
+
if ((t === !0 ? "always" : t) === "always") return o === n ? void 0 : o;
|
|
7
|
+
if (n >= e(r, a) && o !== n) return o;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as resolveNextStickToBottomOffset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const scrollByInputEventKey: (offset: number, lineCount: number, viewportHeight: number, keyName: string) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { scrollByKey as e } from "./scrollByKey.js";
|
|
2
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/scrollByInputEventKey.ts
|
|
3
|
+
var t = (t, n, r, i) => {
|
|
4
|
+
let a = {
|
|
5
|
+
up: { upArrow: !0 },
|
|
6
|
+
down: { downArrow: !0 },
|
|
7
|
+
pageup: { pageUp: !0 },
|
|
8
|
+
pagedown: { pageDown: !0 },
|
|
9
|
+
home: { home: !0 },
|
|
10
|
+
end: { end: !0 }
|
|
11
|
+
}[i];
|
|
12
|
+
return a ? e(t, n, r, a) : t;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { t as scrollByInputEventKey };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ScrollKeyInput = {
|
|
2
|
+
upArrow?: boolean;
|
|
3
|
+
downArrow?: boolean;
|
|
4
|
+
pageUp?: boolean;
|
|
5
|
+
pageDown?: boolean;
|
|
6
|
+
home?: boolean;
|
|
7
|
+
end?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const scrollByKey: (offset: number, lineCount: number, viewportHeight: number, key: ScrollKeyInput) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/scrollByKey.ts
|
|
2
|
+
var e = (e, t, n, r) => {
|
|
3
|
+
let i = Math.max(0, t - n);
|
|
4
|
+
return r.upArrow ? Math.max(0, e - 1) : r.downArrow ? Math.min(i, e + 1) : r.pageUp ? Math.max(0, e - n) : r.pageDown ? Math.min(i, e + n) : r.home ? 0 : r.end ? i : e;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as scrollByKey };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkScrollView/utils/scrollMath/scrollByWheel.ts
|
|
2
|
+
var e = (e, t, n, r, i = 3) => {
|
|
3
|
+
if (r === "up") return Math.max(0, e - i);
|
|
4
|
+
let a = Math.max(0, t - n);
|
|
5
|
+
return Math.min(a, e + i);
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { e as scrollByWheel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stickToBottomOffset: (lineCount: number, viewportHeight: number) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputEvent } from '../../../hooks/useInputEvent/inputEventTypes.js';
|
|
2
|
+
import { InkScrollInputTarget } from './inkScrollInputTarget.js';
|
|
3
|
+
type UseInkScrollInputOptions = {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
keyboardTarget: InkScrollInputTarget | null;
|
|
6
|
+
mouseTargets: InkScrollInputTarget[];
|
|
7
|
+
onInputEvent?: (event: InputEvent) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const useInkScrollInput: ({ enabled, keyboardTarget, mouseTargets, onInputEvent }: UseInkScrollInputOptions) => void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useInputEvent as e } from "../../../hooks/useInputEvent/useInputEvent.js";
|
|
2
|
+
import "../../../hooks/useInputEvent/index.js";
|
|
3
|
+
import { applyInkScrollInput as t } from "./applyInkScrollInput.js";
|
|
4
|
+
import { useRef as n } from "react";
|
|
5
|
+
//#region src/react/ink-components/InkScrollView/utils/useInkScrollInput.ts
|
|
6
|
+
var r = ({ enabled: r, keyboardTarget: i, mouseTargets: a, onInputEvent: o }) => {
|
|
7
|
+
let s = n(void 0);
|
|
8
|
+
e((e) => {
|
|
9
|
+
o?.(e) || t(e, {
|
|
10
|
+
keyboardTarget: i,
|
|
11
|
+
mouseTargets: a,
|
|
12
|
+
draggingTargetIdRef: s
|
|
13
|
+
});
|
|
14
|
+
}, { isActive: r });
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as useInkScrollInput };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextProps } from 'ink';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
export type InkTimerProps = {
|
|
4
|
+
active?: boolean;
|
|
5
|
+
intervalMs?: number;
|
|
6
|
+
onStop?: (elapsedMs: number) => void;
|
|
7
|
+
formatTime?: (seconds: number) => string;
|
|
8
|
+
} & Pick<TextProps, "bold" | "color" | "dimColor">;
|
|
9
|
+
export declare const InkTimer: FC<InkTimerProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect as e, useRef as t, useState as n } from "react";
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { useInterval as i } from "ahooks";
|
|
4
|
+
import { Text as a } from "ink";
|
|
5
|
+
//#region src/react/ink-components/InkTimer/InkTimer.tsx
|
|
6
|
+
var o = (e) => `${Math.round(Math.max(0, e))}s`, s = ({ active: s = !0, bold: c, color: l, dimColor: u, formatTime: d = o, intervalMs: f = 1e3, onStop: p }) => {
|
|
7
|
+
let [m, h] = n(0), g = t(void 0);
|
|
8
|
+
return e(() => {
|
|
9
|
+
if (s) {
|
|
10
|
+
g.current = Date.now(), h(0);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (g.current === void 0) return;
|
|
14
|
+
let e = Date.now() - g.current;
|
|
15
|
+
g.current = void 0, h(e), p?.(e);
|
|
16
|
+
}, [s, p]), i(() => {
|
|
17
|
+
g.current !== void 0 && h(Date.now() - g.current);
|
|
18
|
+
}, s ? f : void 0), /* @__PURE__ */ r(a, {
|
|
19
|
+
...c === void 0 ? {} : { bold: c },
|
|
20
|
+
...l === void 0 ? {} : { color: l },
|
|
21
|
+
...u === void 0 ? {} : { dimColor: u },
|
|
22
|
+
children: d(m / 1e3)
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { s as InkTimer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InkTimer.js';
|