@shoplflow/base 0.18.0 → 0.20.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/dist/index.cjs CHANGED
@@ -39,10 +39,14 @@ var Scrollbars__default = /*#__PURE__*/_interopDefault(Scrollbars);
39
39
  var ShoplAssets__namespace = /*#__PURE__*/_interopNamespace(ShoplAssets);
40
40
  var HadaAssets__namespace = /*#__PURE__*/_interopNamespace(HadaAssets);
41
41
 
42
+ var __create = Object.create;
42
43
  var __defProp = Object.defineProperty;
43
44
  var __defProps = Object.defineProperties;
45
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
44
46
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
47
+ var __getOwnPropNames = Object.getOwnPropertyNames;
45
48
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
49
+ var __getProtoOf = Object.getPrototypeOf;
46
50
  var __hasOwnProp = Object.prototype.hasOwnProperty;
47
51
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
48
52
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -70,6 +74,74 @@ var __objRest = (source, exclude) => {
70
74
  }
71
75
  return target;
72
76
  };
77
+ var __commonJS = (cb, mod) => function __require() {
78
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
79
+ };
80
+ var __copyProps = (to, from, except, desc) => {
81
+ if (from && typeof from === "object" || typeof from === "function") {
82
+ for (let key of __getOwnPropNames(from))
83
+ if (!__hasOwnProp.call(to, key) && key !== except)
84
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
85
+ }
86
+ return to;
87
+ };
88
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
89
+ // If the importer is in node compatibility mode or this is not an ESM
90
+ // file that has been converted to a CommonJS file using a Babel-
91
+ // compatible transform (i.e. "__esModule" has not been set), then set
92
+ // "default" to the CommonJS "module.exports" for node compatibility.
93
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
94
+ mod
95
+ ));
96
+
97
+ // ../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js
98
+ var require_classnames = __commonJS({
99
+ "../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js"(exports, module) {
100
+ (function() {
101
+ var hasOwn = {}.hasOwnProperty;
102
+ function classNames2() {
103
+ var classes = [];
104
+ for (var i = 0; i < arguments.length; i++) {
105
+ var arg = arguments[i];
106
+ if (!arg)
107
+ continue;
108
+ var argType = typeof arg;
109
+ if (argType === "string" || argType === "number") {
110
+ classes.push(arg);
111
+ } else if (Array.isArray(arg)) {
112
+ if (arg.length) {
113
+ var inner = classNames2.apply(null, arg);
114
+ if (inner) {
115
+ classes.push(inner);
116
+ }
117
+ }
118
+ } else if (argType === "object") {
119
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
120
+ classes.push(arg.toString());
121
+ continue;
122
+ }
123
+ for (var key in arg) {
124
+ if (hasOwn.call(arg, key) && arg[key]) {
125
+ classes.push(key);
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return classes.join(" ");
131
+ }
132
+ if (typeof module !== "undefined" && module.exports) {
133
+ classNames2.default = classNames2;
134
+ module.exports = classNames2;
135
+ } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
136
+ define("classnames", [], function() {
137
+ return classNames2;
138
+ });
139
+ } else {
140
+ window.classNames = classNames2;
141
+ }
142
+ })();
143
+ }
144
+ });
73
145
  exports.useDomain = (domain = "SHOPL") => {
74
146
  const [domainType, setDomainType] = React3.useState(void 0);
75
147
  React3.useEffect(() => {
@@ -1016,15 +1088,29 @@ exports.ChipToggle = ChipToggle;
1016
1088
  // src/utils/getNextColor.ts
1017
1089
  var getNextColor = (color, step = 1) => {
1018
1090
  const colorName = color.replace(/[0-9]|_/g, "");
1019
- const colorNumberString = color.replace(/[a-z]|_/g, "");
1020
- const decimalColorNumber = Number(colorNumberString) * 0.01;
1021
- const nextColorNumber = Math.floor(decimalColorNumber) + 100 * step;
1022
- const nextColorToken = `${colorName}${nextColorNumber}`;
1023
- const colorKeysOfColorName = Object.keys(exports.colorTokens).filter((colorToken) => colorToken.includes(colorName)).sort((a, b) => Number(a.replace(/[a-z]|_/g, "")) - Number(b.replace(/[a-z]|_/g, "")));
1024
1091
  const colorTokenKeys = Object.keys(exports.colorTokens);
1025
- const findColorToken = colorTokenKeys.find((colorToken) => colorToken === nextColorToken);
1026
- const lastColorToken = colorKeysOfColorName[colorKeysOfColorName.length - 1];
1027
- return findColorToken ? findColorToken : lastColorToken;
1092
+ const findColorToken = colorTokenKeys.filter((colorToken) => colorToken.includes(colorName));
1093
+ const extractNumbers = (str) => {
1094
+ const formattedStr = str.replace(/_/g, ".");
1095
+ const regex = /\d+(\.\d+)?/g;
1096
+ const match = formattedStr.match(regex);
1097
+ return match ? parseFloat(match[0]) : 0;
1098
+ };
1099
+ const sortColorToken = findColorToken.sort((a, b) => extractNumbers(a) - extractNumbers(b));
1100
+ const currentIndex = sortColorToken.indexOf(color);
1101
+ let newIndex = currentIndex + step;
1102
+ let potentialToken = sortColorToken[newIndex];
1103
+ while (potentialToken.endsWith("_5") || potentialToken.includes("50")) {
1104
+ newIndex += Math.sign(step);
1105
+ if (newIndex < 0) {
1106
+ potentialToken = sortColorToken[0];
1107
+ }
1108
+ if (newIndex >= sortColorToken.length) {
1109
+ potentialToken = sortColorToken[sortColorToken.length - 1];
1110
+ }
1111
+ potentialToken = sortColorToken[newIndex];
1112
+ }
1113
+ return potentialToken;
1028
1114
  };
1029
1115
 
1030
1116
  // src/components/Chips/ChipButton/ChipButton.styled.ts
@@ -1921,14 +2007,141 @@ var List = (_a) => {
1921
2007
  rightSource && rightSource
1922
2008
  ] }));
1923
2009
  };
1924
- var Text2Rows = ({ title, subTitle }) => {
2010
+ exports.Text2Rows = ({ title, subTitle }) => {
1925
2011
  return /* @__PURE__ */ jsxRuntime.jsxs(exports.StyledText2Rows, { children: [
1926
2012
  /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_500", color: "neutral700", children: title }),
1927
2013
  subTitle && /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body2_400", color: "neutral400", children: subTitle })
1928
2014
  ] });
1929
2015
  };
1930
- List.Text2Rows = Text2Rows;
2016
+ List.Text2Rows = exports.Text2Rows;
1931
2017
  exports.List = List;
2018
+ var getTypographyBySize = (size2) => {
2019
+ switch (size2) {
2020
+ case "XS":
2021
+ return "caption_400";
2022
+ case "S":
2023
+ return "caption_400";
2024
+ case "M":
2025
+ return "body2_400";
2026
+ default:
2027
+ return "body2_400";
2028
+ }
2029
+ };
2030
+ var getTagStyleBySize = (size2) => {
2031
+ switch (size2) {
2032
+ case "XS":
2033
+ return react$1.css`
2034
+ height: 20px;
2035
+ padding: 0 4px;
2036
+ border-radius: 4px;
2037
+ `;
2038
+ case "S":
2039
+ return react$1.css`
2040
+ height: 24px;
2041
+ padding: 0 8px;
2042
+ border-radius: 4px;
2043
+ `;
2044
+ case "M":
2045
+ return react$1.css`
2046
+ padding: 4px 8px;
2047
+ height: 32px;
2048
+ border-radius: 6px;
2049
+ `;
2050
+ default:
2051
+ return react$1.css`
2052
+ padding: 4px 8px;
2053
+ height: 32px;
2054
+ `;
2055
+ }
2056
+ };
2057
+ var getRadiusBySize = (size2) => {
2058
+ switch (size2) {
2059
+ case "XS":
2060
+ return react$1.css`
2061
+ border-radius: 12px;
2062
+ `;
2063
+ case "S":
2064
+ return react$1.css`
2065
+ border-radius: 16px;
2066
+ `;
2067
+ case "M":
2068
+ return react$1.css`
2069
+ border-radius: 16px;
2070
+ `;
2071
+ default:
2072
+ return react$1.css`
2073
+ border-radius: 16px;
2074
+ `;
2075
+ }
2076
+ };
2077
+ var getColorsByStyleVariant = (styleVariant, color = "neutral700") => {
2078
+ switch (styleVariant) {
2079
+ case "SOLID":
2080
+ return react$1.css`
2081
+ background: ${exports.colorTokens[color]};
2082
+ color: ${exports.colorTokens.neutral0};
2083
+ `;
2084
+ case "TINT":
2085
+ return react$1.css`
2086
+ background: ${exports.colorTokens[getNextColor(color, -2)]};
2087
+ color: ${exports.colorTokens[color]};
2088
+ `;
2089
+ case "LINE":
2090
+ return react$1.css`
2091
+ background: transparent;
2092
+ color: ${exports.colorTokens[color]};
2093
+ border: 1px solid ${exports.colorTokens[color]};
2094
+ `;
2095
+ default:
2096
+ return react$1.css`
2097
+ background: ${exports.colorTokens[color]};
2098
+ color: ${exports.colorTokens.neutral0};
2099
+ `;
2100
+ }
2101
+ };
2102
+ var StyledTag = styled5__default.default.div`
2103
+ display: flex;
2104
+ align-items: center;
2105
+ flex-direction: row;
2106
+ cursor: default;
2107
+ gap: 2px;
2108
+ ${({ sizeVar }) => getTagStyleBySize(sizeVar)};
2109
+ ${({ color, styleVar }) => getColorsByStyleVariant(styleVar, color)};
2110
+ ${({ radius, sizeVar }) => radius && getRadiusBySize(sizeVar)};
2111
+ `;
2112
+
2113
+ // src/components/Tag/Tag.tsx
2114
+ var import_classnames = __toESM(require_classnames(), 1);
2115
+ var Tag = (_a) => {
2116
+ var _b = _a, { sizeVar, children, rightSource, leftSource, className } = _b, rest = __objRest(_b, ["sizeVar", "children", "rightSource", "leftSource", "className"]);
2117
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2118
+ StyledTag,
2119
+ __spreadProps(__spreadValues({
2120
+ sizeVar,
2121
+ className: (0, import_classnames.default)(getTypographyBySize(sizeVar), className)
2122
+ }, rest), {
2123
+ "data-shoplflow": "Tag",
2124
+ children: [
2125
+ leftSource && leftSource,
2126
+ children,
2127
+ rightSource && rightSource
2128
+ ]
2129
+ })
2130
+ );
2131
+ };
2132
+ exports.Tag = Tag;
2133
+
2134
+ // src/components/Tag/Tag.types.ts
2135
+ exports.TagStyleVariants = {
2136
+ SOLID: "SOLID",
2137
+ TINT: "TINT",
2138
+ LINE: "LINE"
2139
+ };
2140
+ exports.TagSizeVariants = {
2141
+ XS: "XS",
2142
+ S: "S",
2143
+ M: "M"
2144
+ };
1932
2145
  var StyledInput = styled5__default.default.input`
1933
2146
  padding: 4px 0 4px 12px;
1934
2147
  background-color: transparent;
@@ -1938,6 +2151,17 @@ var StyledInput = styled5__default.default.input`
1938
2151
  &::placeholder {
1939
2152
  color: ${exports.colorTokens.neutral350};
1940
2153
  }
2154
+ &::-webkit-outer-spin-button,
2155
+ &::-webkit-inner-spin-button {
2156
+ -webkit-appearance: none;
2157
+ margin: 0;
2158
+ }
2159
+ /* Firefox */
2160
+ &[type='number'] {
2161
+ padding: 4px 8px;
2162
+ text-align: center;
2163
+ -moz-appearance: textfield;
2164
+ }
1941
2165
  `;
1942
2166
  var RightElementWrapper = styled5__default.default.div`
1943
2167
  display: flex;
@@ -1986,6 +2210,8 @@ var Input = React3.forwardRef(
1986
2210
  disabled,
1987
2211
  type: initialType,
1988
2212
  maxLength,
2213
+ min,
2214
+ max,
1989
2215
  className,
1990
2216
  width
1991
2217
  } = _b, rest = __objRest(_b, [
@@ -1999,6 +2225,8 @@ var Input = React3.forwardRef(
1999
2225
  "disabled",
2000
2226
  "type",
2001
2227
  "maxLength",
2228
+ "min",
2229
+ "max",
2002
2230
  "className",
2003
2231
  "width"
2004
2232
  ]);
@@ -2024,6 +2252,18 @@ var Input = React3.forwardRef(
2024
2252
  },
2025
2253
  [maxLength]
2026
2254
  );
2255
+ const limitRange = React3.useCallback(
2256
+ (value2) => {
2257
+ if (min && Number(value2) < min) {
2258
+ return String(min);
2259
+ }
2260
+ if (max && Number(value2) > max) {
2261
+ return String(max);
2262
+ }
2263
+ return value2;
2264
+ },
2265
+ [max, min]
2266
+ );
2027
2267
  const handleOnMouseEnter = () => {
2028
2268
  setIsHovered(true);
2029
2269
  };
@@ -2041,8 +2281,20 @@ var Input = React3.forwardRef(
2041
2281
  const handleOnChange = (event) => {
2042
2282
  onChange && onChange(event);
2043
2283
  const slicedText = sliceText(event.target.value);
2284
+ if (type === "number") {
2285
+ const limitedText = limitRange(slicedText);
2286
+ setText(limitedText);
2287
+ return;
2288
+ }
2044
2289
  setText(slicedText);
2045
2290
  };
2291
+ const getWidth = () => {
2292
+ if (type === "number") {
2293
+ return "64px";
2294
+ } else {
2295
+ return width;
2296
+ }
2297
+ };
2046
2298
  const handleOnClear = () => {
2047
2299
  onClear && onClear();
2048
2300
  if (inputRef.current) {
@@ -2058,16 +2310,18 @@ var Input = React3.forwardRef(
2058
2310
  }
2059
2311
  };
2060
2312
  React3.useEffect(() => {
2061
- if (defaultValue) {
2313
+ if (defaultValue !== void 0) {
2062
2314
  const convertString = convertToString(defaultValue);
2063
2315
  const slicedText = sliceText(convertString);
2064
2316
  setText(slicedText);
2065
2317
  }
2066
2318
  }, [convertToString, defaultValue, maxLength, sliceText]);
2067
2319
  React3.useEffect(() => {
2068
- if (value) {
2320
+ var _a2;
2321
+ if (value !== void 0) {
2069
2322
  const convertString = convertToString(value);
2070
2323
  const slicedText = sliceText(convertString);
2324
+ ((_a2 = inputRef.current) == null ? void 0 : _a2.value) && (inputRef.current.value = slicedText);
2071
2325
  setText(slicedText);
2072
2326
  }
2073
2327
  }, [convertToString, maxLength, sliceText, value]);
@@ -2084,7 +2338,7 @@ var Input = React3.forwardRef(
2084
2338
  isHovered,
2085
2339
  onMouseEnter: handleOnMouseEnter,
2086
2340
  onMouseLeave: handleOnMouseLeave,
2087
- width,
2341
+ width: getWidth(),
2088
2342
  "data-shoplflow": "input",
2089
2343
  children: [
2090
2344
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -2102,7 +2356,7 @@ var Input = React3.forwardRef(
2102
2356
  className: "body1_400" + (className ? ` ${className}` : "")
2103
2357
  }, rest)
2104
2358
  ),
2105
- /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2359
+ !(type === "number") && /* @__PURE__ */ jsxRuntime.jsxs(RightElementWrapper, { children: [
2106
2360
  maxLength && isFocused && /* @__PURE__ */ jsxRuntime.jsx(TextCounter_default, { currentLength: String(text).length, maxLength }),
2107
2361
  isFocused && Boolean(String(text).length > 0) && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleOnClear, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: assetFunction("DeleteIcon"), color: "neutral600" }) }),
2108
2362
  initialType === "password" && /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", onClick: handleTogglePasswordType, styleVar: "GHOST", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2403,6 +2657,7 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2403
2657
  fill: ${exports.colorTokens.neutral0};
2404
2658
  }
2405
2659
  ${isHovered && react$1.css`
2660
+ border: 1.5px solid ${exports.colorTokens.primary400};
2406
2661
  background: ${exports.colorTokens.primary400};
2407
2662
  `}
2408
2663
  `;
@@ -2412,6 +2667,7 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2412
2667
  border: 1.5px solid ${exports.colorTokens.neutral200};
2413
2668
  border-radius: 4px;
2414
2669
  ${isHovered && react$1.css`
2670
+ border: 1.5px solid ${exports.colorTokens.neutral300};
2415
2671
  background: ${exports.colorTokens.neutral300};
2416
2672
  `}
2417
2673
 
@@ -2578,6 +2834,7 @@ var Container4 = styled5__default.default.button`
2578
2834
  display: flex;
2579
2835
  align-items: center;
2580
2836
  justify-content: center;
2837
+ background: transparent;
2581
2838
  padding: 4px;
2582
2839
  width: fit-content;
2583
2840
  height: fit-content;
@@ -2614,6 +2871,15 @@ var Radio = (_a) => {
2614
2871
  );
2615
2872
  };
2616
2873
  exports.Radio = Radio;
2874
+ /*! Bundled license information:
2875
+
2876
+ classnames/index.js:
2877
+ (*!
2878
+ Copyright (c) 2018 Jed Watson.
2879
+ Licensed under the MIT License (MIT), see
2880
+ http://jedwatson.github.io/classnames
2881
+ *)
2882
+ */
2617
2883
 
2618
2884
  Object.defineProperty(exports, 'arrow', {
2619
2885
  enumerable: true,