@uncinc/uncinc-react-kitchen-sink 2.8.22 → 2.8.24
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.
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
var _excluded = ["fieldName", "id", "validation", "defaultValue", "onChange", "options", "placeholder", "disabled", "className", "wrapperClassName", "isClearable", "isSearchable", "multiple", "size", "required"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1
5
|
import React from 'react';
|
|
2
6
|
import SelectStyled from 'react-select';
|
|
3
7
|
import c from 'classnames';
|
|
@@ -34,7 +38,8 @@ var SelectInput = function SelectInput(props) {
|
|
|
34
38
|
_props$multiple = props.multiple,
|
|
35
39
|
multiple = _props$multiple === void 0 ? false : _props$multiple,
|
|
36
40
|
size = props.size,
|
|
37
|
-
required = props.required
|
|
41
|
+
required = props.required,
|
|
42
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
38
43
|
var selectedOption = props.selectedOption;
|
|
39
44
|
var _useExtendedFormikCon = useExtendedFormikContext(),
|
|
40
45
|
values = _useExtendedFormikCon.values,
|
|
@@ -83,7 +88,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
83
88
|
value: value,
|
|
84
89
|
validate: handleValidation
|
|
85
90
|
}, function () {
|
|
86
|
-
return /*#__PURE__*/React.createElement(SelectStyled, {
|
|
91
|
+
return /*#__PURE__*/React.createElement(SelectStyled, _extends({}, restProps, {
|
|
87
92
|
id: id,
|
|
88
93
|
inputId: fieldName,
|
|
89
94
|
className: c('Select__select', className),
|
|
@@ -146,7 +151,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
146
151
|
primary75: 'hsla(0,0%,0%, 0)'
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
|
-
});
|
|
154
|
+
}));
|
|
150
155
|
});
|
|
151
156
|
};
|
|
152
157
|
export default SelectInput;
|
|
@@ -80,7 +80,13 @@ var AdaptivePicture = function AdaptivePicture(_ref) {
|
|
|
80
80
|
}, [fallbackImage, status, targetSrc, validatedSources]);
|
|
81
81
|
var loadedUrl = useImageLoader(fallbackImage, targetSrc, imageRef);
|
|
82
82
|
function onErrorFallback(e) {
|
|
83
|
-
|
|
83
|
+
// Make sure that both URLs are absolute URLs, so we can compare them.
|
|
84
|
+
// Otherwise this error callback will constantly be thrown.
|
|
85
|
+
var link = document.createElement('a');
|
|
86
|
+
link.href = e.target.src;
|
|
87
|
+
var link2 = document.createElement('a');
|
|
88
|
+
link2.href = fallbackImage;
|
|
89
|
+
if (link.href !== link2.href) {
|
|
84
90
|
e.target.src = fallbackImage;
|
|
85
91
|
}
|
|
86
92
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add UTM parameters to cookie with 15 minutes expire
|
|
3
|
+
* @returns {void}
|
|
4
|
+
*/
|
|
5
|
+
export function setUtmCookies(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Get the cookies that start with utm_ from the document
|
|
8
|
+
* @returns {Array} An array of utm cookies
|
|
9
|
+
*/
|
|
10
|
+
export function getUtmCookies(): any[];
|
|
11
|
+
/**
|
|
12
|
+
* Add the cookies from the document a url
|
|
13
|
+
* @param {string} href - The URL we would like to add utm cookies to
|
|
14
|
+
* @returns {string | null} the mutated URL or nothing
|
|
15
|
+
*/
|
|
16
|
+
export function addUtmQueryString(href: string): string | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import qs from 'query-string';
|
|
2
|
+
import Cookies from 'js-cookie';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add UTM parameters to cookie with 15 minutes expire
|
|
6
|
+
* @returns {void}
|
|
7
|
+
*/
|
|
8
|
+
export function setUtmCookies() {
|
|
9
|
+
var inFifteenMinutes = new Date(new Date().getTime() + 15 * 60 * 1000);
|
|
10
|
+
var params = qs.parse(window.location.search);
|
|
11
|
+
var utmKeys = Object.keys(params).filter(function (value) {
|
|
12
|
+
return value.startsWith('utm_');
|
|
13
|
+
});
|
|
14
|
+
utmKeys.forEach(function (key) {
|
|
15
|
+
Cookies.set(key, params[key], {
|
|
16
|
+
expires: inFifteenMinutes
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the cookies that start with utm_ from the document
|
|
23
|
+
* @returns {Array} An array of utm cookies
|
|
24
|
+
*/
|
|
25
|
+
export function getUtmCookies() {
|
|
26
|
+
return document.cookie.split(';').map(function (cookie) {
|
|
27
|
+
return cookie.trim();
|
|
28
|
+
}).filter(function (value) {
|
|
29
|
+
return value.startsWith('utm_');
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Add the cookies from the document a url
|
|
35
|
+
* @param {string} href - The URL we would like to add utm cookies to
|
|
36
|
+
* @returns {string | null} the mutated URL or nothing
|
|
37
|
+
*/
|
|
38
|
+
export function addUtmQueryString(href) {
|
|
39
|
+
if (!href) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
var utmQueryString = getUtmCookies().join('&');
|
|
43
|
+
if (utmQueryString) {
|
|
44
|
+
href += (href.split('?')[1] ? '&' : '?') + utmQueryString;
|
|
45
|
+
}
|
|
46
|
+
return href;
|
|
47
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -80,4 +80,5 @@ export { default as useValueForCurrentViewPort } from "./helpers/useValueForCurr
|
|
|
80
80
|
export { getApiAutoCompleteSuggestions } from "./helpers/apiAutoComplete";
|
|
81
81
|
export { default as FormikWrapper, FormikExtendedContextProvider } from "./components/Form/FormikWrapper";
|
|
82
82
|
export { parseDateWithTimezoneOffset, isValidDate, doubleDigits } from "./helpers/date";
|
|
83
|
+
export { setUtmCookies, getUtmCookies, addUtmQueryString } from "./helpers/utm";
|
|
83
84
|
export { isExternalLink, normalizeLink } from "./helpers/link";
|
package/dist/index.js
CHANGED
|
@@ -93,5 +93,6 @@ export { default as useWindowDimensions } from './hooks/useWindowDimensions';
|
|
|
93
93
|
export { default as gtm } from './helpers/gtm';
|
|
94
94
|
export { default as useValueForCurrentViewPort } from './helpers/useValueForCurrentViewPort';
|
|
95
95
|
export { parseDateWithTimezoneOffset, isValidDate, doubleDigits } from './helpers/date';
|
|
96
|
+
export { setUtmCookies, getUtmCookies, addUtmQueryString } from './helpers/utm';
|
|
96
97
|
export { isExternalLink, normalizeLink } from './helpers/link';
|
|
97
98
|
export { getApiAutoCompleteSuggestions } from './helpers/apiAutoComplete';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uncinc/uncinc-react-kitchen-sink",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.24",
|
|
4
4
|
"description": "Default React components that are easily extended.",
|
|
5
5
|
"author": "uncinc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -148,6 +148,7 @@
|
|
|
148
148
|
"jest-junit": "^16.0.0",
|
|
149
149
|
"nodemon": "^3.0.3",
|
|
150
150
|
"prop-types": "^15.8.1",
|
|
151
|
+
"query-string": "^6.13.1",
|
|
151
152
|
"react-scripts": "^5.0.1",
|
|
152
153
|
"react-test-renderer": "^18.2.0",
|
|
153
154
|
"sinon": "^9.0.2",
|