ecomlab-components-next 0.1.83 → 0.1.84
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/components/ArticleElements/ShortTileArticleBox/ShortTileArticleBox.stories.js +1 -1
- package/dist/components/Inputs/InputDinamycPlaceholder/InputDinamycPlaceholder.js +85 -32
- package/dist/components/Inputs/InputDinamycPlaceholder/InputDinamycPlaceholder.stories.js +3 -7
- package/package.json +7 -5
|
@@ -18,7 +18,7 @@ var _default = exports["default"] = {
|
|
|
18
18
|
annotation: 'Когда селлер, торгующий на маркетплейсе, становится популярнее, ему приходится ежедневно обрабатывать… Когда селлер, торгующий на маркетплейсе, становится популярнее, ему приходится ежедневно обрабатывать…',
|
|
19
19
|
photoPreview: ['https://assets.cdn.personio.de/career-site/header/43501/28ed0d8a9de664d5fdcd5314facf8b51png', 'https://www.rollingstone.com/wp-content/uploads/2018/06/rs-186804-peripheryjeremysaffer.jpg'],
|
|
20
20
|
tags: ['какой-то тэг', 'какой-то тэг'],
|
|
21
|
-
date:
|
|
21
|
+
date: "14 апреля 2025",
|
|
22
22
|
timeToRead: 100500,
|
|
23
23
|
views: 15,
|
|
24
24
|
statusArray: ["https://dl.ecomru.ru/svg-storage/icon-waiting.svg", "Update"],
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
8
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
9
8
|
var _imask = _interopRequireDefault(require("imask"));
|
|
9
|
+
var _libphonenumberJs = require("libphonenumber-js");
|
|
10
10
|
require("./InputDinamycPlaceholder.scss");
|
|
11
|
-
var _excluded = ["tooltip", "tooltipStatic", "rows", "changeValue", "setChangeValue", "classname", "placeholder", "type", "onChange", "passwordTooltip", "err", "textErr", "infoHeader", "info", "autoComplete", "disabled", "showClearIndicator", "multiline", "maxLength", "autoFocus", "variant", "size", "maxlength", "required", "onBlur", "mask", "readOnly"];
|
|
11
|
+
var _excluded = ["tooltip", "tooltipStatic", "rows", "changeValue", "setChangeValue", "classname", "placeholder", "type", "onChange", "passwordTooltip", "err", "textErr", "infoHeader", "info", "autoComplete", "disabled", "showClearIndicator", "multiline", "maxLength", "autoFocus", "variant", "size", "maxlength", "required", "onBlur", "mask", "readOnly", "countrySelect"];
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
15
13
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
16
14
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
15
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -62,6 +60,8 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
62
60
|
mask = _ref$mask === void 0 ? null : _ref$mask,
|
|
63
61
|
_ref$readOnly = _ref.readOnly,
|
|
64
62
|
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
63
|
+
_ref$countrySelect = _ref.countrySelect,
|
|
64
|
+
countrySelect = _ref$countrySelect === void 0 ? false : _ref$countrySelect,
|
|
65
65
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
66
66
|
var _useState = (0, _react.useState)(false),
|
|
67
67
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -79,8 +79,45 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
79
79
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
80
80
|
isFocus = _useState8[0],
|
|
81
81
|
setIsFocus = _useState8[1];
|
|
82
|
+
var _useState9 = (0, _react.useState)('RU'),
|
|
83
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
84
|
+
country = _useState10[0],
|
|
85
|
+
setCountry = _useState10[1]; // По умолчанию Россия
|
|
82
86
|
var inputRef = (0, _react.useRef)(null);
|
|
83
87
|
var maskRef = (0, _react.useRef)(null);
|
|
88
|
+
|
|
89
|
+
// Список всех стран
|
|
90
|
+
var countries = (0, _libphonenumberJs.getCountries)();
|
|
91
|
+
|
|
92
|
+
// Обработчик изменения страны
|
|
93
|
+
var handleCountryChange = function handleCountryChange(e) {
|
|
94
|
+
var newCountry = e.target.value;
|
|
95
|
+
setCountry(newCountry);
|
|
96
|
+
|
|
97
|
+
// Обновляем маску для IMask
|
|
98
|
+
if (type === 'tel' && inputRef.current) {
|
|
99
|
+
var code = (0, _libphonenumberJs.getCountryCallingCode)(newCountry);
|
|
100
|
+
var newMask = {
|
|
101
|
+
mask: "+".concat(code, " (000) 000-00-00")
|
|
102
|
+
}; // Пример маски для России
|
|
103
|
+
|
|
104
|
+
if (maskRef.current) {
|
|
105
|
+
maskRef.current.destroy();
|
|
106
|
+
}
|
|
107
|
+
maskRef.current = (0, _imask["default"])(inputRef.current, newMask);
|
|
108
|
+
maskRef.current.on('accept', function () {
|
|
109
|
+
setValueInside(maskRef.current.value);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Получаем полное название страны по коду
|
|
115
|
+
var getCountryName = function getCountryName(code) {
|
|
116
|
+
var country = countries[code];
|
|
117
|
+
return country ? country.name : code; // Если страны нет в списке, вернём код
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Обработчик размытия поля
|
|
84
121
|
var handleBlur = function handleBlur() {
|
|
85
122
|
if (onBlur) onBlur(valueInside);
|
|
86
123
|
};
|
|
@@ -94,33 +131,49 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
94
131
|
}, [changeValue]);
|
|
95
132
|
(0, _react.useEffect)(function () {
|
|
96
133
|
if (type === 'tel' && inputRef.current) {
|
|
134
|
+
var code = (0, _libphonenumberJs.getCountryCallingCode)(country);
|
|
97
135
|
var maskOptions = {
|
|
98
|
-
mask:
|
|
136
|
+
mask: "+".concat(code, " (000) 000-00-00")
|
|
99
137
|
};
|
|
100
138
|
maskRef.current = (0, _imask["default"])(inputRef.current, maskOptions);
|
|
101
139
|
maskRef.current.on('accept', function () {
|
|
102
140
|
setValueInside(maskRef.current.value);
|
|
103
141
|
});
|
|
104
142
|
return function () {
|
|
105
|
-
|
|
143
|
+
var _maskRef$current;
|
|
144
|
+
return (_maskRef$current = maskRef.current) === null || _maskRef$current === void 0 ? void 0 : _maskRef$current.destroy();
|
|
106
145
|
};
|
|
107
146
|
}
|
|
108
|
-
}, [type]);
|
|
147
|
+
}, [type, country]);
|
|
148
|
+
|
|
149
|
+
// Обновление значения из props
|
|
109
150
|
(0, _react.useEffect)(function () {
|
|
110
|
-
|
|
111
|
-
maskRef.current.value = changeValue || '';
|
|
112
|
-
maskRef.current.updateValue();
|
|
113
|
-
}
|
|
151
|
+
setValueInside(changeValue || '');
|
|
114
152
|
}, [changeValue]);
|
|
115
|
-
return /*#__PURE__*/
|
|
153
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
116
154
|
className: "input-dinamyc-placeholder",
|
|
117
155
|
style: {
|
|
118
156
|
width: '100%',
|
|
119
157
|
marginBottom: tooltip ? '24px' : ''
|
|
120
158
|
}
|
|
121
|
-
}, /*#__PURE__*/
|
|
122
|
-
|
|
123
|
-
|
|
159
|
+
}, countrySelect && /*#__PURE__*/React.createElement("select", {
|
|
160
|
+
value: country,
|
|
161
|
+
onChange: handleCountryChange,
|
|
162
|
+
style: {
|
|
163
|
+
marginRight: '10px',
|
|
164
|
+
padding: '8px',
|
|
165
|
+
borderRadius: '4px',
|
|
166
|
+
border: '1px solid #ccc',
|
|
167
|
+
marginBottom: '12px'
|
|
168
|
+
}
|
|
169
|
+
}, countries.map(function (countryCode) {
|
|
170
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
171
|
+
key: countryCode,
|
|
172
|
+
value: countryCode
|
|
173
|
+
}, getCountryName(countryCode), " (+", (0, _libphonenumberJs.getCountryCallingCode)(countryCode), ")");
|
|
174
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
className: "".concat(err ? 'input-box__err' : 'input-box', " ").concat(size === 's' ? 'size-s' : 'size-l', " ").concat(disabled ? 'input-box_disabled' : '')
|
|
176
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
124
177
|
ref: inputRef,
|
|
125
178
|
className: "input-dynamic",
|
|
126
179
|
maxLength: maxlength,
|
|
@@ -148,46 +201,46 @@ var InputDinamycPlaceholder = function InputDinamycPlaceholder(_ref) {
|
|
|
148
201
|
disabled: disabled,
|
|
149
202
|
required: required,
|
|
150
203
|
size: size
|
|
151
|
-
}), placeholder && /*#__PURE__*/
|
|
204
|
+
}), placeholder && /*#__PURE__*/React.createElement("div", {
|
|
152
205
|
className: valueInside.length > 0 || isFocus ? 'placeholder-dinamyc_min-blue' : 'placeholder-dinamyc'
|
|
153
|
-
}, /*#__PURE__*/
|
|
206
|
+
}, /*#__PURE__*/React.createElement("label", null, placeholder, required && /*#__PURE__*/React.createElement("span", {
|
|
154
207
|
style: {
|
|
155
208
|
color: 'red'
|
|
156
209
|
}
|
|
157
|
-
}, " *"))), /*#__PURE__*/
|
|
210
|
+
}, " *"))), /*#__PURE__*/React.createElement("div", {
|
|
158
211
|
className: "input-box__clean-value"
|
|
159
|
-
}, showClearIndicator && (valueInside === null || valueInside === void 0 ? void 0 : valueInside.length) > 0 && /*#__PURE__*/
|
|
212
|
+
}, showClearIndicator && (valueInside === null || valueInside === void 0 ? void 0 : valueInside.length) > 0 && /*#__PURE__*/React.createElement("button", {
|
|
160
213
|
className: "btn__clean",
|
|
161
214
|
onClick: function onClick() {
|
|
162
215
|
return setValueInside('');
|
|
163
216
|
}
|
|
164
|
-
}), type === 'password' && /*#__PURE__*/
|
|
217
|
+
}), type === 'password' && /*#__PURE__*/React.createElement("button", {
|
|
165
218
|
className: "btn__".concat(hidePassword ? 'show' : 'hide'),
|
|
166
219
|
onClick: function onClick() {
|
|
167
220
|
return setHidePassword(!hidePassword);
|
|
168
221
|
}
|
|
169
|
-
}), info && !err && showInfo && /*#__PURE__*/
|
|
222
|
+
}), info && !err && showInfo && /*#__PURE__*/React.createElement("div", {
|
|
170
223
|
className: "input-box__info"
|
|
171
|
-
}, /*#__PURE__*/
|
|
224
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
172
225
|
className: "tooltip-box"
|
|
173
|
-
}, /*#__PURE__*/
|
|
226
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
174
227
|
className: "btn__info",
|
|
175
228
|
disabled: true
|
|
176
|
-
}), /*#__PURE__*/
|
|
229
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
177
230
|
className: "tooltip"
|
|
178
|
-
}, /*#__PURE__*/
|
|
231
|
+
}, /*#__PURE__*/React.createElement("h6", {
|
|
179
232
|
className: "title"
|
|
180
|
-
}, infoHeader), /*#__PURE__*/
|
|
233
|
+
}, infoHeader), /*#__PURE__*/React.createElement("p", {
|
|
181
234
|
className: "text"
|
|
182
|
-
}, info))))), err ? /*#__PURE__*/
|
|
235
|
+
}, info))))), err ? /*#__PURE__*/React.createElement("div", {
|
|
183
236
|
className: "err"
|
|
184
|
-
}, /*#__PURE__*/
|
|
237
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
185
238
|
className: "text_red"
|
|
186
|
-
}, textErr)) : /*#__PURE__*/
|
|
239
|
+
}, textErr)) : /*#__PURE__*/React.createElement("div", {
|
|
187
240
|
className: "err"
|
|
188
|
-
}, /*#__PURE__*/
|
|
241
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
189
242
|
className: "text_tooltip"
|
|
190
|
-
}, tooltip))), tooltipStatic && /*#__PURE__*/
|
|
243
|
+
}, tooltip))), tooltipStatic && /*#__PURE__*/React.createElement("p", {
|
|
191
244
|
className: "text_tooltip-mui"
|
|
192
245
|
}, tooltipStatic));
|
|
193
246
|
};
|
|
@@ -7,10 +7,6 @@ exports["default"] = exports.Default = void 0;
|
|
|
7
7
|
var _InputDinamycPlaceholder = _interopRequireDefault(require("./InputDinamycPlaceholder.js"));
|
|
8
8
|
var _addonActions = require("@storybook/addon-actions");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
10
|
var _default = exports["default"] = {
|
|
15
11
|
title: 'Input dinamyc placeholder',
|
|
16
12
|
component: _InputDinamycPlaceholder["default"],
|
|
@@ -19,7 +15,7 @@ var _default = exports["default"] = {
|
|
|
19
15
|
control: 'date'
|
|
20
16
|
}
|
|
21
17
|
},
|
|
22
|
-
args:
|
|
18
|
+
args: {
|
|
23
19
|
tooltip: 'Подсказка',
|
|
24
20
|
tooltipStatic: false,
|
|
25
21
|
rows: false,
|
|
@@ -29,7 +25,7 @@ var _default = exports["default"] = {
|
|
|
29
25
|
setValue: _addonActions.action,
|
|
30
26
|
classname: false,
|
|
31
27
|
placeholder: 'Value',
|
|
32
|
-
type: '
|
|
28
|
+
type: 'tel',
|
|
33
29
|
onChange: _addonActions.action,
|
|
34
30
|
passwordTooltip: true,
|
|
35
31
|
err: false,
|
|
@@ -45,6 +41,6 @@ var _default = exports["default"] = {
|
|
|
45
41
|
variant: 'filled',
|
|
46
42
|
size: 'l',
|
|
47
43
|
required: true
|
|
48
|
-
}
|
|
44
|
+
}
|
|
49
45
|
};
|
|
50
46
|
var Default = exports.Default = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecomlab-components-next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.84",
|
|
4
4
|
"description": "A set of common and reusable React components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
"@monaco-editor/react": "^4.7.0",
|
|
23
23
|
"@types/styled-components": "^5.1.34",
|
|
24
24
|
"chart.js": "^4.4.7",
|
|
25
|
+
"country-data": "^0.0.31",
|
|
25
26
|
"deep-equal": "^2.2.3",
|
|
27
|
+
"libphonenumber-js": "^1.12.7",
|
|
28
|
+
"monaco-editor": "^0.52.2",
|
|
29
|
+
"monaco-jsx-highlighter": "^2.77.77",
|
|
26
30
|
"next": "15.1.5",
|
|
27
31
|
"react": "^19.0.0",
|
|
28
32
|
"react-chartjs-2": "^5.3.0",
|
|
@@ -31,9 +35,7 @@
|
|
|
31
35
|
"react-spinners": "^0.15.0",
|
|
32
36
|
"sass": "^1.55.0",
|
|
33
37
|
"styled-components": "^6.1.14",
|
|
34
|
-
"universal-cookie": "^7.2.2"
|
|
35
|
-
"monaco-editor": "^0.52.2",
|
|
36
|
-
"monaco-jsx-highlighter": "^2.77.77"
|
|
38
|
+
"universal-cookie": "^7.2.2"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@babel/cli": "^7.26.4",
|
|
@@ -67,4 +69,4 @@
|
|
|
67
69
|
"plugin:storybook/recommended"
|
|
68
70
|
]
|
|
69
71
|
}
|
|
70
|
-
}
|
|
72
|
+
}
|