@udecode/plate-resizable
Advanced tools
Comparing version 36.0.0 to 37.0.0
@@ -79,5 +79,5 @@ "use strict"; | ||
// src/components/Resizable.tsx | ||
var import_react2 = __toESM(require("react")); | ||
var import_plate_common3 = require("@udecode/plate-common"); | ||
var import_server = require("@udecode/plate-common/server"); | ||
var import_react4 = __toESM(require("react")); | ||
var import_plate_common = require("@udecode/plate-common"); | ||
var import_react5 = require("@udecode/plate-common/react"); | ||
@@ -134,7 +134,7 @@ // src/utils/isTouchEvent.ts | ||
var import_react = __toESM(require("react")); | ||
var import_plate_common = require("@udecode/plate-common"); | ||
var import_react2 = require("@udecode/plate-common/react"); | ||
var initialState = { | ||
onResize: null | ||
}; | ||
var { ResizeHandleProvider, useResizeHandleStore } = (0, import_plate_common.createAtomStore)( | ||
var { ResizeHandleProvider, useResizeHandleStore } = (0, import_react2.createAtomStore)( | ||
initialState, | ||
@@ -262,3 +262,3 @@ { name: "resizeHandle" } | ||
}; | ||
var ResizeHandle = (0, import_plate_common.createPrimitiveComponent)("div")({ | ||
var ResizeHandle = (0, import_react2.createPrimitiveComponent)("div")({ | ||
propsHook: useResizeHandle, | ||
@@ -269,4 +269,4 @@ stateHook: useResizeHandleState | ||
// src/components/useResizableStore.ts | ||
var import_plate_common2 = require("@udecode/plate-common"); | ||
var { ResizableProvider, resizableStore, useResizableStore } = (0, import_plate_common2.createAtomStore)( | ||
var import_react3 = require("@udecode/plate-common/react"); | ||
var { ResizableProvider, resizableStore, useResizableStore } = (0, import_react3.createAtomStore)( | ||
{ | ||
@@ -285,15 +285,15 @@ width: 0 | ||
var _a; | ||
const element = (0, import_plate_common3.useElement)(); | ||
const editor = (0, import_plate_common3.useEditorRef)(); | ||
const element = (0, import_react5.useElement)(); | ||
const editor = (0, import_react5.useEditorRef)(); | ||
const nodeWidth = (_a = element == null ? void 0 : element.width) != null ? _a : "100%"; | ||
const [width, setWidth] = useResizableStore().use.width(); | ||
const setNodeWidth = import_react2.default.useCallback( | ||
const setNodeWidth = import_react4.default.useCallback( | ||
(w) => { | ||
const path = (0, import_plate_common3.findNodePath)(editor, element); | ||
const path = (0, import_react5.findNodePath)(editor, element); | ||
if (!path) | ||
return; | ||
if (w === nodeWidth) { | ||
(0, import_server.select)(editor, path); | ||
(0, import_plate_common.select)(editor, path); | ||
} else { | ||
(0, import_server.setNodes)(editor, { width: w }, { at: path }); | ||
(0, import_plate_common.setNodes)(editor, { width: w }, { at: path }); | ||
} | ||
@@ -303,3 +303,3 @@ }, | ||
); | ||
import_react2.default.useEffect(() => { | ||
import_react4.default.useEffect(() => { | ||
setWidth(nodeWidth); | ||
@@ -324,6 +324,6 @@ }, [nodeWidth, setWidth]); | ||
}) => { | ||
const wrapperRef = import_react2.default.useRef(null); | ||
const wrapperRef = import_react4.default.useRef(null); | ||
return { | ||
context: { | ||
onResize: import_react2.default.useCallback( | ||
onResize: import_react4.default.useCallback( | ||
({ delta, direction, finished, initialSize }) => { | ||
@@ -365,7 +365,7 @@ const wrapperStaticWidth = wrapperRef.current.offsetWidth; | ||
}; | ||
var Resizable = import_react2.default.forwardRef((_a, ref) => { | ||
var Resizable = import_react4.default.forwardRef((_a, ref) => { | ||
var _b = _a, { children, options } = _b, rest = __objRest(_b, ["children", "options"]); | ||
const state = useResizableState(options); | ||
const { context, props, wrapperProps, wrapperRef } = useResizable(state); | ||
return /* @__PURE__ */ import_react2.default.createElement("div", __spreadValues({ ref: wrapperRef }, wrapperProps), /* @__PURE__ */ import_react2.default.createElement("div", __spreadValues(__spreadValues({ ref }, props), rest), /* @__PURE__ */ import_react2.default.createElement(ResizeHandleProvider, { onResize: context.onResize }, children))); | ||
return /* @__PURE__ */ import_react4.default.createElement("div", __spreadValues({ ref: wrapperRef }, wrapperProps), /* @__PURE__ */ import_react4.default.createElement("div", __spreadValues(__spreadValues({ ref }, props), rest), /* @__PURE__ */ import_react4.default.createElement(ResizeHandleProvider, { onResize: context.onResize }, children))); | ||
}); | ||
@@ -372,0 +372,0 @@ Resizable.displayName = "Resizable"; |
{ | ||
"name": "@udecode/plate-resizable", | ||
"version": "36.0.0", | ||
"description": "Resize components", | ||
"license": "MIT", | ||
"version": "37.0.0", | ||
"description": "Plate React resize components", | ||
"keywords": [ | ||
"plate", | ||
"resize" | ||
], | ||
"homepage": "https://platejs.org", | ||
"bugs": { | ||
"url": "https://github.com/udecode/plate/issues" | ||
}, | ||
"repository": { | ||
@@ -12,12 +18,4 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/udecode/plate/issues" | ||
}, | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"exports": { | ||
@@ -31,6 +29,12 @@ ".": { | ||
}, | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"scripts": { | ||
"brl": "yarn p:brl", | ||
"build": "yarn p:build", | ||
"build:watch": "yarn p:build:watch", | ||
"brl": "yarn p:brl", | ||
"clean": "yarn p:clean", | ||
@@ -47,14 +51,10 @@ "lint": "yarn p:lint", | ||
"peerDependencies": { | ||
"@udecode/plate-common": ">=36.0.0", | ||
"@udecode/plate-common": ">=37.0.0", | ||
"react": ">=16.8.0", | ||
"react-dom": ">=16.8.0", | ||
"slate": ">=0.94.0", | ||
"slate": ">=0.103.0", | ||
"slate-history": ">=0.93.0", | ||
"slate-hyperscript": ">=0.66.0", | ||
"slate-react": ">=0.99.0" | ||
"slate-react": ">=0.108.0" | ||
}, | ||
"keywords": [ | ||
"plate", | ||
"resize" | ||
], | ||
"publishConfig": { | ||
@@ -61,0 +61,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70698
53268
850