diff --git a/packages/ngx-moveable/projects/ngx-moveable/src/consts.ts b/packages/ngx-moveable/projects/ngx-moveable/src/consts.ts index 952cbae09..81bc0e72c 100644 --- a/packages/ngx-moveable/projects/ngx-moveable/src/consts.ts +++ b/packages/ngx-moveable/projects/ngx-moveable/src/consts.ts @@ -1,4 +1,4 @@ // auto // eslint-disable-next-line max-len -export const ANGULAR_MOVEABLE_INPUTS: ["target","dragTarget","dragContainer","container","warpSelf","rootContainer","useResizeObserver","useMutationObserver","zoom","dragFocusedInput","transformOrigin","edge","ables","className","pinchThreshold","pinchOutside","triggerAblesSimultaneously","checkInput","cspNonce","translateZ","hideDefaultLines","props","flushSync","stopPropagation","preventClickEventOnDrag","preventClickDefault","viewContainer","persistData","useAccuratePosition","firstRenderState","linePadding","displayAroundControls","controlPadding","preventDefault","requestStyles","snappable","snapContainer","snapDirections","elementSnapDirections","snapGap","snapGridWidth","snapGridHeight","isDisplaySnapDigit","isDisplayInnerSnapDigit","isDisplayGridGuidelines","snapDigit","snapThreshold","snapRenderThreshold","snapRotationThreshold","snapRotationDegress","horizontalGuidelines","verticalGuidelines","elementGuidelines","bounds","innerBounds","snapDistFormat","maxSnapElementGuidelineDistance","maxSnapElementGapDistance","pinchable","draggable","throttleDrag","throttleDragRotate","hideThrottleDragRotateLine","startDragRotate","edgeDraggable","resizable","throttleResize","renderDirections","keepRatio","resizeFormat","keepRatioFinally","checkResizableError","scalable","throttleScale","warpable","rotatable","rotationPosition","throttleRotate","rotationTarget","rotateAroundControls","resolveAblesWithRotatable","scrollable","scrollContainer","scrollThreshold","scrollThrottleTime","getScrollPosition","scrollOptions","origin","svgOrigin","originDraggable","originRelative","clippable","defaultClipPath","customClipPath","clipRelative","clipArea","dragWithClip","clipTargetBounds","clipVerticalGuidelines","clipHorizontalGuidelines","clipSnapThreshold","roundable","roundRelative","minRoundControls","maxRoundControls","roundClickable","roundPadding","isDisplayShadowRoundControls","defaultGroupRotate","useDefaultGroupRotate","defaultGroupOrigin","groupable","groupableProps","targetGroups","hideChildMoveableDefaultLines","individualGroupable","individualGroupableProps","clickable","dragArea","passDragArea"] = ["target","dragTarget","dragContainer","container","warpSelf","rootContainer","useResizeObserver","useMutationObserver","zoom","dragFocusedInput","transformOrigin","edge","ables","className","pinchThreshold","pinchOutside","triggerAblesSimultaneously","checkInput","cspNonce","translateZ","hideDefaultLines","props","flushSync","stopPropagation","preventClickEventOnDrag","preventClickDefault","viewContainer","persistData","useAccuratePosition","firstRenderState","linePadding","displayAroundControls","controlPadding","preventDefault","requestStyles","snappable","snapContainer","snapDirections","elementSnapDirections","snapGap","snapGridWidth","snapGridHeight","isDisplaySnapDigit","isDisplayInnerSnapDigit","isDisplayGridGuidelines","snapDigit","snapThreshold","snapRenderThreshold","snapRotationThreshold","snapRotationDegress","horizontalGuidelines","verticalGuidelines","elementGuidelines","bounds","innerBounds","snapDistFormat","maxSnapElementGuidelineDistance","maxSnapElementGapDistance","pinchable","draggable","throttleDrag","throttleDragRotate","hideThrottleDragRotateLine","startDragRotate","edgeDraggable","resizable","throttleResize","renderDirections","keepRatio","resizeFormat","keepRatioFinally","checkResizableError","scalable","throttleScale","warpable","rotatable","rotationPosition","throttleRotate","rotationTarget","rotateAroundControls","resolveAblesWithRotatable","scrollable","scrollContainer","scrollThreshold","scrollThrottleTime","getScrollPosition","scrollOptions","origin","svgOrigin","originDraggable","originRelative","clippable","defaultClipPath","customClipPath","clipRelative","clipArea","dragWithClip","clipTargetBounds","clipVerticalGuidelines","clipHorizontalGuidelines","clipSnapThreshold","roundable","roundRelative","minRoundControls","maxRoundControls","roundClickable","roundPadding","isDisplayShadowRoundControls","defaultGroupRotate","useDefaultGroupRotate","defaultGroupOrigin","groupable","groupableProps","targetGroups","hideChildMoveableDefaultLines","individualGroupable","individualGroupableProps","clickable","dragArea","passDragArea"]; +export const ANGULAR_MOVEABLE_INPUTS: ["target","dragTarget","dragContainer","container","warpSelf","rootContainer","useResizeObserver","useMutationObserver","zoom","dragFocusedInput","transformOrigin","ables","className","pinchThreshold","pinchOutside","triggerAblesSimultaneously","checkInput","cspNonce","translateZ","hideDefaultLines","props","flushSync","stopPropagation","preventClickEventOnDrag","preventClickDefault","viewContainer","persistData","useAccuratePosition","firstRenderState","linePadding","controlPadding","preventDefault","requestStyles","snappable","snapContainer","snapDirections","elementSnapDirections","snapGap","snapGridWidth","snapGridHeight","isDisplaySnapDigit","isDisplayInnerSnapDigit","isDisplayGridGuidelines","snapDigit","snapThreshold","snapRenderThreshold","snapRotationThreshold","snapRotationDegress","horizontalGuidelines","verticalGuidelines","elementGuidelines","bounds","innerBounds","snapDistFormat","maxSnapElementGuidelineDistance","maxSnapElementGapDistance","pinchable","draggable","throttleDrag","throttleDragRotate","hideThrottleDragRotateLine","startDragRotate","edgeDraggable","resizable","throttleResize","renderDirections","displayAroundControls","keepRatio","resizeFormat","keepRatioFinally","edge","checkResizableError","scalable","throttleScale","warpable","rotatable","rotationPosition","throttleRotate","rotationTarget","rotateAroundControls","resolveAblesWithRotatable","scrollable","scrollContainer","scrollThreshold","scrollThrottleTime","getScrollPosition","scrollOptions","padding","origin","svgOrigin","originDraggable","originRelative","clippable","defaultClipPath","customClipPath","clipRelative","clipArea","dragWithClip","clipTargetBounds","clipVerticalGuidelines","clipHorizontalGuidelines","clipSnapThreshold","roundable","roundRelative","minRoundControls","maxRoundControls","roundClickable","roundPadding","isDisplayShadowRoundControls","defaultGroupRotate","useDefaultGroupRotate","defaultGroupOrigin","groupable","groupableProps","targetGroups","hideChildMoveableDefaultLines","individualGroupable","individualGroupableProps","clickable","dragArea","passDragArea"] = ["target","dragTarget","dragContainer","container","warpSelf","rootContainer","useResizeObserver","useMutationObserver","zoom","dragFocusedInput","transformOrigin","ables","className","pinchThreshold","pinchOutside","triggerAblesSimultaneously","checkInput","cspNonce","translateZ","hideDefaultLines","props","flushSync","stopPropagation","preventClickEventOnDrag","preventClickDefault","viewContainer","persistData","useAccuratePosition","firstRenderState","linePadding","controlPadding","preventDefault","requestStyles","snappable","snapContainer","snapDirections","elementSnapDirections","snapGap","snapGridWidth","snapGridHeight","isDisplaySnapDigit","isDisplayInnerSnapDigit","isDisplayGridGuidelines","snapDigit","snapThreshold","snapRenderThreshold","snapRotationThreshold","snapRotationDegress","horizontalGuidelines","verticalGuidelines","elementGuidelines","bounds","innerBounds","snapDistFormat","maxSnapElementGuidelineDistance","maxSnapElementGapDistance","pinchable","draggable","throttleDrag","throttleDragRotate","hideThrottleDragRotateLine","startDragRotate","edgeDraggable","resizable","throttleResize","renderDirections","displayAroundControls","keepRatio","resizeFormat","keepRatioFinally","edge","checkResizableError","scalable","throttleScale","warpable","rotatable","rotationPosition","throttleRotate","rotationTarget","rotateAroundControls","resolveAblesWithRotatable","scrollable","scrollContainer","scrollThreshold","scrollThrottleTime","getScrollPosition","scrollOptions","padding","origin","svgOrigin","originDraggable","originRelative","clippable","defaultClipPath","customClipPath","clipRelative","clipArea","dragWithClip","clipTargetBounds","clipVerticalGuidelines","clipHorizontalGuidelines","clipSnapThreshold","roundable","roundRelative","minRoundControls","maxRoundControls","roundClickable","roundPadding","isDisplayShadowRoundControls","defaultGroupRotate","useDefaultGroupRotate","defaultGroupOrigin","groupable","groupableProps","targetGroups","hideChildMoveableDefaultLines","individualGroupable","individualGroupableProps","clickable","dragArea","passDragArea"]; export const ANGULAR_MOVEABLE_OUTPUTS: ["beforeRenderStart","beforeRender","beforeRenderEnd","beforeRenderGroupStart","beforeRenderGroup","beforeRenderGroupEnd","changeTargets","snap","pinchStart","pinch","pinchEnd","pinchGroupStart","pinchGroup","pinchGroupEnd","dragStart","drag","dragEnd","dragGroupStart","dragGroup","dragGroupEnd","resizeStart","beforeResize","resize","resizeEnd","resizeGroupStart","beforeResizeGroup","resizeGroup","resizeGroupEnd","scaleStart","beforeScale","scale","scaleEnd","scaleGroupStart","beforeScaleGroup","scaleGroup","scaleGroupEnd","warpStart","warp","warpEnd","rotateStart","beforeRotate","rotate","rotateEnd","rotateGroupStart","beforeRotateGroup","rotateGroup","rotateGroupEnd","scroll","scrollGroup","dragOriginStart","dragOrigin","dragOriginEnd","clipStart","clip","clipEnd","roundStart","round","roundEnd","roundGroupStart","roundGroup","roundGroupEnd","click","clickGroup","renderStart","render","renderEnd","renderGroupStart","renderGroup","renderGroupEnd"] = ["beforeRenderStart","beforeRender","beforeRenderEnd","beforeRenderGroupStart","beforeRenderGroup","beforeRenderGroupEnd","changeTargets","snap","pinchStart","pinch","pinchEnd","pinchGroupStart","pinchGroup","pinchGroupEnd","dragStart","drag","dragEnd","dragGroupStart","dragGroup","dragGroupEnd","resizeStart","beforeResize","resize","resizeEnd","resizeGroupStart","beforeResizeGroup","resizeGroup","resizeGroupEnd","scaleStart","beforeScale","scale","scaleEnd","scaleGroupStart","beforeScaleGroup","scaleGroup","scaleGroupEnd","warpStart","warp","warpEnd","rotateStart","beforeRotate","rotate","rotateEnd","rotateGroupStart","beforeRotateGroup","rotateGroup","rotateGroupEnd","scroll","scrollGroup","dragOriginStart","dragOrigin","dragOriginEnd","clipStart","clip","clipEnd","roundStart","round","roundEnd","roundGroupStart","roundGroup","roundGroupEnd","click","clickGroup","renderStart","render","renderEnd","renderGroupStart","renderGroup","renderGroupEnd"]; diff --git a/packages/react-moveable/package.json b/packages/react-moveable/package.json index a7e9b70f4..c5f59171d 100644 --- a/packages/react-moveable/package.json +++ b/packages/react-moveable/package.json @@ -23,8 +23,9 @@ "test:fail": "SKIP_TEST=true test-storybook", "test:fail-build": "SKIP_TEST=true build-storybook -o ./test-static", "test:fail-ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"yarn test:fail-build --quiet && npx http-server ./test-static --port 6006 --silent\" \"wait-on tcp:6006 && yarn test:fail\"", + "test:type": "tsc -p tsconfig.test.json", "coverage": "test-storybook --maxWorkers=2 --coverage", - "build": "npm run lint && rollup -c && npm run declaration && print-sizes ./dist ", + "build": "npm run lint && npm run test:type && rollup -c && npm run declaration && print-sizes ./dist", "build:storybook": "SKIP_TEST=true build-storybook -o ../../demo/storybook", "declaration": "rm -rf declaration && tsc -p tsconfig.declaration.json" }, diff --git a/packages/react-moveable/src/ables/AbleManager.ts b/packages/react-moveable/src/ables/AbleManager.ts index 6241eb135..e1ba190a1 100644 --- a/packages/react-moveable/src/ables/AbleManager.ts +++ b/packages/react-moveable/src/ables/AbleManager.ts @@ -6,8 +6,8 @@ export function makeAble< Props extends DefaultProps, >(name: Name, able: AbleObject) { return { - events: [] as const, - props: [] as Array, + events: [] as AbleObject["events"] extends readonly any[] ? AbleObject["events"] : readonly [], + props: [] as AbleObject["props"] extends readonly any[] ? AbleObject["props"] : readonly [], name, ...able, } as const; diff --git a/packages/react-moveable/src/ables/Default.ts b/packages/react-moveable/src/ables/Default.ts index 2625798c4..2b5c86541 100644 --- a/packages/react-moveable/src/ables/Default.ts +++ b/packages/react-moveable/src/ables/Default.ts @@ -12,7 +12,6 @@ export default { "zoom", "dragFocusedInput", "transformOrigin", - "edge", "ables", "className", "pinchThreshold", @@ -32,7 +31,6 @@ export default { "useAccuratePosition", "firstRenderState", "linePadding", - "displayAroundControls", "controlPadding", "preventDefault", "requestStyles", diff --git a/packages/react-moveable/src/ables/Padding.tsx b/packages/react-moveable/src/ables/Padding.tsx index ed462d9d4..9c0736407 100644 --- a/packages/react-moveable/src/ables/Padding.tsx +++ b/packages/react-moveable/src/ables/Padding.tsx @@ -4,6 +4,7 @@ import { createWarpMatrix } from "@scena/matrix"; import { makeAble } from "./AbleManager"; export default makeAble("padding", { + props: ["padding"] as const, render(moveable: MoveableManagerInterface, React: Renderer): any[] { const props = moveable.props; if (props.dragArea) { diff --git a/packages/react-moveable/tests/types.ts b/packages/react-moveable/tests/types.ts index b8a5e8998..fbd3a801f 100644 --- a/packages/react-moveable/tests/types.ts +++ b/packages/react-moveable/tests/types.ts @@ -1,4 +1,3 @@ -import { IObject } from "@daybrush/utils"; import { DraggableEvents, ResizableEvents, ScalableEvents, RotatableEvents, DraggableOptions, @@ -8,12 +7,13 @@ import { ClippableOptions, ClippableEvents, OriginDraggableEvents, DefaultOptions, DragAreaOptions, PinchableOptions, PinchableEvents, ScrollableEvents, - ScrollableOptions, MoveableProps, ScrollableProps, PinchableProps, DragAreaProps, - OriginDraggableProps, ClippableProps, RoundableProps, SnappableProps, WarpableProps, - RotatableProps, ScalableProps, ResizableProps, DraggableProps, OriginOptions, - PaddingOptions, GroupableProps, ExcludeKeys, OriginDraggableOptions, - MoveableOptions, BeforeRenderableEvents, + ScrollableOptions, + + OriginOptions, + PaddingOptions, OriginDraggableOptions, + MoveableOptions, BeforeRenderableEvents, ClickableOptions, MoveableEvents, MoveableDefaultEvents, } from "../src"; + import Draggable from "../src/ables/Draggable"; import Resizable from "../src/ables/Resizable"; import Scalable from "../src/ables/Scalable"; @@ -28,7 +28,6 @@ import Clippable from "../src/ables/Clippable"; import OriginDraggable from "../src/ables/OriginDraggable"; import Pinchable from "../src/ables/Pinchable"; import Scrollable from "../src/ables/Scrollable"; -import { MOVEABLE_PROPS_MAP, MOVEABLE_EVENTS_PROPS_MAP } from "../src/ables/consts"; import Origin from "../src/ables/Origin"; import Padding from "../src/ables/Padding"; import Renderable from "../src/ables/Renderable"; @@ -37,91 +36,61 @@ import Clickable from "../src/ables/Clickable"; type MatchTypes< T extends { [key in keyof Required]: any }, - E extends IObject> = { - [key in keyof Required]: Required[key] - }; + E extends { [key in keyof Required]: any }, +> = any; type Writable = { -readonly [key in keyof T]: any }; -export type P00 = MatchTypes; -export type P01 = MatchTypes; -export type P02 = MatchTypes; -export type P03 = MatchTypes; - -export type E1 = MatchTypes; -export type P1 = MatchTypes; -export type PP1 = MatchTypes; - -export type E2 = MatchTypes; -export type P2 = MatchTypes; -export type PP2 = MatchTypes; - -export type E3 = MatchTypes; -export type P3 = MatchTypes; -export type PP3 = MatchTypes; - -export type E4 = MatchTypes; -export type P4 = MatchTypes; -export type PP4 = MatchTypes; - -export type E6 = MatchTypes; -export type P6 = MatchTypes; -export type PP6 = MatchTypes; - -export type E7 = MatchTypes; -export type P7 = MatchTypes; -export type PP7 = MatchTypes; - -export type E8 = MatchTypes; -export type P8 = MatchTypes; -export type PP8 = MatchTypes; - -export type E9 = MatchTypes; -export type P9 = MatchTypes; -export type PP9 = MatchTypes< - typeof Resizable["events"] & - typeof Resizable["props"] & - typeof Draggable["events"] & - typeof Draggable["props"] & - typeof Scalable["events"] & - typeof Scalable["props"] & - typeof Rotatable["events"] & - typeof Rotatable["props"] & - typeof Pinchable["events"] & - typeof Pinchable["props"] & - typeof Pinchable["events"] & - typeof Pinchable["props"], PinchableProps>; - -export type P10 = MatchTypes; -export type PP10 = MatchTypes>; - -export type E11 = MatchTypes; -export type P11 = MatchTypes; -export type PP11 = MatchTypes; - -export type E12 = MatchTypes; -export type P12 = MatchTypes; -export type PP12 = MatchTypes; - -export type E13 = MatchTypes; - -export type P13 - = MatchTypes - & MatchTypes, typeof Clippable["props"]>; -export type PP13 = MatchTypes; - -export type E14 = MatchTypes; - -export type E15 = MatchTypes; - -export type P15 - = MatchTypes - & MatchTypes, typeof Scrollable["props"]>; -export type PP15 = MatchTypes; - -export type E16 = MatchTypes; - -export type E17 = MatchTypes; - -export type PAll = MatchTypes; -export type PAllOptions = MatchTypes; -export type PAllOptions2 = MatchTypes, typeof MOVEABLE_PROPS_MAP>; +type PropsTester = MoveableOptions> = { + -readonly [key in Able["props"][number]]: Props[key]; +}; +type EventsTester = MoveableEvents> = { + -readonly [key in Able["events"][number] as `on${Capitalize}`]: Events[key]; +}; + +interface EmptyOptions { } + +export type TestProps = [ + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, +]; + +export type TestProps2 = [ + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, + MatchTypes, Required>, +]; diff --git a/packages/react-moveable/tsconfig.test.json b/packages/react-moveable/tsconfig.test.json index e158e243d..40acf7f75 100644 --- a/packages/react-moveable/tsconfig.test.json +++ b/packages/react-moveable/tsconfig.test.json @@ -1,25 +1,11 @@ { "extends": "./tsconfig", "compilerOptions": { - "module": "commonjs", - "noImplicitAny": false, "jsx": "react", - "types": [ - "karma-chai", - "mocha" - ], - "strict": false, - "strictNullChecks": false, - "forceConsistentCasingInFileNames": false, - "resolveJsonModule": false, - "isolatedModules": false, - "noEmit": false, - "allowUnreachableCode": true, - "allowUnusedLabels": true + "noEmit": true }, "include": [ - "./src/**/*.ts", - "./test/**/*.ts", - "./test/**/*.tsx" + "./tests/**/*.ts", + "./tests/**/*.tsx" ] }