Skip to content

Commit 552b0ce

Browse files
committed
Updated/Added packages for latest release
1 parent 0932963 commit 552b0ce

File tree

713 files changed

+12317
-1028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

713 files changed

+12317
-1028
lines changed

components/base/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ Check the changelog [here](https://github.com/syncfusion/react-ui-components/blo
4343
4444
See [LICENSE FILE](https://github.com/syncfusion/react-ui-components/blob/master/license?utm_source=npm&utm_campaign=notification) for more info.
4545

46-
© Copyright 2025 Syncfusion, Inc. All Rights Reserved. The Syncfusion Essential Studio license and copyright applies to this distribution.
46+
© Copyright 2025 Syncfusion, Inc. All Rights Reserved. The Syncfusion Essential Studio license and copyright applies to this distribution.

components/base/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ gulp.task('styles', function (done) {
4848
/**
4949
* Build ts and scss files
5050
*/
51-
gulp.task('build', gulp.series('scripts', 'styles'));
51+
gulp.task('build', gulp.series('scripts'));
5252

components/base/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@syncfusion/react-base",
3-
"version": "29.2.4",
4-
"description": "A common package of core Pure React base, methods and class definitions",
3+
"version": "30.1.37",
4+
"description": "A common package of core React base, methods and class definitions",
55
"author": "Syncfusion Inc.",
66
"license": "SEE LICENSE IN license",
77
"keywords": [
@@ -21,6 +21,9 @@
2121
"homepage": "https://www.syncfusion.com/react-ui-components",
2222
"module": "./index.js",
2323
"readme": "README.md",
24+
"bin": {
25+
"syncfusion-license": "bin/syncfusion-license.js"
26+
},
2427
"devDependencies": {
2528
"gulp": "4.0.2",
2629
"gulp-typescript": "5.0.1",

components/base/src/drag-util.tsx

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
import { select } from './dom';
2+
import { IPosition } from './draggable';
3+
import { isNullOrUndefined } from './util';
4+
5+
/**
6+
* Position coordinates
7+
*/
8+
export interface PositionCoordinates {
9+
left?: number;
10+
top?: number;
11+
bottom?: number;
12+
right?: number;
13+
}
14+
15+
/**
16+
* Coordinates for element position
17+
*
18+
* @private
19+
*/
20+
export interface Coordinates {
21+
/**
22+
* Defines the x Coordinate of page.
23+
*/
24+
pageX?: number;
25+
/**
26+
* Defines the y Coordinate of page.
27+
*/
28+
pageY?: number;
29+
/**
30+
* Defines the x Coordinate of client.
31+
*/
32+
clientX?: number;
33+
/**
34+
* Defines the y Coordinate of client.
35+
*/
36+
clientY?: number;
37+
}
38+
39+
let left: number;
40+
let top: number;
41+
let width: number;
42+
let height: number;
43+
44+
/**
45+
* Sets the permitted drag area boundaries based on the defined dragArea.
46+
*
47+
* @private
48+
* @param {HTMLElement | string} dragArea - The element or selector string defining the drag area
49+
* @param {Element} helperElement - The helper element used in dragging
50+
* @param {PositionCoordinates} borderWidth - The border width of the drag area
51+
* @param {PositionCoordinates} padding - The padding of the drag area
52+
* @param {PositionCoordinates} dragLimit - The object to store the calculated drag limits
53+
* @returns {void}
54+
*/
55+
export function setDragArea(
56+
dragArea: HTMLElement | string, helperElement: Element,
57+
borderWidth: PositionCoordinates, padding: PositionCoordinates,
58+
dragLimit: PositionCoordinates
59+
): void {
60+
let eleWidthBound: number;
61+
let eleHeightBound: number;
62+
let top: number = 0;
63+
let left: number = 0;
64+
let ele: HTMLElement;
65+
const type: string = typeof dragArea;
66+
if (type === 'string') {
67+
ele = select(dragArea as string) as HTMLElement;
68+
} else {
69+
ele = dragArea as HTMLElement;
70+
}
71+
if (ele) {
72+
const elementArea: ClientRect | DOMRect = ele.getBoundingClientRect();
73+
eleWidthBound = ele.scrollWidth ? ele.scrollWidth : elementArea.right - elementArea.left;
74+
eleHeightBound = ele.scrollHeight ? (dragArea && !isNullOrUndefined(helperElement) && helperElement.classList.contains('sf-treeview')) ? ele.clientHeight : ele.scrollHeight : elementArea.bottom - elementArea.top;
75+
const keys: string[] = ['Top', 'Left', 'Bottom', 'Right'];
76+
const styles: CSSStyleDeclaration = getComputedStyle(ele);
77+
for (let i: number = 0; i < keys.length; i++) {
78+
const key: string = keys[parseInt(i.toString(), 10)];
79+
const tborder: string = styles['border' + key + 'Width'];
80+
const tpadding: string = styles['padding' + key];
81+
const lowerKey: string = key.toLowerCase();
82+
(borderWidth as Record<string, number>)[`${lowerKey}`] = isNaN(parseFloat(tborder)) ? 0 : parseFloat(tborder);
83+
(padding as Record<string, number>)[`${lowerKey}`] = isNaN(parseFloat(tpadding)) ? 0 : parseFloat(tpadding);
84+
}
85+
if (dragArea && !isNullOrUndefined(helperElement) && helperElement.classList.contains('sf-treeview')) {
86+
top = elementArea.top + document.scrollingElement.scrollTop;
87+
} else {
88+
top = elementArea.top;
89+
}
90+
left = elementArea.left;
91+
dragLimit.left = left + borderWidth.left + padding.left;
92+
dragLimit.top = ele.offsetTop + borderWidth.top + padding.top;
93+
dragLimit.right = left + eleWidthBound - (borderWidth.right + padding.right);
94+
dragLimit.bottom = top + eleHeightBound - (borderWidth.bottom + padding.bottom);
95+
}
96+
}
97+
98+
/**
99+
* Retrieves the document's full height or width, considering the scroll and offset values.
100+
*
101+
* @private
102+
* @param {string} str - The dimension type ('Height' or 'Width') to calculate.
103+
* @returns {number} - The maximum value across scroll, offset, and client dimensions.
104+
*/
105+
export function getDocumentWidthHeight(str: 'Height' | 'Width'): number {
106+
const docBody: HTMLElement = document.body;
107+
const docEle: HTMLElement = document.documentElement;
108+
return Math.max(
109+
docBody['scroll' + str], docEle['scroll' + str],
110+
docBody['offset' + str], docEle['offset' + str],
111+
docEle['client' + str]
112+
);
113+
}
114+
115+
/**
116+
* Determines if a given element is within the bounds of the viewport.
117+
*
118+
* @private
119+
* @param {HTMLElement} el - The element to check.
120+
* @returns {boolean} - True if the element is in the viewport, false otherwise.
121+
*/
122+
export function elementInViewport(el: HTMLElement): boolean {
123+
top = el.offsetTop;
124+
left = el.offsetLeft;
125+
width = el.offsetWidth;
126+
height = el.offsetHeight;
127+
while (el.offsetParent) {
128+
el = el.offsetParent as HTMLElement;
129+
top += el.offsetTop;
130+
left += el.offsetLeft;
131+
}
132+
return (
133+
top >= window.pageYOffset &&
134+
left >= window.pageXOffset &&
135+
(top + height) <= (window.pageYOffset + window.innerHeight) &&
136+
(left + width) <= (window.pageXOffset + window.innerWidth)
137+
);
138+
}
139+
140+
/**
141+
* Gets the coordinates of a mouse or touch event.
142+
*
143+
* @private
144+
* @param {MouseEvent | TouchEvent} evt - The event object.
145+
* @returns {Coordinates} - The x and y coordinates of the page and client.
146+
*/
147+
export function getCoordinates(evt: MouseEvent & TouchEvent): Coordinates {
148+
if (evt.type.indexOf('touch') > -1) {
149+
return evt.changedTouches[0];
150+
}
151+
return evt as Coordinates;
152+
}
153+
154+
/**
155+
* Calculates the parent position of the element relative to the document.
156+
*
157+
* @private
158+
* @param {Element} ele - The element for which the parent position is calculated.
159+
* @returns {IPosition} - The calculated left and top position.
160+
*/
161+
export function calculateParentPosition(ele: Element): IPosition {
162+
if (isNullOrUndefined(ele)) {
163+
return { left: 0, top: 0 };
164+
}
165+
const rect: ClientRect | DOMRect = ele.getBoundingClientRect();
166+
const style: CSSStyleDeclaration = getComputedStyle(ele);
167+
return {
168+
left: (rect.left + window.pageXOffset) - parseInt(style.marginLeft, 10),
169+
top: (rect.top + window.pageYOffset) - parseInt(style.marginTop, 10)
170+
};
171+
}
172+
173+
/**
174+
* Retrieves all elements from a point defined by event coordinates.
175+
*
176+
* @private
177+
* @param {MouseEvent | TouchEvent} evt - The event object containing coordinates.
178+
* @returns {Element[]} - An array of elements located at the event's point.
179+
*/
180+
export function getPathElements(evt: MouseEvent & TouchEvent): Element[] {
181+
const elementTop: number = evt.clientX > 0 ? evt.clientX : 0;
182+
const elementLeft: number = evt.clientY > 0 ? evt.clientY : 0;
183+
return document.elementsFromPoint(elementTop, elementLeft);
184+
}
185+
186+
/**
187+
* Identifies the scrollable parent of the current node element.
188+
*
189+
* @private
190+
* @param {Element[]} nodes - The path of elements to check.
191+
* @param {boolean} reverse - Whether to reverse the array to check from bottom to top.
192+
* @returns {Element | null} - The first scrollable parent element or null.
193+
*/
194+
export function getScrollParent(nodes: Element[], reverse: boolean): Element | null {
195+
const nodeList: Element[] = reverse ? [...nodes].reverse() : nodes;
196+
for (const node of nodeList) {
197+
const computedStyle: CSSStyleDeclaration = window.getComputedStyle(node);
198+
const overflowY: string = computedStyle.overflowY;
199+
if ((overflowY === 'auto' || overflowY === 'scroll') &&
200+
node.scrollHeight > node.clientHeight) {
201+
return node;
202+
}
203+
}
204+
const scrollingElement: HTMLElement = document.scrollingElement as HTMLElement;
205+
const docOverflowY: string = window.getComputedStyle(scrollingElement).overflowY;
206+
if (docOverflowY === 'visible') {
207+
scrollingElement.style.overflow = 'auto';
208+
return scrollingElement;
209+
}
210+
return null;
211+
}

components/base/src/dragdrop.tsx

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { createContext, useContext, useState, ReactNode, RefObject, useRef } from 'react';
2+
import { IDroppable } from './droppable';
3+
4+
/**
5+
* Interface defining the methods available in the DragDropContext.
6+
*
7+
* @private
8+
*/
9+
export interface DragDropContextProps {
10+
/**
11+
* Registers a droppable instance with a unique identifier.
12+
*
13+
* @param {string} id - The unique identifier for the droppable instance
14+
* @param {DragDropContext} instance - The droppable instance to register
15+
* @returns {void}
16+
*/
17+
registerDroppable: (id: string, instance: DroppableContext) => void;
18+
19+
/**
20+
* Unregisters a droppable instance by its identifier.
21+
*
22+
* @param {string} id - The unique identifier of the droppable instance to unregister
23+
* @returns {void}
24+
*/
25+
unregisterDroppable: (id: string) => void;
26+
27+
/**
28+
* Retrieves all registered droppable instances.
29+
*
30+
* @returns {Record<string, DragDropContext>} A record of all droppable instances indexed by their identifiers
31+
*/
32+
getAllDroppables: () => Record<string, DroppableContext>;
33+
}
34+
35+
/**
36+
* Interface defining the Droppable instance reference with element.
37+
*
38+
* @private
39+
*/
40+
export interface DroppableContext extends IDroppable {
41+
element?: RefObject<HTMLElement>;
42+
}
43+
44+
const DragDropContext: React.Context<DragDropContextProps | undefined> = createContext<DragDropContextProps | undefined>(undefined);
45+
46+
/**
47+
* Custom hook that provides access to the droppable context functionality.
48+
*
49+
* @private
50+
* @returns {DragDropContextProps} The droppable context methods and state
51+
*/
52+
export const useDragDropContext: () => DragDropContextProps | undefined = (): DragDropContextProps | undefined => {
53+
const context: DragDropContextProps | undefined = useContext(DragDropContext);
54+
if (!context) {
55+
return undefined;
56+
}
57+
return context;
58+
};
59+
60+
/**
61+
* Props for the DragDrop component.
62+
*/
63+
interface DragDropProps {
64+
/**
65+
* The child components that will have access to the droppable context.
66+
*/
67+
children: ReactNode;
68+
}
69+
70+
/**
71+
* Provider component that manages droppable instances throughout the application, provides registration and retrieval methods for droppable elements.
72+
*
73+
* @param {DragDropProps} props - The component props
74+
* @param {ReactNode} props.children - The child elements to render within the provider
75+
* @returns {Element} The rendered DragDrop provider component
76+
*/
77+
export const DragDrop: React.FC<DragDropProps> = ({ children }: { children: ReactNode }) => {
78+
const [droppables, setDroppables] = useState<Record<string, DroppableContext>>({});
79+
const currentDroppables: RefObject<Record<string, DroppableContext>> = useRef<Record<string, DroppableContext>>({});
80+
81+
/**
82+
* Registers a droppable instance with a unique identifier.
83+
*
84+
* @param {string} id - The unique identifier for the droppable instance
85+
* @param {DragDropContext} instance - The droppable instance to register
86+
* @returns {void}
87+
*/
88+
const registerDroppable: (id: string, instance: DroppableContext) => void = (id: string, instance: DroppableContext): void => {
89+
setDroppables((prev: Record<string, DroppableContext>) => {
90+
const updated: {[x: string]: DroppableContext} = {
91+
...prev,
92+
[id]: instance
93+
};
94+
currentDroppables.current = updated;
95+
return updated;
96+
});
97+
};
98+
99+
/**
100+
* Unregisters a droppable instance by its identifier.
101+
*
102+
* @param {string} id - The unique identifier of the droppable instance to unregister
103+
* @returns {void}
104+
*/
105+
const unregisterDroppable: (id: string) => void = (id: string): void => {
106+
setDroppables((prev: Record<string, DroppableContext>) => {
107+
const newDroppables: Record<string, DroppableContext> = { ...prev };
108+
delete newDroppables[`${id}`];
109+
return newDroppables;
110+
});
111+
};
112+
113+
/**
114+
* Retrieves all registered droppable instances.
115+
*
116+
* @returns {Record<string, DragDropContext>} A record of all droppable instances indexed by their identifiers
117+
*/
118+
const getAllDroppables: () => Record<string, DroppableContext> = (): Record<string, DroppableContext> => {
119+
return currentDroppables.current || droppables;
120+
};
121+
122+
return (
123+
<DragDropContext.Provider value={{
124+
registerDroppable,
125+
unregisterDroppable,
126+
getAllDroppables
127+
}}>
128+
{children}
129+
</DragDropContext.Provider>
130+
);
131+
};

0 commit comments

Comments
 (0)