@willphan1712000/frontend 1.0.0
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/.babelrc +20 -0
- package/README.md +52 -0
- package/dist/index.css +233 -0
- package/dist/index.d.mts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +662 -0
- package/dist/index.mjs +588 -0
- package/index.ts +13 -0
- package/package.json +35 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/will.png +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function _iterable_to_array_limit(arr, i) {
|
|
11
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
12
|
+
if (_i == null) return;
|
|
13
|
+
var _arr = [];
|
|
14
|
+
var _n = true;
|
|
15
|
+
var _d = false;
|
|
16
|
+
var _s, _e;
|
|
17
|
+
try {
|
|
18
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
19
|
+
_arr.push(_s.value);
|
|
20
|
+
if (i && _arr.length === i) break;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_d = true;
|
|
24
|
+
_e = err;
|
|
25
|
+
} finally{
|
|
26
|
+
try {
|
|
27
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
28
|
+
} finally{
|
|
29
|
+
if (_d) throw _e;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return _arr;
|
|
33
|
+
}
|
|
34
|
+
function _non_iterable_rest() {
|
|
35
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
|
+
}
|
|
37
|
+
function _sliced_to_array(arr, i) {
|
|
38
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
39
|
+
}
|
|
40
|
+
function _type_of(obj) {
|
|
41
|
+
"@swc/helpers - typeof";
|
|
42
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
43
|
+
}
|
|
44
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
45
|
+
if (!o) return;
|
|
46
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
47
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
48
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
49
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
50
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
51
|
+
}
|
|
52
|
+
var __defProp = Object.defineProperty;
|
|
53
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
54
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
55
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
56
|
+
var __export = function(target, all) {
|
|
57
|
+
for(var name in all)__defProp(target, name, {
|
|
58
|
+
get: all[name],
|
|
59
|
+
enumerable: true
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var __copyProps = function(to, from, except, desc) {
|
|
63
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
64
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
65
|
+
try {
|
|
66
|
+
var _loop = function() {
|
|
67
|
+
var key = _step.value;
|
|
68
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
69
|
+
get: function() {
|
|
70
|
+
return from[key];
|
|
71
|
+
},
|
|
72
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_didIteratorError = true;
|
|
78
|
+
_iteratorError = err;
|
|
79
|
+
} finally{
|
|
80
|
+
try {
|
|
81
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
82
|
+
_iterator.return();
|
|
83
|
+
}
|
|
84
|
+
} finally{
|
|
85
|
+
if (_didIteratorError) {
|
|
86
|
+
throw _iteratorError;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return to;
|
|
92
|
+
};
|
|
93
|
+
var __toCommonJS = function(mod) {
|
|
94
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
95
|
+
value: true
|
|
96
|
+
}), mod);
|
|
97
|
+
};
|
|
98
|
+
// index.ts
|
|
99
|
+
var index_exports = {};
|
|
100
|
+
__export(index_exports, {
|
|
101
|
+
ColorPickerSlider: function() {
|
|
102
|
+
return ColorPickerSlider_default;
|
|
103
|
+
},
|
|
104
|
+
DropdownSelect: function() {
|
|
105
|
+
return DropdownSelect_default;
|
|
106
|
+
},
|
|
107
|
+
OptionSlider: function() {
|
|
108
|
+
return OptionSlider_default;
|
|
109
|
+
},
|
|
110
|
+
RangeSlider: function() {
|
|
111
|
+
return RangeSlider_default;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
module.exports = __toCommonJS(index_exports);
|
|
115
|
+
// src/components/DropdownSelect/DropdownSelect.tsx
|
|
116
|
+
var import_react3 = require("react");
|
|
117
|
+
// src/components/DropdownSelect/context.ts
|
|
118
|
+
var import_react = require("react");
|
|
119
|
+
var MyContext = (0, import_react.createContext)(void 0);
|
|
120
|
+
function useMyContext() {
|
|
121
|
+
var data = (0, import_react.useContext)(MyContext);
|
|
122
|
+
if (data === void 0) throw new Error("Select context is undefined");
|
|
123
|
+
return data;
|
|
124
|
+
}
|
|
125
|
+
// src/components/DropdownSelect/Dropdown.tsx
|
|
126
|
+
var import_react2 = require("react");
|
|
127
|
+
// scss-module:./dropdownSelect.module.css#scss-module
|
|
128
|
+
var dropdownSelect_module_default = {
|
|
129
|
+
"select_box": "dropdownSelect-module__select_box___Q8S31",
|
|
130
|
+
"value": "dropdownSelect-module__value___izaXQ",
|
|
131
|
+
"close": "dropdownSelect-module__close___axGDo",
|
|
132
|
+
"element": "dropdownSelect-module__element___Q56x3",
|
|
133
|
+
"dropdown": "dropdownSelect-module__dropdown___cjfHn",
|
|
134
|
+
"search_border": "dropdownSelect-module__search_border___xQU5q",
|
|
135
|
+
"search": "dropdownSelect-module__search___kGmqs"
|
|
136
|
+
};
|
|
137
|
+
// src/components/DropdownSelect/Search.tsx
|
|
138
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
139
|
+
var Search = function(param) {
|
|
140
|
+
var options = param.options, onSearch = param.onSearch;
|
|
141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
142
|
+
className: dropdownSelect_module_default.search_border,
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
144
|
+
placeholder: "Search",
|
|
145
|
+
className: dropdownSelect_module_default.search,
|
|
146
|
+
id: "search",
|
|
147
|
+
name: "search",
|
|
148
|
+
onChange: function(e) {
|
|
149
|
+
return onSearch(options.filter(function(ele) {
|
|
150
|
+
return ele.value.toLowerCase().includes(e.target.value.toLowerCase());
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
var Search_default = Search;
|
|
157
|
+
// src/components/DropdownSelect/Dropdown.tsx
|
|
158
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
159
|
+
var Dropdown = function() {
|
|
160
|
+
var _useMyContext = useMyContext(), options = _useMyContext.options, onChange = _useMyContext.onChange, setOpen = _useMyContext.setOpen;
|
|
161
|
+
var _ref = _sliced_to_array((0, import_react2.useState)(true), 2), isVisible = _ref[0], setVisible = _ref[1];
|
|
162
|
+
var _ref1 = _sliced_to_array((0, import_react2.useState)(options), 2), optionsCopy = _ref1[0], setOption = _ref1[1];
|
|
163
|
+
var dropdownRef = (0, import_react2.useRef)(null);
|
|
164
|
+
var handleResize = function() {
|
|
165
|
+
var dropdown = dropdownRef.current;
|
|
166
|
+
var dimension = dropdown.getBoundingClientRect();
|
|
167
|
+
var distanceToBottom = window.innerHeight - dimension.bottom;
|
|
168
|
+
var distanceToTop = dimension.top;
|
|
169
|
+
if (distanceToBottom < 0) {
|
|
170
|
+
setVisible(false);
|
|
171
|
+
}
|
|
172
|
+
if (distanceToTop < 0) {
|
|
173
|
+
setVisible(true);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
(0, import_react2.useEffect)(function() {
|
|
177
|
+
handleResize();
|
|
178
|
+
window.addEventListener("scroll", handleResize);
|
|
179
|
+
return function() {
|
|
180
|
+
window.removeEventListener("scroll", handleResize);
|
|
181
|
+
};
|
|
182
|
+
}, []);
|
|
183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
|
|
184
|
+
className: dropdownSelect_module_default.dropdown,
|
|
185
|
+
ref: dropdownRef,
|
|
186
|
+
style: isVisible ? {
|
|
187
|
+
top: "calc(100% + 5px)"
|
|
188
|
+
} : {
|
|
189
|
+
bottom: "calc(100% + 5px)"
|
|
190
|
+
},
|
|
191
|
+
children: [
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Search_default, {
|
|
193
|
+
options: options,
|
|
194
|
+
onSearch: setOption
|
|
195
|
+
}),
|
|
196
|
+
optionsCopy.map(function(option, key) {
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", {
|
|
198
|
+
className: dropdownSelect_module_default.element,
|
|
199
|
+
onClick: function() {
|
|
200
|
+
onChange(option.value);
|
|
201
|
+
setOpen(function(prev) {
|
|
202
|
+
return !prev;
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
children: option.label
|
|
206
|
+
}, key);
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
var Dropdown_default = Dropdown;
|
|
212
|
+
// src/components/DropdownSelect/DropdownSelect.tsx
|
|
213
|
+
var import_io = require("react-icons/io");
|
|
214
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
215
|
+
var DropdownSelect = function(param) {
|
|
216
|
+
var options = param.options, value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width;
|
|
217
|
+
var _ref = _sliced_to_array((0, import_react3.useState)(false), 2), open = _ref[0], setOpen = _ref[1];
|
|
218
|
+
var selectRef = (0, import_react3.useRef)(null);
|
|
219
|
+
var clickHandler = function(e) {
|
|
220
|
+
var select = selectRef.current;
|
|
221
|
+
if (!select.contains(e.target)) {
|
|
222
|
+
setOpen(false);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
(0, import_react3.useEffect)(function() {
|
|
226
|
+
window.addEventListener("click", clickHandler);
|
|
227
|
+
return function() {
|
|
228
|
+
return window.removeEventListener("click", clickHandler);
|
|
229
|
+
};
|
|
230
|
+
}, []);
|
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MyContext.Provider, {
|
|
232
|
+
value: {
|
|
233
|
+
options: options,
|
|
234
|
+
value: value,
|
|
235
|
+
onChange: onChange,
|
|
236
|
+
setOpen: setOpen
|
|
237
|
+
},
|
|
238
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", {
|
|
239
|
+
style: {
|
|
240
|
+
width: "".concat(width, "px"),
|
|
241
|
+
position: "relative"
|
|
242
|
+
},
|
|
243
|
+
ref: selectRef,
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", {
|
|
246
|
+
className: dropdownSelect_module_default.select_box,
|
|
247
|
+
onClick: function() {
|
|
248
|
+
return setOpen(function(prev) {
|
|
249
|
+
return !prev;
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
|
|
254
|
+
className: dropdownSelect_module_default.value,
|
|
255
|
+
children: value
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
|
|
258
|
+
className: dropdownSelect_module_default.close,
|
|
259
|
+
title: "clear",
|
|
260
|
+
onClick: function() {
|
|
261
|
+
onChange("");
|
|
262
|
+
setOpen(function(prev) {
|
|
263
|
+
return !prev;
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_io.IoMdClose, {})
|
|
267
|
+
})
|
|
268
|
+
]
|
|
269
|
+
}),
|
|
270
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Dropdown_default, {})
|
|
271
|
+
]
|
|
272
|
+
})
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
var DropdownSelect_default = DropdownSelect;
|
|
276
|
+
// src/components/RangeSlider/RangeSlider.tsx
|
|
277
|
+
var import_react4 = require("react");
|
|
278
|
+
// scss-module:./rangeSlider.module.css#scss-module
|
|
279
|
+
var rangeSlider_module_default = {
|
|
280
|
+
"slider_border": "rangeSlider-module__slider_border___CoeFx",
|
|
281
|
+
"thumb": "rangeSlider-module__thumb___OnFSM",
|
|
282
|
+
"thumb_shadow": "rangeSlider-module__thumb_shadow___L16TY",
|
|
283
|
+
"fill": "rangeSlider-module__fill___urGCN",
|
|
284
|
+
"rest": "rangeSlider-module__rest___pO2pi",
|
|
285
|
+
"value": "rangeSlider-module__value___Evg0D"
|
|
286
|
+
};
|
|
287
|
+
// src/components/RangeSlider/functions.ts
|
|
288
|
+
function encode(value, min, max) {
|
|
289
|
+
return (parseInt(value) - parseInt(min)) * 100 / (parseInt(max) - parseInt(min));
|
|
290
|
+
}
|
|
291
|
+
function decode(percent, min, max) {
|
|
292
|
+
return Math.round(parseInt(min) + percent * (parseInt(max) - parseInt(min)));
|
|
293
|
+
}
|
|
294
|
+
// src/components/RangeSlider/RangeSlider.tsx
|
|
295
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
296
|
+
var RangeSlider = function(param) {
|
|
297
|
+
var _param_min = param.min, min = _param_min === void 0 ? "0" : _param_min, _param_max = param.max, max = _param_max === void 0 ? "100" : _param_max, _param_color = param.color, color = _param_color === void 0 ? "#f0f0f7" : _param_color, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width, value = param.value, onChange = param.onChange;
|
|
298
|
+
var percentage = encode(value, min, max);
|
|
299
|
+
var sliderBorderRef = (0, import_react4.useRef)(null);
|
|
300
|
+
var _ref = _sliced_to_array((0, import_react4.useState)(false), 2), isMouseDown = _ref[0], setMouseDown = _ref[1];
|
|
301
|
+
var _ref1 = _sliced_to_array((0, import_react4.useState)(false), 2), isHover = _ref1[0], setHover = _ref1[1];
|
|
302
|
+
var handleDrag = function(isClicked, e) {
|
|
303
|
+
if (!isMouseDown && !isClicked) return;
|
|
304
|
+
var sliderBorder = sliderBorderRef.current;
|
|
305
|
+
var dimension = sliderBorder.getBoundingClientRect();
|
|
306
|
+
var clientX;
|
|
307
|
+
if ("touches" in e) {
|
|
308
|
+
clientX = e.touches[0].clientX;
|
|
309
|
+
} else {
|
|
310
|
+
clientX = e.clientX;
|
|
311
|
+
}
|
|
312
|
+
percentage = (clientX - dimension.left) / dimension.width;
|
|
313
|
+
var currentValue = decode(percentage, min, max);
|
|
314
|
+
if (currentValue > parseInt(max)) {
|
|
315
|
+
currentValue = parseInt(max);
|
|
316
|
+
}
|
|
317
|
+
if (currentValue < parseInt(min)) {
|
|
318
|
+
currentValue = parseInt(min);
|
|
319
|
+
}
|
|
320
|
+
onChange(currentValue.toString());
|
|
321
|
+
};
|
|
322
|
+
(0, import_react4.useEffect)(function() {
|
|
323
|
+
var handleMove = function(e) {
|
|
324
|
+
if (e.type === "touchmove") {
|
|
325
|
+
e.preventDefault();
|
|
326
|
+
}
|
|
327
|
+
handleDrag(false, e);
|
|
328
|
+
};
|
|
329
|
+
var handleMouseUp = function() {
|
|
330
|
+
setMouseDown(false);
|
|
331
|
+
};
|
|
332
|
+
if (isMouseDown) {
|
|
333
|
+
document.addEventListener("mousemove", handleMove);
|
|
334
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
335
|
+
document.addEventListener("touchmove", handleMove, {
|
|
336
|
+
passive: false
|
|
337
|
+
});
|
|
338
|
+
document.addEventListener("touchend", handleMouseUp);
|
|
339
|
+
}
|
|
340
|
+
return function() {
|
|
341
|
+
document.removeEventListener("mousemove", handleMove);
|
|
342
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
343
|
+
document.removeEventListener("touchmove", handleMove);
|
|
344
|
+
document.removeEventListener("touchend", handleMouseUp);
|
|
345
|
+
};
|
|
346
|
+
}, [
|
|
347
|
+
isMouseDown
|
|
348
|
+
]);
|
|
349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
|
|
350
|
+
className: rangeSlider_module_default.slider_border,
|
|
351
|
+
style: {
|
|
352
|
+
width: "".concat(width, "px")
|
|
353
|
+
},
|
|
354
|
+
onMouseDown: function(e) {
|
|
355
|
+
handleDrag(true, e);
|
|
356
|
+
setMouseDown(true);
|
|
357
|
+
},
|
|
358
|
+
onTouchStart: function(e) {
|
|
359
|
+
handleDrag(true, e);
|
|
360
|
+
setMouseDown(true);
|
|
361
|
+
},
|
|
362
|
+
ref: sliderBorderRef,
|
|
363
|
+
children: [
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
|
|
365
|
+
className: rangeSlider_module_default.fill,
|
|
366
|
+
style: {
|
|
367
|
+
background: color,
|
|
368
|
+
width: "".concat(percentage, "%")
|
|
369
|
+
}
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", {
|
|
372
|
+
className: rangeSlider_module_default.thumb,
|
|
373
|
+
style: {
|
|
374
|
+
background: color,
|
|
375
|
+
left: "".concat(percentage, "%")
|
|
376
|
+
},
|
|
377
|
+
onMouseMove: function() {
|
|
378
|
+
return setHover(true);
|
|
379
|
+
},
|
|
380
|
+
onMouseLeave: function() {
|
|
381
|
+
return setHover(false);
|
|
382
|
+
},
|
|
383
|
+
children: [
|
|
384
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
|
|
385
|
+
className: rangeSlider_module_default.value,
|
|
386
|
+
style: {
|
|
387
|
+
scale: isMouseDown || isHover ? "1" : "0"
|
|
388
|
+
},
|
|
389
|
+
children: value
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
|
|
392
|
+
className: rangeSlider_module_default.thumb_shadow,
|
|
393
|
+
style: {
|
|
394
|
+
background: color,
|
|
395
|
+
scale: isMouseDown || isHover ? "1" : "0"
|
|
396
|
+
}
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
}),
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
|
|
401
|
+
className: rangeSlider_module_default.rest,
|
|
402
|
+
style: {
|
|
403
|
+
background: color
|
|
404
|
+
}
|
|
405
|
+
})
|
|
406
|
+
]
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
var RangeSlider_default = RangeSlider;
|
|
410
|
+
// scss-module:./optionSlider.module.css#scss-module
|
|
411
|
+
var optionSlider_module_default = {
|
|
412
|
+
"border": "optionSlider-module__border___DvXkD",
|
|
413
|
+
"background": "optionSlider-module__background___P6MQP",
|
|
414
|
+
"options": "optionSlider-module__options___OLBcd",
|
|
415
|
+
"element": "optionSlider-module__element___obtjI"
|
|
416
|
+
};
|
|
417
|
+
// src/components/OptionSlider/OptionSlider.tsx
|
|
418
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
419
|
+
var OptionSlider = function(param) {
|
|
420
|
+
var value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width, options = param.options, _param_color = param.color, color = _param_color === void 0 ? "#f0f0f7" : _param_color;
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", {
|
|
422
|
+
className: optionSlider_module_default.border,
|
|
423
|
+
style: {
|
|
424
|
+
width: "".concat(width, "px")
|
|
425
|
+
},
|
|
426
|
+
children: [
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
|
|
428
|
+
className: optionSlider_module_default.background,
|
|
429
|
+
style: {
|
|
430
|
+
background: color
|
|
431
|
+
}
|
|
432
|
+
}),
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
|
|
434
|
+
className: optionSlider_module_default.options,
|
|
435
|
+
children: options.map(function(option, key) {
|
|
436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
|
|
437
|
+
style: {
|
|
438
|
+
background: color,
|
|
439
|
+
border: value === option.value ? "solid 2px #000" : "solid 1px #000"
|
|
440
|
+
},
|
|
441
|
+
className: optionSlider_module_default.element,
|
|
442
|
+
onClick: function() {
|
|
443
|
+
return onChange(option.value);
|
|
444
|
+
},
|
|
445
|
+
title: option.value,
|
|
446
|
+
children: option.label
|
|
447
|
+
}, key);
|
|
448
|
+
})
|
|
449
|
+
})
|
|
450
|
+
]
|
|
451
|
+
});
|
|
452
|
+
};
|
|
453
|
+
var OptionSlider_default = OptionSlider;
|
|
454
|
+
// src/components/ColorPickerSlider/ColorPickerSlider.tsx
|
|
455
|
+
var import_react5 = require("react");
|
|
456
|
+
// scss-module:./colorPickerSlider.module.css#scss-module
|
|
457
|
+
var colorPickerSlider_module_default = {
|
|
458
|
+
"border": "colorPickerSlider-module__border___-6cw8",
|
|
459
|
+
"thumb": "colorPickerSlider-module__thumb___p2fHW",
|
|
460
|
+
"label": "colorPickerSlider-module__label___Aa0AV"
|
|
461
|
+
};
|
|
462
|
+
// src/components/ColorPickerSlider/functions.ts
|
|
463
|
+
function encode2(color) {
|
|
464
|
+
var h = hexToHsl(color).h;
|
|
465
|
+
return h * 100 / 360;
|
|
466
|
+
}
|
|
467
|
+
function decode2(percent) {
|
|
468
|
+
return hslToHex(percent * 360, 100, 50);
|
|
469
|
+
}
|
|
470
|
+
function hexToHsl(hex) {
|
|
471
|
+
if (hex.length === 7) {
|
|
472
|
+
hex = hex.substring(1);
|
|
473
|
+
}
|
|
474
|
+
var r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
475
|
+
var g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
476
|
+
var b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
477
|
+
var cmax = Math.max(r, g, b);
|
|
478
|
+
var cmin = Math.min(r, g, b);
|
|
479
|
+
var delta = cmax - cmin;
|
|
480
|
+
var h = 0;
|
|
481
|
+
var s = 0;
|
|
482
|
+
var l = (cmax + cmin) / 2;
|
|
483
|
+
if (delta !== 0) {
|
|
484
|
+
s = delta / (1 - Math.abs(2 * l - 1));
|
|
485
|
+
if (cmax === r) {
|
|
486
|
+
h = (g - b) / delta;
|
|
487
|
+
} else if (cmax === g) {
|
|
488
|
+
h = (b - r) / delta + 2;
|
|
489
|
+
} else {
|
|
490
|
+
h = (r - g) / delta + 4;
|
|
491
|
+
}
|
|
492
|
+
h = h * 60;
|
|
493
|
+
if (h < 0) {
|
|
494
|
+
h += 360;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
h: Math.round(h),
|
|
499
|
+
s: Math.round(s * 100),
|
|
500
|
+
l: Math.round(l * 100)
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function hslToHex(h, s, l) {
|
|
504
|
+
s /= 100;
|
|
505
|
+
l /= 100;
|
|
506
|
+
var c = (1 - Math.abs(2 * l - 1)) * s;
|
|
507
|
+
var x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
508
|
+
var m = l - c / 2;
|
|
509
|
+
var r_prime = 0;
|
|
510
|
+
var g_prime = 0;
|
|
511
|
+
var b_prime = 0;
|
|
512
|
+
var sector = h / 60;
|
|
513
|
+
if (sector >= 0 && sector < 1) {
|
|
514
|
+
var ref;
|
|
515
|
+
ref = [
|
|
516
|
+
c,
|
|
517
|
+
x,
|
|
518
|
+
0
|
|
519
|
+
], r_prime = ref[0], g_prime = ref[1], b_prime = ref[2], ref;
|
|
520
|
+
} else if (sector >= 1 && sector < 2) {
|
|
521
|
+
var ref1;
|
|
522
|
+
ref1 = [
|
|
523
|
+
x,
|
|
524
|
+
c,
|
|
525
|
+
0
|
|
526
|
+
], r_prime = ref1[0], g_prime = ref1[1], b_prime = ref1[2], ref1;
|
|
527
|
+
} else if (sector >= 2 && sector < 3) {
|
|
528
|
+
var ref2;
|
|
529
|
+
ref2 = [
|
|
530
|
+
0,
|
|
531
|
+
c,
|
|
532
|
+
x
|
|
533
|
+
], r_prime = ref2[0], g_prime = ref2[1], b_prime = ref2[2], ref2;
|
|
534
|
+
} else if (sector >= 3 && sector < 4) {
|
|
535
|
+
var ref3;
|
|
536
|
+
ref3 = [
|
|
537
|
+
0,
|
|
538
|
+
x,
|
|
539
|
+
c
|
|
540
|
+
], r_prime = ref3[0], g_prime = ref3[1], b_prime = ref3[2], ref3;
|
|
541
|
+
} else if (sector >= 4 && sector < 5) {
|
|
542
|
+
var ref4;
|
|
543
|
+
ref4 = [
|
|
544
|
+
x,
|
|
545
|
+
0,
|
|
546
|
+
c
|
|
547
|
+
], r_prime = ref4[0], g_prime = ref4[1], b_prime = ref4[2], ref4;
|
|
548
|
+
} else if (sector >= 5 && sector < 6) {
|
|
549
|
+
var ref5;
|
|
550
|
+
ref5 = [
|
|
551
|
+
c,
|
|
552
|
+
0,
|
|
553
|
+
x
|
|
554
|
+
], r_prime = ref5[0], g_prime = ref5[1], b_prime = ref5[2], ref5;
|
|
555
|
+
}
|
|
556
|
+
var r = Math.round((r_prime + m) * 255);
|
|
557
|
+
var g = Math.round((g_prime + m) * 255);
|
|
558
|
+
var b = Math.round((b_prime + m) * 255);
|
|
559
|
+
var toHex = function(c2) {
|
|
560
|
+
var hex = c2.toString(16).toUpperCase();
|
|
561
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
562
|
+
};
|
|
563
|
+
return "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b));
|
|
564
|
+
}
|
|
565
|
+
// src/components/ColorPickerSlider/ColorPickerSlider.tsx
|
|
566
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
567
|
+
var ColorPickerSlider = function(param) {
|
|
568
|
+
var value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width;
|
|
569
|
+
var percentage = encode2(value);
|
|
570
|
+
var sliderBorderRef = (0, import_react5.useRef)(null);
|
|
571
|
+
var _ref = _sliced_to_array((0, import_react5.useState)(false), 2), isMouseDown = _ref[0], setMouseDown = _ref[1];
|
|
572
|
+
var _ref1 = _sliced_to_array((0, import_react5.useState)(false), 2), isHover = _ref1[0], setHover = _ref1[1];
|
|
573
|
+
var handleDrag = function(isClicked, e) {
|
|
574
|
+
if (!isMouseDown && !isClicked) return;
|
|
575
|
+
var sliderBorder = sliderBorderRef.current;
|
|
576
|
+
var dimension = sliderBorder.getBoundingClientRect();
|
|
577
|
+
var clientX;
|
|
578
|
+
if ("touches" in e) {
|
|
579
|
+
clientX = e.touches[0].clientX;
|
|
580
|
+
} else {
|
|
581
|
+
clientX = e.clientX;
|
|
582
|
+
}
|
|
583
|
+
percentage = (clientX - dimension.left) / dimension.width;
|
|
584
|
+
if (percentage < 0) percentage = 0;
|
|
585
|
+
if (percentage > 1) percentage = 0.99;
|
|
586
|
+
onChange(decode2(percentage));
|
|
587
|
+
};
|
|
588
|
+
(0, import_react5.useEffect)(function() {
|
|
589
|
+
var handleMove = function(e) {
|
|
590
|
+
if (e.type === "touchmove") {
|
|
591
|
+
e.preventDefault();
|
|
592
|
+
}
|
|
593
|
+
handleDrag(false, e);
|
|
594
|
+
};
|
|
595
|
+
var handleMouseUp = function() {
|
|
596
|
+
setMouseDown(false);
|
|
597
|
+
};
|
|
598
|
+
if (isMouseDown) {
|
|
599
|
+
document.addEventListener("mousemove", handleMove);
|
|
600
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
601
|
+
document.addEventListener("touchmove", handleMove, {
|
|
602
|
+
passive: false
|
|
603
|
+
});
|
|
604
|
+
document.addEventListener("touchend", handleMouseUp);
|
|
605
|
+
}
|
|
606
|
+
return function() {
|
|
607
|
+
document.removeEventListener("mousemove", handleMove);
|
|
608
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
609
|
+
document.removeEventListener("touchmove", handleMove);
|
|
610
|
+
document.removeEventListener("touchend", handleMouseUp);
|
|
611
|
+
};
|
|
612
|
+
}, [
|
|
613
|
+
isMouseDown
|
|
614
|
+
]);
|
|
615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
|
|
616
|
+
className: colorPickerSlider_module_default.border,
|
|
617
|
+
style: {
|
|
618
|
+
width: "".concat(width, "px")
|
|
619
|
+
},
|
|
620
|
+
onMouseDown: function(e) {
|
|
621
|
+
handleDrag(true, e);
|
|
622
|
+
setMouseDown(true);
|
|
623
|
+
},
|
|
624
|
+
onTouchStart: function(e) {
|
|
625
|
+
handleDrag(true, e);
|
|
626
|
+
setMouseDown(true);
|
|
627
|
+
},
|
|
628
|
+
ref: sliderBorderRef,
|
|
629
|
+
children: [
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
631
|
+
className: colorPickerSlider_module_default.thumb,
|
|
632
|
+
style: {
|
|
633
|
+
width: "".concat(parseInt(width) * 0.1, "px"),
|
|
634
|
+
background: value,
|
|
635
|
+
left: "".concat(percentage, "%")
|
|
636
|
+
},
|
|
637
|
+
onMouseMove: function() {
|
|
638
|
+
return setHover(true);
|
|
639
|
+
},
|
|
640
|
+
onMouseLeave: function() {
|
|
641
|
+
return setHover(false);
|
|
642
|
+
}
|
|
643
|
+
}),
|
|
644
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
645
|
+
className: colorPickerSlider_module_default.label,
|
|
646
|
+
style: {
|
|
647
|
+
left: "".concat(percentage, "%"),
|
|
648
|
+
scale: isHover || isMouseDown ? "1" : "0"
|
|
649
|
+
},
|
|
650
|
+
children: value
|
|
651
|
+
})
|
|
652
|
+
]
|
|
653
|
+
});
|
|
654
|
+
};
|
|
655
|
+
var ColorPickerSlider_default = ColorPickerSlider;
|
|
656
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
657
|
+
0 && (module.exports = {
|
|
658
|
+
ColorPickerSlider: ColorPickerSlider,
|
|
659
|
+
DropdownSelect: DropdownSelect,
|
|
660
|
+
OptionSlider: OptionSlider,
|
|
661
|
+
RangeSlider: RangeSlider
|
|
662
|
+
});
|