carbon-react 84.4.0 → 86.0.1
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/lib/components/carousel/carousel.component.js +126 -268
- package/lib/components/decimal/decimal.component.js +11 -7
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +1 -1
- package/lib/components/loader/loader-square.style.js +29 -3
- package/lib/components/loader/loader.component.js +2 -2
- package/lib/components/loader/loader.config.js +1 -1
- package/lib/components/loader/loader.d.ts +1 -1
- package/lib/components/loader-bar/index.d.ts +1 -0
- package/lib/components/loader-bar/index.js +15 -0
- package/lib/components/loader-bar/loader-bar.component.js +47 -0
- package/lib/components/loader-bar/loader-bar.config.js +9 -0
- package/lib/components/loader-bar/loader-bar.d.ts +10 -0
- package/lib/components/loader-bar/loader-bar.style.js +97 -0
- package/lib/components/pages/pages.component.js +67 -138
- package/lib/style/themes/aegean/aegean-theme.config.js +2 -1
- package/lib/style/themes/base/base-theme.config.js +1 -0
- package/lib/style/themes/mint/mint-theme.config.js +2 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "Slide", {
|
|
|
11
11
|
});
|
|
12
12
|
exports.Carousel = exports.default = void 0;
|
|
13
13
|
|
|
14
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
|
|
@@ -31,286 +31,151 @@ var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
|
31
31
|
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
33
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
|
|
38
|
-
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, descriptor.key, descriptor); } }
|
|
39
|
-
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
-
|
|
42
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
34
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
45
35
|
|
|
46
|
-
function
|
|
36
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
47
37
|
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
-
|
|
52
|
-
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; } }
|
|
53
|
-
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
56
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
38
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
57
39
|
|
|
58
40
|
const NEXT = "next";
|
|
59
41
|
const PREVIOUS = "previous";
|
|
60
|
-
const TRANSITION_TIME = 750;
|
|
61
|
-
|
|
62
|
-
let BaseCarousel = /*#__PURE__*/function (_React$Component) {
|
|
63
|
-
_inherits(BaseCarousel, _React$Component);
|
|
64
42
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
const BaseCarousel = ({
|
|
44
|
+
children,
|
|
45
|
+
className,
|
|
46
|
+
enableSlideSelector = true,
|
|
47
|
+
enablePreviousButton = true,
|
|
48
|
+
enableNextButton = true,
|
|
49
|
+
initialSlideIndex = 0,
|
|
50
|
+
onSlideChange,
|
|
51
|
+
slideIndex,
|
|
52
|
+
theme = _base.default,
|
|
53
|
+
...props
|
|
54
|
+
}) => {
|
|
55
|
+
const [selectedSlideIndex, setSelectedSlideIndex] = (0, _react.useState)(Number(slideIndex) || Number(initialSlideIndex));
|
|
56
|
+
const transitionDirection = (0, _react.useRef)(NEXT);
|
|
57
|
+
const lastSlideIndexProp = (0, _react.useRef)(props.slideIndex);
|
|
58
|
+
const id = (0, _guid.default)();
|
|
59
|
+
const numOfSlides = (0, _react.useMemo)(() => {
|
|
60
|
+
return Array.isArray(children) ? (0, _lodash.compact)(children).length : 1;
|
|
61
|
+
}, [children]);
|
|
62
|
+
const handleSlideChange = (0, _react.useCallback)(newIndex => {
|
|
63
|
+
setSelectedSlideIndex(newIndex);
|
|
64
|
+
|
|
65
|
+
if (onSlideChange) {
|
|
66
|
+
onSlideChange(newIndex, transitionDirection.current);
|
|
67
|
+
}
|
|
68
|
+
}, [onSlideChange]);
|
|
69
|
+
(0, _react.useEffect)(() => {
|
|
70
|
+
const newIndex = slideIndex;
|
|
71
|
+
const isNewIndexUndefined = typeof newIndex === "undefined";
|
|
72
|
+
const isTheSameIndex = newIndex === lastSlideIndexProp.current || newIndex === selectedSlideIndex;
|
|
73
|
+
if (isNewIndexUndefined || isTheSameIndex) return;
|
|
74
|
+
|
|
75
|
+
if (newIndex > selectedSlideIndex) {
|
|
76
|
+
transitionDirection.current = NEXT;
|
|
77
|
+
} else {
|
|
78
|
+
transitionDirection.current = PREVIOUS;
|
|
79
|
+
}
|
|
69
80
|
|
|
70
|
-
|
|
81
|
+
lastSlideIndexProp.current = newIndex;
|
|
82
|
+
handleSlideChange(newIndex);
|
|
83
|
+
}, [handleSlideChange, slideIndex, selectedSlideIndex]);
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
function onPreviousClick() {
|
|
86
|
+
const newIndex = selectedSlideIndex - 1;
|
|
87
|
+
transitionDirection.current = PREVIOUS;
|
|
88
|
+
handleSlideChange(newIndex);
|
|
89
|
+
}
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
function onNextClick() {
|
|
92
|
+
const newIndex = selectedSlideIndex + 1;
|
|
93
|
+
transitionDirection.current = NEXT;
|
|
94
|
+
handleSlideChange(newIndex);
|
|
95
|
+
}
|
|
79
96
|
|
|
80
|
-
|
|
97
|
+
function onSlideSelection(ev) {
|
|
98
|
+
const newSlideSelection = Number(ev.target.value);
|
|
99
|
+
transitionDirection.current = newSlideSelection > selectedSlideIndex ? NEXT : PREVIOUS;
|
|
100
|
+
handleSlideChange(newSlideSelection);
|
|
101
|
+
}
|
|
81
102
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
theme
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"data-element": "visible-slide",
|
|
92
|
-
key: `carbon-slide-${index}`,
|
|
93
|
-
...visibleSlide.props
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return /*#__PURE__*/_react.default.cloneElement(visibleSlide, (0, _lodash.assign)({}, visibleSlide.props, additionalProps));
|
|
103
|
+
function visibleSlides() {
|
|
104
|
+
const arrayWithKeys = _react.default.Children.map(children, (element, key) => {
|
|
105
|
+
return /*#__PURE__*/_react.default.cloneElement(element, {
|
|
106
|
+
key: `slide-${(0, _guid.default)()}`,
|
|
107
|
+
id: key,
|
|
108
|
+
selectedIndex: selectedSlideIndex,
|
|
109
|
+
theme,
|
|
110
|
+
...element.props
|
|
111
|
+
});
|
|
97
112
|
});
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
_this.onPreviousClick = _this.onPreviousClick.bind(_assertThisInitialized(_this));
|
|
101
|
-
_this.onNextClick = _this.onNextClick.bind(_assertThisInitialized(_this));
|
|
102
|
-
_this.onSlideSelection = _this.onSlideSelection.bind(_assertThisInitialized(_this));
|
|
103
|
-
_this.previousButtonProps = _this.previousButtonProps.bind(_assertThisInitialized(_this));
|
|
104
|
-
_this.nextButtonProps = _this.nextButtonProps.bind(_assertThisInitialized(_this));
|
|
105
|
-
_this.numOfSlides = _this.numOfSlides.bind(_assertThisInitialized(_this));
|
|
106
|
-
_this.slideSelector = _this.slideSelector.bind(_assertThisInitialized(_this));
|
|
107
|
-
_this.id = (0, _guid.default)();
|
|
108
|
-
return _this;
|
|
114
|
+
return arrayWithKeys;
|
|
109
115
|
}
|
|
110
116
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, {
|
|
133
|
-
key: "onPreviousClick",
|
|
134
|
-
value: function onPreviousClick() {
|
|
135
|
-
let newIndex = this.state.selectedSlideIndex - 1;
|
|
136
|
-
|
|
137
|
-
if (newIndex < 0) {
|
|
138
|
-
newIndex = this.numOfSlides() - 1;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.transitionDirection = PREVIOUS;
|
|
142
|
-
this.handleSlideChange(newIndex);
|
|
143
|
-
}
|
|
144
|
-
/** Handles clicking on the next button */
|
|
145
|
-
|
|
146
|
-
}, {
|
|
147
|
-
key: "onNextClick",
|
|
148
|
-
value: function onNextClick() {
|
|
149
|
-
const newIndex = (this.state.selectedSlideIndex + 1) % this.numOfSlides();
|
|
150
|
-
this.transitionDirection = NEXT;
|
|
151
|
-
this.handleSlideChange(newIndex);
|
|
152
|
-
}
|
|
153
|
-
/** Handles clicking slide selector */
|
|
154
|
-
|
|
155
|
-
}, {
|
|
156
|
-
key: "onSlideSelection",
|
|
157
|
-
value: function onSlideSelection(ev) {
|
|
158
|
-
const newSlideSelection = Number(ev.target.value);
|
|
159
|
-
this.transitionDirection = newSlideSelection > this.state.selectedSlideIndex ? NEXT : PREVIOUS;
|
|
160
|
-
this.handleSlideChange(newSlideSelection);
|
|
161
|
-
}
|
|
162
|
-
/** Verifies the new index and corrects it if necessary */
|
|
163
|
-
|
|
164
|
-
}, {
|
|
165
|
-
key: "verifyNewIndex",
|
|
166
|
-
value: function verifyNewIndex(newIndex) {
|
|
167
|
-
if (newIndex < 0) {
|
|
168
|
-
// If the new index is negative, select the last slide
|
|
169
|
-
return this.numOfSlides() - 1;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (newIndex > this.numOfSlides() - 1) {
|
|
173
|
-
// If the new index is bigger than the number of slides, select the first slide
|
|
174
|
-
return 0;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return newIndex;
|
|
117
|
+
function slideSelector() {
|
|
118
|
+
if (!enableSlideSelector) return null;
|
|
119
|
+
const buttons = [];
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < numOfSlides; i++) {
|
|
122
|
+
buttons.push( /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorInputWrapperStyle, {
|
|
123
|
+
key: i,
|
|
124
|
+
"data-element": "selector-inputs"
|
|
125
|
+
}, /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorInputStyle, {
|
|
126
|
+
"data-element": "selector-input",
|
|
127
|
+
name: `carousel-slide-${id}`,
|
|
128
|
+
id: `carousel-slide-${i}-${id}`,
|
|
129
|
+
type: "radio",
|
|
130
|
+
value: i,
|
|
131
|
+
onChange: onSlideSelection,
|
|
132
|
+
checked: selectedSlideIndex === i
|
|
133
|
+
}), /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorLabelStyle, {
|
|
134
|
+
"data-element": "selector-label",
|
|
135
|
+
htmlFor: `carousel-slide-${i}-${id}`
|
|
136
|
+
})));
|
|
178
137
|
}
|
|
179
|
-
/** Handle the slide change to the newIndex */
|
|
180
|
-
|
|
181
|
-
}, {
|
|
182
|
-
key: "handleSlideChange",
|
|
183
|
-
value: function handleSlideChange(newIndex) {
|
|
184
|
-
this.setState({
|
|
185
|
-
selectedSlideIndex: newIndex
|
|
186
|
-
});
|
|
187
138
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
/** Gets the props for the previous button */
|
|
193
|
-
|
|
194
|
-
}, {
|
|
195
|
-
key: "previousButtonProps",
|
|
196
|
-
value: function previousButtonProps() {
|
|
197
|
-
return !this.state.disabled ? {
|
|
198
|
-
onClick: this.onPreviousClick
|
|
199
|
-
} : {};
|
|
200
|
-
}
|
|
201
|
-
/** Gets the props for the next button */
|
|
202
|
-
|
|
203
|
-
}, {
|
|
204
|
-
key: "nextButtonProps",
|
|
205
|
-
value: function nextButtonProps() {
|
|
206
|
-
return !this.state.disabled ? {
|
|
207
|
-
onClick: this.onNextClick
|
|
208
|
-
} : {};
|
|
209
|
-
}
|
|
210
|
-
/** Gets the number of slides */
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorWrapperStyle, {
|
|
140
|
+
"data-element": "slide-selector"
|
|
141
|
+
}, buttons);
|
|
142
|
+
}
|
|
211
143
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
key: `slide-${(0, _guid.default)()}`,
|
|
225
|
-
id: key,
|
|
226
|
-
selectedIndex: this.state.selectedSlideIndex,
|
|
227
|
-
theme: this.props.theme,
|
|
228
|
-
...element.props
|
|
229
|
-
});
|
|
230
|
-
});
|
|
144
|
+
function previousButton() {
|
|
145
|
+
if (!enablePreviousButton) return null;
|
|
146
|
+
const isDisabled = selectedSlideIndex === 0;
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselPreviousButtonWrapperStyle, null, /*#__PURE__*/_react.default.createElement(_carousel.CarouselButtonStyle, {
|
|
148
|
+
onClick: onPreviousClick,
|
|
149
|
+
"data-element": "previous",
|
|
150
|
+
"aria-label": "previous",
|
|
151
|
+
disabled: isDisabled
|
|
152
|
+
}, /*#__PURE__*/_react.default.createElement(_carousel.CarouselStyledIconLeft, {
|
|
153
|
+
type: "chevron_down"
|
|
154
|
+
})));
|
|
155
|
+
}
|
|
231
156
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
"data-element": "selector-inputs"
|
|
246
|
-
}, /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorInputStyle, {
|
|
247
|
-
disabled: this.state.disabled,
|
|
248
|
-
"data-element": "selector-input",
|
|
249
|
-
name: `carousel-slide-${this.id}`,
|
|
250
|
-
id: `carousel-slide-${i}-${this.id}`,
|
|
251
|
-
type: "radio",
|
|
252
|
-
value: i,
|
|
253
|
-
onChange: this.onSlideSelection,
|
|
254
|
-
checked: this.state.selectedSlideIndex === i
|
|
255
|
-
}), /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorLabelStyle, {
|
|
256
|
-
"data-element": "selector-label",
|
|
257
|
-
htmlFor: `carousel-slide-${i}-${this.id}`
|
|
258
|
-
})));
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselSelectorWrapperStyle, {
|
|
262
|
-
"data-element": "slide-selector"
|
|
263
|
-
}, buttons);
|
|
264
|
-
}
|
|
265
|
-
/** Renders the previous button */
|
|
266
|
-
|
|
267
|
-
}, {
|
|
268
|
-
key: "previousButton",
|
|
269
|
-
value: function previousButton() {
|
|
270
|
-
if (!this.props.enablePreviousButton) return null;
|
|
271
|
-
const isDisabled = this.state.selectedSlideIndex === 0;
|
|
272
|
-
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselPreviousButtonWrapperStyle, null, /*#__PURE__*/_react.default.createElement(_carousel.CarouselButtonStyle, _extends({}, this.previousButtonProps(), {
|
|
273
|
-
"data-element": "previous",
|
|
274
|
-
"aria-label": "previous",
|
|
275
|
-
disabled: isDisabled
|
|
276
|
-
}), /*#__PURE__*/_react.default.createElement(_carousel.CarouselStyledIconLeft, {
|
|
277
|
-
type: "chevron_down"
|
|
278
|
-
})));
|
|
279
|
-
}
|
|
280
|
-
/** Renders the next button */
|
|
281
|
-
|
|
282
|
-
}, {
|
|
283
|
-
key: "nextButton",
|
|
284
|
-
value: function nextButton() {
|
|
285
|
-
if (!this.props.enableNextButton) return null;
|
|
286
|
-
const numberOfChildren = this.props.children.length;
|
|
287
|
-
const isDisabled = numberOfChildren === this.state.selectedSlideIndex + 1;
|
|
288
|
-
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselNextButtonWrapperStyle, null, /*#__PURE__*/_react.default.createElement(_carousel.CarouselButtonStyle, _extends({}, this.nextButtonProps(), {
|
|
289
|
-
"data-element": "next",
|
|
290
|
-
"aria-label": "next",
|
|
291
|
-
type: "button",
|
|
292
|
-
disabled: isDisabled
|
|
293
|
-
}), /*#__PURE__*/_react.default.createElement(_carousel.CarouselStyledIconRight, {
|
|
294
|
-
type: "chevron_down"
|
|
295
|
-
})));
|
|
296
|
-
}
|
|
297
|
-
/** Renders the Slide Component */
|
|
298
|
-
|
|
299
|
-
}, {
|
|
300
|
-
key: "render",
|
|
301
|
-
value: function render() {
|
|
302
|
-
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselWrapperStyle, _extends({
|
|
303
|
-
className: this.props.className
|
|
304
|
-
}, (0, _tags.default)("carousel", this.props)), /*#__PURE__*/_react.default.createElement("div", {
|
|
305
|
-
className: "carbon-carousel__content"
|
|
306
|
-
}, this.previousButton(), /*#__PURE__*/_react.default.createElement(_carousel.CarouselSliderWrapper, {
|
|
307
|
-
elementIndex: this.state.selectedSlideIndex
|
|
308
|
-
}, this.visibleSlides()), this.nextButton()), this.slideSelector());
|
|
309
|
-
}
|
|
310
|
-
}]);
|
|
157
|
+
function nextButton() {
|
|
158
|
+
if (!enableNextButton) return null;
|
|
159
|
+
const isDisabled = numOfSlides === selectedSlideIndex + 1;
|
|
160
|
+
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselNextButtonWrapperStyle, null, /*#__PURE__*/_react.default.createElement(_carousel.CarouselButtonStyle, {
|
|
161
|
+
onClick: onNextClick,
|
|
162
|
+
"data-element": "next",
|
|
163
|
+
"aria-label": "next",
|
|
164
|
+
type: "button",
|
|
165
|
+
disabled: isDisabled
|
|
166
|
+
}, /*#__PURE__*/_react.default.createElement(_carousel.CarouselStyledIconRight, {
|
|
167
|
+
type: "chevron_down"
|
|
168
|
+
})));
|
|
169
|
+
}
|
|
311
170
|
|
|
312
|
-
return
|
|
313
|
-
|
|
171
|
+
return /*#__PURE__*/_react.default.createElement(_carousel.CarouselWrapperStyle, _extends({
|
|
172
|
+
className: className
|
|
173
|
+
}, (0, _tags.default)("carousel", props)), /*#__PURE__*/_react.default.createElement("div", {
|
|
174
|
+
className: "carbon-carousel__content"
|
|
175
|
+
}, previousButton(), /*#__PURE__*/_react.default.createElement(_carousel.CarouselSliderWrapper, {
|
|
176
|
+
elementIndex: selectedSlideIndex
|
|
177
|
+
}, visibleSlides()), nextButton()), slideSelector());
|
|
178
|
+
};
|
|
314
179
|
|
|
315
180
|
BaseCarousel.propTypes = {
|
|
316
181
|
/** [legacy] Custom className */
|
|
@@ -340,13 +205,6 @@ BaseCarousel.propTypes = {
|
|
|
340
205
|
/** theme is used only to support legacy code */
|
|
341
206
|
theme: _propTypes.default.object
|
|
342
207
|
};
|
|
343
|
-
BaseCarousel.defaultProps = {
|
|
344
|
-
initialSlideIndex: 0,
|
|
345
|
-
enableSlideSelector: true,
|
|
346
|
-
enablePreviousButton: true,
|
|
347
|
-
enableNextButton: true,
|
|
348
|
-
theme: _base.default
|
|
349
|
-
};
|
|
350
208
|
const Carousel = (0, _styledComponents.withTheme)(BaseCarousel);
|
|
351
209
|
exports.Carousel = Carousel;
|
|
352
210
|
Carousel.displayName = "Carousel";
|
|
@@ -17,6 +17,8 @@ var _textbox = _interopRequireDefault(require("../textbox"));
|
|
|
17
17
|
|
|
18
18
|
var _utils = require("../../style/utils");
|
|
19
19
|
|
|
20
|
+
var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
|
|
21
|
+
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
23
|
|
|
22
24
|
function _extends() { _extends = Object.assign || 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); }
|
|
@@ -50,12 +52,12 @@ let Decimal = /*#__PURE__*/function (_React$Component) {
|
|
|
50
52
|
|
|
51
53
|
var _super = _createSuper(Decimal);
|
|
52
54
|
|
|
53
|
-
function Decimal(props) {
|
|
55
|
+
function Decimal(props, context) {
|
|
54
56
|
var _this;
|
|
55
57
|
|
|
56
58
|
_classCallCheck(this, Decimal);
|
|
57
59
|
|
|
58
|
-
_this = _super.call(this, props);
|
|
60
|
+
_this = _super.call(this, props, context);
|
|
59
61
|
|
|
60
62
|
_defineProperty(_assertThisInitialized(_this), "emptyValue", _this.props.allowEmptyValue ? "" : "0.00");
|
|
61
63
|
|
|
@@ -164,7 +166,7 @@ let Decimal = /*#__PURE__*/function (_React$Component) {
|
|
|
164
166
|
const separator = _this.getSeparator("decimal");
|
|
165
167
|
|
|
166
168
|
const [integer, remainder] = value.split(".");
|
|
167
|
-
const formattedInteger = Intl.NumberFormat(_this.props.locale, {
|
|
169
|
+
const formattedInteger = Intl.NumberFormat(_this.props.locale || _this.context.locale(), {
|
|
168
170
|
maximumFractionDigits: 0
|
|
169
171
|
}).format(integer);
|
|
170
172
|
let formattedNumber = formattedInteger;
|
|
@@ -251,7 +253,7 @@ let Decimal = /*#__PURE__*/function (_React$Component) {
|
|
|
251
253
|
key: "getSeparator",
|
|
252
254
|
value: function getSeparator(separatorType) {
|
|
253
255
|
const numberWithGroupAndDecimalSeparator = 10000.1;
|
|
254
|
-
return Intl.NumberFormat(this.props.locale).formatToParts(numberWithGroupAndDecimalSeparator).find(part => part.type === separatorType).value;
|
|
256
|
+
return Intl.NumberFormat(this.props.locale || this.context.locale()).formatToParts(numberWithGroupAndDecimalSeparator).find(part => part.type === separatorType).value;
|
|
255
257
|
}
|
|
256
258
|
}, {
|
|
257
259
|
key: "render",
|
|
@@ -259,6 +261,7 @@ let Decimal = /*#__PURE__*/function (_React$Component) {
|
|
|
259
261
|
const {
|
|
260
262
|
name,
|
|
261
263
|
defaultValue,
|
|
264
|
+
locale,
|
|
262
265
|
...rest
|
|
263
266
|
} = this.props;
|
|
264
267
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, rest, {
|
|
@@ -278,6 +281,8 @@ let Decimal = /*#__PURE__*/function (_React$Component) {
|
|
|
278
281
|
return Decimal;
|
|
279
282
|
}(_react.default.Component);
|
|
280
283
|
|
|
284
|
+
_defineProperty(Decimal, "contextType", _i18nContext.default);
|
|
285
|
+
|
|
281
286
|
_defineProperty(Decimal, "maxPrecision", 15);
|
|
282
287
|
|
|
283
288
|
Decimal.propTypes = {
|
|
@@ -353,15 +358,14 @@ Decimal.propTypes = {
|
|
|
353
358
|
required: _propTypes.default.bool,
|
|
354
359
|
|
|
355
360
|
/**
|
|
356
|
-
*
|
|
361
|
+
* Override the locale string, default from I18nProvider
|
|
357
362
|
*/
|
|
358
363
|
locale: _propTypes.default.string
|
|
359
364
|
};
|
|
360
365
|
Decimal.defaultProps = {
|
|
361
366
|
align: "right",
|
|
362
367
|
precision: 2,
|
|
363
|
-
allowEmptyValue: false
|
|
364
|
-
locale: "en"
|
|
368
|
+
allowEmptyValue: false
|
|
365
369
|
};
|
|
366
370
|
var _default = Decimal;
|
|
367
371
|
exports.default = _default;
|
|
@@ -45,7 +45,7 @@ const FlatTableHead = ({
|
|
|
45
45
|
This is only needed when the preceding row has rowSpans applied,
|
|
46
46
|
as in any other use case the rows will all have FlatTableRowHeaders */
|
|
47
47
|
const previousRowHasHeader = !!hasFlatTableRowHeader;
|
|
48
|
-
hasFlatTableRowHeader = child.props.children.find(c => c.type === _flatTableRowHeader.default);
|
|
48
|
+
hasFlatTableRowHeader = _react.default.Children.toArray(child.props.children).find(c => c.type === _flatTableRowHeader.default);
|
|
49
49
|
return /*#__PURE__*/_react.default.cloneElement(child, { ...child.props,
|
|
50
50
|
stickyOffset: rowHeights.slice(0, index).reduce((a, b) => a + b, 0),
|
|
51
51
|
ref: refs[index],
|
|
@@ -29,6 +29,34 @@ const loaderAnimation = (0, _styledComponents.keyframes)`
|
|
|
29
29
|
transform: scale(1);
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
32
|
+
|
|
33
|
+
const getDimentions = size => {
|
|
34
|
+
let width;
|
|
35
|
+
let marginRight;
|
|
36
|
+
|
|
37
|
+
switch (size) {
|
|
38
|
+
case "medium":
|
|
39
|
+
width = "16px";
|
|
40
|
+
marginRight = "8px";
|
|
41
|
+
break;
|
|
42
|
+
|
|
43
|
+
case "large":
|
|
44
|
+
width = "20px";
|
|
45
|
+
marginRight = "8px";
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
default:
|
|
49
|
+
width = "12px";
|
|
50
|
+
marginRight = "6px";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return `
|
|
54
|
+
width: ${width};
|
|
55
|
+
height: ${width};
|
|
56
|
+
margin-right: ${marginRight};
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
59
|
+
|
|
32
60
|
const StyledLoaderSquare = _styledComponents.default.div`
|
|
33
61
|
${({
|
|
34
62
|
theme,
|
|
@@ -39,9 +67,7 @@ const StyledLoaderSquare = _styledComponents.default.div`
|
|
|
39
67
|
animation: ${loaderAnimation} 1s infinite ease-in-out both;
|
|
40
68
|
background-color: ${theme.colors.primary};
|
|
41
69
|
display: inline-block;
|
|
42
|
-
|
|
43
|
-
width: ${size === "large" ? "16px" : "8px"};
|
|
44
|
-
margin-right: ${size === "large" ? "10px" : "6px"};
|
|
70
|
+
${getDimentions(size)}
|
|
45
71
|
|
|
46
72
|
${isInsideButton && (0, _styledComponents.css)`
|
|
47
73
|
background-color: ${isActive ? theme.colors.white : theme.colors.border};
|
|
@@ -47,14 +47,14 @@ const Loader = ({
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
Loader.defaultProps = {
|
|
50
|
-
size: "
|
|
50
|
+
size: "medium",
|
|
51
51
|
isInsideButton: false,
|
|
52
52
|
isActive: true
|
|
53
53
|
};
|
|
54
54
|
Loader.propTypes = { ...marginPropTypes,
|
|
55
55
|
|
|
56
56
|
/** Size of the loader. */
|
|
57
|
-
size: _propTypes.default.oneOf(["small", "large"]),
|
|
57
|
+
size: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
58
58
|
|
|
59
59
|
/** Applies white color. */
|
|
60
60
|
isInsideButton: _propTypes.default.bool,
|
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.LOADER_SIZES = void 0;
|
|
7
7
|
// eslint-disable-next-line import/prefer-default-export
|
|
8
|
-
const LOADER_SIZES = ["small", "large"];
|
|
8
|
+
const LOADER_SIZES = ["small", "medium", "large"];
|
|
9
9
|
exports.LOADER_SIZES = LOADER_SIZES;
|
|
@@ -2,7 +2,7 @@ import { MarginProps } from "styled-system";
|
|
|
2
2
|
|
|
3
3
|
export interface LoaderProps extends MarginProps {
|
|
4
4
|
/** Size of the loader. */
|
|
5
|
-
size?: "small" | "large";
|
|
5
|
+
size?: "small" | "medium" | "large";
|
|
6
6
|
/** Applies white color. */
|
|
7
7
|
isInsideButton?: boolean;
|
|
8
8
|
/** Applies slate color. Available only when isInsideButton is true. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./loader-bar";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _loaderBar.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _loaderBar = _interopRequireDefault(require("./loader-bar.component"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
|
|
13
|
+
|
|
14
|
+
var _tags = _interopRequireDefault(require("../../utils/helpers/tags"));
|
|
15
|
+
|
|
16
|
+
var _loaderBar = _interopRequireWildcard(require("./loader-bar.style"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("../../style/utils");
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _extends() { _extends = Object.assign || 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); }
|
|
27
|
+
|
|
28
|
+
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
29
|
+
|
|
30
|
+
const LoaderBar = ({
|
|
31
|
+
size = "medium",
|
|
32
|
+
...rest
|
|
33
|
+
}) => {
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement(_loaderBar.StyledLoader, _extends({}, rest, (0, _tags.default)("loader-bar", rest)), /*#__PURE__*/_react.default.createElement(_loaderBar.default, {
|
|
35
|
+
size: size
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement(_loaderBar.InnerBar, {
|
|
37
|
+
size: size
|
|
38
|
+
})));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
LoaderBar.propTypes = { ...marginPropTypes,
|
|
42
|
+
|
|
43
|
+
/** Size of the loader. */
|
|
44
|
+
size: _propTypes.default.oneOf(["small", "medium", "large"])
|
|
45
|
+
};
|
|
46
|
+
var _default = LoaderBar;
|
|
47
|
+
exports.default = _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LOADER_BAR_SIZES = void 0;
|
|
7
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
8
|
+
const LOADER_BAR_SIZES = ["small", "medium", "large"];
|
|
9
|
+
exports.LOADER_BAR_SIZES = LOADER_BAR_SIZES;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MarginProps } from "styled-system";
|
|
2
|
+
|
|
3
|
+
export interface LoaderBarProps extends MarginProps {
|
|
4
|
+
/** Size of the loaderBar. */
|
|
5
|
+
size?: "small" | "medium" | "large";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare function LoaderBar(props: LoaderBarProps): JSX.Element;
|
|
9
|
+
|
|
10
|
+
export default LoaderBar;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.StyledLoader = exports.InnerBar = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledSystem = require("styled-system");
|
|
13
|
+
|
|
14
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
15
|
+
|
|
16
|
+
var _loaderBar = require("./loader-bar.config");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
23
|
+
|
|
24
|
+
const INNER_BAR_LENGTH = "128px";
|
|
25
|
+
const OUTER_BAR_LENGTH = "256px";
|
|
26
|
+
const StyledLoader = _styledComponents.default.div`
|
|
27
|
+
${_styledSystem.margin}
|
|
28
|
+
text-align: center;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
line-height: 0;
|
|
31
|
+
font-size: 0;
|
|
32
|
+
`;
|
|
33
|
+
exports.StyledLoader = StyledLoader;
|
|
34
|
+
const innerBarAnimation = (0, _styledComponents.keyframes)`
|
|
35
|
+
0% {
|
|
36
|
+
left: -${INNER_BAR_LENGTH}
|
|
37
|
+
}
|
|
38
|
+
100% {
|
|
39
|
+
left: ${OUTER_BAR_LENGTH}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
const StyledLoaderBar = _styledComponents.default.div`
|
|
43
|
+
${({
|
|
44
|
+
size,
|
|
45
|
+
theme
|
|
46
|
+
}) => (0, _styledComponents.css)`
|
|
47
|
+
display: inline-block;
|
|
48
|
+
height: ${getHeight(size)};
|
|
49
|
+
width: ${OUTER_BAR_LENGTH};
|
|
50
|
+
background-color: ${theme.colors.loadingBarBackground};
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
position: relative;
|
|
53
|
+
`}
|
|
54
|
+
`;
|
|
55
|
+
const InnerBar = _styledComponents.default.div`
|
|
56
|
+
${({
|
|
57
|
+
theme,
|
|
58
|
+
size
|
|
59
|
+
}) => (0, _styledComponents.css)`
|
|
60
|
+
position: absolute;
|
|
61
|
+
background-color: ${theme.colors.primary};
|
|
62
|
+
width: ${INNER_BAR_LENGTH};
|
|
63
|
+
height: ${getHeight(size)};
|
|
64
|
+
animation: 2s ${innerBarAnimation} linear 0s infinite normal none running;
|
|
65
|
+
`}
|
|
66
|
+
`;
|
|
67
|
+
exports.InnerBar = InnerBar;
|
|
68
|
+
|
|
69
|
+
function getHeight(size) {
|
|
70
|
+
switch (size) {
|
|
71
|
+
case "small":
|
|
72
|
+
return "4px";
|
|
73
|
+
|
|
74
|
+
case "large":
|
|
75
|
+
return "16px";
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
return "8px";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
StyledLoader.defaultProps = {
|
|
83
|
+
theme: _base.default
|
|
84
|
+
};
|
|
85
|
+
StyledLoaderBar.defaultProps = {
|
|
86
|
+
theme: _base.default,
|
|
87
|
+
size: "medium"
|
|
88
|
+
};
|
|
89
|
+
InnerBar.defaultProps = {
|
|
90
|
+
theme: _base.default,
|
|
91
|
+
size: "medium"
|
|
92
|
+
};
|
|
93
|
+
StyledLoaderBar.propTypes = {
|
|
94
|
+
size: _propTypes.default.oneOf(_loaderBar.LOADER_BAR_SIZES)
|
|
95
|
+
};
|
|
96
|
+
var _default = StyledLoaderBar;
|
|
97
|
+
exports.default = _default;
|
|
@@ -9,165 +9,104 @@ Object.defineProperty(exports, "Page", {
|
|
|
9
9
|
return _page.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
exports.
|
|
12
|
+
exports.default = void 0;
|
|
13
13
|
|
|
14
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
|
|
18
18
|
var _reactTransitionGroup = require("react-transition-group");
|
|
19
19
|
|
|
20
|
-
var _lodash = require("lodash");
|
|
21
|
-
|
|
22
|
-
var _styledComponents = require("styled-components");
|
|
23
|
-
|
|
24
20
|
var _tags = _interopRequireDefault(require("../../utils/helpers/tags"));
|
|
25
21
|
|
|
26
22
|
var _page = _interopRequireDefault(require("./page/page.component"));
|
|
27
23
|
|
|
28
24
|
var _pages = require("./pages.style");
|
|
29
25
|
|
|
30
|
-
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
31
|
-
|
|
32
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
27
|
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
|
|
38
|
-
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, descriptor.key, descriptor); } }
|
|
39
|
-
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
-
|
|
42
|
-
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
28
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
45
29
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
49
|
-
|
|
50
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
-
|
|
52
|
-
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; } }
|
|
53
|
-
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
56
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
30
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
57
31
|
|
|
58
32
|
const NEXT = "next";
|
|
59
33
|
const PREVIOUS = "previous";
|
|
60
34
|
const TRANSITION_TIME = 500;
|
|
61
35
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
const Pages = ({
|
|
37
|
+
pageIndex: incomingPageIndex,
|
|
38
|
+
initialpageIndex = 0,
|
|
39
|
+
transition = "slide",
|
|
40
|
+
children,
|
|
41
|
+
...props
|
|
42
|
+
}) => {
|
|
43
|
+
const [pageIndex, setPageIndex] = (0, _react.useState)(Number(incomingPageIndex) || Number(initialpageIndex));
|
|
44
|
+
const transitionDirection = (0, _react.useRef)(NEXT);
|
|
45
|
+
|
|
46
|
+
const transitionName = () => {
|
|
47
|
+
if (transition === "slide") {
|
|
48
|
+
return `slide-${transitionDirection.current}`;
|
|
49
|
+
}
|
|
69
50
|
|
|
70
|
-
|
|
51
|
+
return `carousel-transition-${transition}`;
|
|
52
|
+
};
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
const handleVisiblePage = () => {
|
|
55
|
+
let index = pageIndex;
|
|
74
56
|
|
|
75
|
-
|
|
76
|
-
// Currently selected page
|
|
77
|
-
pageIndex: Number(_this.props.pageIndex) || Number(_this.props.initialpageIndex)
|
|
78
|
-
});
|
|
57
|
+
const visiblePage = _react.default.Children.toArray(children)[index];
|
|
79
58
|
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
index = visiblePage.props.id || index;
|
|
60
|
+
const additionalProps = {
|
|
61
|
+
transitionName,
|
|
62
|
+
timeout: TRANSITION_TIME,
|
|
63
|
+
"data-element": "visible-page",
|
|
64
|
+
key: `carbon-page-${visiblePage.props.id || pageIndex}`,
|
|
65
|
+
className: visiblePage.props.className
|
|
66
|
+
};
|
|
67
|
+
return /*#__PURE__*/_react.default.cloneElement(visiblePage, { ...visiblePage.props,
|
|
68
|
+
...additionalProps
|
|
82
69
|
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const numOfPages = (0, _react.useCallback)(() => {
|
|
73
|
+
return Array.isArray(children) ? children.length : 1;
|
|
74
|
+
}, [children]);
|
|
75
|
+
const verifyNewIndex = (0, _react.useCallback)(newIndex => {
|
|
76
|
+
if (newIndex < 0) {
|
|
77
|
+
// If the new index is negative, select the last page
|
|
78
|
+
return numOfPages() - 1;
|
|
79
|
+
}
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const additionalProps = {
|
|
89
|
-
transitionName: _this.transitionName,
|
|
90
|
-
timeout: TRANSITION_TIME,
|
|
91
|
-
"data-element": "visible-page",
|
|
92
|
-
key: `carbon-page-${index}`,
|
|
93
|
-
className: visiblePage.props.className
|
|
94
|
-
};
|
|
95
|
-
return /*#__PURE__*/_react.default.cloneElement(visiblePage, (0, _lodash.assign)({}, visiblePage.props, additionalProps));
|
|
96
|
-
});
|
|
81
|
+
if (newIndex > numOfPages() - 1) {
|
|
82
|
+
// If the new index is bigger than the number of slides, select the first page
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
97
85
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
return newIndex;
|
|
87
|
+
}, [numOfPages]);
|
|
88
|
+
(0, _react.useEffect)(() => {
|
|
89
|
+
if (typeof incomingPageIndex === "undefined") return;
|
|
90
|
+
const newIndex = verifyNewIndex(incomingPageIndex); // 2
|
|
102
91
|
|
|
103
|
-
|
|
104
|
-
});
|
|
92
|
+
const currentIndex = pageIndex; // 1
|
|
105
93
|
|
|
106
|
-
|
|
107
|
-
return _this;
|
|
108
|
-
}
|
|
94
|
+
if (newIndex === currentIndex) return;
|
|
109
95
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
function componentDidUpdate(prevProps) {
|
|
115
|
-
if (this.props.pageIndex === prevProps.pageIndex) return;
|
|
116
|
-
if (typeof this.props.pageIndex === "undefined") return;
|
|
117
|
-
const newIndex = this.verifyNewIndex(this.props.pageIndex);
|
|
118
|
-
const currentIndex = this.state.pageIndex;
|
|
119
|
-
if (newIndex === currentIndex) return;
|
|
120
|
-
|
|
121
|
-
if (newIndex > currentIndex) {
|
|
122
|
-
this.transitionDirection = NEXT;
|
|
123
|
-
} else {
|
|
124
|
-
this.transitionDirection = PREVIOUS;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
this.handleStateUpdate(newIndex);
|
|
96
|
+
if (newIndex > currentIndex) {
|
|
97
|
+
transitionDirection.current = NEXT;
|
|
98
|
+
} else {
|
|
99
|
+
transitionDirection.current = PREVIOUS;
|
|
128
100
|
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "handleStateUpdate",
|
|
131
|
-
value: function handleStateUpdate(newIndex) {
|
|
132
|
-
this.setState({
|
|
133
|
-
pageIndex: newIndex
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/** Verifies the new index and corrects it if necessary */
|
|
137
|
-
|
|
138
|
-
}, {
|
|
139
|
-
key: "verifyNewIndex",
|
|
140
|
-
value: function verifyNewIndex(newIndex) {
|
|
141
|
-
if (newIndex < 0) {
|
|
142
|
-
// If the new index is negative, select the last page
|
|
143
|
-
return this.numOfPages() - 1;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (newIndex > this.numOfPages() - 1) {
|
|
147
|
-
// If the new index is bigger than the number of slides, select the first page
|
|
148
|
-
return 0;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return newIndex;
|
|
152
|
-
}
|
|
153
|
-
/** Gets the number of slides */
|
|
154
|
-
|
|
155
|
-
}, {
|
|
156
|
-
key: "render",
|
|
157
|
-
value:
|
|
158
|
-
/** Renders the Slide Component */
|
|
159
|
-
function render() {
|
|
160
|
-
return /*#__PURE__*/_react.default.createElement(_pages.PagesWrapperStyle, _extends({
|
|
161
|
-
className: this.props.className
|
|
162
|
-
}, (0, _tags.default)("carousel", this.props)), /*#__PURE__*/_react.default.createElement(_pages.PagesContent, {
|
|
163
|
-
className: "carbon-carousel__content",
|
|
164
|
-
theme: this.props.theme
|
|
165
|
-
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, this.visiblePage())));
|
|
166
|
-
}
|
|
167
|
-
}]);
|
|
168
101
|
|
|
169
|
-
|
|
170
|
-
}
|
|
102
|
+
setPageIndex(newIndex);
|
|
103
|
+
}, [incomingPageIndex, pageIndex, verifyNewIndex]);
|
|
104
|
+
/** Renders the Slide Component */
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement(_pages.PagesWrapperStyle, (0, _tags.default)("carousel", props), /*#__PURE__*/_react.default.createElement(_pages.PagesContent, {
|
|
107
|
+
className: "carbon-carousel__content"
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, handleVisiblePage())));
|
|
109
|
+
};
|
|
171
110
|
|
|
172
111
|
Pages.propTypes = {
|
|
173
112
|
/** [legacy] Custom className */
|
|
@@ -181,17 +120,7 @@ Pages.propTypes = {
|
|
|
181
120
|
children: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object]),
|
|
182
121
|
|
|
183
122
|
/** Controls which transition to use. */
|
|
184
|
-
transition: _propTypes.default.string
|
|
185
|
-
|
|
186
|
-
/** theme is used only to support legacy code */
|
|
187
|
-
theme: _propTypes.default.object
|
|
188
|
-
};
|
|
189
|
-
Pages.defaultProps = {
|
|
190
|
-
initialpageIndex: 0,
|
|
191
|
-
transition: "slide",
|
|
192
|
-
theme: _base.default
|
|
123
|
+
transition: _propTypes.default.string
|
|
193
124
|
};
|
|
194
|
-
const PagesWithHOC = (0, _styledComponents.withTheme)(Pages);
|
|
195
|
-
exports.Pages = PagesWithHOC;
|
|
196
125
|
var _default = Pages;
|
|
197
126
|
exports.default = _default;
|
|
@@ -21,7 +21,8 @@ var _default = palette => {
|
|
|
21
21
|
whiteMix: palette.productBlueTint(90),
|
|
22
22
|
withOpacity: baseWithOpacity(0.55),
|
|
23
23
|
hoveredTabKeyline: palette.productBlueTint(30),
|
|
24
|
-
disabled: palette.productBlueTint(40)
|
|
24
|
+
disabled: palette.productBlueTint(40),
|
|
25
|
+
loadingBarBackground: palette.productBlueTint(70)
|
|
25
26
|
},
|
|
26
27
|
stepSequence: {
|
|
27
28
|
completedText: palette.productBlueShade(23)
|
|
@@ -26,6 +26,7 @@ var _default = palette => {
|
|
|
26
26
|
disabled: palette.genericGreenTint(40),
|
|
27
27
|
whiteMix: palette.genericGreenTint(90),
|
|
28
28
|
withOpacity: baseWithOpacity(0.55),
|
|
29
|
+
loadingBarBackground: palette.genericGreenTint(70),
|
|
29
30
|
// generic
|
|
30
31
|
black: "#000000",
|
|
31
32
|
slate: "#003349",
|
|
@@ -15,7 +15,8 @@ var _default = palette => {
|
|
|
15
15
|
tertiary: palette.productGreenShade(61),
|
|
16
16
|
whiteMix: palette.productGreenTint(90),
|
|
17
17
|
hoveredTabKeyline: palette.productGreenTint(30),
|
|
18
|
-
disabled: palette.productGreenTint(40)
|
|
18
|
+
disabled: palette.productGreenTint(40),
|
|
19
|
+
loadingBarBackground: palette.productGreenTint(70)
|
|
19
20
|
},
|
|
20
21
|
stepSequence: {
|
|
21
22
|
completedText: palette.productGreenShade(23)
|