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,24 @@
|
|
|
1
|
+
import { createOverlayStackItem as e } from "./createOverlayStackItem.js";
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
//#region src/react/hooks/useOverlayStack/useOverlayStack.ts
|
|
4
|
+
var r = () => {
|
|
5
|
+
let [r, i] = n([]), a = t((t, n) => {
|
|
6
|
+
i((r) => [...r, e(t, r.length + 1, n)]);
|
|
7
|
+
}, []), o = t(() => {
|
|
8
|
+
i((e) => e.length > 0 ? e.slice(0, -1) : e);
|
|
9
|
+
}, []), s = t((e, t) => {
|
|
10
|
+
i((n) => n.map((n) => n.id === e ? {
|
|
11
|
+
...n,
|
|
12
|
+
...t
|
|
13
|
+
} : n));
|
|
14
|
+
}, []);
|
|
15
|
+
return {
|
|
16
|
+
stack: r,
|
|
17
|
+
top: r.at(-1),
|
|
18
|
+
push: a,
|
|
19
|
+
pop: o,
|
|
20
|
+
update: s
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { r as useOverlayStack };
|
package/react/index.d.ts
ADDED
package/react/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useCopyToClipboard as e } from "./hooks/useCopyToClipboard.js";
|
|
2
|
+
import { useDeepCompareSelector as t } from "./hooks/useDeepCompareSelector.js";
|
|
3
|
+
import { formatInputEvent as n } from "./hooks/useInputEvent/formatInputEvent.js";
|
|
4
|
+
import { parserItemToInputEvent as r } from "./hooks/useInputEvent/parseInputEvent.js";
|
|
5
|
+
import { useInputEvent as i } from "./hooks/useInputEvent/useInputEvent.js";
|
|
6
|
+
import "./hooks/useInputEvent/index.js";
|
|
7
|
+
import { createOverlayStackItem as a } from "./hooks/useOverlayStack/createOverlayStackItem.js";
|
|
8
|
+
import { useOverlayStack as o } from "./hooks/useOverlayStack/useOverlayStack.js";
|
|
9
|
+
import "./hooks/useOverlayStack/index.js";
|
|
10
|
+
export { a as createOverlayStackItem, n as formatInputEvent, r as parserItemToInputEvent, e as useCopyToClipboard, t as useDeepCompareSelector, i as useInputEvent, o as useOverlayStack };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useInputEvent as e } from "../../hooks/useInputEvent/useInputEvent.js";
|
|
2
|
+
import "../../hooks/useInputEvent/index.js";
|
|
3
|
+
import { computeInkModalBodyHeight as t } from "./utils/computeInkModalBodyMaxHeight.js";
|
|
4
|
+
import { resolveInkModalSize as n } from "./utils/resolveInkModalSize.js";
|
|
5
|
+
import { useState as r } from "react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
import { Box as o, Text as s, useWindowSize as c } from "ink";
|
|
8
|
+
//#region src/react/ink-components/InkModal/InkModal.tsx
|
|
9
|
+
var l = 1, u = 1, d = ({ cancelLabel: e, focused: t, saveLabel: n }) => /* @__PURE__ */ a(o, {
|
|
10
|
+
flexDirection: "row",
|
|
11
|
+
justifyContent: "center",
|
|
12
|
+
gap: 2,
|
|
13
|
+
children: [/* @__PURE__ */ i(s, {
|
|
14
|
+
bold: t === "save",
|
|
15
|
+
...t === "save" ? { color: "cyan" } : {},
|
|
16
|
+
children: n
|
|
17
|
+
}), /* @__PURE__ */ i(s, {
|
|
18
|
+
bold: t === "cancel",
|
|
19
|
+
...t === "cancel" ? { color: "cyan" } : {},
|
|
20
|
+
children: e
|
|
21
|
+
})]
|
|
22
|
+
}), f = ({ bodyHeight: e, borderColor: t, borderStyle: n, children: r, footer: s, footerHeight: c, header: l, headerHeight: u, height: d, paddingX: f, width: p }) => /* @__PURE__ */ a(o, {
|
|
23
|
+
flexDirection: "column",
|
|
24
|
+
width: p,
|
|
25
|
+
height: d,
|
|
26
|
+
borderStyle: n,
|
|
27
|
+
borderColor: t,
|
|
28
|
+
paddingX: f,
|
|
29
|
+
children: [
|
|
30
|
+
l ? /* @__PURE__ */ i(o, {
|
|
31
|
+
height: u,
|
|
32
|
+
flexShrink: 0,
|
|
33
|
+
flexDirection: "column",
|
|
34
|
+
children: l
|
|
35
|
+
}) : null,
|
|
36
|
+
/* @__PURE__ */ i(o, {
|
|
37
|
+
height: e,
|
|
38
|
+
flexGrow: 1,
|
|
39
|
+
flexShrink: 1,
|
|
40
|
+
flexDirection: "column",
|
|
41
|
+
children: r
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ i(o, {
|
|
44
|
+
height: c,
|
|
45
|
+
flexShrink: 0,
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
justifyContent: "center",
|
|
48
|
+
children: s
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}), p = ({ children: a, onClose: s, onSave: p, onCancel: m, saveLabel: h = "Save", cancelLabel: g = "Cancel", height: _, width: v, header: y, headerHeight: b = l, footer: x, footerHeight: S = u, borderColor: C = "cyan", borderStyle: w = "round", paddingX: T = 1, layout: E = "fullscreen", isActive: D = !0, keyboardEnabled: O = !0 }) => {
|
|
52
|
+
let { columns: k, rows: A } = c(), j = E === "embedded" ? {
|
|
53
|
+
width: v ?? Math.max(20, k - 2),
|
|
54
|
+
height: _ ?? Math.max(8, A - 2)
|
|
55
|
+
} : n(k, A, v, _), M = y ? b : 0, N = t(j.height, M, S), P = x === void 0, [F, I] = r("save");
|
|
56
|
+
e((e) => {
|
|
57
|
+
if (!(e.type !== "key" || e.action === "release")) {
|
|
58
|
+
if (e.name === "escape") {
|
|
59
|
+
s();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (P) {
|
|
63
|
+
if (e.name === "return") {
|
|
64
|
+
F === "save" ? p() : m();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (e.name === "tab" || e.name === "right") {
|
|
68
|
+
I((e) => e === "save" ? "cancel" : "save");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
e.name === "left" && I((e) => e === "cancel" ? "save" : "cancel");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, { isActive: D && O });
|
|
75
|
+
let L = /* @__PURE__ */ i(f, {
|
|
76
|
+
bodyHeight: N,
|
|
77
|
+
borderColor: C,
|
|
78
|
+
borderStyle: w,
|
|
79
|
+
footer: P ? /* @__PURE__ */ i(d, {
|
|
80
|
+
cancelLabel: g,
|
|
81
|
+
focused: F,
|
|
82
|
+
saveLabel: h
|
|
83
|
+
}) : x,
|
|
84
|
+
footerHeight: S,
|
|
85
|
+
header: y,
|
|
86
|
+
headerHeight: M,
|
|
87
|
+
height: j.height,
|
|
88
|
+
paddingX: T,
|
|
89
|
+
width: j.width,
|
|
90
|
+
children: a
|
|
91
|
+
});
|
|
92
|
+
return E === "embedded" ? L : /* @__PURE__ */ i(o, {
|
|
93
|
+
width: k,
|
|
94
|
+
height: A,
|
|
95
|
+
justifyContent: "center",
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
children: L
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//#endregion
|
|
101
|
+
export { p as InkModal };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { InkModal } from './InkModal.js';
|
|
2
|
+
export type { InkModalFooterFocus, InkModalLayout, InkModalProps } from './types.js';
|
|
3
|
+
export { computeInkModalBodyHeight } from './utils/computeInkModalBodyMaxHeight.js';
|
|
4
|
+
export { defaultInkModalHeightRatio, defaultInkModalWidthRatio, resolveInkModalSize } from './utils/resolveInkModalSize.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { computeInkModalBodyHeight as e } from "./utils/computeInkModalBodyMaxHeight.js";
|
|
2
|
+
import { defaultInkModalHeightRatio as t, defaultInkModalWidthRatio as n, resolveInkModalSize as r } from "./utils/resolveInkModalSize.js";
|
|
3
|
+
import { InkModal as i } from "./InkModal.js";
|
|
4
|
+
export { i as InkModal, e as computeInkModalBodyHeight, t as defaultInkModalHeightRatio, n as defaultInkModalWidthRatio, r as resolveInkModalSize };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BoxProps } from 'ink';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type InkModalLayout = "fullscreen" | "embedded";
|
|
4
|
+
export type InkModalProps = {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onSave: () => void;
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
saveLabel?: string;
|
|
10
|
+
cancelLabel?: string;
|
|
11
|
+
height?: number;
|
|
12
|
+
width?: number;
|
|
13
|
+
header?: ReactNode;
|
|
14
|
+
headerHeight?: number;
|
|
15
|
+
footer?: ReactNode;
|
|
16
|
+
footerHeight?: number;
|
|
17
|
+
borderColor?: string;
|
|
18
|
+
borderStyle?: BoxProps["borderStyle"];
|
|
19
|
+
paddingX?: number;
|
|
20
|
+
layout?: InkModalLayout;
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
keyboardEnabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type InkModalFooterFocus = "save" | "cancel";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const computeInkModalBodyHeight: (height: number, headerHeight?: number, footerHeight?: number) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkModal/utils/resolveInkModalSize.ts
|
|
2
|
+
var e = .9, t = .8, n = (e, t, n, r) => ({
|
|
3
|
+
width: n ?? Math.max(20, Math.floor(e * .9)),
|
|
4
|
+
height: r ?? Math.max(8, Math.floor(t * .8))
|
|
5
|
+
});
|
|
6
|
+
//#endregion
|
|
7
|
+
export { t as defaultInkModalHeightRatio, e as defaultInkModalWidthRatio, n as resolveInkModalSize };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { InkMultiSelectColors, InkMultiSelectEmptyState, InkMultiSelectEntry } from './types.js';
|
|
3
|
+
import { UseInkMultiSelectNavigationResult } from './useInkMultiSelectNavigation.js';
|
|
4
|
+
export interface InkMultiSelectProps {
|
|
5
|
+
colors?: InkMultiSelectColors;
|
|
6
|
+
confirmVerb?: string;
|
|
7
|
+
empty?: InkMultiSelectEmptyState;
|
|
8
|
+
entries: InkMultiSelectEntry[];
|
|
9
|
+
error?: boolean;
|
|
10
|
+
errorLabel?: string;
|
|
11
|
+
keyboardEnabled?: boolean;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
loadingLabel?: string;
|
|
14
|
+
navigation?: UseInkMultiSelectNavigationResult;
|
|
15
|
+
noSelectionError: string;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
onConfirm: (selectedEntries: InkMultiSelectEntry[]) => void | Promise<void>;
|
|
18
|
+
onNoSelection?: (message: string) => void;
|
|
19
|
+
title: string;
|
|
20
|
+
visibleCount?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const InkMultiSelect: FC<InkMultiSelectProps>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useInputEvent as e } from "../../hooks/useInputEvent/useInputEvent.js";
|
|
2
|
+
import "../../hooks/useInputEvent/index.js";
|
|
3
|
+
import { resolveInkMultiSelectColors as t } from "./types.js";
|
|
4
|
+
import { InkMultiSelectRow as n } from "./InkMultiSelectRow.js";
|
|
5
|
+
import { applyInkMultiSelectInputEvent as r } from "./inkMultiSelectKeyboard.js";
|
|
6
|
+
import { inkMultiSelectVisibleCount as i } from "./utils/inkMultiSelectVisibleCount.js";
|
|
7
|
+
import { useInkMultiSelectNavigation as a } from "./useInkMultiSelectNavigation.js";
|
|
8
|
+
import { formatMoreLabel as o } from "./utils/formatMoreLabel.js";
|
|
9
|
+
import { createElement as s } from "react";
|
|
10
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
11
|
+
import { Box as u, Text as d } from "ink";
|
|
12
|
+
//#region src/react/ink-components/InkMultiSelect/InkMultiSelect.tsx
|
|
13
|
+
var f = ({ colors: f, confirmVerb: m = "confirm", empty: h, entries: g, error: _ = !1, errorLabel: v = "failed to load", keyboardEnabled: y = !0, loading: b = !1, loadingLabel: x = "loading...", navigation: S, noSelectionError: C, onCancel: w, onConfirm: T, onNoSelection: E, title: D, visibleCount: O = i() }) => {
|
|
14
|
+
let k = t(f), A = a(g.length, O), { moveSelection: j, safeFocusedIndex: M, safeScrollOffset: N, selectedCount: P, selectedIds: F, toggleFocusedItem: I } = S ?? A, L = () => {
|
|
15
|
+
let e = g.filter((e) => F.has(e.id));
|
|
16
|
+
if (e.length === 0) {
|
|
17
|
+
E?.(C);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
T(e);
|
|
21
|
+
}, R = g[M]?.id;
|
|
22
|
+
if (e((e) => {
|
|
23
|
+
r(e, {
|
|
24
|
+
moveSelection: j,
|
|
25
|
+
onCancel: w,
|
|
26
|
+
onConfirm: L,
|
|
27
|
+
pageStep: O,
|
|
28
|
+
toggleFocusedItem: () => {
|
|
29
|
+
I(R);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}, { isActive: y && S === void 0 && !b && !_ && g.length > 0 }), b) return /* @__PURE__ */ c(d, {
|
|
33
|
+
dimColor: !0,
|
|
34
|
+
children: x
|
|
35
|
+
});
|
|
36
|
+
if (_) return /* @__PURE__ */ c(d, {
|
|
37
|
+
color: k.error,
|
|
38
|
+
children: v
|
|
39
|
+
});
|
|
40
|
+
if (g.length === 0) return /* @__PURE__ */ c(p, {
|
|
41
|
+
...f ? { colors: f } : {},
|
|
42
|
+
...h ? { empty: h } : {}
|
|
43
|
+
});
|
|
44
|
+
let z = g.slice(N, N + O), B = o(N), V = o(g.length - N - z.length);
|
|
45
|
+
return /* @__PURE__ */ l(u, {
|
|
46
|
+
flexDirection: "column",
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ c(d, {
|
|
49
|
+
color: k.brand,
|
|
50
|
+
bold: !0,
|
|
51
|
+
children: D
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ c(d, {
|
|
54
|
+
dimColor: !0,
|
|
55
|
+
children: `Up/Down move · Space toggle · Enter ${m} (${P} selected) · Esc cancel`
|
|
56
|
+
}),
|
|
57
|
+
B ? /* @__PURE__ */ c(d, {
|
|
58
|
+
dimColor: !0,
|
|
59
|
+
children: `↑ ${B}`
|
|
60
|
+
}) : null,
|
|
61
|
+
z.map((e, t) => {
|
|
62
|
+
let r = N + t;
|
|
63
|
+
return /* @__PURE__ */ s(n, {
|
|
64
|
+
...f ? { colors: f } : {},
|
|
65
|
+
entry: e,
|
|
66
|
+
isFocused: r === M,
|
|
67
|
+
isSelected: F.has(e.id),
|
|
68
|
+
key: e.id
|
|
69
|
+
});
|
|
70
|
+
}),
|
|
71
|
+
V ? /* @__PURE__ */ c(d, {
|
|
72
|
+
dimColor: !0,
|
|
73
|
+
children: `↓ ${V}`
|
|
74
|
+
}) : null
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
}, p = ({ colors: e, empty: n }) => {
|
|
78
|
+
let r = t(e);
|
|
79
|
+
return n ? /* @__PURE__ */ l(u, {
|
|
80
|
+
flexDirection: "column",
|
|
81
|
+
children: [/* @__PURE__ */ c(d, {
|
|
82
|
+
color: r.error,
|
|
83
|
+
children: n.title
|
|
84
|
+
}), n.hint ? /* @__PURE__ */ c(d, {
|
|
85
|
+
dimColor: !0,
|
|
86
|
+
children: n.hint
|
|
87
|
+
}) : null]
|
|
88
|
+
}) : /* @__PURE__ */ c(d, {
|
|
89
|
+
color: r.error,
|
|
90
|
+
children: "no items"
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
//#endregion
|
|
94
|
+
export { f as InkMultiSelect };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { InkMultiSelectColors, InkMultiSelectEntry } from './types.js';
|
|
3
|
+
interface InkMultiSelectRowProps {
|
|
4
|
+
colors?: InkMultiSelectColors;
|
|
5
|
+
entry: InkMultiSelectEntry;
|
|
6
|
+
isFocused: boolean;
|
|
7
|
+
isSelected: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const InkMultiSelectRow: FC<InkMultiSelectRowProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolveInkMultiSelectColors as e } from "./types.js";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
import { Text as r } from "ink";
|
|
4
|
+
//#region src/react/ink-components/InkMultiSelect/InkMultiSelectRow.tsx
|
|
5
|
+
var i = ({ colors: i, entry: a, isFocused: o, isSelected: s }) => {
|
|
6
|
+
let c = e(i), l = s ? "x" : " ";
|
|
7
|
+
return /* @__PURE__ */ n(r, {
|
|
8
|
+
inverse: o,
|
|
9
|
+
wrap: "truncate-end",
|
|
10
|
+
children: [
|
|
11
|
+
/* @__PURE__ */ t(r, {
|
|
12
|
+
color: o ? c.answer : c.muted,
|
|
13
|
+
bold: !0,
|
|
14
|
+
children: o ? "> " : " "
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ t(r, {
|
|
17
|
+
color: c.accent,
|
|
18
|
+
bold: !0,
|
|
19
|
+
children: `[${l}] `
|
|
20
|
+
}),
|
|
21
|
+
a.inUse ? /* @__PURE__ */ n(r, {
|
|
22
|
+
color: c.success,
|
|
23
|
+
bold: !0,
|
|
24
|
+
children: ["in use ·", " "]
|
|
25
|
+
}) : null,
|
|
26
|
+
/* @__PURE__ */ t(r, {
|
|
27
|
+
color: o ? c.answer : c.response,
|
|
28
|
+
bold: !0,
|
|
29
|
+
children: a.label
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { i as InkMultiSelectRow };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './InkMultiSelect.js';
|
|
2
|
+
export * from './InkMultiSelectRow.js';
|
|
3
|
+
export * from './inkMultiSelectKeyboard.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './useInkMultiSelectNavigation.js';
|
|
6
|
+
export * from './utils/clampListScrollOffset.js';
|
|
7
|
+
export * from './utils/formatMoreLabel.js';
|
|
8
|
+
export * from './utils/inkMultiSelectVisibleCount.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_INK_MULTI_SELECT_COLORS as e, resolveInkMultiSelectColors as t } from "./types.js";
|
|
2
|
+
import { InkMultiSelectRow as n } from "./InkMultiSelectRow.js";
|
|
3
|
+
import { applyInkMultiSelectInputEvent as r } from "./inkMultiSelectKeyboard.js";
|
|
4
|
+
import { clampListScrollOffset as i } from "./utils/clampListScrollOffset.js";
|
|
5
|
+
import { INK_MULTI_SELECT_VISIBLE_COUNT as a, inkMultiSelectVisibleCount as o } from "./utils/inkMultiSelectVisibleCount.js";
|
|
6
|
+
import { useInkMultiSelectNavigation as s } from "./useInkMultiSelectNavigation.js";
|
|
7
|
+
import { formatMoreLabel as c } from "./utils/formatMoreLabel.js";
|
|
8
|
+
import { InkMultiSelect as l } from "./InkMultiSelect.js";
|
|
9
|
+
export { e as DEFAULT_INK_MULTI_SELECT_COLORS, a as INK_MULTI_SELECT_VISIBLE_COUNT, l as InkMultiSelect, n as InkMultiSelectRow, r as applyInkMultiSelectInputEvent, i as clampListScrollOffset, c as formatMoreLabel, o as inkMultiSelectVisibleCount, t as resolveInkMultiSelectColors, s as useInkMultiSelectNavigation };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InputEvent } from '../../hooks/useInputEvent/inputEventTypes.js';
|
|
2
|
+
export type InkMultiSelectKeyboardContext = {
|
|
3
|
+
moveSelection: (offset: number, wrap: boolean) => void;
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
toggleFocusedItem: () => void;
|
|
7
|
+
pageStep: number;
|
|
8
|
+
};
|
|
9
|
+
export type InkMultiSelectInkKey = {
|
|
10
|
+
downArrow?: boolean;
|
|
11
|
+
escape?: boolean;
|
|
12
|
+
pageDown?: boolean;
|
|
13
|
+
pageUp?: boolean;
|
|
14
|
+
return?: boolean;
|
|
15
|
+
upArrow?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function applyInkMultiSelectInputEvent(event: InputEvent, context: InkMultiSelectKeyboardContext): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkMultiSelect/inkMultiSelectKeyboard.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return e === " " ? (t.toggleFocusedItem(), !0) : !1;
|
|
4
|
+
}
|
|
5
|
+
function t(t, n, r) {
|
|
6
|
+
return n.escape ? (r.onCancel(), !0) : n.return ? (r.onConfirm(), !0) : n.upArrow ? (r.moveSelection(-1, !0), !0) : n.downArrow ? (r.moveSelection(1, !0), !0) : n.pageUp ? (r.moveSelection(-r.pageStep, !1), !0) : n.pageDown ? (r.moveSelection(r.pageStep, !1), !0) : e(t, r);
|
|
7
|
+
}
|
|
8
|
+
function n(n, r) {
|
|
9
|
+
return n.type === "key" ? n.action === "release" ? !1 : t(n.text, {
|
|
10
|
+
downArrow: n.name === "down",
|
|
11
|
+
escape: n.name === "escape",
|
|
12
|
+
pageDown: n.name === "pageDown",
|
|
13
|
+
pageUp: n.name === "pageUp",
|
|
14
|
+
return: n.name === "return",
|
|
15
|
+
upArrow: n.name === "up"
|
|
16
|
+
}, r) : n.type === "text" ? e(n.text, r) : !1;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as applyInkMultiSelectInputEvent };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface InkMultiSelectEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
inUse?: boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface InkMultiSelectEmptyState {
|
|
7
|
+
hint?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
}
|
|
10
|
+
export interface InkMultiSelectColors {
|
|
11
|
+
accent?: string;
|
|
12
|
+
answer?: string;
|
|
13
|
+
brand?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
muted?: string;
|
|
16
|
+
response?: string;
|
|
17
|
+
success?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_INK_MULTI_SELECT_COLORS: Required<InkMultiSelectColors>;
|
|
20
|
+
export declare function resolveInkMultiSelectColors(colors?: InkMultiSelectColors): Required<InkMultiSelectColors>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/react/ink-components/InkMultiSelect/types.ts
|
|
2
|
+
var e = {
|
|
3
|
+
accent: "magenta",
|
|
4
|
+
answer: "white",
|
|
5
|
+
brand: "green",
|
|
6
|
+
error: "red",
|
|
7
|
+
muted: "gray",
|
|
8
|
+
response: "white",
|
|
9
|
+
success: "green"
|
|
10
|
+
};
|
|
11
|
+
function t(t) {
|
|
12
|
+
return {
|
|
13
|
+
...e,
|
|
14
|
+
...t
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { e as DEFAULT_INK_MULTI_SELECT_COLORS, t as resolveInkMultiSelectColors };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function useInkMultiSelectNavigation(itemCount: number, visibleCount?: number): {
|
|
2
|
+
moveSelection: (offset: number, wrap: boolean) => void;
|
|
3
|
+
safeFocusedIndex: number;
|
|
4
|
+
safeScrollOffset: number;
|
|
5
|
+
selectedIds: Set<string>;
|
|
6
|
+
selectedCount: number;
|
|
7
|
+
toggleFocusedItem: (itemId: string | undefined) => void;
|
|
8
|
+
visibleCount: number;
|
|
9
|
+
};
|
|
10
|
+
export type UseInkMultiSelectNavigationResult = ReturnType<typeof useInkMultiSelectNavigation>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { clampListScrollOffset as e } from "./utils/clampListScrollOffset.js";
|
|
2
|
+
import { inkMultiSelectVisibleCount as t } from "./utils/inkMultiSelectVisibleCount.js";
|
|
3
|
+
import { useEffect as n, useState as r } from "react";
|
|
4
|
+
//#region src/react/ink-components/InkMultiSelect/useInkMultiSelectNavigation.ts
|
|
5
|
+
function i(i, a = t()) {
|
|
6
|
+
let [o, s] = r(0), [c, l] = r(0), [u, d] = r(() => /* @__PURE__ */ new Set()), f = e(i, a, c), p = i === 0 ? 0 : Math.max(0, Math.min(i - 1, o));
|
|
7
|
+
return n(() => {
|
|
8
|
+
l((t) => e(i, a, t)), s((e) => i === 0 ? 0 : Math.max(0, Math.min(i - 1, e)));
|
|
9
|
+
}, [i, a]), n(() => {
|
|
10
|
+
if (p < f) {
|
|
11
|
+
l(p);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
p >= f + a && l(p - a + 1);
|
|
15
|
+
}, [
|
|
16
|
+
p,
|
|
17
|
+
f,
|
|
18
|
+
a
|
|
19
|
+
]), {
|
|
20
|
+
moveSelection: (e, t) => {
|
|
21
|
+
i !== 0 && s((n) => {
|
|
22
|
+
let r = Math.max(0, Math.min(i - 1, n));
|
|
23
|
+
return t ? (r + e + i) % i : Math.max(0, Math.min(i - 1, r + e));
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
safeFocusedIndex: p,
|
|
27
|
+
safeScrollOffset: f,
|
|
28
|
+
selectedIds: u,
|
|
29
|
+
selectedCount: u.size,
|
|
30
|
+
toggleFocusedItem: (e) => {
|
|
31
|
+
e && d((t) => {
|
|
32
|
+
let n = new Set(t);
|
|
33
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
visibleCount: a
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { i as useInkMultiSelectNavigation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clampListScrollOffset(total: number, visibleCount: number, scrollOffset: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatMoreLabel(count: number): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DOMElement } from 'ink';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
import { StickToBottomMode } from './utils/scrollMath/index.js';
|
|
4
|
+
export type InkScrollViewProps = {
|
|
5
|
+
maxHeight: number;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
scrollOffset?: number;
|
|
8
|
+
defaultScrollOffset?: number;
|
|
9
|
+
onScrollOffsetChange?: (offset: number) => void;
|
|
10
|
+
/** true | "always": follow tail on content change; "whenAtBottom": only if already at bottom; false: off */
|
|
11
|
+
stickToBottom?: StickToBottomMode;
|
|
12
|
+
enableInput?: boolean;
|
|
13
|
+
focused?: boolean;
|
|
14
|
+
showScrollbar?: boolean;
|
|
15
|
+
title?: string;
|
|
16
|
+
viewportRef?: React.RefObject<DOMElement | null>;
|
|
17
|
+
scrollbarRef?: React.RefObject<DOMElement | null>;
|
|
18
|
+
};
|
|
19
|
+
export declare const InkScrollView: FC<InkScrollViewProps>;
|