jy-headless 0.2.35 → 0.3.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/Popover/Popover.d.ts +2 -0
- package/Popover/Popover.js +75 -0
- package/Popover/Popover.type.d.ts +9 -0
- package/Popover/index.d.ts +2 -0
- package/cjs/Popover/Popover.d.ts +2 -0
- package/cjs/Popover/Popover.js +77 -0
- package/cjs/Popover/Popover.type.d.ts +9 -0
- package/cjs/Popover/index.d.ts +2 -0
- package/cjs/index.d.ts +1 -7
- package/cjs/index.js +2 -21
- package/index.d.ts +1 -7
- package/index.js +1 -12
- package/package.json +8 -53
- package/version.txt +1 -1
- package/buttons/Button/Button.d.ts +0 -3
- package/buttons/Button/Button.js +0 -9
- package/buttons/index.d.ts +0 -1
- package/cjs/buttons/Button/Button.d.ts +0 -3
- package/cjs/buttons/Button/Button.js +0 -11
- package/cjs/buttons/index.d.ts +0 -1
- package/cjs/hooks/index.d.ts +0 -3
- package/cjs/hooks/useDebouncing.d.ts +0 -2
- package/cjs/hooks/useDebouncing.js +0 -16
- package/cjs/hooks/useDropdown.d.ts +0 -10
- package/cjs/hooks/useDropdown.js +0 -32
- package/cjs/hooks/useThrottling.d.ts +0 -2
- package/cjs/hooks/useThrottling.js +0 -16
- package/cjs/inputs/ImageInput/ImageInput.d.ts +0 -7
- package/cjs/inputs/ImageInput/ImageInput.js +0 -76
- package/cjs/inputs/Input/Input.d.ts +0 -3
- package/cjs/inputs/Input/Input.js +0 -17
- package/cjs/inputs/checkboxList/index.d.ts +0 -5
- package/cjs/inputs/index.d.ts +0 -2
- package/cjs/selectors/Dropdown/Dropdown.d.ts +0 -8
- package/cjs/selectors/Dropdown/Dropdown.js +0 -55
- package/cjs/selectors/index.d.ts +0 -1
- package/cjs/tooltip/Tooltip/Tooltip.d.ts +0 -5
- package/cjs/tooltip/Tooltip/Tooltip.js +0 -66
- package/cjs/tooltip/index.d.ts +0 -1
- package/cjs/types/buttons/index.d.ts +0 -7
- package/cjs/types/common/index.d.ts +0 -11
- package/cjs/types/index.d.ts +0 -4
- package/cjs/types/inputs/index.d.ts +0 -36
- package/cjs/types/selectors/index.d.ts +0 -16
- package/cjs/types/tooltip/index.d.ts +0 -14
- package/cjs/types/tooltip/index.js +0 -7
- package/cjs/utils/ArrayUtils.d.ts +0 -2
- package/cjs/utils/MessageUtils.d.ts +0 -1
- package/cjs/utils/index.d.ts +0 -1
- package/hooks/index.d.ts +0 -3
- package/hooks/useDebouncing.d.ts +0 -2
- package/hooks/useDebouncing.js +0 -14
- package/hooks/useDropdown.d.ts +0 -10
- package/hooks/useDropdown.js +0 -26
- package/hooks/useThrottling.d.ts +0 -2
- package/hooks/useThrottling.js +0 -14
- package/inputs/ImageInput/ImageInput.d.ts +0 -7
- package/inputs/ImageInput/ImageInput.js +0 -71
- package/inputs/Input/Input.d.ts +0 -3
- package/inputs/Input/Input.js +0 -15
- package/inputs/checkboxList/index.d.ts +0 -5
- package/inputs/index.d.ts +0 -2
- package/selectors/Dropdown/Dropdown.d.ts +0 -8
- package/selectors/Dropdown/Dropdown.js +0 -53
- package/selectors/index.d.ts +0 -1
- package/tooltip/Tooltip/Tooltip.d.ts +0 -5
- package/tooltip/Tooltip/Tooltip.js +0 -64
- package/tooltip/index.d.ts +0 -1
- package/types/buttons/index.d.ts +0 -7
- package/types/common/index.d.ts +0 -11
- package/types/index.d.ts +0 -4
- package/types/inputs/index.d.ts +0 -36
- package/types/selectors/index.d.ts +0 -16
- package/types/tooltip/index.d.ts +0 -14
- package/types/tooltip/index.js +0 -5
- package/utils/ArrayUtils.d.ts +0 -2
- package/utils/MessageUtils.d.ts +0 -1
- package/utils/index.d.ts +0 -1
|
@@ -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;
|
package/cjs/selectors/index.d.ts
DELETED
|
@@ -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;
|
package/cjs/tooltip/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as Tooltip from './Tooltip/Tooltip';
|
|
@@ -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
|
-
}
|
package/cjs/types/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ChangeEvent, CSSProperties, InputHTMLAttributes, ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { DivAttribute } from '../common';
|
|
3
|
-
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
4
|
-
suffixElement?: ReactElement | ReactNode;
|
|
5
|
-
prefixElement?: ReactElement | ReactNode;
|
|
6
|
-
wrapperStyle?: CSSProperties;
|
|
7
|
-
wrapperClass?: string[];
|
|
8
|
-
timeout?: number;
|
|
9
|
-
showLimit?: boolean;
|
|
10
|
-
maxLength?: number;
|
|
11
|
-
onThrottledChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface ImageInputContextData {
|
|
14
|
-
id?: string;
|
|
15
|
-
previewUrl?: string;
|
|
16
|
-
dragOver?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export type ImageType = 'jpeg' | 'png' | 'gif' | 'svg' | 'bmp' | 'webp' | 'heic' | 'heif' | 'tiff' | 'x-icon' | 'vn';
|
|
19
|
-
export interface ImageInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
|
|
20
|
-
accepts?: ImageType[];
|
|
21
|
-
draggable?: boolean;
|
|
22
|
-
onChange?: (file: File) => void;
|
|
23
|
-
value?: File;
|
|
24
|
-
}
|
|
25
|
-
export interface CheckboxProps<T> extends Omit<DivAttribute<T>, 'onChange'> {
|
|
26
|
-
values: T[];
|
|
27
|
-
onChange: (newValue: T[]) => void;
|
|
28
|
-
max?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface CheckboxItemProps<T> extends DivAttribute<T> {
|
|
31
|
-
value: T;
|
|
32
|
-
}
|
|
33
|
-
export interface CheckboxContextData<T> {
|
|
34
|
-
onToggle: (newValue: T, isCheck: boolean) => void;
|
|
35
|
-
values: T[];
|
|
36
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
export interface DropdownContextValue<T> {
|
|
3
|
-
isOpen: boolean;
|
|
4
|
-
toggle: () => void;
|
|
5
|
-
select: (value: T) => void;
|
|
6
|
-
selected: T | null;
|
|
7
|
-
}
|
|
8
|
-
export interface DropdownProps<T> extends HTMLAttributes<HTMLElement> {
|
|
9
|
-
isOpen?: boolean;
|
|
10
|
-
toggle?: () => void;
|
|
11
|
-
select?: (value: T) => void;
|
|
12
|
-
selected?: T | null;
|
|
13
|
-
}
|
|
14
|
-
export interface UseDropdownProps<T> {
|
|
15
|
-
defaultValue?: T;
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
-
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
position?: TooltipPosition;
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
space?: number;
|
|
8
|
-
}
|
|
9
|
-
interface TooltipContextProps {
|
|
10
|
-
show: boolean;
|
|
11
|
-
tooltipPosition: CSSProperties;
|
|
12
|
-
}
|
|
13
|
-
export declare const TooltipContext: import("react").Context<TooltipContextProps | null>;
|
|
14
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const logCannotFindContextError: (componentName: string) => never;
|
package/cjs/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './ArrayUtils';
|
package/hooks/index.d.ts
DELETED
package/hooks/useDebouncing.d.ts
DELETED
package/hooks/useDebouncing.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useRef, useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const useDebouncing = (callback, delay) => {
|
|
4
|
-
const timer = useRef(null);
|
|
5
|
-
return useCallback(() => {
|
|
6
|
-
if (timer.current)
|
|
7
|
-
clearTimeout(timer.current);
|
|
8
|
-
timer.current = setTimeout(() => {
|
|
9
|
-
callback();
|
|
10
|
-
}, delay);
|
|
11
|
-
}, [callback, delay]);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useDebouncing as default };
|
package/hooks/useDropdown.d.ts
DELETED
|
@@ -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;
|
package/hooks/useDropdown.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const DropdownContext = createContext(null);
|
|
4
|
-
const useDropdown = (defaultValue = null) => {
|
|
5
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
6
|
-
const [selected, setSelected] = useState(defaultValue);
|
|
7
|
-
const toggle = () => setIsOpen((prev) => !prev);
|
|
8
|
-
const select = (value) => {
|
|
9
|
-
setSelected(value);
|
|
10
|
-
setIsOpen(false);
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
isOpen,
|
|
14
|
-
selected,
|
|
15
|
-
toggle,
|
|
16
|
-
select,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
const useDropdownContext = () => {
|
|
20
|
-
const context = useContext(DropdownContext);
|
|
21
|
-
if (!context)
|
|
22
|
-
throw new Error('Dropdown components must be used within <Dropdown>');
|
|
23
|
-
return context;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { DropdownContext, useDropdown as default, useDropdownContext };
|
package/hooks/useThrottling.d.ts
DELETED
package/hooks/useThrottling.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useRef, useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
const useThrottling = (callback, delay) => {
|
|
4
|
-
const lastCalled = useRef(0);
|
|
5
|
-
return useCallback((...args) => {
|
|
6
|
-
const now = Date.now();
|
|
7
|
-
if (now - lastCalled.current >= delay) {
|
|
8
|
-
lastCalled.current = now;
|
|
9
|
-
callback(...args);
|
|
10
|
-
}
|
|
11
|
-
}, [callback, delay]);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { useThrottling as default };
|
|
@@ -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,71 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useState, useEffect, useContext } from 'react';
|
|
3
|
-
|
|
4
|
-
const ImageInputContext = createContext(null);
|
|
5
|
-
const getAccepts = (accepts) => {
|
|
6
|
-
return accepts && accepts.length > 0 ? accepts.map((it) => `image/${it}`).join() : 'image/*';
|
|
7
|
-
};
|
|
8
|
-
const ImageInputRoot = ({ accepts, id, value, draggable = false, onChange, children, ...props }) => {
|
|
9
|
-
const [previewUrl, setPreviewUrl] = useState('');
|
|
10
|
-
const [dragOver, setDragOver] = useState(false);
|
|
11
|
-
const inputId = [id, 'image-input'].join('-');
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!value)
|
|
14
|
-
setPreviewUrl('');
|
|
15
|
-
}, [value]);
|
|
16
|
-
const setImagePreview = (file) => {
|
|
17
|
-
const reader = new FileReader();
|
|
18
|
-
reader.onload = (e) => {
|
|
19
|
-
setPreviewUrl(e.target.result);
|
|
20
|
-
};
|
|
21
|
-
reader.readAsDataURL(file);
|
|
22
|
-
};
|
|
23
|
-
const onImageChange = (e) => {
|
|
24
|
-
const file = e.target.files?.[0];
|
|
25
|
-
if (!file)
|
|
26
|
-
return;
|
|
27
|
-
setImagePreview(file);
|
|
28
|
-
onChange?.(file);
|
|
29
|
-
};
|
|
30
|
-
const onDrop = (e) => {
|
|
31
|
-
if (!draggable)
|
|
32
|
-
return;
|
|
33
|
-
e.preventDefault();
|
|
34
|
-
setDragOver(false);
|
|
35
|
-
const file = e.dataTransfer.files?.[0];
|
|
36
|
-
if (file && file.type.startsWith('image/')) {
|
|
37
|
-
setImagePreview(file);
|
|
38
|
-
onChange?.(file);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const onDragOver = (e) => {
|
|
42
|
-
if (!draggable)
|
|
43
|
-
return;
|
|
44
|
-
e.preventDefault();
|
|
45
|
-
setDragOver(true);
|
|
46
|
-
};
|
|
47
|
-
const onDragLeave = () => setDragOver(false);
|
|
48
|
-
return (jsxs("span", { ...props, onDrop: onDrop, onDragOver: onDragOver, onDragEnter: onDragOver, onDragLeave: onDragLeave, children: [jsx("input", { "data-testid": inputId, id: inputId, type: 'file', accept: getAccepts(accepts ?? []), onChange: onImageChange, style: { display: 'none' } }), jsx(ImageInputContext.Provider, { value: { id: inputId, previewUrl, dragOver }, children: children })] }));
|
|
49
|
-
};
|
|
50
|
-
const ImageInputUploader = ({ children, ...props }) => {
|
|
51
|
-
const context = useContext(ImageInputContext);
|
|
52
|
-
if (!context) {
|
|
53
|
-
throw new Error('ImageInput.* 컴포넌트는 ImageInput 내에서만 사용해야 합니다.');
|
|
54
|
-
}
|
|
55
|
-
const { id } = context;
|
|
56
|
-
return (jsx("label", { htmlFor: id ?? '', ...props, children: children }));
|
|
57
|
-
};
|
|
58
|
-
const ImageInputPreview = ({ src: defaultSrc, ...props }) => {
|
|
59
|
-
const context = useContext(ImageInputContext);
|
|
60
|
-
if (!context) {
|
|
61
|
-
throw new Error('ImageInput.* 컴포넌트는 ImageInput 내에서만 사용해야 합니다.');
|
|
62
|
-
}
|
|
63
|
-
const { previewUrl } = context;
|
|
64
|
-
return jsx("img", { ...props, src: previewUrl ?? defaultSrc ?? '' });
|
|
65
|
-
};
|
|
66
|
-
const ImageInput = Object.assign(ImageInputRoot, {
|
|
67
|
-
Preview: ImageInputPreview,
|
|
68
|
-
Uploader: ImageInputUploader,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
export { ImageInputContext, ImageInput as default };
|
package/inputs/Input/Input.d.ts
DELETED
|
@@ -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;
|
package/inputs/Input/Input.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import useThrottling from '../../hooks/useThrottling.js';
|
|
3
|
-
|
|
4
|
-
const Input = ({ id, value, suffixElement, prefixElement, wrapperStyle, wrapperClass = [], onChange, timeout = 300, children, showLimit, maxLength, onThrottledChange, ...props }) => {
|
|
5
|
-
const throttledOnChange = onThrottledChange ? useThrottling(onThrottledChange, timeout) : null;
|
|
6
|
-
const handleChange = (e) => {
|
|
7
|
-
if (maxLength && e.target.value?.length > maxLength)
|
|
8
|
-
return;
|
|
9
|
-
onChange?.(e);
|
|
10
|
-
throttledOnChange?.(e);
|
|
11
|
-
};
|
|
12
|
-
return (jsxs("span", { "data-testid": 'input-wrapper', id: [id, 'input-wrapper'].join('-'), className: wrapperClass?.join(' '), style: wrapperStyle, children: [prefixElement, jsx("input", { role: 'textbox', id: id, value: value, onChange: handleChange, ...props }), showLimit && maxLength && (jsxs("span", { id: [id, 'input-limit'].join('-'), children: [(value ?? '').toString().length, "/", maxLength] })), suffixElement] }));
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { Input as default };
|
|
@@ -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;
|
package/inputs/index.d.ts
DELETED
|
@@ -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,53 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
import useDropdown, { DropdownContext, useDropdownContext } from '../../hooks/useDropdown.js';
|
|
4
|
-
|
|
5
|
-
const DropdownRoot = ({ select, selected, isOpen, toggle, children, ...props }) => {
|
|
6
|
-
const dropdownRef = useRef(null);
|
|
7
|
-
const unControlled = useDropdown();
|
|
8
|
-
const customValue = {
|
|
9
|
-
isOpen: isOpen ?? unControlled.isOpen,
|
|
10
|
-
toggle: toggle ?? unControlled.toggle,
|
|
11
|
-
select: select ?? unControlled.select,
|
|
12
|
-
selected: selected ?? unControlled.selected,
|
|
13
|
-
};
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!dropdownRef.current)
|
|
16
|
-
return;
|
|
17
|
-
const onClickOutside = (e) => {
|
|
18
|
-
if (!dropdownRef.current?.contains(e.target)) {
|
|
19
|
-
if (isOpen && toggle) {
|
|
20
|
-
toggle();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
window.addEventListener('click', onClickOutside);
|
|
25
|
-
return () => window.removeEventListener('click', onClickOutside);
|
|
26
|
-
}, [customValue]);
|
|
27
|
-
return (jsx("div", { ...props, ref: dropdownRef, children: jsx(DropdownContext.Provider, { value: customValue, children: children }) }));
|
|
28
|
-
};
|
|
29
|
-
const DropdownViewer = ({ children, ...props }) => {
|
|
30
|
-
return (jsx("span", { role: 'viewer', ...props, children: children }));
|
|
31
|
-
};
|
|
32
|
-
const DropdownButton = ({ onClick, children, ...props }) => {
|
|
33
|
-
const { toggle } = useDropdownContext();
|
|
34
|
-
return (jsx("span", { ...props, onClick: toggle, children: children }));
|
|
35
|
-
};
|
|
36
|
-
const DropdownOptions = ({ children, ...props }) => {
|
|
37
|
-
const { isOpen } = useDropdownContext();
|
|
38
|
-
if (!isOpen)
|
|
39
|
-
return null;
|
|
40
|
-
return jsx("div", { ...props, children: children });
|
|
41
|
-
};
|
|
42
|
-
const DropdownOption = ({ children, value, ...props }) => {
|
|
43
|
-
const { select } = useDropdownContext();
|
|
44
|
-
return (jsx("div", { role: "option", onClick: () => select(value), ...props, children: children }));
|
|
45
|
-
};
|
|
46
|
-
const Dropdown = Object.assign(DropdownRoot, {
|
|
47
|
-
Button: DropdownButton,
|
|
48
|
-
Options: DropdownOptions,
|
|
49
|
-
Option: DropdownOption,
|
|
50
|
-
Viewer: DropdownViewer,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export { Dropdown as default };
|
package/selectors/index.d.ts
DELETED
|
@@ -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,64 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect, useContext } from 'react';
|
|
3
|
-
import { TooltipContext } from '../../types/tooltip/index.js';
|
|
4
|
-
|
|
5
|
-
const TooltipRoot = ({ children, style, position = 'top', space = 8, ...props }) => {
|
|
6
|
-
const [showTooltip, setShowTooltip] = useState(false);
|
|
7
|
-
const [tooltipPosition, setTooltipPosition] = useState({});
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (!showTooltip)
|
|
10
|
-
return;
|
|
11
|
-
const positionStyles = {
|
|
12
|
-
zIndex: 1000,
|
|
13
|
-
};
|
|
14
|
-
switch (position) {
|
|
15
|
-
case 'top':
|
|
16
|
-
positionStyles.bottom = `calc(100% + ${space}px)`;
|
|
17
|
-
positionStyles.left = '50%';
|
|
18
|
-
positionStyles.transform = 'translateX(-50%)';
|
|
19
|
-
break;
|
|
20
|
-
case 'bottom':
|
|
21
|
-
positionStyles.top = `calc(100% + ${space}px)`;
|
|
22
|
-
positionStyles.left = '50%';
|
|
23
|
-
positionStyles.transform = 'translateX(-50%)';
|
|
24
|
-
break;
|
|
25
|
-
case 'left':
|
|
26
|
-
positionStyles.right = `calc(100% + ${space}px)`;
|
|
27
|
-
positionStyles.top = '50%';
|
|
28
|
-
positionStyles.transform = 'translateY(-50%)';
|
|
29
|
-
break;
|
|
30
|
-
case 'right':
|
|
31
|
-
positionStyles.left = `calc(100% + ${space}px)`;
|
|
32
|
-
positionStyles.top = '50%';
|
|
33
|
-
positionStyles.transform = 'translateY(-50%)';
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
setTooltipPosition(positionStyles);
|
|
37
|
-
}, [showTooltip, position]);
|
|
38
|
-
const onMouseOver = () => setShowTooltip(true);
|
|
39
|
-
const onMouseLeave = () => setShowTooltip(false);
|
|
40
|
-
return (jsx("div", { style: {
|
|
41
|
-
position: 'relative',
|
|
42
|
-
display: 'inline-block', // 자식 크기에 영향 안 받도록
|
|
43
|
-
...style,
|
|
44
|
-
}, onMouseOver: onMouseOver, onMouseLeave: onMouseLeave, ...props, children: jsx(TooltipContext.Provider, { value: { show: showTooltip, tooltipPosition }, children: children }) }));
|
|
45
|
-
};
|
|
46
|
-
const TooltipLabel = ({ children, style, ...props }) => {
|
|
47
|
-
const context = useContext(TooltipContext);
|
|
48
|
-
if (!context) {
|
|
49
|
-
throw new Error('Tooltip.* 컴포넌트는 Tooltip 내에서만 사용해야 합니다.');
|
|
50
|
-
}
|
|
51
|
-
const { show, tooltipPosition } = context;
|
|
52
|
-
const labelStyle = {
|
|
53
|
-
position: 'absolute',
|
|
54
|
-
visibility: show ? 'visible' : 'hidden',
|
|
55
|
-
...tooltipPosition,
|
|
56
|
-
...style,
|
|
57
|
-
};
|
|
58
|
-
return (jsx("div", { style: labelStyle, ...props, children: children }));
|
|
59
|
-
};
|
|
60
|
-
const Tooltip = Object.assign(TooltipRoot, {
|
|
61
|
-
Label: TooltipLabel,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export { Tooltip as default };
|
package/tooltip/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as Tooltip from './Tooltip/Tooltip';
|
package/types/buttons/index.d.ts
DELETED
package/types/common/index.d.ts
DELETED
|
@@ -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
|
-
}
|
package/types/index.d.ts
DELETED