@shoplflow/base 0.41.11 → 0.42.1
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/dist/index.cjs +251 -2
- package/dist/index.d.cts +76 -2
- package/dist/index.d.ts +76 -2
- package/dist/index.js +254 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1623,6 +1623,12 @@ var getStyleBySizeVar2 = (sizeVar) => {
|
|
|
1623
1623
|
min-width: 54px;
|
|
1624
1624
|
min-height: 32px;
|
|
1625
1625
|
`;
|
|
1626
|
+
case "XS":
|
|
1627
|
+
return react$1.css`
|
|
1628
|
+
gap: 2px;
|
|
1629
|
+
padding: 4px 6px;
|
|
1630
|
+
min-height: 24px;
|
|
1631
|
+
`;
|
|
1626
1632
|
default:
|
|
1627
1633
|
return react$1.css`
|
|
1628
1634
|
gap: 4px;
|
|
@@ -1695,6 +1701,12 @@ var Button = React3.forwardRef(
|
|
|
1695
1701
|
"isLoading",
|
|
1696
1702
|
"lineClamp"
|
|
1697
1703
|
]);
|
|
1704
|
+
const getTypography = () => {
|
|
1705
|
+
if (sizeVar === "XS") {
|
|
1706
|
+
return "caption_400";
|
|
1707
|
+
}
|
|
1708
|
+
return sizeVar === "M" ? "body1_400" : "body2_400";
|
|
1709
|
+
};
|
|
1698
1710
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1699
1711
|
StyledButton,
|
|
1700
1712
|
__spreadProps(__spreadValues({
|
|
@@ -1716,7 +1728,7 @@ var Button = React3.forwardRef(
|
|
|
1716
1728
|
whiteSpace: "nowrap",
|
|
1717
1729
|
wordBreak: "keep-all",
|
|
1718
1730
|
color: styleVar === "PRIMARY" ? "neutral0" : "neutral700",
|
|
1719
|
-
typography:
|
|
1731
|
+
typography: getTypography(),
|
|
1720
1732
|
children
|
|
1721
1733
|
}
|
|
1722
1734
|
),
|
|
@@ -1731,7 +1743,8 @@ exports.Button = Button;
|
|
|
1731
1743
|
// src/components/Buttons/Button/Button.types.ts
|
|
1732
1744
|
exports.ButtonSizeVariants = {
|
|
1733
1745
|
S: "S",
|
|
1734
|
-
M: "M"
|
|
1746
|
+
M: "M",
|
|
1747
|
+
XS: "XS"
|
|
1735
1748
|
};
|
|
1736
1749
|
exports.ButtonStyleVariants = {
|
|
1737
1750
|
PRIMARY: "PRIMARY",
|
|
@@ -6999,6 +7012,242 @@ var Slider = ({
|
|
|
6999
7012
|
] }) });
|
|
7000
7013
|
};
|
|
7001
7014
|
exports.Slider = Slider;
|
|
7015
|
+
var SearchBarContext = React3.createContext({});
|
|
7016
|
+
var useSearchBarContext = () => React3.useContext(SearchBarContext);
|
|
7017
|
+
var SearchBarProvider = ({
|
|
7018
|
+
children,
|
|
7019
|
+
useFlexibleWidth,
|
|
7020
|
+
isSelected
|
|
7021
|
+
}) => {
|
|
7022
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SearchBarContext.Provider, { value: { useFlexibleWidth, isSelected }, children });
|
|
7023
|
+
};
|
|
7024
|
+
var DEFAULT_DEBOUNCE_TIME = 300;
|
|
7025
|
+
var SearchBarInput = (_a) => {
|
|
7026
|
+
var _b = _a, {
|
|
7027
|
+
value,
|
|
7028
|
+
defaultValue,
|
|
7029
|
+
onChange,
|
|
7030
|
+
onClear,
|
|
7031
|
+
placeholder,
|
|
7032
|
+
flexiblePlaceholder,
|
|
7033
|
+
disabled,
|
|
7034
|
+
type = "default",
|
|
7035
|
+
onSearch,
|
|
7036
|
+
debounceTime = type === "default" ? 0 : DEFAULT_DEBOUNCE_TIME,
|
|
7037
|
+
icon = /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.SearchIcon, color: "neutral350", sizeVar: "S" })
|
|
7038
|
+
} = _b, rest = __objRest(_b, [
|
|
7039
|
+
"value",
|
|
7040
|
+
"defaultValue",
|
|
7041
|
+
"onChange",
|
|
7042
|
+
"onClear",
|
|
7043
|
+
"placeholder",
|
|
7044
|
+
"flexiblePlaceholder",
|
|
7045
|
+
"disabled",
|
|
7046
|
+
"type",
|
|
7047
|
+
"onSearch",
|
|
7048
|
+
"debounceTime",
|
|
7049
|
+
"icon"
|
|
7050
|
+
]);
|
|
7051
|
+
const { useFlexibleWidth, isSelected } = useSearchBarContext();
|
|
7052
|
+
const [text, setText] = React3.useState("");
|
|
7053
|
+
const convertToString = React3.useCallback((value2) => {
|
|
7054
|
+
if (typeof value2 !== "number") {
|
|
7055
|
+
return typeof value2 === "string" ? value2 : value2.join("");
|
|
7056
|
+
}
|
|
7057
|
+
return String(value2);
|
|
7058
|
+
}, []);
|
|
7059
|
+
const debouncedOnChange = React3.useRef(
|
|
7060
|
+
utils.debounce(
|
|
7061
|
+
(event) => {
|
|
7062
|
+
const newValue = event.target.value;
|
|
7063
|
+
setText(newValue);
|
|
7064
|
+
if (type === "real-time") {
|
|
7065
|
+
onChange && onChange(event);
|
|
7066
|
+
onSearch && onSearch(newValue);
|
|
7067
|
+
}
|
|
7068
|
+
},
|
|
7069
|
+
debounceTime
|
|
7070
|
+
)
|
|
7071
|
+
).current;
|
|
7072
|
+
const handleOnChange = (event) => {
|
|
7073
|
+
debouncedOnChange(event);
|
|
7074
|
+
};
|
|
7075
|
+
const handleOnClear = React3.useCallback(() => {
|
|
7076
|
+
setText("");
|
|
7077
|
+
onClear == null ? void 0 : onClear();
|
|
7078
|
+
}, [onClear]);
|
|
7079
|
+
const handleKeyDown = React3.useCallback(
|
|
7080
|
+
(event) => {
|
|
7081
|
+
if (type === "default" && event.key === "Enter") {
|
|
7082
|
+
onSearch == null ? void 0 : onSearch(text);
|
|
7083
|
+
}
|
|
7084
|
+
},
|
|
7085
|
+
[onSearch, text, type]
|
|
7086
|
+
);
|
|
7087
|
+
const handleIconClick = React3.useCallback(() => {
|
|
7088
|
+
if (type === "default") {
|
|
7089
|
+
onSearch == null ? void 0 : onSearch(text);
|
|
7090
|
+
}
|
|
7091
|
+
}, [onSearch, text, type]);
|
|
7092
|
+
let _placeholder = placeholder;
|
|
7093
|
+
if (useFlexibleWidth && !isSelected) {
|
|
7094
|
+
_placeholder = flexiblePlaceholder;
|
|
7095
|
+
}
|
|
7096
|
+
const getInitialValue = React3.useCallback(() => {
|
|
7097
|
+
if (value !== void 0) {
|
|
7098
|
+
return convertToString(value);
|
|
7099
|
+
}
|
|
7100
|
+
if (defaultValue !== void 0) {
|
|
7101
|
+
return convertToString(defaultValue);
|
|
7102
|
+
}
|
|
7103
|
+
return "";
|
|
7104
|
+
}, [convertToString, defaultValue, value]);
|
|
7105
|
+
React3.useEffect(() => {
|
|
7106
|
+
const initialValue = getInitialValue();
|
|
7107
|
+
setText(initialValue);
|
|
7108
|
+
}, [getInitialValue]);
|
|
7109
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7110
|
+
type === "default" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { styleVar: "GHOST", sizeVar: "S", onClick: handleIconClick, "aria-label": "\uAC80\uC0C9", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.SearchIcon, color: text ? "neutral700" : "neutral350", sizeVar: "S" }) }),
|
|
7111
|
+
type === "real-time" && icon,
|
|
7112
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7113
|
+
exports.Input,
|
|
7114
|
+
__spreadValues({
|
|
7115
|
+
placeholder: _placeholder,
|
|
7116
|
+
onChange: handleOnChange,
|
|
7117
|
+
onKeyDown: handleKeyDown,
|
|
7118
|
+
value: text,
|
|
7119
|
+
onClear: handleOnClear,
|
|
7120
|
+
width: "100%",
|
|
7121
|
+
disabled,
|
|
7122
|
+
"aria-label": "\uAC80\uC0C9\uC5B4 \uC785\uB825"
|
|
7123
|
+
}, rest)
|
|
7124
|
+
)
|
|
7125
|
+
] });
|
|
7126
|
+
};
|
|
7127
|
+
var StyledStackContainer2 = styled6__default.default(exports.Stack.Horizontal)`
|
|
7128
|
+
border: 1px solid ${exports.colorTokens.neutral100};
|
|
7129
|
+
border-radius: ${exports.borderRadiusTokens.borderRadius06};
|
|
7130
|
+
background-color: ${exports.colorTokens.neutral100};
|
|
7131
|
+
justify-content: center;
|
|
7132
|
+
align-items: center;
|
|
7133
|
+
padding: 4px 8px;
|
|
7134
|
+
transition: all 400ms ease-in-out;
|
|
7135
|
+
|
|
7136
|
+
label {
|
|
7137
|
+
flex-grow: 1;
|
|
7138
|
+
border: none;
|
|
7139
|
+
border-radius: 0;
|
|
7140
|
+
height: 32px;
|
|
7141
|
+
background-color: ${exports.colorTokens.neutral100};
|
|
7142
|
+
gap: 0px;
|
|
7143
|
+
|
|
7144
|
+
div {
|
|
7145
|
+
padding: 0;
|
|
7146
|
+
}
|
|
7147
|
+
|
|
7148
|
+
input {
|
|
7149
|
+
padding: 0;
|
|
7150
|
+
}
|
|
7151
|
+
}
|
|
7152
|
+
|
|
7153
|
+
button {
|
|
7154
|
+
background-color: ${exports.colorTokens.neutral100};
|
|
7155
|
+
}
|
|
7156
|
+
`;
|
|
7157
|
+
var CategoriesButton = styled6__default.default(exports.Dropdown.Button)`
|
|
7158
|
+
border-radius: 4px;
|
|
7159
|
+
height: 24px;
|
|
7160
|
+
|
|
7161
|
+
&:hover {
|
|
7162
|
+
background-color: ${exports.colorTokens.neutral200};
|
|
7163
|
+
}
|
|
7164
|
+
`;
|
|
7165
|
+
var DEFAULT_DROPDOWN_WIDTH = "136px";
|
|
7166
|
+
var SearchBarCategory = ({
|
|
7167
|
+
dropdownWidth = DEFAULT_DROPDOWN_WIDTH,
|
|
7168
|
+
dropdownItems = [],
|
|
7169
|
+
selectedDropdownItem,
|
|
7170
|
+
onDropdownSelect
|
|
7171
|
+
}) => {
|
|
7172
|
+
const { isSelected, useFlexibleWidth } = useSearchBarContext();
|
|
7173
|
+
if (!isSelected && useFlexibleWidth) {
|
|
7174
|
+
return null;
|
|
7175
|
+
}
|
|
7176
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7177
|
+
exports.Dropdown,
|
|
7178
|
+
{
|
|
7179
|
+
width: dropdownWidth,
|
|
7180
|
+
trigger: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7181
|
+
CategoriesButton,
|
|
7182
|
+
{
|
|
7183
|
+
value: selectedDropdownItem && /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { lineClamp: 1, typography: "body2_700", children: selectedDropdownItem.label }),
|
|
7184
|
+
"aria-label": "\uCE74\uD14C\uACE0\uB9AC \uC120\uD0DD"
|
|
7185
|
+
}
|
|
7186
|
+
),
|
|
7187
|
+
popper: /* @__PURE__ */ jsxRuntime.jsx(exports.Dropdown.Content, { type: "FILL", children: dropdownItems.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7188
|
+
exports.Menu,
|
|
7189
|
+
{
|
|
7190
|
+
className: "search-bar",
|
|
7191
|
+
onClick: () => onDropdownSelect == null ? void 0 : onDropdownSelect(item),
|
|
7192
|
+
isSelected: (selectedDropdownItem == null ? void 0 : selectedDropdownItem.value) === item.value,
|
|
7193
|
+
"aria-selected": (selectedDropdownItem == null ? void 0 : selectedDropdownItem.value) === item.value,
|
|
7194
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_500", children: item.label })
|
|
7195
|
+
},
|
|
7196
|
+
item.value
|
|
7197
|
+
)) })
|
|
7198
|
+
}
|
|
7199
|
+
);
|
|
7200
|
+
};
|
|
7201
|
+
var DEFAULT_WIDTH = "100%";
|
|
7202
|
+
var DEFAULT_HEIGHT = "32px";
|
|
7203
|
+
var SearchBar = (_a) => {
|
|
7204
|
+
var _b = _a, {
|
|
7205
|
+
width = DEFAULT_WIDTH,
|
|
7206
|
+
height = DEFAULT_HEIGHT,
|
|
7207
|
+
useFlexibleWidth = false,
|
|
7208
|
+
children
|
|
7209
|
+
} = _b, rest = __objRest(_b, [
|
|
7210
|
+
"width",
|
|
7211
|
+
"height",
|
|
7212
|
+
"useFlexibleWidth",
|
|
7213
|
+
"children"
|
|
7214
|
+
]);
|
|
7215
|
+
const [isSelected, setIsSelected] = utils.useOutsideClick({
|
|
7216
|
+
selector: ".search-bar",
|
|
7217
|
+
onClose: () => setIsSelected(false)
|
|
7218
|
+
});
|
|
7219
|
+
const handleContainerClick = React3.useCallback(() => {
|
|
7220
|
+
setIsSelected(true);
|
|
7221
|
+
}, [setIsSelected]);
|
|
7222
|
+
const containerWidth = React3.useMemo(() => {
|
|
7223
|
+
if (!useFlexibleWidth) {
|
|
7224
|
+
return width;
|
|
7225
|
+
}
|
|
7226
|
+
return isSelected ? width : "140px";
|
|
7227
|
+
}, [useFlexibleWidth, isSelected, width]);
|
|
7228
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SearchBarProvider, { useFlexibleWidth, isSelected, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7229
|
+
StyledStackContainer2,
|
|
7230
|
+
__spreadProps(__spreadValues({
|
|
7231
|
+
"data-shoplflow": "SearchBar",
|
|
7232
|
+
width: containerWidth,
|
|
7233
|
+
height,
|
|
7234
|
+
className: "search-bar",
|
|
7235
|
+
spacing: "spacing04",
|
|
7236
|
+
onClick: handleContainerClick,
|
|
7237
|
+
role: "search",
|
|
7238
|
+
"aria-label": "\uAC80\uC0C9"
|
|
7239
|
+
}, rest), {
|
|
7240
|
+
children
|
|
7241
|
+
})
|
|
7242
|
+
) });
|
|
7243
|
+
};
|
|
7244
|
+
SearchBar.Category = SearchBarCategory;
|
|
7245
|
+
SearchBar.Input = SearchBarInput;
|
|
7246
|
+
|
|
7247
|
+
// src/components/SearchBar/index.ts
|
|
7248
|
+
exports.SearchBar = SearchBar;
|
|
7249
|
+
exports.SearchBar.Category = SearchBarCategory;
|
|
7250
|
+
exports.SearchBar.Input = SearchBarInput;
|
|
7002
7251
|
var SpaceMarginWrapper = styled6__default.default(framerMotion.motion.div)`
|
|
7003
7252
|
position: relative;
|
|
7004
7253
|
display: flex;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default, { ElementType, ComponentPropsWithoutRef, ReactNode, ReactElement, ImgHTMLAttributes, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, CSSProperties, HTMLAttributes, ComponentPropsWithRef, ButtonHTMLAttributes, InputHTMLAttributes, MouseEvent, Ref } from 'react';
|
|
3
|
+
import React__default, { ElementType, ComponentPropsWithoutRef, ReactNode, ReactElement, ImgHTMLAttributes, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, CSSProperties, HTMLAttributes, ComponentPropsWithRef, ButtonHTMLAttributes, InputHTMLAttributes, MouseEvent, Ref, ChangeEvent } from 'react';
|
|
4
4
|
import { $Values } from '@shoplflow/utils';
|
|
5
5
|
import { IconSource } from '@shoplflow/shopl-assets';
|
|
6
6
|
import { IconSource as IconSource$1 } from '@shoplflow/hada-assets';
|
|
@@ -610,6 +610,7 @@ declare type PolymorphicComponentProps<T extends React__default.ElementType, Pro
|
|
|
610
610
|
declare const ButtonSizeVariants: {
|
|
611
611
|
readonly S: "S";
|
|
612
612
|
readonly M: "M";
|
|
613
|
+
readonly XS: "XS";
|
|
613
614
|
};
|
|
614
615
|
declare type ButtonSizeVariantType = $Values<typeof ButtonSizeVariants>;
|
|
615
616
|
declare const ButtonStyleVariants: {
|
|
@@ -1620,4 +1621,77 @@ declare const SLIDER_Z_INDEX: {
|
|
|
1620
1621
|
|
|
1621
1622
|
declare const Slider: React__default.FC<SliderProps>;
|
|
1622
1623
|
|
|
1623
|
-
|
|
1624
|
+
/** 드롭다운 아이템 타입 */
|
|
1625
|
+
declare type DropdownItem = {
|
|
1626
|
+
/** 표시되는 라벨 */
|
|
1627
|
+
label: string;
|
|
1628
|
+
/** 실제 값 */
|
|
1629
|
+
value: string;
|
|
1630
|
+
};
|
|
1631
|
+
/** 검색바 타입 */
|
|
1632
|
+
declare type SearchType = 'default' | 'real-time';
|
|
1633
|
+
/** 검색바 기본 props */
|
|
1634
|
+
interface SearchBarBaseProps {
|
|
1635
|
+
/** 검색바 너비 */
|
|
1636
|
+
width?: string;
|
|
1637
|
+
/** 검색바 높이 */
|
|
1638
|
+
height?: string;
|
|
1639
|
+
/** 유연한 너비 사용 여부 */
|
|
1640
|
+
useFlexibleWidth?: boolean;
|
|
1641
|
+
/** 자식 요소 */
|
|
1642
|
+
children?: React.ReactNode;
|
|
1643
|
+
}
|
|
1644
|
+
/** 검색바 카테고리 props */
|
|
1645
|
+
interface SearchBarCategoryProps {
|
|
1646
|
+
/** 카테고리 드롭다운 너비 */
|
|
1647
|
+
dropdownWidth?: string;
|
|
1648
|
+
/** 카테고리 드롭다운 아이템 목록 */
|
|
1649
|
+
dropdownItems?: DropdownItem[];
|
|
1650
|
+
/** 선택된 카테고리 아이템 */
|
|
1651
|
+
selectedDropdownItem?: DropdownItem;
|
|
1652
|
+
/** 카테고리 선택 핸들러 */
|
|
1653
|
+
onDropdownSelect?: (item: DropdownItem) => void;
|
|
1654
|
+
/** 선택 상태 */
|
|
1655
|
+
isSelected: boolean;
|
|
1656
|
+
}
|
|
1657
|
+
/** 검색바 입력 props */
|
|
1658
|
+
interface SearchBarInputProps {
|
|
1659
|
+
/** 검색바 값 */
|
|
1660
|
+
value?: string | number | readonly string[];
|
|
1661
|
+
/** 검색바 기본값 */
|
|
1662
|
+
defaultValue?: string | number | readonly string[];
|
|
1663
|
+
/** 검색어 변경 핸들러 */
|
|
1664
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
1665
|
+
/** 검색어 초기화 핸들러 */
|
|
1666
|
+
onClear?: () => void;
|
|
1667
|
+
/** 플레이스홀더 텍스트 */
|
|
1668
|
+
placeholder?: string;
|
|
1669
|
+
/** 너비 변경 시 플레이스홀더 텍스트 */
|
|
1670
|
+
flexiblePlaceholder?: string;
|
|
1671
|
+
/** 비활성화 여부 */
|
|
1672
|
+
disabled?: boolean;
|
|
1673
|
+
/** 검색 아이콘 */
|
|
1674
|
+
icon?: React.ReactNode;
|
|
1675
|
+
/** 검색 타입 */
|
|
1676
|
+
type?: SearchType;
|
|
1677
|
+
/** 검색 핸들러 */
|
|
1678
|
+
onSearch?: (value: string) => void;
|
|
1679
|
+
/** 디바운스 시간 (ms) */
|
|
1680
|
+
debounceTime?: number;
|
|
1681
|
+
}
|
|
1682
|
+
/** 검색바 props */
|
|
1683
|
+
declare type SearchBarProps = SearchBarBaseProps;
|
|
1684
|
+
/** 검색바 컴포넌트 타입 */
|
|
1685
|
+
interface SearchBarComponent extends React.FC<SearchBarProps> {
|
|
1686
|
+
Category: React.FC<SearchBarCategoryProps>;
|
|
1687
|
+
Input: React.FC<SearchBarInputProps>;
|
|
1688
|
+
}
|
|
1689
|
+
/** 검색바 컴포넌트 타입 (memo) */
|
|
1690
|
+
interface MemoizedSearchBarComponent extends React.MemoExoticComponent<SearchBarComponent> {
|
|
1691
|
+
Category: React.FC<SearchBarCategoryProps>;
|
|
1692
|
+
Input: React.FC<SearchBarInputProps>;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
declare const SearchBar: MemoizedSearchBarComponent;
|
|
1696
|
+
|
|
1697
|
+
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownItem, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, MemoizedSearchBarComponent, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, SLIDER_Z_INDEX, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SearchBar, SearchBarBaseProps, SearchBarCategoryProps, SearchBarComponent, SearchBarInputProps, SearchBarProps, SearchType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, Slider, SliderBounds, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default, { ElementType, ComponentPropsWithoutRef, ReactNode, ReactElement, ImgHTMLAttributes, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, CSSProperties, HTMLAttributes, ComponentPropsWithRef, ButtonHTMLAttributes, InputHTMLAttributes, MouseEvent, Ref } from 'react';
|
|
3
|
+
import React__default, { ElementType, ComponentPropsWithoutRef, ReactNode, ReactElement, ImgHTMLAttributes, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, CSSProperties, HTMLAttributes, ComponentPropsWithRef, ButtonHTMLAttributes, InputHTMLAttributes, MouseEvent, Ref, ChangeEvent } from 'react';
|
|
4
4
|
import { $Values } from '@shoplflow/utils';
|
|
5
5
|
import { IconSource } from '@shoplflow/shopl-assets';
|
|
6
6
|
import { IconSource as IconSource$1 } from '@shoplflow/hada-assets';
|
|
@@ -610,6 +610,7 @@ declare type PolymorphicComponentProps<T extends React__default.ElementType, Pro
|
|
|
610
610
|
declare const ButtonSizeVariants: {
|
|
611
611
|
readonly S: "S";
|
|
612
612
|
readonly M: "M";
|
|
613
|
+
readonly XS: "XS";
|
|
613
614
|
};
|
|
614
615
|
declare type ButtonSizeVariantType = $Values<typeof ButtonSizeVariants>;
|
|
615
616
|
declare const ButtonStyleVariants: {
|
|
@@ -1620,4 +1621,77 @@ declare const SLIDER_Z_INDEX: {
|
|
|
1620
1621
|
|
|
1621
1622
|
declare const Slider: React__default.FC<SliderProps>;
|
|
1622
1623
|
|
|
1623
|
-
|
|
1624
|
+
/** 드롭다운 아이템 타입 */
|
|
1625
|
+
declare type DropdownItem = {
|
|
1626
|
+
/** 표시되는 라벨 */
|
|
1627
|
+
label: string;
|
|
1628
|
+
/** 실제 값 */
|
|
1629
|
+
value: string;
|
|
1630
|
+
};
|
|
1631
|
+
/** 검색바 타입 */
|
|
1632
|
+
declare type SearchType = 'default' | 'real-time';
|
|
1633
|
+
/** 검색바 기본 props */
|
|
1634
|
+
interface SearchBarBaseProps {
|
|
1635
|
+
/** 검색바 너비 */
|
|
1636
|
+
width?: string;
|
|
1637
|
+
/** 검색바 높이 */
|
|
1638
|
+
height?: string;
|
|
1639
|
+
/** 유연한 너비 사용 여부 */
|
|
1640
|
+
useFlexibleWidth?: boolean;
|
|
1641
|
+
/** 자식 요소 */
|
|
1642
|
+
children?: React.ReactNode;
|
|
1643
|
+
}
|
|
1644
|
+
/** 검색바 카테고리 props */
|
|
1645
|
+
interface SearchBarCategoryProps {
|
|
1646
|
+
/** 카테고리 드롭다운 너비 */
|
|
1647
|
+
dropdownWidth?: string;
|
|
1648
|
+
/** 카테고리 드롭다운 아이템 목록 */
|
|
1649
|
+
dropdownItems?: DropdownItem[];
|
|
1650
|
+
/** 선택된 카테고리 아이템 */
|
|
1651
|
+
selectedDropdownItem?: DropdownItem;
|
|
1652
|
+
/** 카테고리 선택 핸들러 */
|
|
1653
|
+
onDropdownSelect?: (item: DropdownItem) => void;
|
|
1654
|
+
/** 선택 상태 */
|
|
1655
|
+
isSelected: boolean;
|
|
1656
|
+
}
|
|
1657
|
+
/** 검색바 입력 props */
|
|
1658
|
+
interface SearchBarInputProps {
|
|
1659
|
+
/** 검색바 값 */
|
|
1660
|
+
value?: string | number | readonly string[];
|
|
1661
|
+
/** 검색바 기본값 */
|
|
1662
|
+
defaultValue?: string | number | readonly string[];
|
|
1663
|
+
/** 검색어 변경 핸들러 */
|
|
1664
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
1665
|
+
/** 검색어 초기화 핸들러 */
|
|
1666
|
+
onClear?: () => void;
|
|
1667
|
+
/** 플레이스홀더 텍스트 */
|
|
1668
|
+
placeholder?: string;
|
|
1669
|
+
/** 너비 변경 시 플레이스홀더 텍스트 */
|
|
1670
|
+
flexiblePlaceholder?: string;
|
|
1671
|
+
/** 비활성화 여부 */
|
|
1672
|
+
disabled?: boolean;
|
|
1673
|
+
/** 검색 아이콘 */
|
|
1674
|
+
icon?: React.ReactNode;
|
|
1675
|
+
/** 검색 타입 */
|
|
1676
|
+
type?: SearchType;
|
|
1677
|
+
/** 검색 핸들러 */
|
|
1678
|
+
onSearch?: (value: string) => void;
|
|
1679
|
+
/** 디바운스 시간 (ms) */
|
|
1680
|
+
debounceTime?: number;
|
|
1681
|
+
}
|
|
1682
|
+
/** 검색바 props */
|
|
1683
|
+
declare type SearchBarProps = SearchBarBaseProps;
|
|
1684
|
+
/** 검색바 컴포넌트 타입 */
|
|
1685
|
+
interface SearchBarComponent extends React.FC<SearchBarProps> {
|
|
1686
|
+
Category: React.FC<SearchBarCategoryProps>;
|
|
1687
|
+
Input: React.FC<SearchBarInputProps>;
|
|
1688
|
+
}
|
|
1689
|
+
/** 검색바 컴포넌트 타입 (memo) */
|
|
1690
|
+
interface MemoizedSearchBarComponent extends React.MemoExoticComponent<SearchBarComponent> {
|
|
1691
|
+
Category: React.FC<SearchBarCategoryProps>;
|
|
1692
|
+
Input: React.FC<SearchBarInputProps>;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
declare const SearchBar: MemoizedSearchBarComponent;
|
|
1696
|
+
|
|
1697
|
+
export { AnnualDatepicker, AnnualDatepickerProps, AsProp, Avatar, AvatarOptionProps, AvatarProps, AvatarSizeVariantType, AvatarSizeVariants, BackDropOptionProps, BackDropProps, BorderRadiusTokens, BoxShadowTokens, Button, ButtonComponent, ButtonOptionProps, ButtonProps, ButtonSizeVariantType, ButtonSizeVariants, ButtonStyleVariantType, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout, CalloutOptionProps, CalloutProps, CalloutType, CalloutTypes, Checkbox, CheckboxOptionProps, CheckboxProps, CheckboxStyleVariantType, CheckboxStyleVariants, ChipButton, ChipButtonOptionProps, ChipButtonProps, ChipButtonSizeVariantType, ChipButtonSizeVariants, ChipButtonStyleVariantType, ChipButtonStyleVariants, ChipToggle, ChipToggleOptionProps, ChipToggleProps, ChipToggleSizeVariantType, ChipToggleSizeVariants, ChipToggleStyleVariantType, ChipToggleStyleVariants, ColorTokens, DangerouslySetInnerHTML, DayCalendarType, DayDatepicker, DayDatepickerHeaderCustomProps, DayDatepickerOptionProps, DayDatepickerProps, DayDatepickerSizeVariantType, DayDatepickerSizeVariants, DomainType, Dropdown, DropdownButton, DropdownButtonContext, DropdownButtonContextType, DropdownButtonOptionProps, DropdownButtonProps, DropdownButtonSizeVariantType, DropdownButtonSizeVariants, DropdownButtonStyleVariantType, DropdownButtonStyleVariants, DropdownContentProps, DropdownItem, DropdownOptionProps, DropdownOptionVariantType, DropdownOptionVariants, DropdownProps, DropdownSizeVariantType, DropdownTriggerButtonProps, FontWeightTokens, Icon, IconButton, IconButtonComponent, IconButtonOptionProps, IconButtonProps, IconButtonSizeVariantType, IconButtonSizeVariants, IconButtonStyleVariantType, IconButtonStyleVariants, IconOptionProps, IconProps, IconSizeVariants, IconSizeVariantsType, Input, InputButton, InputButtonOptionProps, InputButtonProps, InputOptionProps, InputProps, InputSizeVariantType, InputSizeVariants, List, ListContent2ColumnsProps, ListOptionProps, ListProps, ListText2RowsProps, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, MemoizedSearchBarComponent, Menu, MenuOptionProps, MenuProps, MenuSizeVariantType, MenuSizeVariants, MinusBoxOptionProps, MinusBoxProps, MinusButton, Modal, ModalBodyOptionProps, ModalBodyProps, ModalBottomProps, ModalContainerOptionProps, ModalContainerProps, ModalContext, ModalFooterOptionProps, ModalFooterProps, ModalFooterType, ModalHandlerContext, ModalHeaderOptionProps, ModalHeaderProps, ModalHeaderType, ModalPortal as ModalProvider, ModalSize, ModalSizeType, ModalStateType, ModalTopProps, MonthClickDateInfo, MonthDatepicker, MonthDatepickerProps, MonthDatepickerStyleType, MotionStack, MotionStackComponentType, MotionStackContainer, MotionStackContainerComponentType, NumberCombobox, NumberComboboxErrorType, NumberComboboxInputType, NumberComboboxOptionProps, NumberComboboxProps, NumberComboboxSizeVariantType, NumberComboboxSizeVariants, Pagination, PaginationOptionProps, PaginationProps, PaginationSizeSelectorProps, PolymorphicComponentProps, PolymorphicRef, Popper, PopperOptionProps, PopperPortal, PopperPortalProps, PopperProps, PopperTrigger, PopperTriggerProps, RADIO_SYMBOL_KEY, Radio, RadioOptionProps, RadioProps, RemoveModalProps, SLIDER_Z_INDEX, ScrollArea, ScrollAreaOptionProps, ScrollAreaProps, ScrollbarRefType, SearchBar, SearchBarBaseProps, SearchBarCategoryProps, SearchBarComponent, SearchBarInputProps, SearchBarProps, SearchType, SelectInputButton, SelectInputButtonOptionProps, SelectInputButtonProps, ShoplflowProvider, ShoplflowProviderProps, Skeleton, SkeletonProps, Slider, SliderBounds, SliderProps, SpacingTokens, SplitButton, SplitButtonContext, SplitButtonContextType, SplitButtonOptionProps, SplitButtonProps, SplitButtonSizeVariantType, SplitButtonSizeVariants, SplitButtonStyleVariantType, SplitButtonStyleVariants, Stack, StackComponentType, StackContainer, StackContainerComponentType, StackContainerGenericProps, StackContainerOptionProps, StackContainerProps, StackGenericProps, StackOptionProps, StackProps, StyledIcon, StyledStack, StyledStackContainer, Switch, SwitchOptionProps, SwitchProps, TREE_SYMBOL_KEY, TabOptionProps, TabProps, TabSizeVariantType, TabSizeVariants, TabStyleVariantType, TabStyleVariants, TabStyledProps, TabTextStyledProps, Tabs, TabsContext, TabsContextType, TabsOptionProps, TabsProps, Tag, TagOptionProps, TagProps, TagSizeVariantType, TagSizeVariants, TagStyleVariantType, TagStyleVariants, Text, Text2Rows, TextArea, TextAreaOptionProps, TextAreaProps, TextOptionProps, TextProps, ToggleButton, ToggleButtonInnerRadioOptionProps, ToggleButtonInnerRadioProps, ToggleButtonOptionProps, ToggleButtonProps, ToggleButtonSizeVariantType, ToggleButtonSizeVariants, Tooltip, TooltipContentProps, TooltipOptionProps, TooltipProps, Tree, TreeItem, TreeItemOptionProps, TreeItemProps, TreeOptionProps, TreeProps, TypographyTokens, WeekClickDateInfo, WeekDatepicker, WeekDatepickerProps, WeekDatepickerStyleType, YearSelectProps, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,13 @@ import { motion, AnimatePresence, LayoutGroup, LazyMotion, domAnimation } from '
|
|
|
5
5
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { css, keyframes } from '@emotion/react';
|
|
8
|
-
import { noop, useMergeRefs, useOutsideClick, OutSideClick, useSelect, useParentElementClick, isNullOrUndefined } from '@shoplflow/utils';
|
|
8
|
+
import { noop, useMergeRefs, useOutsideClick, OutSideClick, debounce, useSelect, useParentElementClick, isNullOrUndefined } from '@shoplflow/utils';
|
|
9
9
|
import Scrollbars from 'react-custom-scrollbars-2';
|
|
10
10
|
import { FloatingPortal, autoUpdate, offset, autoPlacement } from '@floating-ui/react';
|
|
11
11
|
export { arrow, flip, hide, inline, offset, shift, size } from '@floating-ui/react';
|
|
12
12
|
import { useFloating } from '@floating-ui/react-dom';
|
|
13
13
|
import * as ShoplAssets from '@shoplflow/shopl-assets';
|
|
14
|
-
import { DownArrowSolidXsmallIcon, RightArrowSolidXsmallIcon, FirstPageIcon, LeftArrowIcon, RightArrowIcon, EndPageIcon } from '@shoplflow/shopl-assets';
|
|
14
|
+
import { DownArrowSolidXsmallIcon, RightArrowSolidXsmallIcon, FirstPageIcon, LeftArrowIcon, RightArrowIcon, EndPageIcon, SearchIcon } from '@shoplflow/shopl-assets';
|
|
15
15
|
import { shift, flip, offset as offset$1 } from '@floating-ui/core';
|
|
16
16
|
import * as HadaAssets from '@shoplflow/hada-assets';
|
|
17
17
|
import DatePicker2 from 'react-datepicker';
|
|
@@ -1596,6 +1596,12 @@ var getStyleBySizeVar2 = (sizeVar) => {
|
|
|
1596
1596
|
min-width: 54px;
|
|
1597
1597
|
min-height: 32px;
|
|
1598
1598
|
`;
|
|
1599
|
+
case "XS":
|
|
1600
|
+
return css`
|
|
1601
|
+
gap: 2px;
|
|
1602
|
+
padding: 4px 6px;
|
|
1603
|
+
min-height: 24px;
|
|
1604
|
+
`;
|
|
1599
1605
|
default:
|
|
1600
1606
|
return css`
|
|
1601
1607
|
gap: 4px;
|
|
@@ -1668,6 +1674,12 @@ var Button = forwardRef(
|
|
|
1668
1674
|
"isLoading",
|
|
1669
1675
|
"lineClamp"
|
|
1670
1676
|
]);
|
|
1677
|
+
const getTypography = () => {
|
|
1678
|
+
if (sizeVar === "XS") {
|
|
1679
|
+
return "caption_400";
|
|
1680
|
+
}
|
|
1681
|
+
return sizeVar === "M" ? "body1_400" : "body2_400";
|
|
1682
|
+
};
|
|
1671
1683
|
return /* @__PURE__ */ jsxs(
|
|
1672
1684
|
StyledButton,
|
|
1673
1685
|
__spreadProps(__spreadValues({
|
|
@@ -1689,7 +1701,7 @@ var Button = forwardRef(
|
|
|
1689
1701
|
whiteSpace: "nowrap",
|
|
1690
1702
|
wordBreak: "keep-all",
|
|
1691
1703
|
color: styleVar === "PRIMARY" ? "neutral0" : "neutral700",
|
|
1692
|
-
typography:
|
|
1704
|
+
typography: getTypography(),
|
|
1693
1705
|
children
|
|
1694
1706
|
}
|
|
1695
1707
|
),
|
|
@@ -1704,7 +1716,8 @@ var Button_default = Button;
|
|
|
1704
1716
|
// src/components/Buttons/Button/Button.types.ts
|
|
1705
1717
|
var ButtonSizeVariants = {
|
|
1706
1718
|
S: "S",
|
|
1707
|
-
M: "M"
|
|
1719
|
+
M: "M",
|
|
1720
|
+
XS: "XS"
|
|
1708
1721
|
};
|
|
1709
1722
|
var ButtonStyleVariants = {
|
|
1710
1723
|
PRIMARY: "PRIMARY",
|
|
@@ -6972,6 +6985,242 @@ var Slider = ({
|
|
|
6972
6985
|
] }) });
|
|
6973
6986
|
};
|
|
6974
6987
|
var Slider_default = Slider;
|
|
6988
|
+
var SearchBarContext = createContext({});
|
|
6989
|
+
var useSearchBarContext = () => useContext(SearchBarContext);
|
|
6990
|
+
var SearchBarProvider = ({
|
|
6991
|
+
children,
|
|
6992
|
+
useFlexibleWidth,
|
|
6993
|
+
isSelected
|
|
6994
|
+
}) => {
|
|
6995
|
+
return /* @__PURE__ */ jsx(SearchBarContext.Provider, { value: { useFlexibleWidth, isSelected }, children });
|
|
6996
|
+
};
|
|
6997
|
+
var DEFAULT_DEBOUNCE_TIME = 300;
|
|
6998
|
+
var SearchBarInput = (_a) => {
|
|
6999
|
+
var _b = _a, {
|
|
7000
|
+
value,
|
|
7001
|
+
defaultValue,
|
|
7002
|
+
onChange,
|
|
7003
|
+
onClear,
|
|
7004
|
+
placeholder,
|
|
7005
|
+
flexiblePlaceholder,
|
|
7006
|
+
disabled,
|
|
7007
|
+
type = "default",
|
|
7008
|
+
onSearch,
|
|
7009
|
+
debounceTime = type === "default" ? 0 : DEFAULT_DEBOUNCE_TIME,
|
|
7010
|
+
icon = /* @__PURE__ */ jsx(Icon_default, { iconSource: SearchIcon, color: "neutral350", sizeVar: "S" })
|
|
7011
|
+
} = _b, rest = __objRest(_b, [
|
|
7012
|
+
"value",
|
|
7013
|
+
"defaultValue",
|
|
7014
|
+
"onChange",
|
|
7015
|
+
"onClear",
|
|
7016
|
+
"placeholder",
|
|
7017
|
+
"flexiblePlaceholder",
|
|
7018
|
+
"disabled",
|
|
7019
|
+
"type",
|
|
7020
|
+
"onSearch",
|
|
7021
|
+
"debounceTime",
|
|
7022
|
+
"icon"
|
|
7023
|
+
]);
|
|
7024
|
+
const { useFlexibleWidth, isSelected } = useSearchBarContext();
|
|
7025
|
+
const [text, setText] = useState("");
|
|
7026
|
+
const convertToString = useCallback((value2) => {
|
|
7027
|
+
if (typeof value2 !== "number") {
|
|
7028
|
+
return typeof value2 === "string" ? value2 : value2.join("");
|
|
7029
|
+
}
|
|
7030
|
+
return String(value2);
|
|
7031
|
+
}, []);
|
|
7032
|
+
const debouncedOnChange = useRef(
|
|
7033
|
+
debounce(
|
|
7034
|
+
(event) => {
|
|
7035
|
+
const newValue = event.target.value;
|
|
7036
|
+
setText(newValue);
|
|
7037
|
+
if (type === "real-time") {
|
|
7038
|
+
onChange && onChange(event);
|
|
7039
|
+
onSearch && onSearch(newValue);
|
|
7040
|
+
}
|
|
7041
|
+
},
|
|
7042
|
+
debounceTime
|
|
7043
|
+
)
|
|
7044
|
+
).current;
|
|
7045
|
+
const handleOnChange = (event) => {
|
|
7046
|
+
debouncedOnChange(event);
|
|
7047
|
+
};
|
|
7048
|
+
const handleOnClear = useCallback(() => {
|
|
7049
|
+
setText("");
|
|
7050
|
+
onClear == null ? void 0 : onClear();
|
|
7051
|
+
}, [onClear]);
|
|
7052
|
+
const handleKeyDown = useCallback(
|
|
7053
|
+
(event) => {
|
|
7054
|
+
if (type === "default" && event.key === "Enter") {
|
|
7055
|
+
onSearch == null ? void 0 : onSearch(text);
|
|
7056
|
+
}
|
|
7057
|
+
},
|
|
7058
|
+
[onSearch, text, type]
|
|
7059
|
+
);
|
|
7060
|
+
const handleIconClick = useCallback(() => {
|
|
7061
|
+
if (type === "default") {
|
|
7062
|
+
onSearch == null ? void 0 : onSearch(text);
|
|
7063
|
+
}
|
|
7064
|
+
}, [onSearch, text, type]);
|
|
7065
|
+
let _placeholder = placeholder;
|
|
7066
|
+
if (useFlexibleWidth && !isSelected) {
|
|
7067
|
+
_placeholder = flexiblePlaceholder;
|
|
7068
|
+
}
|
|
7069
|
+
const getInitialValue = useCallback(() => {
|
|
7070
|
+
if (value !== void 0) {
|
|
7071
|
+
return convertToString(value);
|
|
7072
|
+
}
|
|
7073
|
+
if (defaultValue !== void 0) {
|
|
7074
|
+
return convertToString(defaultValue);
|
|
7075
|
+
}
|
|
7076
|
+
return "";
|
|
7077
|
+
}, [convertToString, defaultValue, value]);
|
|
7078
|
+
useEffect(() => {
|
|
7079
|
+
const initialValue = getInitialValue();
|
|
7080
|
+
setText(initialValue);
|
|
7081
|
+
}, [getInitialValue]);
|
|
7082
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7083
|
+
type === "default" && /* @__PURE__ */ jsx(IconButton_default, { styleVar: "GHOST", sizeVar: "S", onClick: handleIconClick, "aria-label": "\uAC80\uC0C9", children: /* @__PURE__ */ jsx(Icon_default, { iconSource: SearchIcon, color: text ? "neutral700" : "neutral350", sizeVar: "S" }) }),
|
|
7084
|
+
type === "real-time" && icon,
|
|
7085
|
+
/* @__PURE__ */ jsx(
|
|
7086
|
+
Input_default,
|
|
7087
|
+
__spreadValues({
|
|
7088
|
+
placeholder: _placeholder,
|
|
7089
|
+
onChange: handleOnChange,
|
|
7090
|
+
onKeyDown: handleKeyDown,
|
|
7091
|
+
value: text,
|
|
7092
|
+
onClear: handleOnClear,
|
|
7093
|
+
width: "100%",
|
|
7094
|
+
disabled,
|
|
7095
|
+
"aria-label": "\uAC80\uC0C9\uC5B4 \uC785\uB825"
|
|
7096
|
+
}, rest)
|
|
7097
|
+
)
|
|
7098
|
+
] });
|
|
7099
|
+
};
|
|
7100
|
+
var StyledStackContainer2 = styled6(Stack_default.Horizontal)`
|
|
7101
|
+
border: 1px solid ${colorTokens.neutral100};
|
|
7102
|
+
border-radius: ${borderRadiusTokens.borderRadius06};
|
|
7103
|
+
background-color: ${colorTokens.neutral100};
|
|
7104
|
+
justify-content: center;
|
|
7105
|
+
align-items: center;
|
|
7106
|
+
padding: 4px 8px;
|
|
7107
|
+
transition: all 400ms ease-in-out;
|
|
7108
|
+
|
|
7109
|
+
label {
|
|
7110
|
+
flex-grow: 1;
|
|
7111
|
+
border: none;
|
|
7112
|
+
border-radius: 0;
|
|
7113
|
+
height: 32px;
|
|
7114
|
+
background-color: ${colorTokens.neutral100};
|
|
7115
|
+
gap: 0px;
|
|
7116
|
+
|
|
7117
|
+
div {
|
|
7118
|
+
padding: 0;
|
|
7119
|
+
}
|
|
7120
|
+
|
|
7121
|
+
input {
|
|
7122
|
+
padding: 0;
|
|
7123
|
+
}
|
|
7124
|
+
}
|
|
7125
|
+
|
|
7126
|
+
button {
|
|
7127
|
+
background-color: ${colorTokens.neutral100};
|
|
7128
|
+
}
|
|
7129
|
+
`;
|
|
7130
|
+
var CategoriesButton = styled6(Dropdown_default.Button)`
|
|
7131
|
+
border-radius: 4px;
|
|
7132
|
+
height: 24px;
|
|
7133
|
+
|
|
7134
|
+
&:hover {
|
|
7135
|
+
background-color: ${colorTokens.neutral200};
|
|
7136
|
+
}
|
|
7137
|
+
`;
|
|
7138
|
+
var DEFAULT_DROPDOWN_WIDTH = "136px";
|
|
7139
|
+
var SearchBarCategory = ({
|
|
7140
|
+
dropdownWidth = DEFAULT_DROPDOWN_WIDTH,
|
|
7141
|
+
dropdownItems = [],
|
|
7142
|
+
selectedDropdownItem,
|
|
7143
|
+
onDropdownSelect
|
|
7144
|
+
}) => {
|
|
7145
|
+
const { isSelected, useFlexibleWidth } = useSearchBarContext();
|
|
7146
|
+
if (!isSelected && useFlexibleWidth) {
|
|
7147
|
+
return null;
|
|
7148
|
+
}
|
|
7149
|
+
return /* @__PURE__ */ jsx(
|
|
7150
|
+
Dropdown_default,
|
|
7151
|
+
{
|
|
7152
|
+
width: dropdownWidth,
|
|
7153
|
+
trigger: /* @__PURE__ */ jsx(
|
|
7154
|
+
CategoriesButton,
|
|
7155
|
+
{
|
|
7156
|
+
value: selectedDropdownItem && /* @__PURE__ */ jsx(Text_default, { lineClamp: 1, typography: "body2_700", children: selectedDropdownItem.label }),
|
|
7157
|
+
"aria-label": "\uCE74\uD14C\uACE0\uB9AC \uC120\uD0DD"
|
|
7158
|
+
}
|
|
7159
|
+
),
|
|
7160
|
+
popper: /* @__PURE__ */ jsx(Dropdown_default.Content, { type: "FILL", children: dropdownItems.map((item) => /* @__PURE__ */ jsx(
|
|
7161
|
+
Menu_default,
|
|
7162
|
+
{
|
|
7163
|
+
className: "search-bar",
|
|
7164
|
+
onClick: () => onDropdownSelect == null ? void 0 : onDropdownSelect(item),
|
|
7165
|
+
isSelected: (selectedDropdownItem == null ? void 0 : selectedDropdownItem.value) === item.value,
|
|
7166
|
+
"aria-selected": (selectedDropdownItem == null ? void 0 : selectedDropdownItem.value) === item.value,
|
|
7167
|
+
children: /* @__PURE__ */ jsx(Text_default, { typography: "body1_500", children: item.label })
|
|
7168
|
+
},
|
|
7169
|
+
item.value
|
|
7170
|
+
)) })
|
|
7171
|
+
}
|
|
7172
|
+
);
|
|
7173
|
+
};
|
|
7174
|
+
var DEFAULT_WIDTH = "100%";
|
|
7175
|
+
var DEFAULT_HEIGHT = "32px";
|
|
7176
|
+
var SearchBar = (_a) => {
|
|
7177
|
+
var _b = _a, {
|
|
7178
|
+
width = DEFAULT_WIDTH,
|
|
7179
|
+
height = DEFAULT_HEIGHT,
|
|
7180
|
+
useFlexibleWidth = false,
|
|
7181
|
+
children
|
|
7182
|
+
} = _b, rest = __objRest(_b, [
|
|
7183
|
+
"width",
|
|
7184
|
+
"height",
|
|
7185
|
+
"useFlexibleWidth",
|
|
7186
|
+
"children"
|
|
7187
|
+
]);
|
|
7188
|
+
const [isSelected, setIsSelected] = useOutsideClick({
|
|
7189
|
+
selector: ".search-bar",
|
|
7190
|
+
onClose: () => setIsSelected(false)
|
|
7191
|
+
});
|
|
7192
|
+
const handleContainerClick = useCallback(() => {
|
|
7193
|
+
setIsSelected(true);
|
|
7194
|
+
}, [setIsSelected]);
|
|
7195
|
+
const containerWidth = useMemo(() => {
|
|
7196
|
+
if (!useFlexibleWidth) {
|
|
7197
|
+
return width;
|
|
7198
|
+
}
|
|
7199
|
+
return isSelected ? width : "140px";
|
|
7200
|
+
}, [useFlexibleWidth, isSelected, width]);
|
|
7201
|
+
return /* @__PURE__ */ jsx(SearchBarProvider, { useFlexibleWidth, isSelected, children: /* @__PURE__ */ jsx(
|
|
7202
|
+
StyledStackContainer2,
|
|
7203
|
+
__spreadProps(__spreadValues({
|
|
7204
|
+
"data-shoplflow": "SearchBar",
|
|
7205
|
+
width: containerWidth,
|
|
7206
|
+
height,
|
|
7207
|
+
className: "search-bar",
|
|
7208
|
+
spacing: "spacing04",
|
|
7209
|
+
onClick: handleContainerClick,
|
|
7210
|
+
role: "search",
|
|
7211
|
+
"aria-label": "\uAC80\uC0C9"
|
|
7212
|
+
}, rest), {
|
|
7213
|
+
children
|
|
7214
|
+
})
|
|
7215
|
+
) });
|
|
7216
|
+
};
|
|
7217
|
+
SearchBar.Category = SearchBarCategory;
|
|
7218
|
+
SearchBar.Input = SearchBarInput;
|
|
7219
|
+
|
|
7220
|
+
// src/components/SearchBar/index.ts
|
|
7221
|
+
var SearchBar2 = SearchBar;
|
|
7222
|
+
SearchBar2.Category = SearchBarCategory;
|
|
7223
|
+
SearchBar2.Input = SearchBarInput;
|
|
6975
7224
|
var SpaceMarginWrapper = styled6(motion.div)`
|
|
6976
7225
|
position: relative;
|
|
6977
7226
|
display: flex;
|
|
@@ -7026,4 +7275,4 @@ classnames/index.js:
|
|
|
7026
7275
|
*)
|
|
7027
7276
|
*/
|
|
7028
7277
|
|
|
7029
|
-
export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, DropdownButton_default as DropdownButton, DropdownButtonContext, DropdownButtonSizeVariants, DropdownButtonStyleVariants, DropdownOptionVariants, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, SLIDER_Z_INDEX, ScrollArea_default as ScrollArea, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Skeleton_default as Skeleton, Slider_default as Slider, SplitButton_default as SplitButton, SplitButtonContext, SplitButtonSizeVariants, SplitButtonStyleVariants, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|
|
7278
|
+
export { AnnualDatepicker_default as AnnualDatepicker, Avatar_default as Avatar, AvatarSizeVariants, Button_default as Button, ButtonSizeVariants, ButtonStyleVariants, CHECKBOX_SYMBOL_KEY, Callout_default as Callout, CalloutTypes, Checkbox_default as Checkbox, CheckboxStyleVariants, ChipButton_default as ChipButton, ChipButtonSizeVariants, ChipButtonStyleVariants, ChipToggle_default as ChipToggle, ChipToggleSizeVariants, ChipToggleStyleVariants, DayDatepicker_default as DayDatepicker, DayDatepickerSizeVariants, Dropdown_default as Dropdown, DropdownButton_default as DropdownButton, DropdownButtonContext, DropdownButtonSizeVariants, DropdownButtonStyleVariants, DropdownOptionVariants, Icon_default as Icon, IconButton_default as IconButton, IconButtonSizeVariants, IconButtonStyleVariants, IconSizeVariants, Input_default as Input, InputButton_default as InputButton, InputSizeVariants, List_default as List, MODAL_FOOTER_KEY, MODAL_HEADER_KEY, Menu_default as Menu, MenuSizeVariants, MinusButton_default as MinusButton, Modal, ModalContext, ModalHandlerContext, ModalPortal_default as ModalProvider, ModalSize, MonthDatepicker_default as MonthDatepicker, MotionStack, MotionStackContainer, NumberCombobox_default as NumberCombobox, NumberComboboxSizeVariants, Pagination_default as Pagination, Popper_default as Popper, PopperPortal, PopperTrigger, RADIO_SYMBOL_KEY, Radio_default as Radio, SLIDER_Z_INDEX, ScrollArea_default as ScrollArea, SearchBar2 as SearchBar, SelectInputButton_default as SelectInputButton, ShoplflowProvider_default as ShoplflowProvider, Skeleton_default as Skeleton, Slider_default as Slider, SplitButton_default as SplitButton, SplitButtonContext, SplitButtonSizeVariants, SplitButtonStyleVariants, Stack_default as Stack, StackContainer_default as StackContainer, StyledIcon, StyledStack, StyledStackContainer, Switch_default as Switch, TREE_SYMBOL_KEY, TabSizeVariants, TabStyleVariants, Tabs_default as Tabs, TabsContext, Tag_default as Tag, TagSizeVariants, TagStyleVariants, Text_default as Text, Text2Rows, TextArea_default as TextArea, ToggleButton_default as ToggleButton, ToggleButtonSizeVariants, Tooltip_default as Tooltip, Tree_default as Tree, TreeItem, WeekDatepicker_default as WeekDatepicker, borderRadiusTokens, boxShadowTokens, colorTokens, fontWeightTokens, getDomain, spacingTokens, typographyTokens, useDomain, useDropdownButtonContext, useHandleModal, useModalValue, useSplitButtonContext, useTabs };
|