@uncinc/uncinc-react-kitchen-sink 2.4.0 → 2.4.2
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/Context/KitchenSinkComponentMapperContext.js +11 -3
- package/dist/Context/ViewportContext.js +27 -14
- package/dist/Context/withMapping.js +26 -15
- package/dist/components/AbbreviationAnnotation/index.js +49 -27
- package/dist/components/AbbreviationAnnotation/stories.js +37 -22
- package/dist/components/Accordion/AccordionItem/index.js +55 -36
- package/dist/components/Accordion/AccordionItemVariant/index.js +47 -25
- package/dist/components/Accordion/index.js +17 -10
- package/dist/components/Accordion/stories.js +38 -24
- package/dist/components/ApiAutocomplete/index.js +79 -51
- package/dist/components/ApiAutocomplete/stories.js +18 -9
- package/dist/components/Button/index.js +48 -33
- package/dist/components/Button/stories.js +31 -49
- package/dist/components/Button/stories.scss +7 -5
- package/dist/components/Cookie/Checkbox/index.js +23 -16
- package/dist/components/Cookie/index.js +146 -115
- package/dist/components/Cookie/stories.js +90 -40
- package/dist/components/Dialog/index.d.ts +38 -0
- package/dist/components/Dialog/index.js +63 -56
- package/dist/components/Dialog/stories.js +35 -18
- package/dist/components/FontSizeSwitcher/index.js +58 -32
- package/dist/components/FontSizeSwitcher/stories.js +23 -9
- package/dist/components/Form/Checkbox/index.js +43 -37
- package/dist/components/Form/Checkbox/stories.js +20 -11
- package/dist/components/Form/Checkboxes/index.js +62 -57
- package/dist/components/Form/Checkboxes/index.test.js +113 -62
- package/dist/components/Form/Checkboxes/stories.js +23 -12
- package/dist/components/Form/Date/index.js +13 -5
- package/dist/components/Form/Date/stories.js +18 -9
- package/dist/components/Form/DatePicker/index.js +40 -33
- package/dist/components/Form/DatePicker/stories.js +18 -9
- package/dist/components/Form/DateSelect/index.js +99 -62
- package/dist/components/Form/DateSelect/stories.js +32 -11
- package/dist/components/Form/Email/index.js +13 -5
- package/dist/components/Form/Email/stories.js +18 -9
- package/dist/components/Form/FormikWrapper/index.js +52 -45
- package/dist/components/Form/GenericFormElement/index.js +39 -34
- package/dist/components/Form/Number/index.js +23 -18
- package/dist/components/Form/Number/stories.js +18 -9
- package/dist/components/Form/RadioButtons/index.js +53 -49
- package/dist/components/Form/RadioButtons/index.test.js +106 -57
- package/dist/components/Form/RadioButtons/stories.js +23 -12
- package/dist/components/Form/SearchField/index.js +37 -30
- package/dist/components/Form/Select/Input/index.js +56 -49
- package/dist/components/Form/Select/index.js +33 -24
- package/dist/components/Form/Select/stories.js +25 -15
- package/dist/components/Form/TextField/index.js +39 -33
- package/dist/components/Form/TextField/index.test.js +104 -56
- package/dist/components/Form/TextField/stories.js +22 -11
- package/dist/components/Form/Textarea/index.js +35 -27
- package/dist/components/Form/Textarea/stories.js +18 -9
- package/dist/components/Hamburger/index.js +30 -19
- package/dist/components/Hamburger/stories.js +42 -16
- package/dist/components/Header/index.js +67 -39
- package/dist/components/Header/stories.js +48 -28
- package/dist/components/Image/Background/index.js +36 -21
- package/dist/components/Image/LazyLoadWrapper/index.js +101 -64
- package/dist/components/Image/Picture/index.js +83 -65
- package/dist/components/Image/index.js +21 -15
- package/dist/components/Image/stories.js +87 -64
- package/dist/components/InlineMenu/index.js +60 -38
- package/dist/components/InlineMenu/stories.js +66 -55
- package/dist/components/Layout/Container/index.js +29 -21
- package/dist/components/Layout/Container/stories.js +94 -84
- package/dist/components/Layout/QuickLayout/Auto/index.js +19 -12
- package/dist/components/Layout/QuickLayout/Center/index.js +17 -10
- package/dist/components/Layout/QuickLayout/Clamp/index.js +20 -13
- package/dist/components/Layout/QuickLayout/Sidebar/index.js +20 -13
- package/dist/components/Layout/QuickLayout/SpaceBetween/index.js +20 -13
- package/dist/components/Layout/QuickLayout/Stack/index.js +21 -11
- package/dist/components/Layout/QuickLayout/Wrap/index.js +21 -14
- package/dist/components/Layout/QuickLayout/index.js +31 -21
- package/dist/components/Layout/QuickLayout/stories.js +102 -70
- package/dist/components/Lottie/LottieAnimation/index.js +55 -56
- package/dist/components/Lottie/LottieAnimationWithMousePosition.js +31 -18
- package/dist/components/Lottie/index.js +47 -35
- package/dist/components/Lottie/stories.js +56 -31
- package/dist/components/MagicLine/index.js +50 -27
- package/dist/components/MagicLine/stories.js +60 -46
- package/dist/components/NavigationScroll/index.js +71 -49
- package/dist/components/NavigationScroll/stories.js +19 -8
- package/dist/components/Pagination/index.js +49 -41
- package/dist/components/Pagination/stories.js +46 -17
- package/dist/components/SearchKit/Facets/ChipFacet/index.js +24 -16
- package/dist/components/SearchKit/Facets/ListFacet/index.js +23 -15
- package/dist/components/SearchKit/Facets/SelectFacet/index.js +39 -30
- package/dist/components/SearchKit/Query/index.js +41 -23
- package/dist/components/SearchKit/SearchFacets/index.js +36 -23
- package/dist/components/SearchKit/SearchField/index.js +49 -25
- package/dist/components/SearchKit/SearchLoadMore/index.js +22 -15
- package/dist/components/SearchKit/SearchPage/index.js +22 -14
- package/dist/components/SearchKit/SearchPagination/index.js +17 -10
- package/dist/components/SearchKit/SearchReset/index.js +25 -16
- package/dist/components/SearchKit/SearchResults/index.js +108 -59
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/CustomValue/index.js +17 -10
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/DateRange/index.js +18 -11
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/NumericRange/index.js +18 -11
- package/dist/components/SearchKit/SearchSelectedFilters/Filters/Value/index.js +22 -12
- package/dist/components/SearchKit/SearchSelectedFilters/index.js +34 -28
- package/dist/components/SearchKit/SearchSorting/index.js +29 -19
- package/dist/components/SearchKit/index.js +72 -53
- package/dist/components/SearchKit/stories.js +144 -187
- package/dist/components/Share/index.js +48 -40
- package/dist/components/Share/stories.js +16 -5
- package/dist/components/Sliders/SliderRelated/index.js +32 -25
- package/dist/components/Sliders/SliderRelated/stories.js +75 -57
- package/dist/components/Webform/WebformActions/index.js +19 -13
- package/dist/components/Webform/WebformCheckbox/index.js +32 -24
- package/dist/components/Webform/WebformCheckboxes/index.js +37 -29
- package/dist/components/Webform/WebformContainer/index.js +17 -11
- package/dist/components/Webform/WebformDate/index.js +76 -48
- package/dist/components/Webform/WebformMapper/index.js +53 -38
- package/dist/components/Webform/WebformNumber/index.js +31 -22
- package/dist/components/Webform/WebformRadioButtons/index.js +37 -29
- package/dist/components/Webform/WebformSelect/index.js +37 -29
- package/dist/components/Webform/WebformTextField/index.js +34 -26
- package/dist/components/Webform/WebformTextarea/index.js +32 -24
- package/dist/components/Webform/WebformWizardPage/index.js +56 -43
- package/dist/components/Webform/index.js +42 -20
- package/dist/components/Webform/stories.actions.js +19 -8
- package/dist/components/Webform/stories.checkboxes.js +19 -8
- package/dist/components/Webform/stories.checked.js +20 -9
- package/dist/components/Webform/stories.container.js +19 -8
- package/dist/components/Webform/stories.date.js +19 -8
- package/dist/components/Webform/stories.filled.js +20 -9
- package/dist/components/Webform/stories.number.js +19 -8
- package/dist/components/Webform/stories.radiobuttons.js +19 -8
- package/dist/components/Webform/stories.select.js +19 -8
- package/dist/components/Webform/stories.textarea.js +19 -8
- package/dist/components/Webform/stories.textfield.js +19 -8
- package/dist/components/Webform/stories.wizard.js +19 -8
- package/dist/components/Webform/withStates.js +49 -28
- package/dist/components/WysiwygField/index.js +30 -20
- package/dist/components/WysiwygField/stories.js +39 -29
- package/dist/components/index.js +111 -15
- package/dist/config/constants.js +38 -18
- package/dist/config/i18next/index.js +19 -11
- package/dist/helpers/date.js +25 -5
- package/dist/helpers/gtm.js +27 -17
- package/dist/helpers/link.js +15 -6
- package/dist/helpers/useValueForCurrentViewPort.js +27 -10
- package/dist/hooks/useBoolean.d.ts +8 -0
- package/dist/hooks/useBoolean.js +38 -0
- package/dist/hooks/useClickOutside.d.ts +8 -0
- package/dist/hooks/useClickOutside.js +35 -0
- package/dist/hooks/useDialog.d.ts +10 -0
- package/dist/hooks/useDialog.js +39 -0
- package/dist/hooks/useDialogHelpers.d.ts +20 -0
- package/dist/hooks/{useDialogHelpers.ts → useDialogHelpers.js} +33 -43
- package/dist/hooks/useEscape.d.ts +6 -0
- package/dist/hooks/useEscape.js +24 -0
- package/dist/hooks/useOnScreen.js +27 -6
- package/dist/hooks/usePrevious.js +10 -4
- package/dist/hooks/useScrollPosition.js +25 -7
- package/dist/hooks/useTrapFocus.d.ts +10 -0
- package/dist/hooks/useTrapFocus.js +63 -0
- package/dist/hooks/useWindowDimensions.js +27 -11
- package/dist/index.js +398 -56
- package/dist/setupTests.js +9 -5
- package/dist/styles/assets/_base.scss +0 -3
- package/dist/styles/assets/_fonts.scss +17 -17
- package/dist/styles/assets/_icons.scss +2 -2
- package/package.json +6 -3
- package/dist/hooks/useBoolean.ts +0 -20
- package/dist/hooks/useClickOutside.ts +0 -38
- package/dist/hooks/useDialog.ts +0 -29
- package/dist/hooks/useEscape.ts +0 -26
- package/dist/hooks/useTrapFocus.ts +0 -80
|
@@ -1,69 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _reactLazyload = _interopRequireDefault(require("react-lazyload"));
|
|
11
|
+
var _immutable = require("immutable");
|
|
12
|
+
require("./style.scss");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
17
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
22
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
27
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
30
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
31
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
34
|
+
var LazyLoadWrapper = /*#__PURE__*/function (_Component) {
|
|
35
|
+
_inherits(LazyLoadWrapper, _Component);
|
|
36
|
+
var _super = _createSuper(LazyLoadWrapper);
|
|
37
|
+
function LazyLoadWrapper(props) {
|
|
38
|
+
var _this;
|
|
39
|
+
_classCallCheck(this, LazyLoadWrapper);
|
|
40
|
+
_this = _super.call(this, props);
|
|
41
|
+
_this.state = {
|
|
10
42
|
loaded: false,
|
|
11
43
|
error: false
|
|
12
44
|
};
|
|
45
|
+
return _this;
|
|
13
46
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const newProps = {};
|
|
29
|
-
newProps.onLoad = event => {
|
|
30
|
-
this.setState({
|
|
31
|
-
loaded: true
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
newProps.onError = event => {
|
|
35
|
-
this.setState({
|
|
36
|
-
error: true
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
let elements = [];
|
|
40
|
-
const elementMap = Map(element);
|
|
41
|
-
if (Array.isArray(elementMap.getIn(['props', 'children']))) {
|
|
42
|
-
elements = React.Children.map(element.props.children, child => {
|
|
43
|
-
return addOnLoadCallback(child);
|
|
44
|
-
});
|
|
47
|
+
_createClass(LazyLoadWrapper, [{
|
|
48
|
+
key: "render",
|
|
49
|
+
value: function render() {
|
|
50
|
+
var _this2 = this;
|
|
51
|
+
var _this$props = this.props,
|
|
52
|
+
shouldLazyLoad = _this$props.lazyload,
|
|
53
|
+
children = _this$props.children;
|
|
54
|
+
var placeholder = /*#__PURE__*/_react.default.createElement("img", {
|
|
55
|
+
className: "lazy",
|
|
56
|
+
src: "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
|
|
57
|
+
alt: "placeholder"
|
|
58
|
+
});
|
|
59
|
+
if (!shouldLazyLoad) {
|
|
60
|
+
return children;
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
var addOnLoadCallback = function addOnLoadCallback(element) {
|
|
63
|
+
var newProps = {};
|
|
64
|
+
newProps.onLoad = function (event) {
|
|
65
|
+
_this2.setState({
|
|
66
|
+
loaded: true
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
newProps.onError = function (event) {
|
|
70
|
+
_this2.setState({
|
|
71
|
+
error: true
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
var elements = [];
|
|
75
|
+
var elementMap = (0, _immutable.Map)(element);
|
|
76
|
+
if (Array.isArray(elementMap.getIn(['props', 'children']))) {
|
|
77
|
+
elements = _react.default.Children.map(element.props.children, function (child) {
|
|
78
|
+
return addOnLoadCallback(child);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/_react.default.cloneElement.apply(_react.default, [element, newProps].concat(_toConsumableArray(elements)));
|
|
82
|
+
};
|
|
83
|
+
var _this$state = this.state,
|
|
84
|
+
loaded = _this$state.loaded,
|
|
85
|
+
error = _this$state.error;
|
|
86
|
+
var classes = (0, _classnames.default)('LazyLoadWrapper', {
|
|
87
|
+
'has-loaded': loaded,
|
|
88
|
+
'has-error': error
|
|
89
|
+
});
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_reactLazyload.default, {
|
|
91
|
+
placeholder: placeholder,
|
|
92
|
+
offset: 200,
|
|
93
|
+
once: true
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: classes
|
|
96
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
className: "lazy-load--inner-wrapper"
|
|
98
|
+
}, _react.default.Children.map(children, function (child) {
|
|
99
|
+
return addOnLoadCallback(child);
|
|
100
|
+
}))));
|
|
101
|
+
}
|
|
102
|
+
}]);
|
|
103
|
+
return LazyLoadWrapper;
|
|
104
|
+
}(_react.Component);
|
|
105
|
+
var _default = LazyLoadWrapper;
|
|
106
|
+
exports.default = _default;
|
|
@@ -1,56 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _extToMimeTypes = _interopRequireDefault(require("./data/ext-to-mime-types.json"));
|
|
11
|
+
require("./style.scss");
|
|
12
|
+
var _excluded = ["src", "className", "onLoad", "imageRef", "includeWebP"];
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
14
|
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); }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
height,
|
|
19
|
-
alt,
|
|
20
|
-
title
|
|
21
|
-
} = props;
|
|
22
|
-
const attrs = {
|
|
23
|
-
className,
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
var FALLBACK_MIME_TYPE = 'image/jpg';
|
|
18
|
+
var Picture = function Picture(_ref) {
|
|
19
|
+
var src = _ref.src,
|
|
20
|
+
className = _ref.className,
|
|
21
|
+
_onLoad = _ref.onLoad,
|
|
22
|
+
imageRef = _ref.imageRef,
|
|
23
|
+
includeWebP = _ref.includeWebP,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var width = props.width,
|
|
26
|
+
height = props.height,
|
|
27
|
+
alt = props.alt,
|
|
28
|
+
title = props.title;
|
|
29
|
+
var attrs = {
|
|
30
|
+
className: className,
|
|
24
31
|
typeof: 'foaf:Image',
|
|
25
|
-
width,
|
|
26
|
-
height,
|
|
27
|
-
alt,
|
|
28
|
-
title
|
|
32
|
+
width: width,
|
|
33
|
+
height: height,
|
|
34
|
+
alt: alt,
|
|
35
|
+
title: title
|
|
29
36
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
37
|
+
var getImageExtension = function getImageExtension(url) {
|
|
38
|
+
var sanitizedUrl = url.replace(/\?.*/, '');
|
|
39
|
+
return _path.default.extname(sanitizedUrl).toLowerCase();
|
|
33
40
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
41
|
+
var getMimeType = function getMimeType(url) {
|
|
42
|
+
var extension = getImageExtension(url);
|
|
43
|
+
return _extToMimeTypes.default[extension] ? _extToMimeTypes.default[extension] : FALLBACK_MIME_TYPE;
|
|
37
44
|
};
|
|
38
|
-
|
|
45
|
+
var isValidImage = function isValidImage(url) {
|
|
39
46
|
if (!url) {
|
|
40
47
|
return false;
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
return Object.keys(
|
|
49
|
+
var extension = getImageExtension(url);
|
|
50
|
+
return Object.keys(_extToMimeTypes.default).includes(extension);
|
|
44
51
|
};
|
|
45
|
-
if (
|
|
52
|
+
if (_immutable.default.Iterable.isIterable(_immutable.default.fromJS(src))) {
|
|
46
53
|
// Sources have to be defined in a descending order.
|
|
47
54
|
// We sort them from best to worst quality.
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
var sourcesAll = _immutable.default.fromJS(src).toOrderedMap().sortBy(function (url, breakpoint) {
|
|
56
|
+
return parseInt(breakpoint);
|
|
57
|
+
}).reverse();
|
|
58
|
+
var sources = sourcesAll.map(function (url) {
|
|
50
59
|
if (isValidImage(url)) {
|
|
51
60
|
return url;
|
|
52
61
|
}
|
|
53
|
-
}).filter(image
|
|
62
|
+
}).filter(function (image) {
|
|
54
63
|
if (image !== false) {
|
|
55
64
|
return image;
|
|
56
65
|
}
|
|
@@ -58,57 +67,65 @@ const Picture = ({
|
|
|
58
67
|
});
|
|
59
68
|
|
|
60
69
|
// Only render if all our image sources are valid
|
|
61
|
-
|
|
70
|
+
var hasValidSources = sources.count() > 0;
|
|
62
71
|
if (!hasValidSources) {
|
|
63
72
|
return null;
|
|
64
73
|
}
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
var fallback = sources.valueSeq().first();
|
|
75
|
+
var renderedSourcesWebP = [];
|
|
67
76
|
if (includeWebP) {
|
|
68
77
|
/* eslint-disable react/no-array-index-key */
|
|
69
|
-
renderedSourcesWebP = sources.map((url, breakpoint)
|
|
70
|
-
|
|
71
|
-
return /*#__PURE__*/
|
|
78
|
+
renderedSourcesWebP = sources.map(function (url, breakpoint) {
|
|
79
|
+
var webpUrl = url.replace(/\.(png|gif|jp(e?)g)/ig, '.webp');
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement("source", {
|
|
72
81
|
key: breakpoint,
|
|
73
82
|
srcSet: webpUrl,
|
|
74
83
|
type: getMimeType(webpUrl),
|
|
75
|
-
media:
|
|
84
|
+
media: "screen and (min-width: ".concat(breakpoint, "px)")
|
|
76
85
|
});
|
|
77
86
|
}).valueSeq();
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
/* eslint-disable react/no-array-index-key */
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
var renderedSources = sources.map(function (url, breakpoint) {
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement("source", {
|
|
92
|
+
key: breakpoint,
|
|
93
|
+
srcSet: url,
|
|
94
|
+
type: getMimeType(url),
|
|
95
|
+
media: "screen and (min-width: ".concat(breakpoint, "px)")
|
|
96
|
+
});
|
|
97
|
+
}).valueSeq();
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement("picture", {
|
|
99
|
+
onLoad: function onLoad(e) {
|
|
100
|
+
return _onLoad(e);
|
|
101
|
+
}
|
|
102
|
+
}, renderedSourcesWebP, renderedSources, /*#__PURE__*/_react.default.createElement("img", _extends({}, attrs, {
|
|
90
103
|
ref: imageRef,
|
|
91
104
|
src: fallback
|
|
92
105
|
})));
|
|
93
106
|
}
|
|
94
107
|
if (src && isValidImage(src)) {
|
|
95
108
|
if (includeWebP) {
|
|
96
|
-
|
|
97
|
-
return /*#__PURE__*/
|
|
98
|
-
onLoad:
|
|
99
|
-
|
|
109
|
+
var webpUrl = src.replace(/\.(png|gif|jp(e?)g)/, '.webp');
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement("picture", {
|
|
111
|
+
onLoad: function onLoad(e) {
|
|
112
|
+
return _onLoad(e);
|
|
113
|
+
}
|
|
114
|
+
}, /*#__PURE__*/_react.default.createElement("source", {
|
|
100
115
|
srcSet: webpUrl,
|
|
101
116
|
type: getMimeType(webpUrl)
|
|
102
|
-
}), /*#__PURE__*/
|
|
117
|
+
}), /*#__PURE__*/_react.default.createElement("source", {
|
|
103
118
|
srcSet: src,
|
|
104
119
|
type: getMimeType(src)
|
|
105
|
-
}), /*#__PURE__*/
|
|
120
|
+
}), /*#__PURE__*/_react.default.createElement("img", _extends({}, attrs, {
|
|
106
121
|
ref: imageRef,
|
|
107
122
|
src: src
|
|
108
123
|
})));
|
|
109
124
|
}
|
|
110
|
-
return /*#__PURE__*/
|
|
111
|
-
onLoad:
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement("img", _extends({}, attrs, {
|
|
126
|
+
onLoad: function onLoad(e) {
|
|
127
|
+
return _onLoad(e);
|
|
128
|
+
},
|
|
112
129
|
ref: imageRef,
|
|
113
130
|
src: src
|
|
114
131
|
}));
|
|
@@ -116,6 +133,7 @@ const Picture = ({
|
|
|
116
133
|
return null;
|
|
117
134
|
};
|
|
118
135
|
Picture.defaultProps = {
|
|
119
|
-
onLoad: ()
|
|
136
|
+
onLoad: function onLoad() {}
|
|
120
137
|
};
|
|
121
|
-
|
|
138
|
+
var _default = Picture;
|
|
139
|
+
exports.default = _default;
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
10
|
+
var _LazyLoadWrapper = _interopRequireDefault(require("./LazyLoadWrapper"));
|
|
11
|
+
var _Picture = _interopRequireDefault(require("./Picture"));
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
var Image = function Image(props) {
|
|
14
|
+
var lazyload = props.lazyload;
|
|
10
15
|
if (lazyload) {
|
|
11
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement(_LazyLoadWrapper.default, {
|
|
12
17
|
lazyload: lazyload
|
|
13
|
-
}, /*#__PURE__*/
|
|
18
|
+
}, /*#__PURE__*/_react.default.createElement(_Picture.default, props));
|
|
14
19
|
}
|
|
15
|
-
return /*#__PURE__*/
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_Picture.default, props);
|
|
16
21
|
};
|
|
17
22
|
Image.propTypes = {
|
|
18
|
-
src:
|
|
19
|
-
lazyload:
|
|
23
|
+
src: _propTypes.default.oneOfType([_propTypes.default.string, _reactImmutableProptypes.default.map]).isRequired,
|
|
24
|
+
lazyload: _propTypes.default.bool
|
|
20
25
|
};
|
|
21
26
|
Image.defaultProps = {
|
|
22
27
|
lazyload: true
|
|
23
28
|
};
|
|
24
|
-
|
|
29
|
+
var _default = Image;
|
|
30
|
+
exports.default = _default;
|
|
@@ -1,66 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Responsive = exports.ImageResponsiveFail = exports.Default = exports.BackgroundImageResponsive = exports.BackgroundImage = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _ = _interopRequireDefault(require("."));
|
|
9
|
+
var _Background = _interopRequireDefault(require("./Background"));
|
|
10
|
+
require("./stories.scss");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
var _default = {
|
|
6
13
|
title: 'Atoms/Image'
|
|
7
14
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, /*#__PURE__*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, /*#__PURE__*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, /*#__PURE__*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, /*#__PURE__*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
15
|
+
exports.default = _default;
|
|
16
|
+
var Default = function Default() {
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
18
|
+
className: "ImageWrapper"
|
|
19
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
+
className: "ImageWrapper__image"
|
|
21
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
22
|
+
src: "https://dummyimage.com/400x400/000/fff.jpg",
|
|
23
|
+
alt: "Image 1"
|
|
24
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
25
|
+
className: "ImageWrapper__image"
|
|
26
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
27
|
+
src: "https://dummyimage.com/400x400/f2788f/fff.png",
|
|
28
|
+
alt: "Image 2"
|
|
29
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: "ImageWrapper__image"
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
32
|
+
src: "https://dummyimage.com/400x400/73cac4/fff.gif",
|
|
33
|
+
alt: "Image 3"
|
|
34
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
+
className: "ImageWrapper__image"
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
37
|
+
src: "https://dummyimage.com/400x400/ff8833/fff.svg",
|
|
38
|
+
alt: "Image 4"
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
exports.Default = Default;
|
|
42
|
+
var Responsive = function Responsive() {
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
44
|
+
className: "ImageWrapper"
|
|
45
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
46
|
+
src: {
|
|
47
|
+
400: 'https://dummyimage.com/400x400/000/fff.gif',
|
|
48
|
+
600: 'https://dummyimage.com/600x400/f2788f/fff.png',
|
|
49
|
+
1000: 'https://dummyimage.com/1000x400/73cac4/fff.jpg'
|
|
50
|
+
},
|
|
51
|
+
alt: "Image 1"
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
exports.Responsive = Responsive;
|
|
55
|
+
var BackgroundImage = function BackgroundImage() {
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
+
className: "ImageWrapper"
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement(_Background.default, {
|
|
59
|
+
src: "https://dummyimage.com/600x400/000/fff.jpg",
|
|
60
|
+
alt: "Image 1"
|
|
61
|
+
}));
|
|
62
|
+
};
|
|
63
|
+
exports.BackgroundImage = BackgroundImage;
|
|
64
|
+
var BackgroundImageResponsive = function BackgroundImageResponsive() {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: "ImageWrapper"
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_Background.default, {
|
|
68
|
+
src: {
|
|
69
|
+
400: 'https://dummyimage.com/400x400/000/fff.gif',
|
|
70
|
+
600: 'https://dummyimage.com/600x400/f2788f/fff.png',
|
|
71
|
+
1000: 'https://dummyimage.com/1000x400/73cac4/fff.jpg'
|
|
72
|
+
},
|
|
73
|
+
alt: "Image 1"
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
exports.BackgroundImageResponsive = BackgroundImageResponsive;
|
|
77
|
+
var ImageResponsiveFail = function ImageResponsiveFail() {
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
+
className: "ImageWrapper"
|
|
80
|
+
}, /*#__PURE__*/_react.default.createElement(_.default, {
|
|
81
|
+
src: {
|
|
82
|
+
400: null,
|
|
83
|
+
600: 'https://dummyimage.com/600x400/f2788f/fff.png',
|
|
84
|
+
1000: 'https://dummyimage.com/1000x400/73cac4/fff.jpg'
|
|
85
|
+
},
|
|
86
|
+
alt: "Image 1"
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
exports.ImageResponsiveFail = ImageResponsiveFail;
|