@get-set/gs-sortable 0.0.20 → 0.0.21
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/dist/actions/afterAllImagesLoad.js +53 -43
- package/dist/actions/calculate.js +140 -145
- package/dist/actions/calculateOnSort.js +247 -278
- package/dist/actions/checkItemInContainer.js +26 -28
- package/dist/actions/destroy.js +33 -22
- package/dist/actions/general.js +90 -81
- package/dist/actions/getCurrentParams.js +35 -32
- package/dist/actions/init.js +33 -24
- package/dist/actions/initDraggable.js +88 -87
- package/dist/actions/initMouseMove.js +102 -117
- package/dist/actions/initScroll.js +26 -23
- package/dist/actions/initSortEnd.js +73 -84
- package/dist/components/GSSortable.js +154 -162
- package/dist/constants/constParams.js +10 -5
- package/dist/constants/defaultParams.js +24 -19
- package/dist/constants/types.js +12 -7
- package/dist/helpers/uihelpers.js +56 -52
- package/package.json +3 -3
|
@@ -1,33 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _getCurrentParams = _interopRequireDefault(require("../actions/getCurrentParams"));
|
|
10
|
+
var _init = _interopRequireDefault(require("../actions/init"));
|
|
11
|
+
var _destroy2 = _interopRequireDefault(require("../actions/destroy"));
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _defaultParams = _interopRequireDefault(require("../constants/defaultParams"));
|
|
14
|
+
var _initMouseMove = _interopRequireDefault(require("../actions/initMouseMove"));
|
|
15
|
+
var _initSortEnd = _interopRequireDefault(require("../actions/initSortEnd"));
|
|
16
|
+
var _initScroll = _interopRequireDefault(require("../actions/initScroll"));
|
|
17
|
+
var _types = _interopRequireDefault(require("../constants/types"));
|
|
18
|
+
require("./styles/GSSortable.css");
|
|
19
|
+
var _uihelpers = require("../helpers/uihelpers");
|
|
20
|
+
var _excluded = ["children"];
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
22
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
23
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
24
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
25
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
26
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
27
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
28
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
29
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
32
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
33
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
34
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
35
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
36
|
+
var params = {
|
|
37
|
+
reference: _propTypes["default"].string,
|
|
38
|
+
handler: _propTypes["default"].string,
|
|
39
|
+
className: _propTypes["default"].string,
|
|
40
|
+
afterSort: _propTypes["default"].func,
|
|
41
|
+
gsx: _propTypes["default"].object,
|
|
42
|
+
gap: _propTypes["default"].string,
|
|
43
|
+
allowOutOfBox: _propTypes["default"].bool,
|
|
44
|
+
count: _propTypes["default"].number,
|
|
45
|
+
type: _propTypes["default"].oneOf([_types["default"].column, _types["default"].row, _types["default"].grid])
|
|
46
|
+
};
|
|
47
|
+
|
|
31
48
|
/**
|
|
32
49
|
* GSSortable component to display a customizable sortable.
|
|
33
50
|
*
|
|
@@ -46,135 +63,110 @@ const params = {
|
|
|
46
63
|
* @param {number} props.responsive[].windowSize - Minimum window size for this configuration.
|
|
47
64
|
* @param {Object} props.responsive[].params - The responsive configuration for the grid.
|
|
48
65
|
* @returns {JSX.Element} The rendered sortable component.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
window.addEventListener('
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
window.addEventListener('
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
window.GSSortableConfigue.references.push({
|
|
91
|
-
key: componentKey,
|
|
92
|
-
ref: {
|
|
93
|
-
isAddjusting: false,
|
|
94
|
-
grid: gridRef.current,
|
|
95
|
-
currentParams: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (params.gsx != undefined) {
|
|
111
|
-
|
|
112
|
-
scss[
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, [
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
([key]) => !(key in defaultParams),
|
|
157
|
-
),
|
|
158
|
-
)}>
|
|
159
|
-
{children}
|
|
160
|
-
</div>
|
|
161
|
-
) : (
|
|
162
|
-
<></>
|
|
163
|
-
)}
|
|
164
|
-
</>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
GSSortable.propTypes = {
|
|
169
|
-
...params,
|
|
170
|
-
responsive: PropTypes.arrayOf(
|
|
171
|
-
PropTypes.shape({
|
|
172
|
-
windowSize: PropTypes.number,
|
|
173
|
-
params: PropTypes.shape({
|
|
174
|
-
...params,
|
|
175
|
-
}),
|
|
176
|
-
}),
|
|
177
|
-
),
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default GSSortable;
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
var GSSortable = function GSSortable(_ref) {
|
|
69
|
+
var children = _ref.children,
|
|
70
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
71
|
+
var params = _objectSpread({}, rest);
|
|
72
|
+
var _useState = (0, _react.useState)(null),
|
|
73
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
74
|
+
componentKey = _useState2[0],
|
|
75
|
+
setComponentKey = _useState2[1];
|
|
76
|
+
var gridRef = (0, _react.useRef)(null);
|
|
77
|
+
(0, _react.useEffect)(function () {
|
|
78
|
+
if (componentKey != null) {
|
|
79
|
+
if (typeof window.GSSortableConfigue === 'undefined') {
|
|
80
|
+
window.GSSortableConfigue = {
|
|
81
|
+
references: [],
|
|
82
|
+
instance: function instance(ref) {
|
|
83
|
+
if (ref != undefined && ref != '') {
|
|
84
|
+
var instance = window.GSSortableConfigue.references.find(function (x) {
|
|
85
|
+
return x.key === ref;
|
|
86
|
+
});
|
|
87
|
+
if (instance != undefined) {
|
|
88
|
+
return instance.ref;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
window.addEventListener('mousemove', function (e) {
|
|
94
|
+
(0, _initMouseMove["default"])(e);
|
|
95
|
+
});
|
|
96
|
+
window.addEventListener('mouseup', function (e) {
|
|
97
|
+
(0, _initSortEnd["default"])(e);
|
|
98
|
+
});
|
|
99
|
+
window.addEventListener('scroll', function () {
|
|
100
|
+
(0, _initScroll["default"])();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (window.GSSortableConfigue.references.find(function (x) {
|
|
104
|
+
return x.key === componentKey;
|
|
105
|
+
}) === undefined) {
|
|
106
|
+
var currentParams = (0, _getCurrentParams["default"])(params);
|
|
107
|
+
window.GSSortableConfigue.references.push({
|
|
108
|
+
key: componentKey,
|
|
109
|
+
ref: {
|
|
110
|
+
isAddjusting: false,
|
|
111
|
+
grid: gridRef.current,
|
|
112
|
+
currentParams: _objectSpread(_objectSpread({}, currentParams), {}, {
|
|
113
|
+
reference: componentKey
|
|
114
|
+
}),
|
|
115
|
+
destroy: function destroy() {
|
|
116
|
+
(0, _destroy2["default"])(window.GSSortableConfigue.instance(componentKey));
|
|
117
|
+
},
|
|
118
|
+
refresh: function refresh() {
|
|
119
|
+
(0, _destroy2["default"])(window.GSSortableConfigue.instance(componentKey));
|
|
120
|
+
(0, _init["default"])(window.GSSortableConfigue.instance(componentKey));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
var currentRef = window.GSSortableConfigue.references.find(function (x) {
|
|
125
|
+
return x.key === componentKey;
|
|
126
|
+
}).ref;
|
|
127
|
+
if (params.gsx != undefined) {
|
|
128
|
+
var scss = {};
|
|
129
|
+
scss["[data-key='".concat(componentKey, "']")] = _objectSpread({}, params.gsx);
|
|
130
|
+
var style = (0, _uihelpers.convertScssToCss)(scss);
|
|
131
|
+
(0, _uihelpers.injectCssToHead)(style, componentKey);
|
|
132
|
+
}
|
|
133
|
+
(0, _init["default"])(currentRef);
|
|
134
|
+
}
|
|
135
|
+
return function () {
|
|
136
|
+
if (window.GSCarouselConfigue != undefined) {
|
|
137
|
+
window.GSCarouselConfigue.references = window.GSCarouselConfigue.references.filter(function (x) {
|
|
138
|
+
return x.key !== componentKey;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
(0, _uihelpers.removeCssToHead)(componentKey);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}, [componentKey]);
|
|
145
|
+
(0, _react.useEffect)(function () {
|
|
146
|
+
setComponentKey(params.reference != undefined ? params.reference : (0, _uihelpers.NewGuid)());
|
|
147
|
+
}, []);
|
|
148
|
+
(0, _react.useEffect)(function () {
|
|
149
|
+
if (componentKey != null) {
|
|
150
|
+
var ref = window.GSSortableConfigue.instance(componentKey);
|
|
151
|
+
if (ref !== undefined) {
|
|
152
|
+
ref.refresh();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, [children]);
|
|
156
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, componentKey != null ? /*#__PURE__*/React.createElement("div", _extends({
|
|
157
|
+
className: "gs-sortable-instance gs-sortable-".concat(params.type, " ").concat(rest.className),
|
|
158
|
+
ref: gridRef,
|
|
159
|
+
"data-key": componentKey
|
|
160
|
+
}, Object.fromEntries(Object.entries(_objectSpread({}, rest)).filter(function (_ref2) {
|
|
161
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
162
|
+
key = _ref3[0];
|
|
163
|
+
return !(key in _defaultParams["default"]);
|
|
164
|
+
}))), children) : /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
165
|
+
};
|
|
166
|
+
GSSortable.propTypes = _objectSpread(_objectSpread({}, params), {}, {
|
|
167
|
+
responsive: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
168
|
+
windowSize: _propTypes["default"].number,
|
|
169
|
+
params: _propTypes["default"].shape(_objectSpread({}, params))
|
|
170
|
+
}))
|
|
171
|
+
});
|
|
172
|
+
var _default = exports["default"] = GSSortable;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var constParams = {
|
|
8
|
+
animateionSpeed: 400
|
|
9
|
+
};
|
|
10
|
+
var _default = exports["default"] = Object.freeze(constParams);
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _types = _interopRequireDefault(require("./types"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
var defaultParams = {
|
|
10
|
+
acceptFrom: [],
|
|
11
|
+
className: '',
|
|
12
|
+
takeClone: false,
|
|
13
|
+
reference: '',
|
|
14
|
+
count: 3,
|
|
15
|
+
gap: '',
|
|
16
|
+
gsx: undefined,
|
|
17
|
+
handler: '',
|
|
18
|
+
width: 'auto',
|
|
19
|
+
type: _types["default"].column,
|
|
20
|
+
allowOutOfBox: true,
|
|
21
|
+
responsive: [],
|
|
22
|
+
afterSort: function afterSort() {}
|
|
23
|
+
};
|
|
24
|
+
var _default = exports["default"] = Object.freeze(defaultParams);
|
package/dist/constants/types.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var types = {
|
|
8
|
+
row: 'row',
|
|
9
|
+
column: 'column',
|
|
10
|
+
grid: 'grid'
|
|
11
|
+
};
|
|
12
|
+
var _default = exports["default"] = Object.freeze(types);
|
|
@@ -1,52 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeCssToHead = exports.injectCssToHead = exports.convertScssToCss = exports.NewGuid = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
var NewGuid = exports.NewGuid = function NewGuid() {
|
|
9
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
10
|
+
var r = Math.random() * 16 | 0,
|
|
11
|
+
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
12
|
+
return v.toString(16);
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var removeCssToHead = exports.removeCssToHead = function removeCssToHead(key) {
|
|
16
|
+
var style = document.querySelector("head style[data-key='".concat(key, "']"));
|
|
17
|
+
if (style != null) {
|
|
18
|
+
style.remove();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var injectCssToHead = exports.injectCssToHead = function injectCssToHead(css, key) {
|
|
22
|
+
// Create a <style> element
|
|
23
|
+
var style = document.createElement('style');
|
|
24
|
+
style.dataset.key = key;
|
|
25
|
+
// Set the CSS as the inner content of the <style> element
|
|
26
|
+
style.innerHTML = css;
|
|
27
|
+
// Append the <style> element to the <head>
|
|
28
|
+
document.head.appendChild(style);
|
|
29
|
+
};
|
|
30
|
+
var camelToKebab = function camelToKebab(str) {
|
|
31
|
+
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
32
|
+
};
|
|
33
|
+
var convertScssToCss = exports.convertScssToCss = function convertScssToCss(scssObj) {
|
|
34
|
+
// Helper function to handle nested objects
|
|
35
|
+
var _convertObjectToCss = function convertObjectToCss(obj) {
|
|
36
|
+
var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
37
|
+
var css = '';
|
|
38
|
+
|
|
39
|
+
// Iterate over each key-value pair in the SCSS object
|
|
40
|
+
for (var key in obj) {
|
|
41
|
+
var value = obj[key];
|
|
42
|
+
if (_typeof(value) === 'object') {
|
|
43
|
+
// If the value is an object, it's a nested rule, so we recurse
|
|
44
|
+
var newParent = parent ? "".concat(parent, " ").concat(key) : key;
|
|
45
|
+
css += _convertObjectToCss(value, newParent); // Recurse and concatenate
|
|
46
|
+
} else {
|
|
47
|
+
// Otherwise, it's a property-value pair (e.g. color: red)
|
|
48
|
+
css += "".concat(parent, " { ").concat(camelToKebab(key), ": ").concat(value, "; }\n");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return css;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Start recursion with the top-level object
|
|
55
|
+
return _convertObjectToCss(scssObj, '');
|
|
56
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@get-set/gs-sortable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Get-Set Sortable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Get-Set",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "babel src --out-dir dist --copy-files --ignore 'src/**/*.test.js'"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"react": "
|
|
16
|
+
"react": ">=16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"grid",
|