@get-set/gs-sortable 0.0.36 → 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.
Files changed (110) hide show
  1. package/README.md +99 -1
  2. package/actions/afterAllImagesLoad.ts +36 -0
  3. package/actions/calculate.ts +155 -0
  4. package/actions/calculateOnSort.ts +270 -0
  5. package/actions/checkItemInContainer.ts +22 -0
  6. package/actions/destroy.ts +30 -0
  7. package/actions/general.ts +72 -0
  8. package/actions/getCurrentParams.ts +32 -0
  9. package/actions/init.ts +31 -0
  10. package/actions/initDraggable.ts +85 -0
  11. package/actions/initMouseMove.ts +120 -0
  12. package/actions/initScroll.ts +21 -0
  13. package/actions/initSortEnd.ts +87 -0
  14. package/components/GSSortable.tsx +160 -0
  15. package/components/styles/GSSortable.css +39 -0
  16. package/components/styles/GSSortable.scss +38 -0
  17. package/components/styles/GSSortableCSS.ts +41 -0
  18. package/constants/constParams.ts +5 -0
  19. package/constants/defaultParams.ts +20 -0
  20. package/constants/types.ts +7 -0
  21. package/dist/GSSortable.d.ts +2 -0
  22. package/dist/actions/afterAllImagesLoad.d.ts +4 -0
  23. package/dist/actions/afterAllImagesLoad.d.ts.map +1 -0
  24. package/dist/actions/afterAllImagesLoad.js +35 -0
  25. package/dist/actions/afterAllImagesLoad.js.map +1 -0
  26. package/dist/actions/calculate.d.ts +3 -2
  27. package/dist/actions/calculate.d.ts.map +1 -0
  28. package/dist/actions/calculate.js +13 -18
  29. package/dist/actions/calculate.js.map +1 -1
  30. package/dist/actions/calculateOnSort.d.ts +3 -2
  31. package/dist/actions/calculateOnSort.d.ts.map +1 -0
  32. package/dist/actions/calculateOnSort.js +51 -70
  33. package/dist/actions/calculateOnSort.js.map +1 -1
  34. package/dist/actions/checkItemInContainer.d.ts +1 -0
  35. package/dist/actions/checkItemInContainer.d.ts.map +1 -0
  36. package/dist/actions/checkItemInContainer.js +8 -17
  37. package/dist/actions/checkItemInContainer.js.map +1 -1
  38. package/dist/actions/destroy.d.ts +3 -8
  39. package/dist/actions/destroy.d.ts.map +1 -0
  40. package/dist/actions/destroy.js +7 -9
  41. package/dist/actions/destroy.js.map +1 -1
  42. package/dist/actions/general.d.ts +1 -0
  43. package/dist/actions/general.d.ts.map +1 -0
  44. package/dist/actions/general.js +5 -12
  45. package/dist/actions/general.js.map +1 -1
  46. package/dist/actions/getCurrentParams.d.ts +4 -9
  47. package/dist/actions/getCurrentParams.d.ts.map +1 -0
  48. package/dist/actions/getCurrentParams.js +15 -18
  49. package/dist/actions/getCurrentParams.js.map +1 -1
  50. package/dist/actions/init.d.ts +3 -2
  51. package/dist/actions/init.d.ts.map +1 -0
  52. package/dist/actions/init.js +13 -16
  53. package/dist/actions/init.js.map +1 -1
  54. package/dist/actions/initDraggable.d.ts +3 -2
  55. package/dist/actions/initDraggable.d.ts.map +1 -0
  56. package/dist/actions/initDraggable.js +14 -22
  57. package/dist/actions/initDraggable.js.map +1 -1
  58. package/dist/actions/initMouseMove.d.ts +1 -0
  59. package/dist/actions/initMouseMove.d.ts.map +1 -0
  60. package/dist/actions/initMouseMove.js +40 -53
  61. package/dist/actions/initMouseMove.js.map +1 -1
  62. package/dist/actions/initScroll.d.ts +1 -0
  63. package/dist/actions/initScroll.d.ts.map +1 -0
  64. package/dist/actions/initScroll.js +7 -15
  65. package/dist/actions/initScroll.js.map +1 -1
  66. package/dist/actions/initSortEnd.d.ts +2 -1
  67. package/dist/actions/initSortEnd.d.ts.map +1 -0
  68. package/dist/actions/initSortEnd.js +62 -71
  69. package/dist/actions/initSortEnd.js.map +1 -1
  70. package/dist/components/GSSortable.d.ts +4 -19
  71. package/dist/components/GSSortable.d.ts.map +1 -0
  72. package/dist/components/GSSortable.js +72 -105
  73. package/dist/components/GSSortable.js.map +1 -1
  74. package/dist/components/styles/GSSortableCSS.d.ts +2 -1
  75. package/dist/components/styles/GSSortableCSS.d.ts.map +1 -0
  76. package/dist/components/styles/GSSortableCSS.js +3 -4
  77. package/dist/components/styles/GSSortableCSS.js.map +1 -1
  78. package/dist/constants/constParams.d.ts +4 -3
  79. package/dist/constants/constParams.d.ts.map +1 -0
  80. package/dist/constants/constParams.js +2 -4
  81. package/dist/constants/constParams.js.map +1 -1
  82. package/dist/constants/defaultParams.d.ts +3 -2
  83. package/dist/constants/defaultParams.d.ts.map +1 -0
  84. package/dist/constants/defaultParams.js +3 -8
  85. package/dist/constants/defaultParams.js.map +1 -1
  86. package/dist/constants/types.d.ts +1 -0
  87. package/dist/constants/types.d.ts.map +1 -0
  88. package/dist/constants/types.js +1 -3
  89. package/dist/constants/types.js.map +1 -1
  90. package/dist/helpers/uihelpers.d.ts +2 -1
  91. package/dist/helpers/uihelpers.d.ts.map +1 -0
  92. package/dist/helpers/uihelpers.js +9 -23
  93. package/dist/helpers/uihelpers.js.map +1 -1
  94. package/dist/types/params.d.ts +23 -0
  95. package/dist/types/params.d.ts.map +1 -0
  96. package/dist/types/params.js +2 -0
  97. package/dist/types/params.js.map +1 -0
  98. package/dist/types/ref.d.ts +41 -0
  99. package/dist/types/ref.d.ts.map +1 -0
  100. package/dist/types/ref.js +2 -0
  101. package/dist/types/ref.js.map +1 -0
  102. package/dist-js/bundle.js +1181 -0
  103. package/helpers/uihelpers.ts +44 -0
  104. package/package.json +71 -43
  105. package/styles/GSSortable.css +39 -0
  106. package/styles/GSSortable.scss +38 -0
  107. package/types/global.d.ts +19 -0
  108. package/types/params.ts +24 -0
  109. package/types/ref.ts +41 -0
  110. 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.36",
4
- "description": "Get-Set Sortable",
5
- "main": "index.js",
6
- "author": "Get-Set",
7
- "license": "ISC",
8
- "files": [
9
- "index.js",
10
- "dist"
11
- ],
12
- "scripts": {
13
- "build": "tsc"
14
- },
15
- "peerDependencies": {
16
- "react": ">=16.0.0"
17
- },
18
- "keywords": [
19
- "grid",
20
- "flexiblegrid",
21
- "plugin",
22
- "sortable",
23
- "draggable",
24
- "droppable",
25
- "react",
26
- "react-component"
27
- ],
28
- "devDependencies": {
29
- "@babel/cli": "^7.24.1",
30
- "@babel/core": "^7.24.4",
31
- "@babel/preset-env": "^7.24.4",
32
- "@babel/preset-react": "^7.24.1",
33
- "@types/react": "^19.1.3",
34
- "cpy-cli": "^5.0.0",
35
- "prettier": "2.7.1",
36
- "raw-loader": "^4.0.2"
37
- },
38
- "dependencies": {
39
- "@types/prop-types": "^15.7.13",
40
- "jsdoc": "^4.0.3",
41
- "prop-types": "^15.8.1"
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 {};
@@ -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
@@ -1,3 +0,0 @@
1
- import GSSortable from './dist/components/GSSortable';
2
-
3
- export default GSSortable;