@get-set/gs-sortable 0.0.35 → 0.0.37
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 +99 -1
- package/actions/afterAllImagesLoad.ts +36 -0
- package/actions/calculate.ts +155 -0
- package/actions/calculateOnSort.ts +270 -0
- package/actions/checkItemInContainer.ts +22 -0
- package/actions/destroy.ts +30 -0
- package/actions/general.ts +72 -0
- package/actions/getCurrentParams.ts +32 -0
- package/actions/init.ts +31 -0
- package/actions/initDraggable.ts +85 -0
- package/actions/initMouseMove.ts +120 -0
- package/actions/initScroll.ts +21 -0
- package/actions/initSortEnd.ts +87 -0
- package/components/GSSortable.tsx +160 -0
- package/components/styles/GSSortable.css +39 -0
- package/components/styles/GSSortable.scss +38 -0
- package/components/styles/GSSortableCSS.ts +41 -0
- package/constants/constParams.ts +5 -0
- package/constants/defaultParams.ts +20 -0
- package/constants/types.ts +7 -0
- package/dist/GSSortable.d.ts +2 -0
- package/dist/actions/afterAllImagesLoad.d.ts +4 -0
- package/dist/actions/afterAllImagesLoad.d.ts.map +1 -0
- package/dist/actions/afterAllImagesLoad.js +35 -0
- package/dist/actions/afterAllImagesLoad.js.map +1 -0
- package/dist/actions/calculate.d.ts +3 -2
- package/dist/actions/calculate.d.ts.map +1 -0
- package/dist/actions/calculate.js +13 -18
- package/dist/actions/calculate.js.map +1 -1
- package/dist/actions/calculateOnSort.d.ts +3 -2
- package/dist/actions/calculateOnSort.d.ts.map +1 -0
- package/dist/actions/calculateOnSort.js +164 -58
- package/dist/actions/calculateOnSort.js.map +1 -1
- package/dist/actions/checkItemInContainer.d.ts +1 -0
- package/dist/actions/checkItemInContainer.d.ts.map +1 -0
- package/dist/actions/checkItemInContainer.js +8 -17
- package/dist/actions/checkItemInContainer.js.map +1 -1
- package/dist/actions/destroy.d.ts +3 -8
- package/dist/actions/destroy.d.ts.map +1 -0
- package/dist/actions/destroy.js +7 -9
- package/dist/actions/destroy.js.map +1 -1
- package/dist/actions/general.d.ts +1 -0
- package/dist/actions/general.d.ts.map +1 -0
- package/dist/actions/general.js +5 -12
- package/dist/actions/general.js.map +1 -1
- package/dist/actions/getCurrentParams.d.ts +4 -9
- package/dist/actions/getCurrentParams.d.ts.map +1 -0
- package/dist/actions/getCurrentParams.js +15 -18
- package/dist/actions/getCurrentParams.js.map +1 -1
- package/dist/actions/init.d.ts +3 -2
- package/dist/actions/init.d.ts.map +1 -0
- package/dist/actions/init.js +13 -16
- package/dist/actions/init.js.map +1 -1
- package/dist/actions/initDraggable.d.ts +3 -2
- package/dist/actions/initDraggable.d.ts.map +1 -0
- package/dist/actions/initDraggable.js +14 -22
- package/dist/actions/initDraggable.js.map +1 -1
- package/dist/actions/initMouseMove.d.ts +1 -0
- package/dist/actions/initMouseMove.d.ts.map +1 -0
- package/dist/actions/initMouseMove.js +40 -53
- package/dist/actions/initMouseMove.js.map +1 -1
- package/dist/actions/initScroll.d.ts +1 -0
- package/dist/actions/initScroll.d.ts.map +1 -0
- package/dist/actions/initScroll.js +7 -15
- package/dist/actions/initScroll.js.map +1 -1
- package/dist/actions/initSortEnd.d.ts +2 -1
- package/dist/actions/initSortEnd.d.ts.map +1 -0
- package/dist/actions/initSortEnd.js +62 -71
- package/dist/actions/initSortEnd.js.map +1 -1
- package/dist/components/GSSortable.d.ts +4 -19
- package/dist/components/GSSortable.d.ts.map +1 -0
- package/dist/components/GSSortable.js +72 -105
- package/dist/components/GSSortable.js.map +1 -1
- package/dist/components/styles/GSSortableCSS.d.ts +2 -1
- package/dist/components/styles/GSSortableCSS.d.ts.map +1 -0
- package/dist/components/styles/GSSortableCSS.js +3 -4
- package/dist/components/styles/GSSortableCSS.js.map +1 -1
- package/dist/constants/constParams.d.ts +4 -3
- package/dist/constants/constParams.d.ts.map +1 -0
- package/dist/constants/constParams.js +2 -4
- package/dist/constants/constParams.js.map +1 -1
- package/dist/constants/defaultParams.d.ts +3 -2
- package/dist/constants/defaultParams.d.ts.map +1 -0
- package/dist/constants/defaultParams.js +3 -8
- package/dist/constants/defaultParams.js.map +1 -1
- package/dist/constants/types.d.ts +1 -0
- package/dist/constants/types.d.ts.map +1 -0
- package/dist/constants/types.js +1 -3
- package/dist/constants/types.js.map +1 -1
- package/dist/helpers/uihelpers.d.ts +2 -1
- package/dist/helpers/uihelpers.d.ts.map +1 -0
- package/dist/helpers/uihelpers.js +9 -23
- package/dist/helpers/uihelpers.js.map +1 -1
- package/dist/types/params.d.ts +23 -0
- package/dist/types/params.d.ts.map +1 -0
- package/dist/types/params.js +2 -0
- package/dist/types/params.js.map +1 -0
- package/dist/types/ref.d.ts +41 -0
- package/dist/types/ref.d.ts.map +1 -0
- package/dist/types/ref.js +2 -0
- package/dist/types/ref.js.map +1 -0
- package/dist-js/bundle.js +1181 -0
- package/helpers/uihelpers.ts +44 -0
- package/package.json +71 -43
- package/styles/GSSortable.css +39 -0
- package/styles/GSSortable.scss +38 -0
- package/types/global.d.ts +19 -0
- package/types/params.ts +24 -0
- package/types/ref.ts +41 -0
- package/index.js +0 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const NewGuid = (): string => {
|
|
2
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
3
|
+
const r = (Math.random() * 16) | 0;
|
|
4
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
5
|
+
return v.toString(16);
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const removeCssFromHead = (key: string): void => {
|
|
10
|
+
const style = document.querySelector(`head style[data-key='${key}']`);
|
|
11
|
+
if (style != null) {
|
|
12
|
+
style.remove();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const injectCssToHead = (css: string, key: string): void => {
|
|
17
|
+
const style = document.createElement('style');
|
|
18
|
+
style.dataset.key = key;
|
|
19
|
+
style.innerHTML = css;
|
|
20
|
+
document.head.appendChild(style);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const camelToKebab = (str: string): string =>
|
|
24
|
+
str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
25
|
+
|
|
26
|
+
export const convertScssToCss = (scssObj: Record<string, any>): string => {
|
|
27
|
+
const convertObjectToCss = (
|
|
28
|
+
obj: Record<string, any>,
|
|
29
|
+
parent: string = '',
|
|
30
|
+
): string => {
|
|
31
|
+
let css = '';
|
|
32
|
+
for (const key in obj) {
|
|
33
|
+
const value = obj[key];
|
|
34
|
+
if (typeof value === 'object') {
|
|
35
|
+
const newParent = parent ? `${parent} ${key}` : key;
|
|
36
|
+
css += convertObjectToCss(value, newParent);
|
|
37
|
+
} else {
|
|
38
|
+
css += `${parent} { ${camelToKebab(key)}: ${value}; }\n`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return css;
|
|
42
|
+
};
|
|
43
|
+
return convertObjectToCss(scssObj, '');
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,43 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@get-set/gs-sortable",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Get-Set Sortable",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@get-set/gs-sortable",
|
|
3
|
+
"version": "0.0.37",
|
|
4
|
+
"description": "Get-Set Sortable",
|
|
5
|
+
"author": "Get-Set",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"main": "dist/components/GSSortable.js",
|
|
8
|
+
"module": "dist/components/GSSortable.js",
|
|
9
|
+
"types": "dist/components/GSSortable.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/components/GSSortable.js",
|
|
13
|
+
"require": "./dist-js/bundle.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "npm run build:js && npm run build:react",
|
|
18
|
+
"build:js": "webpack --config webpack.config.js",
|
|
19
|
+
"build:react": "tsc -p tsconfig.react.json"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"grid",
|
|
23
|
+
"sortable",
|
|
24
|
+
"draggable",
|
|
25
|
+
"droppable",
|
|
26
|
+
"plugin",
|
|
27
|
+
"react",
|
|
28
|
+
"react-component"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"webpack": "^5.94.0",
|
|
32
|
+
"webpack-cli": "^5.1.4"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": "^16.8.0 || ^17.0 || ^18.0 || ^19.0",
|
|
36
|
+
"react-dom": "^16.8.0 || ^17.0 || ^18.0 || ^19.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"react": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"react-dom": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@babel/cli": "^7.24.0",
|
|
48
|
+
"@babel/core": "^7.24.0",
|
|
49
|
+
"@babel/preset-env": "^7.24.0",
|
|
50
|
+
"@babel/preset-typescript": "^7.24.0",
|
|
51
|
+
"@types/react": "^18.0.0",
|
|
52
|
+
"babel-loader": "^9.1.3",
|
|
53
|
+
"react": "^18.0.0",
|
|
54
|
+
"react-dom": "^18.0.0",
|
|
55
|
+
"ts-loader": "^9.5.4",
|
|
56
|
+
"typescript": "^5.3.0"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"dist-js",
|
|
61
|
+
"components",
|
|
62
|
+
"constants",
|
|
63
|
+
"types",
|
|
64
|
+
"actions",
|
|
65
|
+
"helpers",
|
|
66
|
+
"styles"
|
|
67
|
+
],
|
|
68
|
+
"publishConfig": {
|
|
69
|
+
"access": "public"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.gs-sortable-instance {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
-webkit-user-select: none !important;
|
|
4
|
+
-moz-user-select: none !important;
|
|
5
|
+
user-select: none !important;
|
|
6
|
+
transition: 0.4s;
|
|
7
|
+
z-index: 1;
|
|
8
|
+
}
|
|
9
|
+
.gs-sortable-instance.gs-sortable-active {
|
|
10
|
+
z-index: 2;
|
|
11
|
+
}
|
|
12
|
+
.gs-sortable-instance * {
|
|
13
|
+
-webkit-user-select: none !important;
|
|
14
|
+
-moz-user-select: none !important;
|
|
15
|
+
user-select: none !important;
|
|
16
|
+
}
|
|
17
|
+
.gs-sortable-instance .gs-sortable-placeholder {
|
|
18
|
+
position: absolute;
|
|
19
|
+
background-color: #f1f1f1;
|
|
20
|
+
border: 1px solid;
|
|
21
|
+
z-index: 1;
|
|
22
|
+
}
|
|
23
|
+
.gs-sortable-instance .gs-sortable-item {
|
|
24
|
+
z-index: 2;
|
|
25
|
+
}
|
|
26
|
+
.gs-sortable-instance .gs-sortable-item.gs-sortable-item-active-parent {
|
|
27
|
+
z-index: 3;
|
|
28
|
+
}
|
|
29
|
+
.gs-sortable-instance .gs-sortable-item-inmove {
|
|
30
|
+
transition: none !important;
|
|
31
|
+
z-index: 99999;
|
|
32
|
+
}
|
|
33
|
+
.gs-sortable-instance .gs-sortable-item-addjusting {
|
|
34
|
+
z-index: 99999;
|
|
35
|
+
}
|
|
36
|
+
.gs-sortable-instance.gs-sortable-row .gs-sortable-item {
|
|
37
|
+
width: -moz-max-content;
|
|
38
|
+
width: max-content;
|
|
39
|
+
}/*# sourceMappingURL=GSSortable.css.map */
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.gs-sortable-instance {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
user-select: none !important;
|
|
4
|
+
transition: 0.4s;
|
|
5
|
+
z-index: 1;
|
|
6
|
+
&.gs-sortable-active {
|
|
7
|
+
z-index: 2;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
* {
|
|
11
|
+
user-select: none !important;
|
|
12
|
+
}
|
|
13
|
+
.gs-sortable-placeholder {
|
|
14
|
+
position: absolute;
|
|
15
|
+
background-color: #f1f1f1;
|
|
16
|
+
border: 1px solid;
|
|
17
|
+
z-index: 1;
|
|
18
|
+
}
|
|
19
|
+
.gs-sortable-item {
|
|
20
|
+
z-index: 2;
|
|
21
|
+
&.gs-sortable-item-active-parent {
|
|
22
|
+
z-index: 3;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
.gs-sortable-item-inmove {
|
|
26
|
+
//transition: width 0.2s, height 0.2s !important;
|
|
27
|
+
transition: none !important;
|
|
28
|
+
z-index: 99999;
|
|
29
|
+
}
|
|
30
|
+
.gs-sortable-item-addjusting {
|
|
31
|
+
z-index: 99999;
|
|
32
|
+
}
|
|
33
|
+
&.gs-sortable-row {
|
|
34
|
+
.gs-sortable-item {
|
|
35
|
+
width: max-content;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Ref, DraggableInfo } from './ref';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
GSSortable: any;
|
|
6
|
+
GSSortableConfigue?: {
|
|
7
|
+
references: Array<{ key: string; ref: Ref }>;
|
|
8
|
+
overInItemRef?: Ref;
|
|
9
|
+
takeFrom?: Ref;
|
|
10
|
+
draggableInfo?: DraggableInfo;
|
|
11
|
+
instance: (ref: string) => Ref | undefined;
|
|
12
|
+
};
|
|
13
|
+
// Scroll position tracking for drag-while-scroll correction
|
|
14
|
+
scrollY: number;
|
|
15
|
+
scrollX: number;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {};
|
package/types/params.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ResponsiveOption {
|
|
2
|
+
windowSize: number;
|
|
3
|
+
params: Partial<Params>;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Params {
|
|
7
|
+
reference?: string;
|
|
8
|
+
handler?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
width?: string;
|
|
11
|
+
takeClone?: boolean;
|
|
12
|
+
afterSort?: (items: NodeListOf<Element>) => void;
|
|
13
|
+
gsx?: Record<string, any>;
|
|
14
|
+
gap?: string;
|
|
15
|
+
allowOutOfBox?: boolean;
|
|
16
|
+
count?: number;
|
|
17
|
+
type?: 'row' | 'column' | 'grid';
|
|
18
|
+
// Array of reference keys from other GSSortable instances that can drop into this one
|
|
19
|
+
acceptFrom?: string[];
|
|
20
|
+
responsive?: ResponsiveOption[];
|
|
21
|
+
beforeInit?: () => void;
|
|
22
|
+
afterInit?: () => void;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
package/types/ref.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Params } from './params';
|
|
2
|
+
|
|
3
|
+
export interface UiData {
|
|
4
|
+
containerPT: number;
|
|
5
|
+
containerPR: number;
|
|
6
|
+
containerPB: number;
|
|
7
|
+
containerPL: number;
|
|
8
|
+
containerWidth: number;
|
|
9
|
+
currentHeight: number;
|
|
10
|
+
currentWidth: number;
|
|
11
|
+
itemWidth: number;
|
|
12
|
+
gapX: number;
|
|
13
|
+
gapY: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Ref {
|
|
17
|
+
grid: HTMLElement;
|
|
18
|
+
currentParams: Params & { reference: string };
|
|
19
|
+
itemWidth?: string;
|
|
20
|
+
uiData?: UiData;
|
|
21
|
+
count?: number;
|
|
22
|
+
isAdjusting: boolean;
|
|
23
|
+
itemResizeObservers?: ResizeObserver[];
|
|
24
|
+
calculate?: () => void;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
refresh: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface DraggableInfo {
|
|
30
|
+
moved: boolean;
|
|
31
|
+
ref: Ref;
|
|
32
|
+
$el: HTMLElement;
|
|
33
|
+
clientX: number;
|
|
34
|
+
clientY: number;
|
|
35
|
+
fromTop: number;
|
|
36
|
+
fromLeft: number;
|
|
37
|
+
placeholder?: HTMLElement;
|
|
38
|
+
newTop: number;
|
|
39
|
+
newLeft: number;
|
|
40
|
+
index?: number;
|
|
41
|
+
}
|
package/index.js
DELETED