@shoplflow/base 0.42.8 → 0.42.10
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 +27 -27
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +27 -27
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -276,9 +276,17 @@ var StyledAvatarBadge = styled6__default.default.div`
|
|
|
276
276
|
// src/assets/mocks/AvatarNone.png
|
|
277
277
|
var AvatarNone_default = "./AvatarNone-F5VQQNT7.png";
|
|
278
278
|
var Avatar = (_a) => {
|
|
279
|
-
var _b = _a, { src, badge } = _b, rest = __objRest(_b, ["src", "badge"]);
|
|
279
|
+
var _b = _a, { src, badge, fallbackUrl } = _b, rest = __objRest(_b, ["src", "badge", "fallbackUrl"]);
|
|
280
280
|
return /* @__PURE__ */ jsxRuntime.jsxs(StyledAvatarContainer, { children: [
|
|
281
|
-
/* @__PURE__ */ jsxRuntime.jsx(StyledAvatar, __spreadProps(__spreadValues({ "data-shoplflow": "Avatar" }, rest), { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledAvatar, __spreadProps(__spreadValues({ "data-shoplflow": "Avatar" }, rest), { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
282
|
+
StyledAvatarImage,
|
|
283
|
+
{
|
|
284
|
+
src: src != null ? src : fallbackUrl,
|
|
285
|
+
onError: (e) => {
|
|
286
|
+
e.currentTarget.src = fallbackUrl != null ? fallbackUrl : AvatarNone_default;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
) })),
|
|
282
290
|
/* @__PURE__ */ jsxRuntime.jsx(StyledAvatarBadge, { children: badge })
|
|
283
291
|
] });
|
|
284
292
|
};
|
|
@@ -7089,7 +7097,6 @@ var DEFAULT_DEBOUNCE_TIME = 300;
|
|
|
7089
7097
|
var SearchBarInput = (_a) => {
|
|
7090
7098
|
var _b = _a, {
|
|
7091
7099
|
value,
|
|
7092
|
-
defaultValue,
|
|
7093
7100
|
onChange,
|
|
7094
7101
|
onClear,
|
|
7095
7102
|
placeholder,
|
|
@@ -7098,10 +7105,10 @@ var SearchBarInput = (_a) => {
|
|
|
7098
7105
|
type = "default",
|
|
7099
7106
|
onSearch,
|
|
7100
7107
|
debounceTime = type === "default" ? 0 : DEFAULT_DEBOUNCE_TIME,
|
|
7101
|
-
icon = /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.SearchIcon, color: "neutral350", sizeVar: "S" })
|
|
7108
|
+
icon = /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.SearchIcon, color: "neutral350", sizeVar: "S" }),
|
|
7109
|
+
maxLength
|
|
7102
7110
|
} = _b, rest = __objRest(_b, [
|
|
7103
7111
|
"value",
|
|
7104
|
-
"defaultValue",
|
|
7105
7112
|
"onChange",
|
|
7106
7113
|
"onClear",
|
|
7107
7114
|
"placeholder",
|
|
@@ -7110,16 +7117,11 @@ var SearchBarInput = (_a) => {
|
|
|
7110
7117
|
"type",
|
|
7111
7118
|
"onSearch",
|
|
7112
7119
|
"debounceTime",
|
|
7113
|
-
"icon"
|
|
7120
|
+
"icon",
|
|
7121
|
+
"maxLength"
|
|
7114
7122
|
]);
|
|
7115
7123
|
const { useFlexibleWidth, isSelected } = useSearchBarContext();
|
|
7116
7124
|
const [text, setText] = React3.useState("");
|
|
7117
|
-
const convertToString = React3.useCallback((value2) => {
|
|
7118
|
-
if (typeof value2 !== "number") {
|
|
7119
|
-
return typeof value2 === "string" ? value2 : value2.join("");
|
|
7120
|
-
}
|
|
7121
|
-
return String(value2);
|
|
7122
|
-
}, []);
|
|
7123
7125
|
const debouncedOnChange = React3.useRef(
|
|
7124
7126
|
utils.debounce(
|
|
7125
7127
|
(event) => {
|
|
@@ -7134,7 +7136,18 @@ var SearchBarInput = (_a) => {
|
|
|
7134
7136
|
)
|
|
7135
7137
|
).current;
|
|
7136
7138
|
const handleOnChange = (event) => {
|
|
7137
|
-
|
|
7139
|
+
const newValue = event.target.value;
|
|
7140
|
+
if (maxLength && newValue.length > maxLength) {
|
|
7141
|
+
event.target.value = value === void 0 ? text : String(value);
|
|
7142
|
+
return;
|
|
7143
|
+
}
|
|
7144
|
+
setText(newValue);
|
|
7145
|
+
if (debounceTime === 0 || maxLength && newValue.length === maxLength) {
|
|
7146
|
+
onChange && onChange(event);
|
|
7147
|
+
}
|
|
7148
|
+
if (type === "real-time") {
|
|
7149
|
+
debouncedOnChange(event);
|
|
7150
|
+
}
|
|
7138
7151
|
};
|
|
7139
7152
|
const handleOnClear = React3.useCallback(() => {
|
|
7140
7153
|
setText("");
|
|
@@ -7157,19 +7170,6 @@ var SearchBarInput = (_a) => {
|
|
|
7157
7170
|
if (useFlexibleWidth && !isSelected) {
|
|
7158
7171
|
_placeholder = flexiblePlaceholder;
|
|
7159
7172
|
}
|
|
7160
|
-
const getInitialValue = React3.useCallback(() => {
|
|
7161
|
-
if (value !== void 0) {
|
|
7162
|
-
return convertToString(value);
|
|
7163
|
-
}
|
|
7164
|
-
if (defaultValue !== void 0) {
|
|
7165
|
-
return convertToString(defaultValue);
|
|
7166
|
-
}
|
|
7167
|
-
return "";
|
|
7168
|
-
}, [convertToString, defaultValue, value]);
|
|
7169
|
-
React3.useEffect(() => {
|
|
7170
|
-
const initialValue = getInitialValue();
|
|
7171
|
-
setText(initialValue);
|
|
7172
|
-
}, [getInitialValue]);
|
|
7173
7173
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7174
7174
|
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" }) }),
|
|
7175
7175
|
type === "real-time" && icon,
|
|
@@ -7179,7 +7179,7 @@ var SearchBarInput = (_a) => {
|
|
|
7179
7179
|
placeholder: _placeholder,
|
|
7180
7180
|
onChange: handleOnChange,
|
|
7181
7181
|
onKeyDown: handleKeyDown,
|
|
7182
|
-
value: text,
|
|
7182
|
+
value: value === void 0 ? text : value,
|
|
7183
7183
|
onClear: handleOnClear,
|
|
7184
7184
|
width: "100%",
|
|
7185
7185
|
disabled,
|
package/dist/index.d.cts
CHANGED
|
@@ -282,6 +282,7 @@ declare const AvatarSizeVariants: {
|
|
|
282
282
|
};
|
|
283
283
|
declare type AvatarSizeVariantType = $Values<typeof AvatarSizeVariants>;
|
|
284
284
|
interface AvatarProps extends AvatarOptionProps {
|
|
285
|
+
fallbackUrl?: string;
|
|
285
286
|
}
|
|
286
287
|
interface AvatarOptionProps extends SizeVariantProps<AvatarSizeVariantType>, ImgHTMLAttributes<HTMLImageElement> {
|
|
287
288
|
/**
|
|
@@ -290,7 +291,7 @@ interface AvatarOptionProps extends SizeVariantProps<AvatarSizeVariantType>, Img
|
|
|
290
291
|
badge?: ReactNode;
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
declare const Avatar: ({ src, badge, ...rest }: AvatarProps) =>
|
|
294
|
+
declare const Avatar: ({ src, badge, fallbackUrl, ...rest }: AvatarProps) => JSX.Element;
|
|
294
295
|
|
|
295
296
|
declare type StackGenericProps<T extends StringElementType = 'div'> = RenderConfigProps & StackProps & HTMLPropsWithoutRef<T>;
|
|
296
297
|
declare type StackComponentType = ForwardRefExoticComponent<PropsWithoutRef<StackGenericProps> & RefAttributes<HTMLElement>>;
|
|
@@ -1683,6 +1684,8 @@ interface SearchBarInputProps {
|
|
|
1683
1684
|
onSearch?: (value: string) => void;
|
|
1684
1685
|
/** 디바운스 시간 (ms) */
|
|
1685
1686
|
debounceTime?: number;
|
|
1687
|
+
/** 최대 길이 */
|
|
1688
|
+
maxLength?: number;
|
|
1686
1689
|
}
|
|
1687
1690
|
/** 검색바 props */
|
|
1688
1691
|
declare type SearchBarProps = SearchBarBaseProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -282,6 +282,7 @@ declare const AvatarSizeVariants: {
|
|
|
282
282
|
};
|
|
283
283
|
declare type AvatarSizeVariantType = $Values<typeof AvatarSizeVariants>;
|
|
284
284
|
interface AvatarProps extends AvatarOptionProps {
|
|
285
|
+
fallbackUrl?: string;
|
|
285
286
|
}
|
|
286
287
|
interface AvatarOptionProps extends SizeVariantProps<AvatarSizeVariantType>, ImgHTMLAttributes<HTMLImageElement> {
|
|
287
288
|
/**
|
|
@@ -290,7 +291,7 @@ interface AvatarOptionProps extends SizeVariantProps<AvatarSizeVariantType>, Img
|
|
|
290
291
|
badge?: ReactNode;
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
declare const Avatar: ({ src, badge, ...rest }: AvatarProps) =>
|
|
294
|
+
declare const Avatar: ({ src, badge, fallbackUrl, ...rest }: AvatarProps) => JSX.Element;
|
|
294
295
|
|
|
295
296
|
declare type StackGenericProps<T extends StringElementType = 'div'> = RenderConfigProps & StackProps & HTMLPropsWithoutRef<T>;
|
|
296
297
|
declare type StackComponentType = ForwardRefExoticComponent<PropsWithoutRef<StackGenericProps> & RefAttributes<HTMLElement>>;
|
|
@@ -1683,6 +1684,8 @@ interface SearchBarInputProps {
|
|
|
1683
1684
|
onSearch?: (value: string) => void;
|
|
1684
1685
|
/** 디바운스 시간 (ms) */
|
|
1685
1686
|
debounceTime?: number;
|
|
1687
|
+
/** 최대 길이 */
|
|
1688
|
+
maxLength?: number;
|
|
1686
1689
|
}
|
|
1687
1690
|
/** 검색바 props */
|
|
1688
1691
|
declare type SearchBarProps = SearchBarBaseProps;
|
package/dist/index.js
CHANGED
|
@@ -249,9 +249,17 @@ var StyledAvatarBadge = styled6.div`
|
|
|
249
249
|
// src/assets/mocks/AvatarNone.png
|
|
250
250
|
var AvatarNone_default = "./AvatarNone-F5VQQNT7.png";
|
|
251
251
|
var Avatar = (_a) => {
|
|
252
|
-
var _b = _a, { src, badge } = _b, rest = __objRest(_b, ["src", "badge"]);
|
|
252
|
+
var _b = _a, { src, badge, fallbackUrl } = _b, rest = __objRest(_b, ["src", "badge", "fallbackUrl"]);
|
|
253
253
|
return /* @__PURE__ */ jsxs(StyledAvatarContainer, { children: [
|
|
254
|
-
/* @__PURE__ */ jsx(StyledAvatar, __spreadProps(__spreadValues({ "data-shoplflow": "Avatar" }, rest), { children: /* @__PURE__ */ jsx(
|
|
254
|
+
/* @__PURE__ */ jsx(StyledAvatar, __spreadProps(__spreadValues({ "data-shoplflow": "Avatar" }, rest), { children: /* @__PURE__ */ jsx(
|
|
255
|
+
StyledAvatarImage,
|
|
256
|
+
{
|
|
257
|
+
src: src != null ? src : fallbackUrl,
|
|
258
|
+
onError: (e) => {
|
|
259
|
+
e.currentTarget.src = fallbackUrl != null ? fallbackUrl : AvatarNone_default;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
) })),
|
|
255
263
|
/* @__PURE__ */ jsx(StyledAvatarBadge, { children: badge })
|
|
256
264
|
] });
|
|
257
265
|
};
|
|
@@ -7062,7 +7070,6 @@ var DEFAULT_DEBOUNCE_TIME = 300;
|
|
|
7062
7070
|
var SearchBarInput = (_a) => {
|
|
7063
7071
|
var _b = _a, {
|
|
7064
7072
|
value,
|
|
7065
|
-
defaultValue,
|
|
7066
7073
|
onChange,
|
|
7067
7074
|
onClear,
|
|
7068
7075
|
placeholder,
|
|
@@ -7071,10 +7078,10 @@ var SearchBarInput = (_a) => {
|
|
|
7071
7078
|
type = "default",
|
|
7072
7079
|
onSearch,
|
|
7073
7080
|
debounceTime = type === "default" ? 0 : DEFAULT_DEBOUNCE_TIME,
|
|
7074
|
-
icon = /* @__PURE__ */ jsx(Icon_default, { iconSource: SearchIcon, color: "neutral350", sizeVar: "S" })
|
|
7081
|
+
icon = /* @__PURE__ */ jsx(Icon_default, { iconSource: SearchIcon, color: "neutral350", sizeVar: "S" }),
|
|
7082
|
+
maxLength
|
|
7075
7083
|
} = _b, rest = __objRest(_b, [
|
|
7076
7084
|
"value",
|
|
7077
|
-
"defaultValue",
|
|
7078
7085
|
"onChange",
|
|
7079
7086
|
"onClear",
|
|
7080
7087
|
"placeholder",
|
|
@@ -7083,16 +7090,11 @@ var SearchBarInput = (_a) => {
|
|
|
7083
7090
|
"type",
|
|
7084
7091
|
"onSearch",
|
|
7085
7092
|
"debounceTime",
|
|
7086
|
-
"icon"
|
|
7093
|
+
"icon",
|
|
7094
|
+
"maxLength"
|
|
7087
7095
|
]);
|
|
7088
7096
|
const { useFlexibleWidth, isSelected } = useSearchBarContext();
|
|
7089
7097
|
const [text, setText] = useState("");
|
|
7090
|
-
const convertToString = useCallback((value2) => {
|
|
7091
|
-
if (typeof value2 !== "number") {
|
|
7092
|
-
return typeof value2 === "string" ? value2 : value2.join("");
|
|
7093
|
-
}
|
|
7094
|
-
return String(value2);
|
|
7095
|
-
}, []);
|
|
7096
7098
|
const debouncedOnChange = useRef(
|
|
7097
7099
|
debounce(
|
|
7098
7100
|
(event) => {
|
|
@@ -7107,7 +7109,18 @@ var SearchBarInput = (_a) => {
|
|
|
7107
7109
|
)
|
|
7108
7110
|
).current;
|
|
7109
7111
|
const handleOnChange = (event) => {
|
|
7110
|
-
|
|
7112
|
+
const newValue = event.target.value;
|
|
7113
|
+
if (maxLength && newValue.length > maxLength) {
|
|
7114
|
+
event.target.value = value === void 0 ? text : String(value);
|
|
7115
|
+
return;
|
|
7116
|
+
}
|
|
7117
|
+
setText(newValue);
|
|
7118
|
+
if (debounceTime === 0 || maxLength && newValue.length === maxLength) {
|
|
7119
|
+
onChange && onChange(event);
|
|
7120
|
+
}
|
|
7121
|
+
if (type === "real-time") {
|
|
7122
|
+
debouncedOnChange(event);
|
|
7123
|
+
}
|
|
7111
7124
|
};
|
|
7112
7125
|
const handleOnClear = useCallback(() => {
|
|
7113
7126
|
setText("");
|
|
@@ -7130,19 +7143,6 @@ var SearchBarInput = (_a) => {
|
|
|
7130
7143
|
if (useFlexibleWidth && !isSelected) {
|
|
7131
7144
|
_placeholder = flexiblePlaceholder;
|
|
7132
7145
|
}
|
|
7133
|
-
const getInitialValue = useCallback(() => {
|
|
7134
|
-
if (value !== void 0) {
|
|
7135
|
-
return convertToString(value);
|
|
7136
|
-
}
|
|
7137
|
-
if (defaultValue !== void 0) {
|
|
7138
|
-
return convertToString(defaultValue);
|
|
7139
|
-
}
|
|
7140
|
-
return "";
|
|
7141
|
-
}, [convertToString, defaultValue, value]);
|
|
7142
|
-
useEffect(() => {
|
|
7143
|
-
const initialValue = getInitialValue();
|
|
7144
|
-
setText(initialValue);
|
|
7145
|
-
}, [getInitialValue]);
|
|
7146
7146
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7147
7147
|
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" }) }),
|
|
7148
7148
|
type === "real-time" && icon,
|
|
@@ -7152,7 +7152,7 @@ var SearchBarInput = (_a) => {
|
|
|
7152
7152
|
placeholder: _placeholder,
|
|
7153
7153
|
onChange: handleOnChange,
|
|
7154
7154
|
onKeyDown: handleKeyDown,
|
|
7155
|
-
value: text,
|
|
7155
|
+
value: value === void 0 ? text : value,
|
|
7156
7156
|
onClear: handleOnClear,
|
|
7157
7157
|
width: "100%",
|
|
7158
7158
|
disabled,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoplflow/base",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"react-dom": "^18.2.0",
|
|
92
92
|
"simplebar-react": "^3.2.6",
|
|
93
93
|
"@shoplflow/hada-assets": "^0.1.7",
|
|
94
|
-
"@shoplflow/
|
|
95
|
-
"@shoplflow/
|
|
94
|
+
"@shoplflow/shopl-assets": "^0.12.22",
|
|
95
|
+
"@shoplflow/utils": "^0.7.0"
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
98
|
"type-check": "tsc --noEmit",
|