jy-headless 0.2.36 → 0.3.6

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 (116) hide show
  1. package/Input/NumberInput.d.ts +3 -0
  2. package/Input/NumberInput.type.d.ts +31 -0
  3. package/Input/TextInput.d.ts +3 -0
  4. package/Input/TextInput.type.d.ts +95 -0
  5. package/Popover/Popover.d.ts +2 -0
  6. package/Popover/Popover.js +75 -0
  7. package/Popover/Popover.type.d.ts +9 -0
  8. package/Popover/index.d.ts +2 -0
  9. package/Select/Select.d.ts +51 -0
  10. package/Select/Select.type.d.ts +52 -0
  11. package/Tooltip/Tooltip.d.ts +10 -0
  12. package/Tooltip/Tooltip.js +36 -0
  13. package/Tooltip/Tooltip.type.d.ts +20 -0
  14. package/Tooltip/index.d.ts +2 -0
  15. package/cjs/Input/NumberInput.d.ts +3 -0
  16. package/cjs/Input/NumberInput.type.d.ts +31 -0
  17. package/cjs/Input/TextInput.d.ts +3 -0
  18. package/cjs/Input/TextInput.type.d.ts +95 -0
  19. package/cjs/Popover/Popover.d.ts +2 -0
  20. package/cjs/Popover/Popover.js +77 -0
  21. package/cjs/Popover/Popover.type.d.ts +9 -0
  22. package/cjs/Popover/index.d.ts +2 -0
  23. package/cjs/Select/Select.d.ts +51 -0
  24. package/cjs/Select/Select.type.d.ts +52 -0
  25. package/cjs/Tooltip/Tooltip.d.ts +10 -0
  26. package/cjs/Tooltip/Tooltip.js +38 -0
  27. package/cjs/Tooltip/Tooltip.type.d.ts +20 -0
  28. package/cjs/Tooltip/index.d.ts +2 -0
  29. package/cjs/hooks/index.d.ts +3 -3
  30. package/cjs/hooks/useDebounce.d.ts +1 -0
  31. package/cjs/hooks/useDebounce.js +24 -0
  32. package/cjs/hooks/usePortal.d.ts +23 -0
  33. package/cjs/hooks/usePortal.js +80 -0
  34. package/cjs/hooks/useThrottle.d.ts +1 -0
  35. package/cjs/hooks/useThrottle.js +34 -0
  36. package/cjs/index.d.ts +3 -6
  37. package/cjs/index.js +8 -23
  38. package/hooks/index.d.ts +3 -3
  39. package/hooks/useDebounce.d.ts +1 -0
  40. package/hooks/useDebounce.js +22 -0
  41. package/hooks/usePortal.d.ts +23 -0
  42. package/hooks/usePortal.js +78 -0
  43. package/hooks/useThrottle.d.ts +1 -0
  44. package/hooks/useThrottle.js +32 -0
  45. package/index.d.ts +3 -6
  46. package/index.js +5 -13
  47. package/package.json +23 -63
  48. package/version.txt +1 -1
  49. package/buttons/Button/Button.d.ts +0 -3
  50. package/buttons/Button/Button.js +0 -9
  51. package/buttons/index.d.ts +0 -1
  52. package/cjs/buttons/Button/Button.d.ts +0 -3
  53. package/cjs/buttons/Button/Button.js +0 -11
  54. package/cjs/buttons/index.d.ts +0 -1
  55. package/cjs/hooks/useDebouncing.d.ts +0 -2
  56. package/cjs/hooks/useDebouncing.js +0 -16
  57. package/cjs/hooks/useDropdown.d.ts +0 -10
  58. package/cjs/hooks/useDropdown.js +0 -32
  59. package/cjs/hooks/useThrottling.d.ts +0 -2
  60. package/cjs/hooks/useThrottling.js +0 -16
  61. package/cjs/inputs/ImageInput/ImageInput.d.ts +0 -7
  62. package/cjs/inputs/ImageInput/ImageInput.js +0 -76
  63. package/cjs/inputs/Input/Input.d.ts +0 -3
  64. package/cjs/inputs/Input/Input.js +0 -17
  65. package/cjs/inputs/checkboxList/CheckboxList.d.ts +0 -5
  66. package/cjs/inputs/checkboxList/CheckboxList.js +0 -32
  67. package/cjs/inputs/checkboxList/index.d.ts +0 -5
  68. package/cjs/inputs/checkboxList/index.js +0 -32
  69. package/cjs/inputs/index.d.ts +0 -3
  70. package/cjs/selectors/Dropdown/Dropdown.d.ts +0 -8
  71. package/cjs/selectors/Dropdown/Dropdown.js +0 -55
  72. package/cjs/selectors/index.d.ts +0 -1
  73. package/cjs/tooltip/Tooltip/Tooltip.d.ts +0 -5
  74. package/cjs/tooltip/Tooltip/Tooltip.js +0 -66
  75. package/cjs/tooltip/index.d.ts +0 -1
  76. package/cjs/types/buttons/index.d.ts +0 -7
  77. package/cjs/types/common/index.d.ts +0 -11
  78. package/cjs/types/index.d.ts +0 -4
  79. package/cjs/types/inputs/index.d.ts +0 -36
  80. package/cjs/types/selectors/index.d.ts +0 -16
  81. package/cjs/types/tooltip/index.d.ts +0 -14
  82. package/cjs/types/tooltip/index.js +0 -7
  83. package/cjs/utils/ArrayUtils.d.ts +0 -2
  84. package/cjs/utils/MessageUtils.d.ts +0 -1
  85. package/cjs/utils/index.d.ts +0 -1
  86. package/hooks/useDebouncing.d.ts +0 -2
  87. package/hooks/useDebouncing.js +0 -14
  88. package/hooks/useDropdown.d.ts +0 -10
  89. package/hooks/useDropdown.js +0 -26
  90. package/hooks/useThrottling.d.ts +0 -2
  91. package/hooks/useThrottling.js +0 -14
  92. package/inputs/ImageInput/ImageInput.d.ts +0 -7
  93. package/inputs/ImageInput/ImageInput.js +0 -71
  94. package/inputs/Input/Input.d.ts +0 -3
  95. package/inputs/Input/Input.js +0 -15
  96. package/inputs/checkboxList/CheckboxList.d.ts +0 -5
  97. package/inputs/checkboxList/CheckboxList.js +0 -30
  98. package/inputs/checkboxList/index.d.ts +0 -5
  99. package/inputs/checkboxList/index.js +0 -30
  100. package/inputs/index.d.ts +0 -3
  101. package/selectors/Dropdown/Dropdown.d.ts +0 -8
  102. package/selectors/Dropdown/Dropdown.js +0 -53
  103. package/selectors/index.d.ts +0 -1
  104. package/tooltip/Tooltip/Tooltip.d.ts +0 -5
  105. package/tooltip/Tooltip/Tooltip.js +0 -64
  106. package/tooltip/index.d.ts +0 -1
  107. package/types/buttons/index.d.ts +0 -7
  108. package/types/common/index.d.ts +0 -11
  109. package/types/index.d.ts +0 -4
  110. package/types/inputs/index.d.ts +0 -36
  111. package/types/selectors/index.d.ts +0 -16
  112. package/types/tooltip/index.d.ts +0 -14
  113. package/types/tooltip/index.js +0 -5
  114. package/utils/ArrayUtils.d.ts +0 -2
  115. package/utils/MessageUtils.d.ts +0 -1
  116. package/utils/index.d.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jy-headless",
3
- "version": "0.2.36",
3
+ "version": "0.3.6",
4
4
  "description": "A lightweight and customizable headless UI library for React components",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/yCZwIqY/jy-headless",
@@ -13,80 +13,40 @@
13
13
  "require": "./cjs/index.js",
14
14
  "types": "./index.d.ts"
15
15
  },
16
- "./Button": {
17
- "import": "./cjs/buttons/Button/Button.js",
18
- "require": "./cjs/cjs/buttons/Button/Button.js",
19
- "types": "./cjs/buttons/Button/Button.d.ts"
20
- },
21
16
  "./cjs": {
22
17
  "import": "./cjs/index.js",
23
18
  "require": "./cjs/cjs/index.js",
24
19
  "types": "./cjs/index.d.ts"
25
20
  },
26
- "./useDebouncing": {
27
- "import": "./hooks/useDebouncing.js",
28
- "require": "./cjs/hooks/useDebouncing.js",
29
- "types": "./hooks/useDebouncing.d.ts"
21
+ "./useDebounce": {
22
+ "import": "./hooks/useDebounce.js",
23
+ "require": "./cjs/hooks/useDebounce.js",
24
+ "types": "./hooks/useDebounce.d.ts"
30
25
  },
31
- "./useDropdown": {
32
- "import": "./hooks/useDropdown.js",
33
- "require": "./cjs/hooks/useDropdown.js",
34
- "types": "./hooks/useDropdown.d.ts"
26
+ "./usePortal": {
27
+ "import": "./hooks/usePortal.js",
28
+ "require": "./cjs/hooks/usePortal.js",
29
+ "types": "./hooks/usePortal.d.ts"
35
30
  },
36
- "./useThrottling": {
37
- "import": "./hooks/useThrottling.js",
38
- "require": "./cjs/hooks/useThrottling.js",
39
- "types": "./hooks/useThrottling.d.ts"
31
+ "./useThrottle": {
32
+ "import": "./hooks/useThrottle.js",
33
+ "require": "./cjs/hooks/useThrottle.js",
34
+ "types": "./hooks/useThrottle.d.ts"
40
35
  },
41
36
  "./index": {
42
- "import": "./types/tooltip/index.js",
43
- "require": "./cjs/types/tooltip/index.js",
44
- "types": "./types/tooltip/index.d.ts"
45
- },
46
- "./cjs/inputs/checkboxList": {
47
- "import": "./cjs/inputs/checkboxList/index.js",
48
- "require": "./cjs/cjs/inputs/checkboxList/index.js",
49
- "types": "./cjs/inputs/checkboxList/index.d.ts"
50
- },
51
- "./CheckboxList": {
52
- "import": "./inputs/checkboxList/CheckboxList.js",
53
- "require": "./cjs/inputs/checkboxList/CheckboxList.js",
54
- "types": "./inputs/checkboxList/CheckboxList.d.ts"
55
- },
56
- "./ImageInput": {
57
- "import": "./inputs/ImageInput/ImageInput.js",
58
- "require": "./cjs/inputs/ImageInput/ImageInput.js",
59
- "types": "./inputs/ImageInput/ImageInput.d.ts"
60
- },
61
- "./Input": {
62
- "import": "./inputs/Input/Input.js",
63
- "require": "./cjs/inputs/Input/Input.js",
64
- "types": "./inputs/Input/Input.d.ts"
37
+ "import": "./index.js",
38
+ "require": "./cjs/index.js",
39
+ "types": "./index.d.ts"
65
40
  },
66
- "./Dropdown": {
67
- "import": "./selectors/Dropdown/Dropdown.js",
68
- "require": "./cjs/selectors/Dropdown/Dropdown.js",
69
- "types": "./selectors/Dropdown/Dropdown.d.ts"
41
+ "./Popover": {
42
+ "import": "./Popover/Popover.js",
43
+ "require": "./cjs/Popover/Popover.js",
44
+ "types": "./Popover/Popover.d.ts"
70
45
  },
71
46
  "./Tooltip": {
72
- "import": "./tooltip/Tooltip/Tooltip.js",
73
- "require": "./cjs/tooltip/Tooltip/Tooltip.js",
74
- "types": "./tooltip/Tooltip/Tooltip.d.ts"
75
- },
76
- "./cjs/types/tooltip": {
77
- "import": "./cjs/types/tooltip/index.js",
78
- "require": "./cjs/cjs/types/tooltip/index.js",
79
- "types": "./cjs/types/tooltip/index.d.ts"
80
- },
81
- "./inputs/checkboxList": {
82
- "import": "./inputs/checkboxList/index.js",
83
- "require": "./cjs/inputs/checkboxList/index.js",
84
- "types": "./inputs/checkboxList/index.d.ts"
85
- },
86
- "./types/tooltip": {
87
- "import": "./types/tooltip/index.js",
88
- "require": "./cjs/types/tooltip/index.js",
89
- "types": "./types/tooltip/index.d.ts"
47
+ "import": "./Tooltip/Tooltip.js",
48
+ "require": "./cjs/Tooltip/Tooltip.js",
49
+ "types": "./Tooltip/Tooltip.d.ts"
90
50
  }
91
51
  },
92
52
  "keywords": [
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.2.36
1
+ 0.3.6
@@ -1,3 +0,0 @@
1
- import type { ButtonProps } from '../../types';
2
- declare const Button: ({ onClick, loading, readOnly, disabled, useDebounce, timeout, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
3
- export default Button;
@@ -1,9 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import useDebouncing from '../../hooks/useDebouncing.js';
3
-
4
- const Button = ({ onClick, loading = false, readOnly = false, disabled = false, useDebounce = false, timeout = 300, children, ...props }) => {
5
- const handleClick = onClick && useDebounce ? useDebouncing(onClick, timeout || 300) : onClick;
6
- return (jsx("button", { onClick: handleClick, disabled: disabled || loading || readOnly, ...props, children: children }));
7
- };
8
-
9
- export { Button as default };
@@ -1 +0,0 @@
1
- export * as Button from './Button/Button';
@@ -1,3 +0,0 @@
1
- import type { ButtonProps } from '../../types';
2
- declare const Button: ({ onClick, loading, readOnly, disabled, useDebounce, timeout, children, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
3
- export default Button;
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var useDebouncing = require('../../hooks/useDebouncing.js');
5
-
6
- const Button = ({ onClick, loading = false, readOnly = false, disabled = false, useDebounce = false, timeout = 300, children, ...props }) => {
7
- const handleClick = onClick && useDebounce ? useDebouncing(onClick, timeout || 300) : onClick;
8
- return (jsxRuntime.jsx("button", { onClick: handleClick, disabled: disabled || loading || readOnly, ...props, children: children }));
9
- };
10
-
11
- module.exports = Button;
@@ -1 +0,0 @@
1
- export * as Button from './Button/Button';
@@ -1,2 +0,0 @@
1
- declare const useDebouncing: <T extends (...args: any[]) => void>(callback: T, delay: number) => T;
2
- export default useDebouncing;
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
-
5
- const useDebouncing = (callback, delay) => {
6
- const timer = react.useRef(null);
7
- return react.useCallback(() => {
8
- if (timer.current)
9
- clearTimeout(timer.current);
10
- timer.current = setTimeout(() => {
11
- callback();
12
- }, delay);
13
- }, [callback, delay]);
14
- };
15
-
16
- module.exports = useDebouncing;
@@ -1,10 +0,0 @@
1
- import { DropdownContextValue } from '../types';
2
- export declare const DropdownContext: import("react").Context<DropdownContextValue<any> | null>;
3
- declare const useDropdown: <T>(defaultValue?: T | null) => {
4
- isOpen: boolean;
5
- selected: T | null;
6
- toggle: () => void;
7
- select: (value: T) => void;
8
- };
9
- export declare const useDropdownContext: <T>() => DropdownContextValue<T>;
10
- export default useDropdown;
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var react = require('react');
6
-
7
- const DropdownContext = react.createContext(null);
8
- const useDropdown = (defaultValue = null) => {
9
- const [isOpen, setIsOpen] = react.useState(false);
10
- const [selected, setSelected] = react.useState(defaultValue);
11
- const toggle = () => setIsOpen((prev) => !prev);
12
- const select = (value) => {
13
- setSelected(value);
14
- setIsOpen(false);
15
- };
16
- return {
17
- isOpen,
18
- selected,
19
- toggle,
20
- select,
21
- };
22
- };
23
- const useDropdownContext = () => {
24
- const context = react.useContext(DropdownContext);
25
- if (!context)
26
- throw new Error('Dropdown components must be used within <Dropdown>');
27
- return context;
28
- };
29
-
30
- exports.DropdownContext = DropdownContext;
31
- exports.default = useDropdown;
32
- exports.useDropdownContext = useDropdownContext;
@@ -1,2 +0,0 @@
1
- declare const useThrottling: <T extends (...args: any[]) => void>(callback: T, delay: number) => T;
2
- export default useThrottling;
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
-
5
- const useThrottling = (callback, delay) => {
6
- const lastCalled = react.useRef(0);
7
- return react.useCallback((...args) => {
8
- const now = Date.now();
9
- if (now - lastCalled.current >= delay) {
10
- lastCalled.current = now;
11
- callback(...args);
12
- }
13
- }, [callback, delay]);
14
- };
15
-
16
- module.exports = useThrottling;
@@ -1,7 +0,0 @@
1
- import { ImageAttribute, ImageInputContextData, ImageInputProps, LabelAttribute } from '../../types';
2
- export declare const ImageInputContext: import("react").Context<ImageInputContextData | null>;
3
- declare const ImageInput: (({ accepts, id, value, draggable, onChange, children, ...props }: ImageInputProps) => import("react/jsx-runtime").JSX.Element) & {
4
- Preview: ({ src: defaultSrc, ...props }: ImageAttribute) => import("react/jsx-runtime").JSX.Element;
5
- Uploader: ({ children, ...props }: LabelAttribute) => import("react/jsx-runtime").JSX.Element;
6
- };
7
- export default ImageInput;
@@ -1,76 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var react = require('react');
7
-
8
- const ImageInputContext = react.createContext(null);
9
- const getAccepts = (accepts) => {
10
- return accepts && accepts.length > 0 ? accepts.map((it) => `image/${it}`).join() : 'image/*';
11
- };
12
- const ImageInputRoot = ({ accepts, id, value, draggable = false, onChange, children, ...props }) => {
13
- const [previewUrl, setPreviewUrl] = react.useState('');
14
- const [dragOver, setDragOver] = react.useState(false);
15
- const inputId = [id, 'image-input'].join('-');
16
- react.useEffect(() => {
17
- if (!value)
18
- setPreviewUrl('');
19
- }, [value]);
20
- const setImagePreview = (file) => {
21
- const reader = new FileReader();
22
- reader.onload = (e) => {
23
- setPreviewUrl(e.target.result);
24
- };
25
- reader.readAsDataURL(file);
26
- };
27
- const onImageChange = (e) => {
28
- const file = e.target.files?.[0];
29
- if (!file)
30
- return;
31
- setImagePreview(file);
32
- onChange?.(file);
33
- };
34
- const onDrop = (e) => {
35
- if (!draggable)
36
- return;
37
- e.preventDefault();
38
- setDragOver(false);
39
- const file = e.dataTransfer.files?.[0];
40
- if (file && file.type.startsWith('image/')) {
41
- setImagePreview(file);
42
- onChange?.(file);
43
- }
44
- };
45
- const onDragOver = (e) => {
46
- if (!draggable)
47
- return;
48
- e.preventDefault();
49
- setDragOver(true);
50
- };
51
- const onDragLeave = () => setDragOver(false);
52
- return (jsxRuntime.jsxs("span", { ...props, onDrop: onDrop, onDragOver: onDragOver, onDragEnter: onDragOver, onDragLeave: onDragLeave, children: [jsxRuntime.jsx("input", { "data-testid": inputId, id: inputId, type: 'file', accept: getAccepts(accepts ?? []), onChange: onImageChange, style: { display: 'none' } }), jsxRuntime.jsx(ImageInputContext.Provider, { value: { id: inputId, previewUrl, dragOver }, children: children })] }));
53
- };
54
- const ImageInputUploader = ({ children, ...props }) => {
55
- const context = react.useContext(ImageInputContext);
56
- if (!context) {
57
- throw new Error('ImageInput.* 컴포넌트는 ImageInput 내에서만 사용해야 합니다.');
58
- }
59
- const { id } = context;
60
- return (jsxRuntime.jsx("label", { htmlFor: id ?? '', ...props, children: children }));
61
- };
62
- const ImageInputPreview = ({ src: defaultSrc, ...props }) => {
63
- const context = react.useContext(ImageInputContext);
64
- if (!context) {
65
- throw new Error('ImageInput.* 컴포넌트는 ImageInput 내에서만 사용해야 합니다.');
66
- }
67
- const { previewUrl } = context;
68
- return jsxRuntime.jsx("img", { ...props, src: previewUrl ?? defaultSrc ?? '' });
69
- };
70
- const ImageInput = Object.assign(ImageInputRoot, {
71
- Preview: ImageInputPreview,
72
- Uploader: ImageInputUploader,
73
- });
74
-
75
- exports.ImageInputContext = ImageInputContext;
76
- exports.default = ImageInput;
@@ -1,3 +0,0 @@
1
- import { InputProps } from '../../types';
2
- declare const Input: ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass, onChange, timeout, children, showLimit, maxLength, onThrottledChange, ...props }: InputProps) => import("react/jsx-runtime").JSX.Element;
3
- export default Input;
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var useThrottling = require('../../hooks/useThrottling.js');
5
-
6
- const Input = ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, children, showLimit, maxLength, onThrottledChange, ...props }) => {
7
- const throttledOnChange = onThrottledChange ? useThrottling(onThrottledChange, timeout) : null;
8
- const handleChange = (e) => {
9
- if (maxLength && e.target.value?.length > maxLength)
10
- return;
11
- onChange?.(e);
12
- throttledOnChange?.(e);
13
- };
14
- return (jsxRuntime.jsxs("span", { "data-testid": 'input-wrapper', id: [id, 'input-wrapper'].join('-'), className: wrapperClass?.join(' '), style: wrapperStyle, children: [prefixElement, jsxRuntime.jsx("input", { role: 'textbox', id: id, value: value, onChange: handleChange, ...props }), showLimit && maxLength && (jsxRuntime.jsxs("span", { id: [id, 'input-limit'].join('-'), children: [(value ?? '').toString().length, "/", maxLength] })), suffixElement] }));
15
- };
16
-
17
- module.exports = Input;
@@ -1,5 +0,0 @@
1
- import { CheckboxItemProps, CheckboxProps } from '../../types';
2
- declare const CheckboxList: (<T>({ children, values, onChange, max, ...props }: CheckboxProps<T>) => import("react/jsx-runtime").JSX.Element) & {
3
- Item: <T>({ value, children, id, ...props }: CheckboxItemProps<T>) => import("react/jsx-runtime").JSX.Element | null;
4
- };
5
- export default CheckboxList;
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
-
6
- const CheckboxContext = react.createContext(null);
7
- const CheckBoxRoot = ({ children, values, onChange, max = Infinity, ...props }) => {
8
- const onToggle = (checked, isCheck) => {
9
- if (isCheck && values.length < max) {
10
- onChange([...values, checked]);
11
- }
12
- else {
13
- onChange(values.filter((it) => it != checked));
14
- }
15
- };
16
- return (jsxRuntime.jsx("div", { ...props, children: jsxRuntime.jsx(CheckboxContext.Provider, { value: { values, onToggle }, children: children }) }));
17
- };
18
- const CheckBoxItem = ({ value, children, id, ...props }) => {
19
- const context = react.useContext(CheckboxContext);
20
- if (!context) {
21
- logCannotFindContextError('CheckboxList');
22
- return null;
23
- }
24
- const uuid = react.useMemo(() => id || crypto.randomUUID(), []);
25
- const { values, onToggle } = context;
26
- return (jsxRuntime.jsxs("div", { ...props, children: [jsxRuntime.jsx("input", { id: uuid, checked: values.includes(value), onChange: (e) => onToggle(value, e.target.checked), type: 'checkbox' }), jsxRuntime.jsxs("label", { htmlFor: uuid, children: [" ", children] })] }));
27
- };
28
- const CheckboxList = Object.assign(CheckBoxRoot, {
29
- Item: CheckBoxItem,
30
- });
31
-
32
- module.exports = CheckboxList;
@@ -1,5 +0,0 @@
1
- import { CheckboxItemProps, CheckboxProps } from '../../types';
2
- declare const CheckboxList: (<T>({ children, values, onChange, max, ...props }: CheckboxProps<T>) => import("react/jsx-runtime").JSX.Element) & {
3
- Item: <T>({ value, children, id, ...props }: CheckboxItemProps<T>) => import("react/jsx-runtime").JSX.Element | null;
4
- };
5
- export default CheckboxList;
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
-
6
- const CheckboxContext = react.createContext(null);
7
- const CheckBoxRoot = ({ children, values, onChange, max = Infinity, ...props }) => {
8
- const onToggle = (checked, isCheck) => {
9
- if (isCheck && values.length < max) {
10
- onChange([...values, checked]);
11
- }
12
- else {
13
- onChange(values.filter((it) => it != checked));
14
- }
15
- };
16
- return (jsxRuntime.jsx("div", { ...props, children: jsxRuntime.jsx(CheckboxContext.Provider, { value: { values, onToggle }, children: children }) }));
17
- };
18
- const CheckBoxItem = ({ value, children, id, ...props }) => {
19
- const context = react.useContext(CheckboxContext);
20
- if (!context) {
21
- logCannotFindContextError('CheckboxList');
22
- return null;
23
- }
24
- const uuid = react.useMemo(() => id || crypto.randomUUID(), []);
25
- const { values, onToggle } = context;
26
- return (jsxRuntime.jsxs("div", { ...props, children: [jsxRuntime.jsx("input", { id: uuid, checked: values.includes(value), onChange: (e) => onToggle(value, e.target.checked), type: 'checkbox' }), jsxRuntime.jsxs("label", { htmlFor: uuid, children: [" ", children] })] }));
27
- };
28
- const CheckboxList = Object.assign(CheckBoxRoot, {
29
- Item: CheckBoxItem,
30
- });
31
-
32
- module.exports = CheckboxList;
@@ -1,3 +0,0 @@
1
- export * as Input from './Input/Input';
2
- export * as ImageInput from './ImageInput/ImageInput';
3
- export * as CheckboxList from './checkboxList/CheckboxList';
@@ -1,8 +0,0 @@
1
- import { DivAttribute, DropdownProps, SpanAttribute } from '../../types';
2
- declare const Dropdown: (<T>({ select, selected, isOpen, toggle, children, ...props }: DropdownProps<T>) => import("react/jsx-runtime").JSX.Element) & {
3
- Button: <T>({ onClick, children, ...props }: SpanAttribute<T>) => import("react/jsx-runtime").JSX.Element;
4
- Options: <T>({ children, ...props }: DivAttribute<T>) => import("react/jsx-runtime").JSX.Element | null;
5
- Option: <T>({ children, value, ...props }: DivAttribute<T>) => import("react/jsx-runtime").JSX.Element;
6
- Viewer: ({ children, ...props }: SpanAttribute<null>) => import("react/jsx-runtime").JSX.Element;
7
- };
8
- export default Dropdown;
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var useDropdown = require('../../hooks/useDropdown.js');
6
-
7
- const DropdownRoot = ({ select, selected, isOpen, toggle, children, ...props }) => {
8
- const dropdownRef = react.useRef(null);
9
- const unControlled = useDropdown.default();
10
- const customValue = {
11
- isOpen: isOpen ?? unControlled.isOpen,
12
- toggle: toggle ?? unControlled.toggle,
13
- select: select ?? unControlled.select,
14
- selected: selected ?? unControlled.selected,
15
- };
16
- react.useEffect(() => {
17
- if (!dropdownRef.current)
18
- return;
19
- const onClickOutside = (e) => {
20
- if (!dropdownRef.current?.contains(e.target)) {
21
- if (isOpen && toggle) {
22
- toggle();
23
- }
24
- }
25
- };
26
- window.addEventListener('click', onClickOutside);
27
- return () => window.removeEventListener('click', onClickOutside);
28
- }, [customValue]);
29
- return (jsxRuntime.jsx("div", { ...props, ref: dropdownRef, children: jsxRuntime.jsx(useDropdown.DropdownContext.Provider, { value: customValue, children: children }) }));
30
- };
31
- const DropdownViewer = ({ children, ...props }) => {
32
- return (jsxRuntime.jsx("span", { role: 'viewer', ...props, children: children }));
33
- };
34
- const DropdownButton = ({ onClick, children, ...props }) => {
35
- const { toggle } = useDropdown.useDropdownContext();
36
- return (jsxRuntime.jsx("span", { ...props, onClick: toggle, children: children }));
37
- };
38
- const DropdownOptions = ({ children, ...props }) => {
39
- const { isOpen } = useDropdown.useDropdownContext();
40
- if (!isOpen)
41
- return null;
42
- return jsxRuntime.jsx("div", { ...props, children: children });
43
- };
44
- const DropdownOption = ({ children, value, ...props }) => {
45
- const { select } = useDropdown.useDropdownContext();
46
- return (jsxRuntime.jsx("div", { role: "option", onClick: () => select(value), ...props, children: children }));
47
- };
48
- const Dropdown = Object.assign(DropdownRoot, {
49
- Button: DropdownButton,
50
- Options: DropdownOptions,
51
- Option: DropdownOption,
52
- Viewer: DropdownViewer,
53
- });
54
-
55
- module.exports = Dropdown;
@@ -1 +0,0 @@
1
- export * as Dropdown from './Dropdown/Dropdown';
@@ -1,5 +0,0 @@
1
- import { TooltipProps } from '../../types/tooltip';
2
- declare const Tooltip: (({ children, style, position, space, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element) & {
3
- Label: ({ children, style, ...props }: React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
4
- };
5
- export default Tooltip;
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var index = require('../../types/tooltip/index.js');
6
-
7
- const TooltipRoot = ({ children, style, position = 'top', space = 8, ...props }) => {
8
- const [showTooltip, setShowTooltip] = react.useState(false);
9
- const [tooltipPosition, setTooltipPosition] = react.useState({});
10
- react.useEffect(() => {
11
- if (!showTooltip)
12
- return;
13
- const positionStyles = {
14
- zIndex: 1000,
15
- };
16
- switch (position) {
17
- case 'top':
18
- positionStyles.bottom = `calc(100% + ${space}px)`;
19
- positionStyles.left = '50%';
20
- positionStyles.transform = 'translateX(-50%)';
21
- break;
22
- case 'bottom':
23
- positionStyles.top = `calc(100% + ${space}px)`;
24
- positionStyles.left = '50%';
25
- positionStyles.transform = 'translateX(-50%)';
26
- break;
27
- case 'left':
28
- positionStyles.right = `calc(100% + ${space}px)`;
29
- positionStyles.top = '50%';
30
- positionStyles.transform = 'translateY(-50%)';
31
- break;
32
- case 'right':
33
- positionStyles.left = `calc(100% + ${space}px)`;
34
- positionStyles.top = '50%';
35
- positionStyles.transform = 'translateY(-50%)';
36
- break;
37
- }
38
- setTooltipPosition(positionStyles);
39
- }, [showTooltip, position]);
40
- const onMouseOver = () => setShowTooltip(true);
41
- const onMouseLeave = () => setShowTooltip(false);
42
- return (jsxRuntime.jsx("div", { style: {
43
- position: 'relative',
44
- display: 'inline-block', // 자식 크기에 영향 안 받도록
45
- ...style,
46
- }, onMouseOver: onMouseOver, onMouseLeave: onMouseLeave, ...props, children: jsxRuntime.jsx(index.TooltipContext.Provider, { value: { show: showTooltip, tooltipPosition }, children: children }) }));
47
- };
48
- const TooltipLabel = ({ children, style, ...props }) => {
49
- const context = react.useContext(index.TooltipContext);
50
- if (!context) {
51
- throw new Error('Tooltip.* 컴포넌트는 Tooltip 내에서만 사용해야 합니다.');
52
- }
53
- const { show, tooltipPosition } = context;
54
- const labelStyle = {
55
- position: 'absolute',
56
- visibility: show ? 'visible' : 'hidden',
57
- ...tooltipPosition,
58
- ...style,
59
- };
60
- return (jsxRuntime.jsx("div", { style: labelStyle, ...props, children: children }));
61
- };
62
- const Tooltip = Object.assign(TooltipRoot, {
63
- Label: TooltipLabel,
64
- });
65
-
66
- module.exports = Tooltip;
@@ -1 +0,0 @@
1
- export * as Tooltip from './Tooltip/Tooltip';
@@ -1,7 +0,0 @@
1
- import { ButtonHTMLAttributes } from 'react';
2
- export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
- loading?: boolean;
4
- readOnly?: boolean;
5
- useDebounce?: boolean;
6
- timeout?: number;
7
- }
@@ -1,11 +0,0 @@
1
- import { HTMLAttributes, ImgHTMLAttributes } from 'react';
2
- export interface DivAttribute<T> extends HTMLAttributes<HTMLDivElement> {
3
- value?: T;
4
- }
5
- export interface SpanAttribute<T> extends HTMLAttributes<HTMLSpanElement> {
6
- value?: T;
7
- }
8
- export interface LabelAttribute extends HTMLAttributes<HTMLLabelElement> {
9
- }
10
- export interface ImageAttribute extends ImgHTMLAttributes<HTMLImageElement> {
11
- }
@@ -1,4 +0,0 @@
1
- export * from './buttons';
2
- export * from './inputs';
3
- export * from './selectors';
4
- export * from './common';