@bbodek/hooks 0.0.19 → 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.
Files changed (27) hide show
  1. package/dist/FilterCalendarPanel-tgOkj1yi-Ca95srv1-CXb7mQ6r.js +46 -0
  2. package/dist/FilterCalendarPanel-tgOkj1yi-Ca95srv1-CXb7mQ6r.js.map +1 -0
  3. package/dist/FilterCalendarPanel-xRJERPNn-CFJAMzHr.js +46 -0
  4. package/dist/FilterCalendarPanel-xRJERPNn-CFJAMzHr.js.map +1 -0
  5. package/dist/FilterMultiSelectPanel-BKJ7F-nP-DqwwAW3z-mmfuCg1f.js +51 -0
  6. package/dist/FilterMultiSelectPanel-BKJ7F-nP-DqwwAW3z-mmfuCg1f.js.map +1 -0
  7. package/dist/FilterMultiSelectPanel-M8j-s3EV-BzHL2e14.js +51 -0
  8. package/dist/FilterMultiSelectPanel-M8j-s3EV-BzHL2e14.js.map +1 -0
  9. package/dist/FilterSelectOptionPanel-D_AQGIT2-DUOIV1sc.js +22 -0
  10. package/dist/FilterSelectOptionPanel-D_AQGIT2-DUOIV1sc.js.map +1 -0
  11. package/dist/FilterSelectOptionPanel-uodA0iXc-kXTbi7Ni-BlAqWYjA.js +22 -0
  12. package/dist/FilterSelectOptionPanel-uodA0iXc-kXTbi7Ni-BlAqWYjA.js.map +1 -0
  13. package/dist/hooks/useDropzone/types/index.d.ts +2 -2
  14. package/dist/hooks/useDropzone/types/index.d.ts.map +1 -1
  15. package/dist/hooks/useDropzone/useDropzoneInput.d.ts +3 -2
  16. package/dist/hooks/useDropzone/useDropzoneInput.d.ts.map +1 -1
  17. package/dist/hooks/useDropzone/useDropzoneUpload.d.ts +1 -1
  18. package/dist/hooks/useDropzone/useDropzoneUpload.d.ts.map +1 -1
  19. package/dist/index-_fK2m8cY.js +72035 -0
  20. package/dist/index-_fK2m8cY.js.map +1 -0
  21. package/dist/index.es.js +6 -504
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/useFilterSelectOptionPanel-CliL1k8Q-B38iwnY2.js +38 -0
  24. package/dist/useFilterSelectOptionPanel-CliL1k8Q-B38iwnY2.js.map +1 -0
  25. package/dist/useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13-COH6mNr-.js +38 -0
  26. package/dist/useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13-COH6mNr-.js.map +1 -0
  27. package/package.json +13 -7
package/dist/index.es.js CHANGED
@@ -1,505 +1,7 @@
1
- import { useRef, useEffect, useLayoutEffect, useCallback, useMemo, useReducer, useState } from 'react';
2
- import { composeEventHandler, ACCEPT_FILES, executeFunction, getUUID } from '@bbodek/utils';
3
-
4
- const useFirstRenderEffect = (effect) => {
5
- const isFirstRender = useRef(true);
6
- useEffect(() => {
7
- if (isFirstRender.current) {
8
- isFirstRender.current = false;
9
- effect();
10
- }
11
- }, []);
12
- };
13
-
14
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
15
-
16
- const useScrollLockEffect = ({ isLocked, target, }) => {
17
- useEffect(() => {
18
- const element = target ? document.getElementById(target) : document.body;
19
- if (element) {
20
- if (isLocked) {
21
- element.style.overflow = 'hidden';
22
- }
23
- else {
24
- element.style.overflow = 'auto';
25
- }
26
- return () => {
27
- element.style.overflow = 'auto';
28
- };
29
- }
30
- }, [isLocked, target]);
31
- };
32
-
33
- const useClickOutSideEffect = ({ ref, onClose, useClickOutsideEvent = true, }) => {
34
- useEffect(() => {
35
- const onClickOutSide = (e) => {
36
- if (!ref.current || ref.current.contains(e.target))
37
- return;
38
- onClose(e);
39
- };
40
- if (useClickOutsideEvent) {
41
- document.addEventListener('mousedown', onClickOutSide);
42
- }
43
- else {
44
- document.removeEventListener('mousedown', onClickOutSide);
45
- }
46
- return () => {
47
- if (useClickOutsideEvent) {
48
- document.removeEventListener('mousedown', onClickOutSide);
49
- }
50
- };
51
- }, [ref.current, useClickOutsideEvent]);
52
- };
53
-
54
- const useClickOutside = ({ onClose, useClickOutsideEvent, }) => {
55
- const contentRef = useRef(null);
56
- useClickOutSideEffect({
57
- ref: contentRef,
58
- onClose,
59
- useClickOutsideEvent,
60
- });
61
- return { contentRef };
62
- };
63
-
64
- const useComposeEventHandler = () => {
65
- const compose = useCallback((handler) => composeEventHandler(handler), []);
66
- return { compose };
67
- };
68
-
69
- const DROPZONE_ACTION_MAPPER = {
70
- DRAG: 'drag',
71
- HOVER: 'hover',
72
- SET_FILES: 'setFiles',
73
- SET_REJECT: 'setReject',
74
- DELETE_FILE: 'deleteFile',
75
- RESET_FILES: 'resetFiles',
76
- };
77
- const DROPZONE_REJECT_CODE_MAPPER = {
78
- SINGLE_FILE_ONLY: 'SINGLE_FILE_ONLY',
79
- TOO_MANY_FILES: 'TOO_MANY_FILES',
80
- NEED_ACTIVE_MULTIPLE_OPTION: 'NEED_ACTIVE_MULTIPLE_OPTION',
81
- INVALID_FILE_FORMAT: 'INVALID_FILE_FORMAT',
82
- };
83
- const DROPZONE_REJECT_MESSAGE = {
84
- [DROPZONE_REJECT_CODE_MAPPER['SINGLE_FILE_ONLY']]: '한 개의 파일만 선택할 수 있어요',
85
- [DROPZONE_REJECT_CODE_MAPPER['TOO_MANY_FILES']]: '너무 많은 파일이 선택되었어요',
86
- [DROPZONE_REJECT_CODE_MAPPER['NEED_ACTIVE_MULTIPLE_OPTION']]: '다중 선택 옵션을 활성화 시켜주세요',
87
- [DROPZONE_REJECT_CODE_MAPPER['INVALID_FILE_FORMAT']]: '지원하지 않는 형식의 파일이 있어요',
88
- };
89
-
90
- const revokeFile = ({ url }) => Array.isArray(url)
91
- ? url.forEach((_url) => URL.revokeObjectURL(_url))
92
- : URL.revokeObjectURL(url);
93
-
94
- const useDropzoneFilesCleanupEffect = ({ acceptedFiles, }) => {
95
- useFirstRenderEffect(() => {
96
- revokeFile({ url: acceptedFiles.map((file) => file['blob']) });
97
- });
98
- };
99
-
100
- const parseAcceptAttr = ({ accept = ACCEPT_FILES, }) => accept.join(',');
101
-
102
- const useExecuteFunction = () => {
103
- const execute = useCallback((params) => executeFunction(params), []);
104
- return { execute };
105
- };
106
-
107
- const useDropzoneInput = ({ multiple = true, accept = ACCEPT_FILES, disabled = false, handleUpload, }) => {
108
- const inputRef = useRef(null);
109
- const { execute } = useExecuteFunction();
110
- const { compose } = useComposeEventHandler();
111
- const handleChangeCallback = useCallback((e) => {
112
- e.preventDefault();
113
- if (!e.target || !e.target.files)
114
- return;
115
- const { files } = e.target;
116
- handleUpload({ files });
117
- }, [handleUpload]);
118
- const inputProps = useMemo(() => ({ onChange, ...rest } = {}) => {
119
- const props = {
120
- multiple,
121
- type: 'file',
122
- style: { display: 'none' },
123
- tabIndex: -1,
124
- ref: inputRef,
125
- onChange: execute({
126
- disabled,
127
- fn: compose({
128
- externalEventHandler: onChange,
129
- internalEventHandler: handleChangeCallback,
130
- }),
131
- }),
132
- accept: parseAcceptAttr({ accept }),
133
- disabled,
134
- };
135
- return { ...props, ...rest };
136
- }, [
137
- multiple,
138
- accept,
139
- inputRef,
140
- handleChangeCallback,
141
- disabled,
142
- execute,
143
- compose,
144
- ]);
145
- return { inputProps, inputRef };
146
- };
147
-
148
- const initialState = {
149
- isDragActive: false,
150
- isHover: false,
151
- isActive: false,
152
- acceptedFiles: [],
153
- rejectedFiles: undefined,
154
- };
155
- const dropZoneReducer = (state, action) => {
156
- switch (action.type) {
157
- case DROPZONE_ACTION_MAPPER['DRAG']:
158
- return {
159
- ...state,
160
- isDragActive: action['isDragActive'] ?? state['isDragActive'],
161
- isActive: action['isDragActive'] ?? state['isDragActive'],
162
- };
163
- case DROPZONE_ACTION_MAPPER['HOVER']:
164
- return {
165
- ...state,
166
- isHover: action['isHover'] ?? state['isHover'],
167
- isActive: action['isHover'] ?? state['isHover'],
168
- };
169
- case DROPZONE_ACTION_MAPPER['SET_FILES']:
170
- return {
171
- ...state,
172
- acceptedFiles: action['acceptedFiles'] ?? state['acceptedFiles'],
173
- rejectedFiles: undefined,
174
- isDragActive: false,
175
- isHover: false,
176
- isActive: false,
177
- };
178
- case DROPZONE_ACTION_MAPPER['SET_REJECT']:
179
- return {
180
- ...state,
181
- rejectedFiles: action['rejectedFiles'] ?? state['rejectedFiles'],
182
- isDragActive: false,
183
- isHover: false,
184
- isActive: false,
185
- };
186
- case DROPZONE_ACTION_MAPPER['DELETE_FILE']:
187
- return {
188
- ...state,
189
- acceptedFiles: state['acceptedFiles'].filter((file) => file['id'] !== action['id']),
190
- };
191
- case DROPZONE_ACTION_MAPPER['RESET_FILES']:
192
- return {
193
- ...state,
194
- acceptedFiles: [],
195
- };
196
- default:
197
- return state;
198
- }
199
- };
200
- const useDropzoneReducer = () => {
201
- const [state, dispatch] = useReducer(dropZoneReducer, initialState);
202
- return { state, dispatch };
203
- };
204
-
205
- const useDropzoneRoot = ({ inputRef, dispatch, disabled = false, handleUpload, }) => {
206
- const rootRef = useRef(null);
207
- const { execute } = useExecuteFunction();
208
- const { compose } = useComposeEventHandler();
209
- const isRelatedDropZone = useMemo(() => (e) => e.relatedTarget instanceof Node &&
210
- rootRef.current &&
211
- rootRef.current.contains(e.relatedTarget), [rootRef.current]);
212
- const handleMouseEnterCallback = useCallback(() => dispatch({ type: DROPZONE_ACTION_MAPPER['HOVER'], isHover: true }), [dispatch]);
213
- const handleMouseLeaveCallback = useCallback((e) => {
214
- if (isRelatedDropZone(e))
215
- return;
216
- dispatch({ type: DROPZONE_ACTION_MAPPER['HOVER'], isHover: false });
217
- }, [dispatch, isRelatedDropZone]);
218
- const handleDragEnterCallback = useCallback((e) => {
219
- e.preventDefault();
220
- dispatch({ type: DROPZONE_ACTION_MAPPER['DRAG'], isDragActive: true });
221
- }, [dispatch]);
222
- const handleDragLeaveCallback = useCallback((e) => {
223
- e.preventDefault();
224
- if (isRelatedDropZone(e))
225
- return;
226
- dispatch({ type: DROPZONE_ACTION_MAPPER['DRAG'], isDragActive: false });
227
- }, [dispatch, isRelatedDropZone]);
228
- const handleDragOverCallback = useCallback((e) => e.preventDefault(), []);
229
- const handleDropCallback = useCallback((e) => {
230
- e.preventDefault();
231
- if (!e.dataTransfer || !e.dataTransfer.files)
232
- return;
233
- const { files } = e.dataTransfer;
234
- handleUpload({ files });
235
- }, [handleUpload]);
236
- const handleClickCallback = useCallback(() => {
237
- if (inputRef.current) {
238
- inputRef.current.value = '';
239
- inputRef.current.click();
240
- }
241
- }, [inputRef.current]);
242
- const rootProps = useMemo(() => ({ onDrop, onClick, onDragEnter, onDragLeave, onDragOver, onMouseEnter, onMouseLeave, role, ...rest } = {}) => {
243
- const props = {
244
- onDrop: execute({
245
- disabled,
246
- fn: compose({
247
- externalEventHandler: onDrop,
248
- internalEventHandler: handleDropCallback,
249
- }),
250
- }),
251
- onClick: execute({
252
- disabled,
253
- fn: compose({
254
- externalEventHandler: onClick,
255
- internalEventHandler: handleClickCallback,
256
- }),
257
- }),
258
- onDragEnter: execute({
259
- disabled,
260
- fn: compose({
261
- externalEventHandler: onDragEnter,
262
- internalEventHandler: handleDragEnterCallback,
263
- }),
264
- }),
265
- onDragLeave: execute({
266
- disabled,
267
- fn: compose({
268
- externalEventHandler: onDragLeave,
269
- internalEventHandler: handleDragLeaveCallback,
270
- }),
271
- }),
272
- onDragOver: execute({
273
- disabled,
274
- fn: compose({
275
- externalEventHandler: onDragOver,
276
- internalEventHandler: handleDragOverCallback,
277
- }),
278
- }),
279
- onMouseEnter: execute({
280
- disabled,
281
- fn: compose({
282
- externalEventHandler: onMouseEnter,
283
- internalEventHandler: handleMouseEnterCallback,
284
- }),
285
- }),
286
- onMouseLeave: execute({
287
- disabled,
288
- fn: compose({
289
- externalEventHandler: onMouseLeave,
290
- internalEventHandler: handleMouseLeaveCallback,
291
- }),
292
- }),
293
- role: typeof role === 'string' && role !== '' ? role : 'presentation',
294
- ref: rootRef,
295
- };
296
- return {
297
- ...props,
298
- ...rest,
299
- };
300
- }, [
301
- handleDropCallback,
302
- handleClickCallback,
303
- handleDragEnterCallback,
304
- handleDragLeaveCallback,
305
- handleDragOverCallback,
306
- handleMouseEnterCallback,
307
- handleMouseLeaveCallback,
308
- rootRef,
309
- disabled,
310
- execute,
311
- compose,
312
- ]);
313
- return { rootProps };
314
- };
315
-
316
- const useDropzoneUpload = ({ uploadedFiles, state, dispatch, multiple = true, limit, onDrop, onDropAccepted, onDropRejected, accept = ACCEPT_FILES, }) => {
317
- const parseFileData = (file) => {
318
- const { name, size, type, lastModified, webkitRelativePath } = file;
319
- return {
320
- id: getUUID(),
321
- name,
322
- size,
323
- type,
324
- lastModified,
325
- webkitRelativePath,
326
- blob: URL.createObjectURL(file),
327
- original: file,
328
- };
329
- };
330
- const rejectUpload = ({ acceptedFiles, rejectCode }) => {
331
- const rejectedFiles = {
332
- files: acceptedFiles,
333
- code: rejectCode,
334
- };
335
- dispatch({
336
- type: DROPZONE_ACTION_MAPPER['SET_REJECT'],
337
- acceptedFiles,
338
- rejectedFiles,
339
- });
340
- onDropRejected?.({ rejectedFiles, state, dispatch });
341
- onDrop?.({
342
- acceptedFiles: [],
343
- rejectedFiles,
344
- state,
345
- dispatch,
346
- });
347
- console.error(`An error occurred in Dropzone. code: ${rejectCode}`);
348
- };
349
- const handleUpload = ({ files }) => {
350
- const acceptedFiles = Array.from(files, parseFileData);
351
- if (!multiple && acceptedFiles.length > 1) {
352
- return rejectUpload({
353
- acceptedFiles,
354
- rejectCode: DROPZONE_REJECT_CODE_MAPPER['SINGLE_FILE_ONLY'],
355
- });
356
- }
357
- if (typeof limit !== 'undefined') {
358
- if (!multiple) {
359
- return rejectUpload({
360
- acceptedFiles,
361
- rejectCode: DROPZONE_REJECT_CODE_MAPPER['NEED_ACTIVE_MULTIPLE_OPTION'],
362
- });
363
- }
364
- if (acceptedFiles.length > limit) {
365
- return rejectUpload({
366
- acceptedFiles,
367
- rejectCode: DROPZONE_REJECT_CODE_MAPPER['TOO_MANY_FILES'],
368
- });
369
- }
370
- }
371
- const isRejectAccept = acceptedFiles.some((file) => {
372
- const acceptFileKeys = ['type', 'name'];
373
- return acceptFileKeys.every((acceptFileKey) => !accept.some((acceptType) => file[acceptFileKey].toLowerCase().includes(acceptType)));
374
- });
375
- if (isRejectAccept) {
376
- return rejectUpload({
377
- acceptedFiles,
378
- rejectCode: DROPZONE_REJECT_CODE_MAPPER['INVALID_FILE_FORMAT'],
379
- });
380
- }
381
- dispatch({ type: DROPZONE_ACTION_MAPPER['SET_FILES'], acceptedFiles });
382
- onDropAccepted?.({ acceptedFiles, state, dispatch });
383
- onDrop?.({
384
- acceptedFiles,
385
- state,
386
- dispatch,
387
- });
388
- };
389
- const resetFiles = () => {
390
- revokeFile({ url: uploadedFiles.map((file) => file['blob']) });
391
- dispatch({ type: DROPZONE_ACTION_MAPPER['RESET_FILES'] });
392
- };
393
- const deleteFile = ({ id }) => {
394
- dispatch({ type: DROPZONE_ACTION_MAPPER['DELETE_FILE'], id });
395
- };
396
- return { handleUpload, deleteFile, resetFiles };
397
- };
398
-
399
- const useDropzone = (props) => {
400
- const { multiple = true, limit, disabled = false, onDrop, onDropAccepted, onDropRejected, accept = ACCEPT_FILES, } = props;
401
- const { state, dispatch } = useDropzoneReducer();
402
- const { handleUpload, deleteFile, resetFiles } = useDropzoneUpload({
403
- uploadedFiles: state['acceptedFiles'],
404
- state,
405
- dispatch,
406
- multiple,
407
- limit,
408
- onDrop,
409
- onDropAccepted,
410
- onDropRejected,
411
- accept,
412
- });
413
- const { inputProps, inputRef } = useDropzoneInput({
414
- disabled,
415
- handleUpload,
416
- multiple,
417
- accept,
418
- });
419
- const { rootProps } = useDropzoneRoot({
420
- inputRef,
421
- dispatch,
422
- disabled,
423
- handleUpload,
424
- });
425
- useDropzoneFilesCleanupEffect({ acceptedFiles: state['acceptedFiles'] });
426
- return { state, deleteFile, resetFiles, rootProps, inputProps, dispatch };
427
- };
428
-
429
- const useForm = ({ initialValues, validate, }) => {
430
- const [values, setValuesState] = useState(initialValues);
431
- const [errors, setErrors] = useState({});
432
- const handleChange = (e) => {
433
- const { name, value } = e.target;
434
- if (name in initialValues) {
435
- setValuesState({ ...values, [name]: value });
436
- if (validate) {
437
- const validationErrors = validate({
438
- ...values,
439
- [name]: value,
440
- });
441
- setErrors(validationErrors);
442
- }
443
- }
444
- };
445
- const setValues = (newValues) => {
446
- const updatedValues = typeof newValues === 'function' ? newValues(values) : newValues;
447
- setValuesState(updatedValues);
448
- if (validate) {
449
- const validationErrors = validate(updatedValues);
450
- setErrors(validationErrors);
451
- }
452
- };
453
- return {
454
- values,
455
- setValues,
456
- errors,
457
- handleChange,
458
- setErrors,
459
- };
460
- };
461
-
462
- const RESPONSIBLE_STATUS = {
463
- MOBILE: 'MOBILE',
464
- TABLET: 'TABLET',
465
- DESKTOP: 'DESKTOP',
466
- };
467
- const BREAKPOINT_SIZE = {
468
- [RESPONSIBLE_STATUS.MOBILE]: 360,
469
- [RESPONSIBLE_STATUS.TABLET]: 820,
470
- [RESPONSIBLE_STATUS.DESKTOP]: 1180,
471
- };
472
-
473
- const useResponsibleStatusEffect = ({ setStatus, }) => {
474
- useEffect(() => {
475
- const handleResize = () => {
476
- const width = window.innerWidth;
477
- const calculateStatus = () => {
478
- if (width >= BREAKPOINT_SIZE.DESKTOP) {
479
- return RESPONSIBLE_STATUS.DESKTOP;
480
- }
481
- else if (width >= BREAKPOINT_SIZE.TABLET) {
482
- return RESPONSIBLE_STATUS.TABLET;
483
- }
484
- else {
485
- return RESPONSIBLE_STATUS.MOBILE;
486
- }
487
- };
488
- setStatus(calculateStatus());
489
- };
490
- handleResize();
491
- window.addEventListener('resize', handleResize);
492
- return () => {
493
- window.removeEventListener('resize', handleResize);
494
- };
495
- }, []);
496
- };
497
-
498
- const useResponsible = () => {
499
- const [status, setStatus] = useState(null);
500
- useResponsibleStatusEffect({ setStatus });
501
- return { status };
502
- };
503
-
504
- export { BREAKPOINT_SIZE, DROPZONE_ACTION_MAPPER, DROPZONE_REJECT_CODE_MAPPER, DROPZONE_REJECT_MESSAGE, RESPONSIBLE_STATUS, useClickOutSideEffect, useClickOutside, useComposeEventHandler, useDropzone, useExecuteFunction, useFirstRenderEffect, useForm, useIsomorphicLayoutEffect, useResponsible, useScrollLockEffect };
1
+ export { a0 as BREAKPOINT_SIZE, V as DROPZONE_ACTION_MAPPER, W as DROPZONE_REJECT_CODE_MAPPER, X as DROPZONE_REJECT_MESSAGE, $ as RESPONSIBLE_STATUS, S as useClickOutSideEffect, R as useClickOutside, T as useComposeEventHandler, U as useDropzone, Y as useExecuteFunction, O as useFirstRenderEffect, Z as useForm, P as useIsomorphicLayoutEffect, _ as useResponsible, Q as useScrollLockEffect } from './index-_fK2m8cY.js';
2
+ import 'react';
3
+ import 'react/jsx-runtime';
4
+ import 'react-dom';
5
+ import 'fs';
6
+ import 'stream';
505
7
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { p as useFilterContext, u as useFilterPanelContext, q as FILTER_STEPS, B as Button, r as BUTTON_THEMES, s as BUTTON_SIZES } from './index-_fK2m8cY.js';
3
+ import { useCallback } from 'react';
4
+
5
+ const FilterSelectButton = ({ onClick, disabled }) => {
6
+ return (jsx("div", { className: 'border-t-in-gray-02 border-t p-4', children: jsx(Button, { className: 'w-full', disabled: disabled, label: '\uC120\uD0DD \uC644\uB8CC', size: BUTTON_SIZES.SM, theme: BUTTON_THEMES.PRIMARY, onClick: onClick }) }));
7
+ };
8
+
9
+ const useFilterSelectOptionPanel = () => {
10
+ const { toggleValues = null, selectValues, selectOptions, onChange, } = useFilterContext();
11
+ const { currentOptions, currentSelectValue, setCurrentSelectValue, setFilterStep, } = useFilterPanelContext();
12
+ const { key } = currentOptions;
13
+ const selectValue = selectValues?.[key] ?? null;
14
+ const _currentSelectValue = currentSelectValue?.[key] ?? null;
15
+ const value = selectValue ?? _currentSelectValue;
16
+ const options = selectOptions.find((option) => option.key === key);
17
+ const handleChange = useCallback(({ value }) => {
18
+ onChange({
19
+ toggleValues,
20
+ selectValues: {
21
+ ...selectValues,
22
+ [key]: value,
23
+ },
24
+ });
25
+ setFilterStep(FILTER_STEPS.IDLE);
26
+ setCurrentSelectValue(null);
27
+ }, [key, currentSelectValue, selectValues]);
28
+ return {
29
+ models: {
30
+ value,
31
+ options,
32
+ },
33
+ operations: { handleChange, setCurrentSelectValue },
34
+ };
35
+ };
36
+
37
+ export { FilterSelectButton as F, useFilterSelectOptionPanel as u };
38
+ //# sourceMappingURL=useFilterSelectOptionPanel-CliL1k8Q-B38iwnY2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFilterSelectOptionPanel-CliL1k8Q-B38iwnY2.js","sources":["../../../node_modules/.pnpm/@bbodek+internal-ui@0.0.47_@bbodek+hooks@0.0.20_@bbodek+utils@0.0.18_react-dom@19.1.0_r_d6746e838fae43790bb6979f6e7cc369/node_modules/@bbodek/internal-ui/dist/useFilterSelectOptionPanel-CliL1k8Q.js"],"sourcesContent":["import { jsx } from 'react/jsx-runtime';\nimport { B as Button, l as BUTTON_THEMES, m as BUTTON_SIZES, n as useFilterContext, u as useFilterPanelContext, o as FILTER_STEPS } from './index-nvdefcFf.js';\nimport { useCallback } from 'react';\n\nconst FilterSelectButton = ({ onClick, disabled }) => {\n return (jsx(\"div\", { className: 'border-t-in-gray-02 border-t p-4', children: jsx(Button, { className: 'w-full', disabled: disabled, label: '\\uC120\\uD0DD \\uC644\\uB8CC', size: BUTTON_SIZES.SM, theme: BUTTON_THEMES.PRIMARY, onClick: onClick }) }));\n};\n\nconst useFilterSelectOptionPanel = () => {\n const { toggleValues = null, selectValues, selectOptions, onChange, } = useFilterContext();\n const { currentOptions, currentSelectValue, setCurrentSelectValue, setFilterStep, } = useFilterPanelContext();\n const { key } = currentOptions;\n const selectValue = selectValues?.[key] ?? null;\n const _currentSelectValue = currentSelectValue?.[key] ?? null;\n const value = selectValue ?? _currentSelectValue;\n const options = selectOptions.find((option) => option.key === key);\n const handleChange = useCallback(({ value }) => {\n onChange({\n toggleValues,\n selectValues: {\n ...selectValues,\n [key]: value,\n },\n });\n setFilterStep(FILTER_STEPS.IDLE);\n setCurrentSelectValue(null);\n }, [key, currentSelectValue, selectValues]);\n return {\n models: {\n value,\n options,\n },\n operations: { handleChange, setCurrentSelectValue },\n };\n};\n\nexport { FilterSelectButton as F, useFilterSelectOptionPanel as u };\n//# sourceMappingURL=useFilterSelectOptionPanel-CliL1k8Q.js.map\n"],"names":[],"mappings":";;;;AAIK,MAAC,kBAAkB,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK;AACtD,IAAI,QAAQ,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,kCAAkC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,2BAA2B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YAAY,EAAE,qBAAqB,EAAE;AAC3D,KAAK;AACL;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,38 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { I as useFilterContext, a as useFilterPanelContext, J as FILTER_STEPS, K as Button, L as BUTTON_SIZES, N as BUTTON_THEMES } from './index-_fK2m8cY.js';
3
+ import { useCallback } from 'react';
4
+
5
+ const FilterSelectButton = ({ onClick, disabled }) => {
6
+ return (jsx("div", { className: 'border-t-in-gray-02 border-t p-4', children: jsx(Button, { label: '\uC120\uD0DD \uC644\uB8CC', theme: BUTTON_THEMES.PRIMARY, size: BUTTON_SIZES.SM, onClick: onClick, className: 'w-full', disabled: disabled }) }));
7
+ };
8
+
9
+ const useFilterSelectOptionPanel = () => {
10
+ const { toggleValues = null, selectValues, selectOptions, onChange, } = useFilterContext();
11
+ const { currentOptions, currentSelectValue, setCurrentSelectValue, setFilterStep, } = useFilterPanelContext();
12
+ const { key } = currentOptions;
13
+ const selectValue = selectValues?.[key] ?? null;
14
+ const _currentSelectValue = currentSelectValue?.[key] ?? null;
15
+ const value = selectValue ?? _currentSelectValue;
16
+ const options = selectOptions.find((option) => option.key === key);
17
+ const handleChange = useCallback(({ value }) => {
18
+ onChange({
19
+ toggleValues,
20
+ selectValues: {
21
+ ...selectValues,
22
+ [key]: value,
23
+ },
24
+ });
25
+ setFilterStep(FILTER_STEPS.IDLE);
26
+ setCurrentSelectValue(null);
27
+ }, [key, currentSelectValue, selectValues]);
28
+ return {
29
+ models: {
30
+ value,
31
+ options,
32
+ },
33
+ operations: { handleChange, setCurrentSelectValue },
34
+ };
35
+ };
36
+
37
+ export { FilterSelectButton as F, useFilterSelectOptionPanel as u };
38
+ //# sourceMappingURL=useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13-COH6mNr-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13-COH6mNr-.js","sources":["../../../node_modules/.pnpm/@bbodek+hooks@0.0.20_@bbodek+internal-ui@0.0.47_next@15.3.2_react-dom@19.1.0_react@19.1_ec9476c75b6e0c0ca8f9de2a0dfc11c9/node_modules/@bbodek/hooks/dist/useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13.js"],"sourcesContent":["import { jsx } from 'react/jsx-runtime';\nimport { l as useFilterContext, u as useFilterPanelContext, m as FILTER_STEPS, B as Button, n as BUTTON_SIZES, o as BUTTON_THEMES } from './index-BotlieCc.js';\nimport { useCallback } from 'react';\n\nconst FilterSelectButton = ({ onClick, disabled }) => {\n return (jsx(\"div\", { className: 'border-t-in-gray-02 border-t p-4', children: jsx(Button, { label: '\\uC120\\uD0DD \\uC644\\uB8CC', theme: BUTTON_THEMES.PRIMARY, size: BUTTON_SIZES.SM, onClick: onClick, className: 'w-full', disabled: disabled }) }));\n};\n\nconst useFilterSelectOptionPanel = () => {\n const { toggleValues = null, selectValues, selectOptions, onChange, } = useFilterContext();\n const { currentOptions, currentSelectValue, setCurrentSelectValue, setFilterStep, } = useFilterPanelContext();\n const { key } = currentOptions;\n const selectValue = selectValues?.[key] ?? null;\n const _currentSelectValue = currentSelectValue?.[key] ?? null;\n const value = selectValue ?? _currentSelectValue;\n const options = selectOptions.find((option) => option.key === key);\n const handleChange = useCallback(({ value }) => {\n onChange({\n toggleValues,\n selectValues: {\n ...selectValues,\n [key]: value,\n },\n });\n setFilterStep(FILTER_STEPS.IDLE);\n setCurrentSelectValue(null);\n }, [key, currentSelectValue, selectValues]);\n return {\n models: {\n value,\n options,\n },\n operations: { handleChange, setCurrentSelectValue },\n };\n};\n\nexport { FilterSelectButton as F, useFilterSelectOptionPanel as u };\n//# sourceMappingURL=useFilterSelectOptionPanel-E9OE1xmu-hQsWrD13.js.map\n"],"names":[],"mappings":";;;;AAIK,MAAC,kBAAkB,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK;AACtD,IAAI,QAAQ,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,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,CAAC,CAAC;AAC/C,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE;AAChB,YAAY,KAAK;AACjB,YAAY,OAAO;AACnB,SAAS;AACT,QAAQ,UAAU,EAAE,EAAE,YAAY,EAAE,qBAAqB,EAAE;AAC3D,KAAK;AACL;;;;","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@bbodek/hooks",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/thebbodek/dotoli",
9
+ "directory": "apps/hooks"
10
+ },
11
+ "homepage": "https://github.com/thebbodek/dotoli/tree/main/apps/hooks#readme",
6
12
  "exports": {
7
13
  ".": {
8
14
  "import": "./dist/index.es.js",
@@ -12,18 +18,18 @@
12
18
  "files": [
13
19
  "dist"
14
20
  ],
15
- "dependencies": {},
21
+ "dependencies": {
22
+ "@bbodek/utils": "0.0.19"
23
+ },
16
24
  "peerDependencies": {
17
25
  "next": "^15.3.1",
18
26
  "react": "^19.1.0",
19
- "react-dom": "^19.1.0",
20
- "@bbodek/utils": "^0.0.16"
27
+ "react-dom": "^19.1.0"
21
28
  },
22
29
  "devDependencies": {
23
30
  "next": "^15.3.1",
24
31
  "react": "^19.1.0",
25
32
  "react-dom": "^19.1.0",
26
- "@bbodek/utils": "^0.0.16",
27
33
  "@types/node": "^20",
28
34
  "@types/react": "^19",
29
35
  "@types/react-dom": "^19",
@@ -32,7 +38,7 @@
32
38
  "tsc-alias": "^1.8.16",
33
39
  "tslib": "^2.8.1",
34
40
  "typescript": "^5.8.3",
35
- "@dotoli/eslint-config": "0.0.0",
41
+ "@bbodek/eslint-config": "0.0.4",
36
42
  "@dotoli/typescript-config": "0.0.0",
37
43
  "@dotoli/rollup-config": "0.0.0"
38
44
  },
@@ -40,6 +46,6 @@
40
46
  "dev": "rollup -c --watch & tsc -p tsconfig.build.json --watch & tsc-alias -p tsconfig.build.json --watch",
41
47
  "build": "rollup -c && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
42
48
  "start": "next start",
43
- "lint": "next lint"
49
+ "lint": "eslint \"./src\" --ext .ts,.tsx"
44
50
  }
45
51
  }