@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.mjs
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
// src/components/DropdownSelect/DropdownSelect.tsx
|
|
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 _unsupported_iterable_to_array(o, minLen) {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
43
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
44
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
45
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
46
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
47
|
+
}
|
|
48
|
+
import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
49
|
+
// src/components/DropdownSelect/context.ts
|
|
50
|
+
import { createContext, useContext } from "react";
|
|
51
|
+
var MyContext = createContext(void 0);
|
|
52
|
+
function useMyContext() {
|
|
53
|
+
var data = useContext(MyContext);
|
|
54
|
+
if (data === void 0) throw new Error("Select context is undefined");
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
// src/components/DropdownSelect/Dropdown.tsx
|
|
58
|
+
import { useEffect, useRef, useState } from "react";
|
|
59
|
+
// scss-module:./dropdownSelect.module.css#scss-module
|
|
60
|
+
var dropdownSelect_module_default = {
|
|
61
|
+
"select_box": "dropdownSelect-module__select_box___Q8S31",
|
|
62
|
+
"value": "dropdownSelect-module__value___izaXQ",
|
|
63
|
+
"close": "dropdownSelect-module__close___axGDo",
|
|
64
|
+
"element": "dropdownSelect-module__element___Q56x3",
|
|
65
|
+
"dropdown": "dropdownSelect-module__dropdown___cjfHn",
|
|
66
|
+
"search_border": "dropdownSelect-module__search_border___xQU5q",
|
|
67
|
+
"search": "dropdownSelect-module__search___kGmqs"
|
|
68
|
+
};
|
|
69
|
+
// src/components/DropdownSelect/Search.tsx
|
|
70
|
+
import { jsx } from "react/jsx-runtime";
|
|
71
|
+
var Search = function(param) {
|
|
72
|
+
var options = param.options, onSearch = param.onSearch;
|
|
73
|
+
return /* @__PURE__ */ jsx("div", {
|
|
74
|
+
className: dropdownSelect_module_default.search_border,
|
|
75
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
76
|
+
placeholder: "Search",
|
|
77
|
+
className: dropdownSelect_module_default.search,
|
|
78
|
+
id: "search",
|
|
79
|
+
name: "search",
|
|
80
|
+
onChange: function(e) {
|
|
81
|
+
return onSearch(options.filter(function(ele) {
|
|
82
|
+
return ele.value.toLowerCase().includes(e.target.value.toLowerCase());
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
var Search_default = Search;
|
|
89
|
+
// src/components/DropdownSelect/Dropdown.tsx
|
|
90
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
91
|
+
var Dropdown = function() {
|
|
92
|
+
var _useMyContext = useMyContext(), options = _useMyContext.options, onChange = _useMyContext.onChange, setOpen = _useMyContext.setOpen;
|
|
93
|
+
var _useState = _sliced_to_array(useState(true), 2), isVisible = _useState[0], setVisible = _useState[1];
|
|
94
|
+
var _useState1 = _sliced_to_array(useState(options), 2), optionsCopy = _useState1[0], setOption = _useState1[1];
|
|
95
|
+
var dropdownRef = useRef(null);
|
|
96
|
+
var handleResize = function() {
|
|
97
|
+
var dropdown = dropdownRef.current;
|
|
98
|
+
var dimension = dropdown.getBoundingClientRect();
|
|
99
|
+
var distanceToBottom = window.innerHeight - dimension.bottom;
|
|
100
|
+
var distanceToTop = dimension.top;
|
|
101
|
+
if (distanceToBottom < 0) {
|
|
102
|
+
setVisible(false);
|
|
103
|
+
}
|
|
104
|
+
if (distanceToTop < 0) {
|
|
105
|
+
setVisible(true);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
useEffect(function() {
|
|
109
|
+
handleResize();
|
|
110
|
+
window.addEventListener("scroll", handleResize);
|
|
111
|
+
return function() {
|
|
112
|
+
window.removeEventListener("scroll", handleResize);
|
|
113
|
+
};
|
|
114
|
+
}, []);
|
|
115
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
className: dropdownSelect_module_default.dropdown,
|
|
117
|
+
ref: dropdownRef,
|
|
118
|
+
style: isVisible ? {
|
|
119
|
+
top: "calc(100% + 5px)"
|
|
120
|
+
} : {
|
|
121
|
+
bottom: "calc(100% + 5px)"
|
|
122
|
+
},
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx2(Search_default, {
|
|
125
|
+
options: options,
|
|
126
|
+
onSearch: setOption
|
|
127
|
+
}),
|
|
128
|
+
optionsCopy.map(function(option, key) {
|
|
129
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
130
|
+
className: dropdownSelect_module_default.element,
|
|
131
|
+
onClick: function() {
|
|
132
|
+
onChange(option.value);
|
|
133
|
+
setOpen(function(prev) {
|
|
134
|
+
return !prev;
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
children: option.label
|
|
138
|
+
}, key);
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
var Dropdown_default = Dropdown;
|
|
144
|
+
// src/components/DropdownSelect/DropdownSelect.tsx
|
|
145
|
+
import { IoMdClose } from "react-icons/io";
|
|
146
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
147
|
+
var DropdownSelect = function(param) {
|
|
148
|
+
var options = param.options, value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width;
|
|
149
|
+
var _useState2 = _sliced_to_array(useState2(false), 2), open = _useState2[0], setOpen = _useState2[1];
|
|
150
|
+
var selectRef = useRef2(null);
|
|
151
|
+
var clickHandler = function(e) {
|
|
152
|
+
var select = selectRef.current;
|
|
153
|
+
if (!select.contains(e.target)) {
|
|
154
|
+
setOpen(false);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
useEffect2(function() {
|
|
158
|
+
window.addEventListener("click", clickHandler);
|
|
159
|
+
return function() {
|
|
160
|
+
return window.removeEventListener("click", clickHandler);
|
|
161
|
+
};
|
|
162
|
+
}, []);
|
|
163
|
+
return /* @__PURE__ */ jsx3(MyContext.Provider, {
|
|
164
|
+
value: {
|
|
165
|
+
options: options,
|
|
166
|
+
value: value,
|
|
167
|
+
onChange: onChange,
|
|
168
|
+
setOpen: setOpen
|
|
169
|
+
},
|
|
170
|
+
children: /* @__PURE__ */ jsxs2("div", {
|
|
171
|
+
style: {
|
|
172
|
+
width: "".concat(width, "px"),
|
|
173
|
+
position: "relative"
|
|
174
|
+
},
|
|
175
|
+
ref: selectRef,
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsxs2("div", {
|
|
178
|
+
className: dropdownSelect_module_default.select_box,
|
|
179
|
+
onClick: function() {
|
|
180
|
+
return setOpen(function(prev) {
|
|
181
|
+
return !prev;
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsx3("div", {
|
|
186
|
+
className: dropdownSelect_module_default.value,
|
|
187
|
+
children: value
|
|
188
|
+
}),
|
|
189
|
+
/* @__PURE__ */ jsx3("div", {
|
|
190
|
+
className: dropdownSelect_module_default.close,
|
|
191
|
+
title: "clear",
|
|
192
|
+
onClick: function() {
|
|
193
|
+
onChange("");
|
|
194
|
+
setOpen(function(prev) {
|
|
195
|
+
return !prev;
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx3(IoMdClose, {})
|
|
199
|
+
})
|
|
200
|
+
]
|
|
201
|
+
}),
|
|
202
|
+
open && /* @__PURE__ */ jsx3(Dropdown_default, {})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
var DropdownSelect_default = DropdownSelect;
|
|
208
|
+
// src/components/RangeSlider/RangeSlider.tsx
|
|
209
|
+
import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
210
|
+
// scss-module:./rangeSlider.module.css#scss-module
|
|
211
|
+
var rangeSlider_module_default = {
|
|
212
|
+
"slider_border": "rangeSlider-module__slider_border___CoeFx",
|
|
213
|
+
"thumb": "rangeSlider-module__thumb___OnFSM",
|
|
214
|
+
"thumb_shadow": "rangeSlider-module__thumb_shadow___L16TY",
|
|
215
|
+
"fill": "rangeSlider-module__fill___urGCN",
|
|
216
|
+
"rest": "rangeSlider-module__rest___pO2pi",
|
|
217
|
+
"value": "rangeSlider-module__value___Evg0D"
|
|
218
|
+
};
|
|
219
|
+
// src/components/RangeSlider/functions.ts
|
|
220
|
+
function encode(value, min, max) {
|
|
221
|
+
return (parseInt(value) - parseInt(min)) * 100 / (parseInt(max) - parseInt(min));
|
|
222
|
+
}
|
|
223
|
+
function decode(percent, min, max) {
|
|
224
|
+
return Math.round(parseInt(min) + percent * (parseInt(max) - parseInt(min)));
|
|
225
|
+
}
|
|
226
|
+
// src/components/RangeSlider/RangeSlider.tsx
|
|
227
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
228
|
+
var RangeSlider = function(param) {
|
|
229
|
+
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;
|
|
230
|
+
var percentage = encode(value, min, max);
|
|
231
|
+
var sliderBorderRef = useRef3(null);
|
|
232
|
+
var _useState3 = _sliced_to_array(useState3(false), 2), isMouseDown = _useState3[0], setMouseDown = _useState3[1];
|
|
233
|
+
var _useState31 = _sliced_to_array(useState3(false), 2), isHover = _useState31[0], setHover = _useState31[1];
|
|
234
|
+
var handleDrag = function(isClicked, e) {
|
|
235
|
+
if (!isMouseDown && !isClicked) return;
|
|
236
|
+
var sliderBorder = sliderBorderRef.current;
|
|
237
|
+
var dimension = sliderBorder.getBoundingClientRect();
|
|
238
|
+
var clientX;
|
|
239
|
+
if ("touches" in e) {
|
|
240
|
+
clientX = e.touches[0].clientX;
|
|
241
|
+
} else {
|
|
242
|
+
clientX = e.clientX;
|
|
243
|
+
}
|
|
244
|
+
percentage = (clientX - dimension.left) / dimension.width;
|
|
245
|
+
var currentValue = decode(percentage, min, max);
|
|
246
|
+
if (currentValue > parseInt(max)) {
|
|
247
|
+
currentValue = parseInt(max);
|
|
248
|
+
}
|
|
249
|
+
if (currentValue < parseInt(min)) {
|
|
250
|
+
currentValue = parseInt(min);
|
|
251
|
+
}
|
|
252
|
+
onChange(currentValue.toString());
|
|
253
|
+
};
|
|
254
|
+
useEffect3(function() {
|
|
255
|
+
var handleMove = function(e) {
|
|
256
|
+
if (e.type === "touchmove") {
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
}
|
|
259
|
+
handleDrag(false, e);
|
|
260
|
+
};
|
|
261
|
+
var handleMouseUp = function() {
|
|
262
|
+
setMouseDown(false);
|
|
263
|
+
};
|
|
264
|
+
if (isMouseDown) {
|
|
265
|
+
document.addEventListener("mousemove", handleMove);
|
|
266
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
267
|
+
document.addEventListener("touchmove", handleMove, {
|
|
268
|
+
passive: false
|
|
269
|
+
});
|
|
270
|
+
document.addEventListener("touchend", handleMouseUp);
|
|
271
|
+
}
|
|
272
|
+
return function() {
|
|
273
|
+
document.removeEventListener("mousemove", handleMove);
|
|
274
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
275
|
+
document.removeEventListener("touchmove", handleMove);
|
|
276
|
+
document.removeEventListener("touchend", handleMouseUp);
|
|
277
|
+
};
|
|
278
|
+
}, [
|
|
279
|
+
isMouseDown
|
|
280
|
+
]);
|
|
281
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
282
|
+
className: rangeSlider_module_default.slider_border,
|
|
283
|
+
style: {
|
|
284
|
+
width: "".concat(width, "px")
|
|
285
|
+
},
|
|
286
|
+
onMouseDown: function(e) {
|
|
287
|
+
handleDrag(true, e);
|
|
288
|
+
setMouseDown(true);
|
|
289
|
+
},
|
|
290
|
+
onTouchStart: function(e) {
|
|
291
|
+
handleDrag(true, e);
|
|
292
|
+
setMouseDown(true);
|
|
293
|
+
},
|
|
294
|
+
ref: sliderBorderRef,
|
|
295
|
+
children: [
|
|
296
|
+
/* @__PURE__ */ jsx4("span", {
|
|
297
|
+
className: rangeSlider_module_default.fill,
|
|
298
|
+
style: {
|
|
299
|
+
background: color,
|
|
300
|
+
width: "".concat(percentage, "%")
|
|
301
|
+
}
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ jsxs3("span", {
|
|
304
|
+
className: rangeSlider_module_default.thumb,
|
|
305
|
+
style: {
|
|
306
|
+
background: color,
|
|
307
|
+
left: "".concat(percentage, "%")
|
|
308
|
+
},
|
|
309
|
+
onMouseMove: function() {
|
|
310
|
+
return setHover(true);
|
|
311
|
+
},
|
|
312
|
+
onMouseLeave: function() {
|
|
313
|
+
return setHover(false);
|
|
314
|
+
},
|
|
315
|
+
children: [
|
|
316
|
+
/* @__PURE__ */ jsx4("span", {
|
|
317
|
+
className: rangeSlider_module_default.value,
|
|
318
|
+
style: {
|
|
319
|
+
scale: isMouseDown || isHover ? "1" : "0"
|
|
320
|
+
},
|
|
321
|
+
children: value
|
|
322
|
+
}),
|
|
323
|
+
/* @__PURE__ */ jsx4("span", {
|
|
324
|
+
className: rangeSlider_module_default.thumb_shadow,
|
|
325
|
+
style: {
|
|
326
|
+
background: color,
|
|
327
|
+
scale: isMouseDown || isHover ? "1" : "0"
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
]
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ jsx4("span", {
|
|
333
|
+
className: rangeSlider_module_default.rest,
|
|
334
|
+
style: {
|
|
335
|
+
background: color
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
var RangeSlider_default = RangeSlider;
|
|
342
|
+
// scss-module:./optionSlider.module.css#scss-module
|
|
343
|
+
var optionSlider_module_default = {
|
|
344
|
+
"border": "optionSlider-module__border___DvXkD",
|
|
345
|
+
"background": "optionSlider-module__background___P6MQP",
|
|
346
|
+
"options": "optionSlider-module__options___OLBcd",
|
|
347
|
+
"element": "optionSlider-module__element___obtjI"
|
|
348
|
+
};
|
|
349
|
+
// src/components/OptionSlider/OptionSlider.tsx
|
|
350
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
351
|
+
var OptionSlider = function(param) {
|
|
352
|
+
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;
|
|
353
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
354
|
+
className: optionSlider_module_default.border,
|
|
355
|
+
style: {
|
|
356
|
+
width: "".concat(width, "px")
|
|
357
|
+
},
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ jsx5("div", {
|
|
360
|
+
className: optionSlider_module_default.background,
|
|
361
|
+
style: {
|
|
362
|
+
background: color
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
/* @__PURE__ */ jsx5("div", {
|
|
366
|
+
className: optionSlider_module_default.options,
|
|
367
|
+
children: options.map(function(option, key) {
|
|
368
|
+
return /* @__PURE__ */ jsx5("div", {
|
|
369
|
+
style: {
|
|
370
|
+
background: color,
|
|
371
|
+
border: value === option.value ? "solid 2px #000" : "solid 1px #000"
|
|
372
|
+
},
|
|
373
|
+
className: optionSlider_module_default.element,
|
|
374
|
+
onClick: function() {
|
|
375
|
+
return onChange(option.value);
|
|
376
|
+
},
|
|
377
|
+
title: option.value,
|
|
378
|
+
children: option.label
|
|
379
|
+
}, key);
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
]
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
var OptionSlider_default = OptionSlider;
|
|
386
|
+
// src/components/ColorPickerSlider/ColorPickerSlider.tsx
|
|
387
|
+
import { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
388
|
+
// scss-module:./colorPickerSlider.module.css#scss-module
|
|
389
|
+
var colorPickerSlider_module_default = {
|
|
390
|
+
"border": "colorPickerSlider-module__border___-6cw8",
|
|
391
|
+
"thumb": "colorPickerSlider-module__thumb___p2fHW",
|
|
392
|
+
"label": "colorPickerSlider-module__label___Aa0AV"
|
|
393
|
+
};
|
|
394
|
+
// src/components/ColorPickerSlider/functions.ts
|
|
395
|
+
function encode2(color) {
|
|
396
|
+
var h = hexToHsl(color).h;
|
|
397
|
+
return h * 100 / 360;
|
|
398
|
+
}
|
|
399
|
+
function decode2(percent) {
|
|
400
|
+
return hslToHex(percent * 360, 100, 50);
|
|
401
|
+
}
|
|
402
|
+
function hexToHsl(hex) {
|
|
403
|
+
if (hex.length === 7) {
|
|
404
|
+
hex = hex.substring(1);
|
|
405
|
+
}
|
|
406
|
+
var r = parseInt(hex.substring(0, 2), 16) / 255;
|
|
407
|
+
var g = parseInt(hex.substring(2, 4), 16) / 255;
|
|
408
|
+
var b = parseInt(hex.substring(4, 6), 16) / 255;
|
|
409
|
+
var cmax = Math.max(r, g, b);
|
|
410
|
+
var cmin = Math.min(r, g, b);
|
|
411
|
+
var delta = cmax - cmin;
|
|
412
|
+
var h = 0;
|
|
413
|
+
var s = 0;
|
|
414
|
+
var l = (cmax + cmin) / 2;
|
|
415
|
+
if (delta !== 0) {
|
|
416
|
+
s = delta / (1 - Math.abs(2 * l - 1));
|
|
417
|
+
if (cmax === r) {
|
|
418
|
+
h = (g - b) / delta;
|
|
419
|
+
} else if (cmax === g) {
|
|
420
|
+
h = (b - r) / delta + 2;
|
|
421
|
+
} else {
|
|
422
|
+
h = (r - g) / delta + 4;
|
|
423
|
+
}
|
|
424
|
+
h = h * 60;
|
|
425
|
+
if (h < 0) {
|
|
426
|
+
h += 360;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
h: Math.round(h),
|
|
431
|
+
s: Math.round(s * 100),
|
|
432
|
+
l: Math.round(l * 100)
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function hslToHex(h, s, l) {
|
|
436
|
+
s /= 100;
|
|
437
|
+
l /= 100;
|
|
438
|
+
var c = (1 - Math.abs(2 * l - 1)) * s;
|
|
439
|
+
var x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
440
|
+
var m = l - c / 2;
|
|
441
|
+
var r_prime = 0;
|
|
442
|
+
var g_prime = 0;
|
|
443
|
+
var b_prime = 0;
|
|
444
|
+
var sector = h / 60;
|
|
445
|
+
if (sector >= 0 && sector < 1) {
|
|
446
|
+
var ref;
|
|
447
|
+
ref = [
|
|
448
|
+
c,
|
|
449
|
+
x,
|
|
450
|
+
0
|
|
451
|
+
], r_prime = ref[0], g_prime = ref[1], b_prime = ref[2], ref;
|
|
452
|
+
} else if (sector >= 1 && sector < 2) {
|
|
453
|
+
var ref1;
|
|
454
|
+
ref1 = [
|
|
455
|
+
x,
|
|
456
|
+
c,
|
|
457
|
+
0
|
|
458
|
+
], r_prime = ref1[0], g_prime = ref1[1], b_prime = ref1[2], ref1;
|
|
459
|
+
} else if (sector >= 2 && sector < 3) {
|
|
460
|
+
var ref2;
|
|
461
|
+
ref2 = [
|
|
462
|
+
0,
|
|
463
|
+
c,
|
|
464
|
+
x
|
|
465
|
+
], r_prime = ref2[0], g_prime = ref2[1], b_prime = ref2[2], ref2;
|
|
466
|
+
} else if (sector >= 3 && sector < 4) {
|
|
467
|
+
var ref3;
|
|
468
|
+
ref3 = [
|
|
469
|
+
0,
|
|
470
|
+
x,
|
|
471
|
+
c
|
|
472
|
+
], r_prime = ref3[0], g_prime = ref3[1], b_prime = ref3[2], ref3;
|
|
473
|
+
} else if (sector >= 4 && sector < 5) {
|
|
474
|
+
var ref4;
|
|
475
|
+
ref4 = [
|
|
476
|
+
x,
|
|
477
|
+
0,
|
|
478
|
+
c
|
|
479
|
+
], r_prime = ref4[0], g_prime = ref4[1], b_prime = ref4[2], ref4;
|
|
480
|
+
} else if (sector >= 5 && sector < 6) {
|
|
481
|
+
var ref5;
|
|
482
|
+
ref5 = [
|
|
483
|
+
c,
|
|
484
|
+
0,
|
|
485
|
+
x
|
|
486
|
+
], r_prime = ref5[0], g_prime = ref5[1], b_prime = ref5[2], ref5;
|
|
487
|
+
}
|
|
488
|
+
var r = Math.round((r_prime + m) * 255);
|
|
489
|
+
var g = Math.round((g_prime + m) * 255);
|
|
490
|
+
var b = Math.round((b_prime + m) * 255);
|
|
491
|
+
var toHex = function(c2) {
|
|
492
|
+
var hex = c2.toString(16).toUpperCase();
|
|
493
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
494
|
+
};
|
|
495
|
+
return "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b));
|
|
496
|
+
}
|
|
497
|
+
// src/components/ColorPickerSlider/ColorPickerSlider.tsx
|
|
498
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
499
|
+
var ColorPickerSlider = function(param) {
|
|
500
|
+
var value = param.value, onChange = param.onChange, _param_width = param.width, width = _param_width === void 0 ? "200" : _param_width;
|
|
501
|
+
var percentage = encode2(value);
|
|
502
|
+
var sliderBorderRef = useRef4(null);
|
|
503
|
+
var _useState4 = _sliced_to_array(useState4(false), 2), isMouseDown = _useState4[0], setMouseDown = _useState4[1];
|
|
504
|
+
var _useState41 = _sliced_to_array(useState4(false), 2), isHover = _useState41[0], setHover = _useState41[1];
|
|
505
|
+
var handleDrag = function(isClicked, e) {
|
|
506
|
+
if (!isMouseDown && !isClicked) return;
|
|
507
|
+
var sliderBorder = sliderBorderRef.current;
|
|
508
|
+
var dimension = sliderBorder.getBoundingClientRect();
|
|
509
|
+
var clientX;
|
|
510
|
+
if ("touches" in e) {
|
|
511
|
+
clientX = e.touches[0].clientX;
|
|
512
|
+
} else {
|
|
513
|
+
clientX = e.clientX;
|
|
514
|
+
}
|
|
515
|
+
percentage = (clientX - dimension.left) / dimension.width;
|
|
516
|
+
if (percentage < 0) percentage = 0;
|
|
517
|
+
if (percentage > 1) percentage = 0.99;
|
|
518
|
+
onChange(decode2(percentage));
|
|
519
|
+
};
|
|
520
|
+
useEffect4(function() {
|
|
521
|
+
var handleMove = function(e) {
|
|
522
|
+
if (e.type === "touchmove") {
|
|
523
|
+
e.preventDefault();
|
|
524
|
+
}
|
|
525
|
+
handleDrag(false, e);
|
|
526
|
+
};
|
|
527
|
+
var handleMouseUp = function() {
|
|
528
|
+
setMouseDown(false);
|
|
529
|
+
};
|
|
530
|
+
if (isMouseDown) {
|
|
531
|
+
document.addEventListener("mousemove", handleMove);
|
|
532
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
533
|
+
document.addEventListener("touchmove", handleMove, {
|
|
534
|
+
passive: false
|
|
535
|
+
});
|
|
536
|
+
document.addEventListener("touchend", handleMouseUp);
|
|
537
|
+
}
|
|
538
|
+
return function() {
|
|
539
|
+
document.removeEventListener("mousemove", handleMove);
|
|
540
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
541
|
+
document.removeEventListener("touchmove", handleMove);
|
|
542
|
+
document.removeEventListener("touchend", handleMouseUp);
|
|
543
|
+
};
|
|
544
|
+
}, [
|
|
545
|
+
isMouseDown
|
|
546
|
+
]);
|
|
547
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
548
|
+
className: colorPickerSlider_module_default.border,
|
|
549
|
+
style: {
|
|
550
|
+
width: "".concat(width, "px")
|
|
551
|
+
},
|
|
552
|
+
onMouseDown: function(e) {
|
|
553
|
+
handleDrag(true, e);
|
|
554
|
+
setMouseDown(true);
|
|
555
|
+
},
|
|
556
|
+
onTouchStart: function(e) {
|
|
557
|
+
handleDrag(true, e);
|
|
558
|
+
setMouseDown(true);
|
|
559
|
+
},
|
|
560
|
+
ref: sliderBorderRef,
|
|
561
|
+
children: [
|
|
562
|
+
/* @__PURE__ */ jsx6("div", {
|
|
563
|
+
className: colorPickerSlider_module_default.thumb,
|
|
564
|
+
style: {
|
|
565
|
+
width: "".concat(parseInt(width) * 0.1, "px"),
|
|
566
|
+
background: value,
|
|
567
|
+
left: "".concat(percentage, "%")
|
|
568
|
+
},
|
|
569
|
+
onMouseMove: function() {
|
|
570
|
+
return setHover(true);
|
|
571
|
+
},
|
|
572
|
+
onMouseLeave: function() {
|
|
573
|
+
return setHover(false);
|
|
574
|
+
}
|
|
575
|
+
}),
|
|
576
|
+
/* @__PURE__ */ jsx6("div", {
|
|
577
|
+
className: colorPickerSlider_module_default.label,
|
|
578
|
+
style: {
|
|
579
|
+
left: "".concat(percentage, "%"),
|
|
580
|
+
scale: isHover || isMouseDown ? "1" : "0"
|
|
581
|
+
},
|
|
582
|
+
children: value
|
|
583
|
+
})
|
|
584
|
+
]
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
var ColorPickerSlider_default = ColorPickerSlider;
|
|
588
|
+
export { ColorPickerSlider_default as ColorPickerSlider, DropdownSelect_default as DropdownSelect, OptionSlider_default as OptionSlider, RangeSlider_default as RangeSlider };
|
package/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// DropSelect component
|
|
2
|
+
export { default as DropdownSelect } from './src/components/DropdownSelect/DropdownSelect';
|
|
3
|
+
export type { Options } from './src/components/DropdownSelect/DropdownSelect';
|
|
4
|
+
|
|
5
|
+
// RangeSlider component
|
|
6
|
+
export { default as RangeSlider } from './src/components/RangeSlider/RangeSlider';
|
|
7
|
+
|
|
8
|
+
// OptionSlider component
|
|
9
|
+
export { default as OptionSlider } from './src/components/OptionSlider/OptionSlider';
|
|
10
|
+
export type { Options as SliderOptions } from './src/components/OptionSlider/OptionSlider';
|
|
11
|
+
|
|
12
|
+
// ColorPickerSlider
|
|
13
|
+
export { default as ColorPickerSlider } from './src/components/ColorPickerSlider/ColorPickerSlider';
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@willphan1712000/frontend",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Frontend Library",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"watch": "tsup --watch",
|
|
10
|
+
"build": "tsup"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": ">=18.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@swc/core": "^1.13.5",
|
|
17
|
+
"@testing-library/jest-dom": "^6.9.0",
|
|
18
|
+
"@testing-library/react": "^16.3.0",
|
|
19
|
+
"@types/jest": "^27.5.2",
|
|
20
|
+
"@types/node": "^16.18.126",
|
|
21
|
+
"@types/react": "^19.1.16",
|
|
22
|
+
"@types/react-dom": "^19.1.9",
|
|
23
|
+
"esbuild-plugin-css-module": "^0.1.0",
|
|
24
|
+
"esbuild-plugin-react18-css": "^0.0.4",
|
|
25
|
+
"react": "^19.1.1",
|
|
26
|
+
"react-dom": "^19.1.1",
|
|
27
|
+
"ts-loader": "^9.5.4",
|
|
28
|
+
"tsup": "^8.5.0",
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"web-vitals": "^5.1.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"react-icons": "^5.5.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
Binary file
|
|
Binary file
|