@popsure/dirty-swan 0.27.23 → 0.27.25
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/Readme.md +2 -0
- package/dist/index.js +79 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/components/autocompleteAddress/index.test.d.ts +1 -0
- package/dist/lib/components/input/index.d.ts +7 -1
- package/package.json +4 -2
- package/src/lib/components/autocompleteAddress/index.test.tsx +94 -0
- package/src/lib/components/autocompleteAddress/index.tsx +6 -0
- package/src/lib/components/input/currency/index.stories.mdx +6 -0
- package/src/lib/components/input/index.stories.mdx +42 -0
- package/src/lib/components/input/index.tsx +76 -40
- package/src/lib/components/input/style.module.scss +16 -0
- package/src/setupTests.js +48 -2
package/Readme.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var require$$0 = require('react');
|
|
7
|
+
var crypto = require('crypto');
|
|
7
8
|
var require$$1 = require('react-dom');
|
|
8
9
|
var path = require('path');
|
|
9
10
|
var require$$2 = require('querystring');
|
|
@@ -11,6 +12,7 @@ var require$$2 = require('querystring');
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
13
14
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
15
|
+
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
14
16
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
15
17
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
16
18
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
@@ -5151,18 +5153,80 @@ module.exports = isEqual;
|
|
|
5151
5153
|
|
|
5152
5154
|
var isEqual = lodash_isequal.exports;
|
|
5153
5155
|
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
+
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
|
5157
|
+
|
|
5158
|
+
let poolPtr = rnds8Pool.length;
|
|
5159
|
+
function rng() {
|
|
5160
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
|
5161
|
+
crypto__default['default'].randomFillSync(rnds8Pool);
|
|
5162
|
+
poolPtr = 0;
|
|
5163
|
+
}
|
|
5164
|
+
|
|
5165
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5168
|
+
/**
|
|
5169
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
5170
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
5171
|
+
*/
|
|
5172
|
+
|
|
5173
|
+
const byteToHex = [];
|
|
5174
|
+
|
|
5175
|
+
for (let i = 0; i < 256; ++i) {
|
|
5176
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
function unsafeStringify(arr, offset = 0) {
|
|
5180
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
5181
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
5182
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
5183
|
+
}
|
|
5184
|
+
|
|
5185
|
+
var native = {
|
|
5186
|
+
randomUUID: crypto__default['default'].randomUUID
|
|
5187
|
+
};
|
|
5188
|
+
|
|
5189
|
+
function v4(options, buf, offset) {
|
|
5190
|
+
if (native.randomUUID && !buf && !options) {
|
|
5191
|
+
return native.randomUUID();
|
|
5192
|
+
}
|
|
5193
|
+
|
|
5194
|
+
options = options || {};
|
|
5195
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
5196
|
+
|
|
5197
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
5198
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
5199
|
+
|
|
5200
|
+
if (buf) {
|
|
5201
|
+
offset = offset || 0;
|
|
5202
|
+
|
|
5203
|
+
for (let i = 0; i < 16; ++i) {
|
|
5204
|
+
buf[offset + i] = rnds[i];
|
|
5205
|
+
}
|
|
5206
|
+
|
|
5207
|
+
return buf;
|
|
5208
|
+
}
|
|
5209
|
+
|
|
5210
|
+
return unsafeStringify(rnds);
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
var css_248z$p = ".style-module_container__2L4SP {\n position: relative;\n}\n\n.style-module_prefix__3jAFZ {\n position: absolute;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--ds-grey-500);\n transition: 0.3s top;\n}\n.style-module_prefix--with-error__1yTTM {\n color: var(--ds-red-500);\n}\n.style-module_prefix--disabled__2-gcw {\n color: var(--ds-grey-600);\n}\n\n.style-module_input__1eJO5:not(:placeholder-shown) ~ .style-module_placeholder__1U2z0,\n.style-module_input__1eJO5:focus ~ .style-module_placeholder__1U2z0 {\n top: 7px;\n left: 16px;\n transform: translateY(0);\n font-size: 10px;\n line-height: 12px;\n opacity: 1;\n}\n\n.style-module_input__1eJO5:focus ~ .style-module_placeholder__1U2z0 {\n color: var(--ds-primary-500);\n}\n.style-module_input__1eJO5:focus ~ .style-module_placeholder--with-error__2ieRU {\n color: var(--ds-red-500);\n}\n\n.style-module_input__1eJO5:focus ~ .style-module_prefix__3jAFZ {\n color: var(--ds-primary-500);\n}\n.style-module_input__1eJO5:focus ~ .style-module_prefix--with-error__1yTTM {\n color: var(--ds-red-500);\n}\n\n.style-module_input__1eJO5:not(:placeholder-shown) ~ .style-module_prefix__3jAFZ,\n.style-module_input__1eJO5:focus ~ .style-module_prefix__3jAFZ {\n top: 28px;\n}\n\n.style-module_input__1eJO5 {\n box-sizing: border-box;\n padding-top: 9px;\n font-family: inherit;\n}\n.style-module_input--no-placeholder__3EGwh {\n padding-top: 0px;\n}\n.style-module_input--with-prefix__38e0j {\n padding-left: 32px !important;\n}\n\n.style-module_placeholder__1U2z0 {\n position: absolute;\n pointer-events: none;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n transition: 0.3s ease all;\n color: var(--ds-grey-500);\n}\n.style-module_placeholder--with-prefix__2PquQ {\n left: 32px;\n}\n.style-module_placeholder--with-error__2ieRU {\n color: var(--ds-red-500);\n}\n\n.style-module_label__3FEZ1 {\n display: inline-block;\n margin-top: 8px;\n margin-bottom: 8px;\n color: var(--ds-grey-600);\n}\n.style-module_label--with-error__166bP {\n color: var(--ds-red-500);\n}\n.style-module_label--hidden__1e9iX {\n visibility: hidden;\n height: 0;\n}\n\n.style-module_error__167Zc {\n margin-top: 4px;\n}";
|
|
5214
|
+
var styles$o = {"container":"style-module_container__2L4SP","prefix":"style-module_prefix__3jAFZ","prefix--with-error":"style-module_prefix--with-error__1yTTM","prefix--disabled":"style-module_prefix--disabled__2-gcw","input":"style-module_input__1eJO5","placeholder":"style-module_placeholder__1U2z0","placeholder--with-error":"style-module_placeholder--with-error__2ieRU","input--no-placeholder":"style-module_input--no-placeholder__3EGwh","input--with-prefix":"style-module_input--with-prefix__38e0j","placeholder--with-prefix":"style-module_placeholder--with-prefix__2PquQ","label":"style-module_label__3FEZ1","label--with-error":"style-module_label--with-error__166bP","label--hidden":"style-module_label--hidden__1e9iX","error":"style-module_error__167Zc"};
|
|
5156
5215
|
styleInject(css_248z$p);
|
|
5157
5216
|
|
|
5158
5217
|
var Input = require$$0__default['default'].forwardRef(function (_a, ref) {
|
|
5159
|
-
var _b, _c, _d, _e, _f;
|
|
5160
|
-
var className = _a.className, placeholder = _a.placeholder, prefix = _a.prefix, error = _a.error, disabled = _a.disabled, props = __rest$1(_a, ["className", "placeholder", "prefix", "error", "disabled"]);
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5218
|
+
var _b, _c, _d, _e, _f, _g;
|
|
5219
|
+
var className = _a.className, placeholder = _a.placeholder, label = _a.label, id = _a.id, prefix = _a.prefix, error = _a.error, disabled = _a.disabled, _h = _a.hideLabel, hideLabel = _h === void 0 ? false : _h, props = __rest$1(_a, ["className", "placeholder", "label", "id", "prefix", "error", "disabled", "hideLabel"]);
|
|
5220
|
+
var uniqueId = id !== null && id !== void 0 ? id : v4();
|
|
5221
|
+
return (jsxRuntime.jsxs("div", __assign({ className: styles$o.container + " " + (className !== null && className !== void 0 ? className : '') }, { children: [label && (jsxRuntime.jsx("label", __assign({ htmlFor: uniqueId, className: classNames('p-p', styles$o.label, (_b = {},
|
|
5222
|
+
_b[styles$o['label--with-error']] = error,
|
|
5223
|
+
_b[styles$o['label--hidden']] = hideLabel,
|
|
5224
|
+
_b)) }, { children: label }), void 0)),
|
|
5225
|
+
jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx("input", __assign({ id: uniqueId, "data-testid": "ds-input-input", type: "text", ref: ref, className: classNames(error ? 'p-input--error' : 'p-input', !label && placeholder && placeholder.length > 0
|
|
5226
|
+
? styles$o.input
|
|
5227
|
+
: styles$o['input--no-placeholder'], (_c = {}, _c[styles$o['input--with-prefix']] = prefix, _c)), placeholder: label ? placeholder : ' ', disabled: disabled }, props), void 0),
|
|
5228
|
+
prefix && (jsxRuntime.jsx("span", __assign({ className: classNames(styles$o.prefix, (_d = {}, _d[styles$o['prefix--with-error']] = error, _d), (_e = {}, _e[styles$o['prefix--disabled']] = disabled, _e)) }, { children: prefix }), void 0)),
|
|
5229
|
+
!label && (jsxRuntime.jsx("label", __assign({ htmlFor: uniqueId, className: classNames(styles$o.placeholder, (_f = {}, _f[styles$o['placeholder--with-prefix']] = prefix, _f), (_g = {}, _g[styles$o['placeholder--with-error']] = error, _g)) }, { children: placeholder }), void 0))] }), void 0),
|
|
5166
5230
|
error && (jsxRuntime.jsx("p", __assign({ className: "p-p--small tc-red-500 w100 " + styles$o.error }, { children: error }), void 0))] }), void 0));
|
|
5167
5231
|
});
|
|
5168
5232
|
|
|
@@ -5331,32 +5395,32 @@ var AutoCompleteAddress = function (_a) {
|
|
|
5331
5395
|
_b[styles$n['map-container--hidden']] = place === null,
|
|
5332
5396
|
_b)) }, { children: [jsxRuntime.jsx("div", { className: styles$n.map, id: "map" }, void 0),
|
|
5333
5397
|
isLoading && (jsxRuntime.jsx("div", __assign({ className: styles$n['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0),
|
|
5334
|
-
jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry === false ? (jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry) || 'Search for address', ref: autocompleteElement },
|
|
5398
|
+
jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry === false ? (jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry) || 'Search for address', ref: autocompleteElement }, "autocomplete-search"),
|
|
5335
5399
|
hasLoadedGoogleAPI === false && (jsxRuntime.jsx("div", __assign({ className: styles$n['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.street) || 'Street', value: (address === null || address === void 0 ? void 0 : address.street) || '', onChange: function (e) {
|
|
5336
5400
|
var newAddress = __assign(__assign({}, address), { street: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
5337
5401
|
setAddress(newAddress);
|
|
5338
5402
|
debouncedSetPlace(newAddress);
|
|
5339
|
-
} },
|
|
5403
|
+
} }, "autocomplete-street"),
|
|
5340
5404
|
jsxRuntime.jsx(Input, { className: "wmx2 " + styles$n['house-number-input'], "data-cy": "autocomplete-house-number", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber) || 'House Number', value: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', onChange: function (e) {
|
|
5341
5405
|
var newAddress = __assign(__assign({}, address), { houseNumber: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
5342
5406
|
setAddress(newAddress);
|
|
5343
5407
|
debouncedSetPlace(newAddress);
|
|
5344
|
-
} },
|
|
5408
|
+
} }, "autocomplete-house-number")] }), void 0),
|
|
5345
5409
|
jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation) ||
|
|
5346
5410
|
'Additional information (C/O, apartment, …)', value: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', onChange: function (e) {
|
|
5347
5411
|
var newAddress = __assign(__assign({}, address), { additionalInformation: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
5348
5412
|
setAddress(newAddress);
|
|
5349
|
-
} },
|
|
5413
|
+
} }, "autocomplete-additional-info"),
|
|
5350
5414
|
jsxRuntime.jsxs("div", __assign({ className: "d-flex mt16 c-gap16 " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-postcode", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode) || 'Postcode', value: (address === null || address === void 0 ? void 0 : address.postcode) || '', onChange: function (e) {
|
|
5351
5415
|
var newAddress = __assign(__assign({}, address), { postcode: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
5352
5416
|
setAddress(newAddress);
|
|
5353
5417
|
debouncedSetPlace(newAddress);
|
|
5354
|
-
} },
|
|
5418
|
+
} }, "autocomplete-postcode"),
|
|
5355
5419
|
jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.city) || 'City', value: (address === null || address === void 0 ? void 0 : address.city) || '', onChange: function (e) {
|
|
5356
5420
|
var newAddress = __assign(__assign({}, address), { city: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
5357
5421
|
setAddress(newAddress);
|
|
5358
5422
|
debouncedSetPlace(newAddress);
|
|
5359
|
-
} },
|
|
5423
|
+
} }, "autocomplete-city")] }), void 0)] }, void 0)) }), void 0),
|
|
5360
5424
|
manualAddressEntry === false && (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ',
|
|
5361
5425
|
jsxRuntime.jsx("span", __assign({ className: "p-a fw-bold c-pointer", onClick: handleEnterAddressManually }, { children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'Enter address manually' }), void 0)] }), void 0))] }, void 0));
|
|
5362
5426
|
};
|