@telefonica/mistica 12.1.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/button-group.d.ts +2 -1
- package/dist/button-group.js +35 -4
- package/dist/button-group.js.flow +2 -1
- package/dist/button-layout.d.ts +2 -1
- package/dist/button-layout.js +22 -4
- package/dist/button-layout.js.flow +2 -1
- package/dist/button.js +110 -32
- package/dist/dialog.d.ts +21 -4
- package/dist/dialog.js +51 -26
- package/dist/dialog.js.flow +17 -4
- package/dist/generated/mistica-icons/icon-gift-light.js +1 -1
- package/dist/generated/mistica-icons/icon-hand-snap-filled.js +1 -1
- package/dist/generated/mistica-icons/icon-intranet-light.js +1 -1
- package/dist/generated/mistica-icons/icon-support-agent-premium-regular.js +1 -1
- package/dist/generated/mistica-icons/icon-support-agent-regular.js +1 -1
- package/dist/generated/mistica-icons/icon-tag-discount-euro-regular.js +1 -1
- package/dist/generated/mistica-icons/icon-tips-and-tricks-regular.js +2 -2
- package/dist/generated/mistica-icons/icon-world-device-filled.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-world-device-filled.js +109 -0
- package/dist/generated/mistica-icons/icon-world-device-filled.js.flow +6 -0
- package/dist/generated/mistica-icons/icon-world-device-light.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-world-device-light.js +115 -0
- package/dist/generated/mistica-icons/icon-world-device-light.js.flow +6 -0
- package/dist/generated/mistica-icons/icon-world-device-regular.d.ts +4 -0
- package/dist/generated/mistica-icons/icon-world-device-regular.js +109 -0
- package/dist/generated/mistica-icons/icon-world-device-regular.js.flow +6 -0
- package/dist/grid-layout.d.ts +16 -0
- package/dist/grid-layout.js +96 -35
- package/dist/grid-layout.js.flow +33 -1
- package/dist/header.d.ts +3 -1
- package/dist/header.js +4 -2
- package/dist/header.js.flow +7 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +58 -0
- package/dist/index.js.flow +11 -1
- package/dist/navigation-bar.js +121 -96
- package/dist/overscroll-color-context.d.ts +1 -1
- package/dist/overscroll-color-context.js +12 -14
- package/dist/overscroll-color-context.js.flow +1 -1
- package/dist/package-version.js +1 -1
- package/dist/skeleton-base.d.ts +9 -0
- package/dist/skeleton-base.js +75 -0
- package/dist/skeleton-base.js.flow +11 -0
- package/dist/skeletons.d.ts +21 -0
- package/dist/skeletons.js +232 -0
- package/dist/skeletons.js.flow +29 -0
- package/dist/skins/blau.js +1 -1
- package/dist/skins/movistar.js +1 -1
- package/dist/skins/o2-classic.js +1 -1
- package/dist/skins/o2.js +1 -1
- package/dist/skins/telefonica.js +2 -2
- package/dist/skins/utils.d.ts +2 -0
- package/dist/skins/utils.js +34 -1
- package/dist/skins/utils.js.flow +2 -0
- package/dist/skins/vivo.js +1 -1
- package/dist/tabs.d.ts +2 -1
- package/dist/tabs.js +22 -4
- package/dist/tabs.js.flow +2 -1
- package/dist-es/button-group.js +34 -4
- package/dist-es/button-layout.js +21 -4
- package/dist-es/button.js +110 -32
- package/dist-es/dialog.js +51 -25
- package/dist-es/generated/mistica-icons/icon-gift-light.js +1 -1
- package/dist-es/generated/mistica-icons/icon-hand-snap-filled.js +1 -1
- package/dist-es/generated/mistica-icons/icon-intranet-light.js +1 -1
- package/dist-es/generated/mistica-icons/icon-support-agent-premium-regular.js +1 -1
- package/dist-es/generated/mistica-icons/icon-support-agent-regular.js +1 -1
- package/dist-es/generated/mistica-icons/icon-tag-discount-euro-regular.js +1 -1
- package/dist-es/generated/mistica-icons/icon-tips-and-tricks-regular.js +2 -2
- package/dist-es/generated/mistica-icons/icon-world-device-filled.js +85 -0
- package/dist-es/generated/mistica-icons/icon-world-device-light.js +91 -0
- package/dist-es/generated/mistica-icons/icon-world-device-regular.js +85 -0
- package/dist-es/grid-layout.js +95 -35
- package/dist-es/header.js +4 -2
- package/dist-es/index.js +5 -1
- package/dist-es/navigation-bar.js +121 -96
- package/dist-es/overscroll-color-context.js +12 -14
- package/dist-es/package-version.js +1 -1
- package/dist-es/skeleton-base.js +43 -0
- package/dist-es/skeletons.js +196 -0
- package/dist-es/skins/blau.js +1 -1
- package/dist-es/skins/movistar.js +1 -1
- package/dist-es/skins/o2-classic.js +1 -1
- package/dist-es/skins/o2.js +1 -1
- package/dist-es/skins/telefonica.js +2 -2
- package/dist-es/skins/utils.js +12 -0
- package/dist-es/skins/vivo.js +1 -1
- package/dist-es/tabs.js +21 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+

|
|
2
|
+

|
|
3
3
|
|
|
4
4
|
React components library for Telefonica Design System ([Mistica](https://github.com/Telefonica/mistica))
|
|
5
5
|
|
package/dist/button-group.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ButtonLink, ButtonPrimary, ButtonSecondary } from './button';
|
|
3
|
-
import type { RendersNullableElement } from './utils/types';
|
|
3
|
+
import type { DataAttributes, RendersNullableElement } from './utils/types';
|
|
4
4
|
export interface ButtonGroupProps {
|
|
5
5
|
primaryButton?: RendersNullableElement<typeof ButtonPrimary>;
|
|
6
6
|
secondaryButton?: RendersNullableElement<typeof ButtonSecondary>;
|
|
7
7
|
link?: RendersNullableElement<typeof ButtonLink>;
|
|
8
|
+
dataAttributes?: DataAttributes;
|
|
8
9
|
}
|
|
9
10
|
declare const ButtonGroup: React.FC<ButtonGroupProps>;
|
|
10
11
|
export default ButtonGroup;
|
package/dist/button-group.js
CHANGED
|
@@ -7,6 +7,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _jss = require("./jss");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _dom = require("./utils/dom");
|
|
10
11
|
function _interopRequireDefault(obj) {
|
|
11
12
|
return obj && obj.__esModule ? obj : {
|
|
12
13
|
default: obj
|
|
@@ -33,6 +34,35 @@ function _interopRequireWildcard(obj) {
|
|
|
33
34
|
return newObj;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
function _defineProperty(obj, key, value) {
|
|
38
|
+
if (key in obj) {
|
|
39
|
+
Object.defineProperty(obj, key, {
|
|
40
|
+
value: value,
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
obj[key] = value;
|
|
47
|
+
}
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
function _objectSpread(target) {
|
|
51
|
+
var _arguments = arguments, _loop = function(i) {
|
|
52
|
+
var source = _arguments[i] != null ? _arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_defineProperty(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
for(var i = 1; i < arguments.length; i++)_loop(i);
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
36
66
|
var buttonLayoutSpacing = 16;
|
|
37
67
|
var buttonLinkPadding = 12;
|
|
38
68
|
var useStyles = (0, _jss).createUseStyles(function() {
|
|
@@ -65,14 +95,15 @@ var useStyles = (0, _jss).createUseStyles(function() {
|
|
|
65
95
|
};
|
|
66
96
|
});
|
|
67
97
|
var ButtonGroup = function ButtonGroup(param) {
|
|
68
|
-
var primaryButton = param.primaryButton, secondaryButton = param.secondaryButton, link = param.link;
|
|
98
|
+
var primaryButton = param.primaryButton, secondaryButton = param.secondaryButton, link = param.link, dataAttributes = param.dataAttributes;
|
|
69
99
|
var anyAction = !!primaryButton || !!secondaryButton || !!link;
|
|
70
100
|
var bothButtons = !!primaryButton && !!secondaryButton;
|
|
71
101
|
var classes = useStyles({
|
|
72
102
|
bothButtons: bothButtons
|
|
73
103
|
});
|
|
74
|
-
return anyAction ? /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
75
|
-
className: (0, _classnames).default(classes.inline, classes.container)
|
|
104
|
+
return anyAction ? /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", _objectSpread({
|
|
105
|
+
className: (0, _classnames).default(classes.inline, classes.container)
|
|
106
|
+
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
76
107
|
children: [
|
|
77
108
|
(primaryButton || secondaryButton) && /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
78
109
|
className: (0, _classnames).default(classes.inline, classes.buttons),
|
|
@@ -90,7 +121,7 @@ var ButtonGroup = function ButtonGroup(param) {
|
|
|
90
121
|
children: link
|
|
91
122
|
})
|
|
92
123
|
]
|
|
93
|
-
}) : null;
|
|
124
|
+
})) : null;
|
|
94
125
|
};
|
|
95
126
|
var _default = ButtonGroup;
|
|
96
127
|
exports.default = _default;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ButtonLink, ButtonPrimary, ButtonSecondary } from "./button";
|
|
5
|
-
import type { RendersNullableElement } from "./utils/types";
|
|
5
|
+
import type { DataAttributes, RendersNullableElement } from "./utils/types";
|
|
6
6
|
export type ButtonGroupProps = {
|
|
7
7
|
primaryButton?: RendersNullableElement<typeof ButtonPrimary>,
|
|
8
8
|
secondaryButton?: RendersNullableElement<typeof ButtonSecondary>,
|
|
9
9
|
link?: RendersNullableElement<typeof ButtonLink>,
|
|
10
|
+
dataAttributes?: DataAttributes,
|
|
10
11
|
};
|
|
11
12
|
declare var ButtonGroup: React.ComponentType<ButtonGroupProps>;
|
|
12
13
|
declare export default typeof ButtonGroup;
|
package/dist/button-layout.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ButtonLink } from './button';
|
|
3
|
-
import type { RendersNullableElement } from './utils/types';
|
|
3
|
+
import type { DataAttributes, RendersNullableElement } from './utils/types';
|
|
4
4
|
import type { NullableButtonElement } from './button';
|
|
5
5
|
declare type MaybeButtonElement = NullableButtonElement | void | false;
|
|
6
6
|
declare type ButtonLayoutProps = {
|
|
@@ -8,6 +8,7 @@ declare type ButtonLayoutProps = {
|
|
|
8
8
|
align?: 'center' | 'left' | 'right' | 'full-width';
|
|
9
9
|
link?: RendersNullableElement<typeof ButtonLink>;
|
|
10
10
|
withMargins?: boolean;
|
|
11
|
+
dataAttributes?: DataAttributes;
|
|
11
12
|
};
|
|
12
13
|
declare const ButtonLayout: React.FC<ButtonLayoutProps>;
|
|
13
14
|
export default ButtonLayout;
|
package/dist/button-layout.js
CHANGED
|
@@ -10,6 +10,7 @@ var _hooks = require("./hooks");
|
|
|
10
10
|
var _button = require("./button");
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
13
|
+
var _dom = require("./utils/dom");
|
|
13
14
|
function _interopRequireDefault(obj) {
|
|
14
15
|
return obj && obj.__esModule ? obj : {
|
|
15
16
|
default: obj
|
|
@@ -93,6 +94,22 @@ function _nonIterableRest() {
|
|
|
93
94
|
function _nonIterableSpread() {
|
|
94
95
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
95
96
|
}
|
|
97
|
+
function _objectSpread(target) {
|
|
98
|
+
var _arguments = arguments, _loop = function(i) {
|
|
99
|
+
var source = _arguments[i] != null ? _arguments[i] : {};
|
|
100
|
+
var ownKeys = Object.keys(source);
|
|
101
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
102
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
103
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
ownKeys.forEach(function(key) {
|
|
107
|
+
_defineProperty(target, key, source[key]);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
for(var i = 1; i < arguments.length; i++)_loop(i);
|
|
111
|
+
return target;
|
|
112
|
+
}
|
|
96
113
|
function _slicedToArray(arr, i) {
|
|
97
114
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
98
115
|
}
|
|
@@ -212,7 +229,7 @@ var buttonsRange = [
|
|
|
212
229
|
_button.ButtonPrimary
|
|
213
230
|
];
|
|
214
231
|
var ButtonLayout = function ButtonLayout(param1) {
|
|
215
|
-
var children = param1.children, _align = param1.align, align = _align === void 0 ? "full-width" : _align, link = param1.link, _withMargins = param1.withMargins, withMargins = _withMargins === void 0 ? false : _withMargins;
|
|
232
|
+
var children = param1.children, _align = param1.align, align = _align === void 0 ? "full-width" : _align, link = param1.link, _withMargins = param1.withMargins, withMargins = _withMargins === void 0 ? false : _withMargins, dataAttributes = param1.dataAttributes;
|
|
216
233
|
var isTabletOrSmaller = (0, _hooks).useScreenSize().isTabletOrSmaller;
|
|
217
234
|
var childrenCount = React.Children.count(children);
|
|
218
235
|
var ref = _slicedToArray(React.useState({
|
|
@@ -304,9 +321,10 @@ var ButtonLayout = function ButtonLayout(param1) {
|
|
|
304
321
|
return range1 - range2;
|
|
305
322
|
});
|
|
306
323
|
var needsLinkAlignment = !isTabletOrSmaller && align === "left";
|
|
307
|
-
var content = /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
324
|
+
var content = /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", _objectSpread({
|
|
308
325
|
ref: wrapperElRef,
|
|
309
|
-
className: classes.container
|
|
326
|
+
className: classes.container
|
|
327
|
+
}, (0, _dom).getPrefixedDataAttributes(dataAttributes), {
|
|
310
328
|
children: [
|
|
311
329
|
link ? /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
312
330
|
className: (0, _classnames).default(classes.link, _defineProperty({}, classes.linkAlignment, needsLinkAlignment)),
|
|
@@ -314,7 +332,7 @@ var ButtonLayout = function ButtonLayout(param1) {
|
|
|
314
332
|
}) : null,
|
|
315
333
|
sortedButtons
|
|
316
334
|
]
|
|
317
|
-
});
|
|
335
|
+
}));
|
|
318
336
|
return withMargins ? /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
319
337
|
className: classes.margins,
|
|
320
338
|
children: content
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ButtonLink } from "./button";
|
|
5
|
-
import type { RendersNullableElement } from "./utils/types";
|
|
5
|
+
import type { DataAttributes, RendersNullableElement } from "./utils/types";
|
|
6
6
|
import type { NullableButtonElement } from "./button";
|
|
7
7
|
declare type MaybeButtonElement = NullableButtonElement | void | false;
|
|
8
8
|
declare type ButtonLayoutProps = {
|
|
@@ -10,6 +10,7 @@ declare type ButtonLayoutProps = {
|
|
|
10
10
|
align?: "center" | "left" | "right" | "full-width",
|
|
11
11
|
link?: RendersNullableElement<typeof ButtonLink>,
|
|
12
12
|
withMargins?: boolean,
|
|
13
|
+
dataAttributes?: DataAttributes,
|
|
13
14
|
};
|
|
14
15
|
declare var ButtonLayout: React.ComponentType<ButtonLayoutProps>;
|
|
15
16
|
declare export default typeof ButtonLayout;
|
package/dist/button.js
CHANGED
|
@@ -17,6 +17,7 @@ var _box = _interopRequireDefault(require("./box"));
|
|
|
17
17
|
var _common = require("./utils/common");
|
|
18
18
|
var _analytics = require("./utils/analytics");
|
|
19
19
|
var _hooks = require("./hooks");
|
|
20
|
+
var _utils = require("./skins/utils");
|
|
20
21
|
function _interopRequireDefault(obj) {
|
|
21
22
|
return obj && obj.__esModule ? obj : {
|
|
22
23
|
default: obj
|
|
@@ -122,11 +123,15 @@ var BUTTON_MIN_WIDTH = 136;
|
|
|
122
123
|
exports.BUTTON_MIN_WIDTH = BUTTON_MIN_WIDTH;
|
|
123
124
|
var transitionTiming = "0.3s cubic-bezier(0.77, 0, 0.175, 1)";
|
|
124
125
|
var BORDER_PX = 1.5;
|
|
125
|
-
var
|
|
126
|
+
var ICON_MARGIN_PX = 8;
|
|
126
127
|
var X_PADDING_PX = 16 - BORDER_PX;
|
|
127
128
|
var Y_PADDING_PX = 12 - BORDER_PX;
|
|
128
129
|
var X_SMALL_PADDING_PX = 12 - BORDER_PX;
|
|
129
130
|
var Y_SMALL_PADDING_PX = 6 - BORDER_PX;
|
|
131
|
+
var ICON_SIZE = 24;
|
|
132
|
+
var SMALL_ICON_SIZE = 20;
|
|
133
|
+
var SPINNER_SIZE = 20;
|
|
134
|
+
var SMALL_SPINNER_SIZE = 16;
|
|
130
135
|
var commonClasses = function commonClasses() {
|
|
131
136
|
return {
|
|
132
137
|
button: {
|
|
@@ -134,7 +139,6 @@ var commonClasses = function commonClasses() {
|
|
|
134
139
|
position: "relative",
|
|
135
140
|
width: "auto",
|
|
136
141
|
minWidth: BUTTON_MIN_WIDTH,
|
|
137
|
-
textAlign: "center",
|
|
138
142
|
border: "".concat(BORDER_PX, "px solid transparent"),
|
|
139
143
|
borderRadius: 4,
|
|
140
144
|
overflow: "hidden",
|
|
@@ -169,6 +173,9 @@ var commonClasses = function commonClasses() {
|
|
|
169
173
|
}
|
|
170
174
|
},
|
|
171
175
|
textContent: {
|
|
176
|
+
display: "flex",
|
|
177
|
+
alignItems: "center",
|
|
178
|
+
justifyContent: "center",
|
|
172
179
|
padding: "".concat(Y_PADDING_PX, "px ").concat(X_PADDING_PX, "px"),
|
|
173
180
|
opacity: 1,
|
|
174
181
|
transition: "opacity ".concat(transitionTiming, ", transform ").concat(transitionTiming),
|
|
@@ -176,9 +183,7 @@ var commonClasses = function commonClasses() {
|
|
|
176
183
|
padding: "".concat(Y_SMALL_PADDING_PX, "px ").concat(X_SMALL_PADDING_PX, "px")
|
|
177
184
|
},
|
|
178
185
|
"& svg": {
|
|
179
|
-
|
|
180
|
-
verticalAlign: "bottom",
|
|
181
|
-
height: "100%"
|
|
186
|
+
display: "block"
|
|
182
187
|
}
|
|
183
188
|
},
|
|
184
189
|
isLoading: {
|
|
@@ -299,6 +304,48 @@ var useDangerButtonStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
299
304
|
inverse: dangerButtonStyles(theme)
|
|
300
305
|
});
|
|
301
306
|
});
|
|
307
|
+
var renderButtonContent = function renderButtonContent(param) {
|
|
308
|
+
var content = param.content, defaultIconSize = param.defaultIconSize, renderText = param.renderText;
|
|
309
|
+
var childrenArr = (0, _utils).flattenChildren(content);
|
|
310
|
+
var length = childrenArr.length;
|
|
311
|
+
var resultChildrenArr = [];
|
|
312
|
+
var accText = [];
|
|
313
|
+
var flushAccText = function flushAccText() {
|
|
314
|
+
resultChildrenArr.push(/*#__PURE__*/ (0, _jsxRuntime).jsx(React.Fragment, {
|
|
315
|
+
children: renderText(accText)
|
|
316
|
+
}, resultChildrenArr.length));
|
|
317
|
+
accText = [];
|
|
318
|
+
};
|
|
319
|
+
childrenArr.forEach(function(element, idx) {
|
|
320
|
+
var isFirstChild = idx === 0;
|
|
321
|
+
var isLastChild = idx === length - 1;
|
|
322
|
+
var isIconElement = /*#__PURE__*/ React.isValidElement(element);
|
|
323
|
+
if (isIconElement) {
|
|
324
|
+
if (accText.length) {
|
|
325
|
+
flushAccText();
|
|
326
|
+
}
|
|
327
|
+
var _size;
|
|
328
|
+
var sizeInPx = (_size = element.props.size) !== null && _size !== void 0 ? _size : defaultIconSize;
|
|
329
|
+
resultChildrenArr.push(/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
330
|
+
style: {
|
|
331
|
+
display: "flex",
|
|
332
|
+
alignItems: "center",
|
|
333
|
+
marginLeft: isFirstChild ? 0 : ICON_MARGIN_PX,
|
|
334
|
+
marginRight: isLastChild ? 0 : ICON_MARGIN_PX
|
|
335
|
+
},
|
|
336
|
+
children: /*#__PURE__*/ React.cloneElement(element, {
|
|
337
|
+
size: (0, _css).pxToRem(sizeInPx)
|
|
338
|
+
})
|
|
339
|
+
}, resultChildrenArr.length));
|
|
340
|
+
} else {
|
|
341
|
+
accText.push(element);
|
|
342
|
+
if (isLastChild) {
|
|
343
|
+
flushAccText();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
return resultChildrenArr;
|
|
348
|
+
};
|
|
302
349
|
var Button = function Button(props) {
|
|
303
350
|
var eventFormat = (0, _analytics).useTrackingConfig().eventFormat;
|
|
304
351
|
var ref = (0, _formContext).useForm(), formStatus = ref.formStatus, formId = ref.formId;
|
|
@@ -321,24 +368,6 @@ var Button = function Button(props) {
|
|
|
321
368
|
shouldRenderSpinner,
|
|
322
369
|
formStatus
|
|
323
370
|
]);
|
|
324
|
-
var spinnerSizeRem = (0, _css).pxToRem(props.small ? 16 : 24);
|
|
325
|
-
var renderText = function renderText(text) {
|
|
326
|
-
return props.small ? /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text, {
|
|
327
|
-
size: 14,
|
|
328
|
-
lineHeight: 20,
|
|
329
|
-
weight: "medium",
|
|
330
|
-
truncate: 1,
|
|
331
|
-
color: "inherit",
|
|
332
|
-
as: "div",
|
|
333
|
-
children: text
|
|
334
|
-
}) : /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text3, {
|
|
335
|
-
medium: true,
|
|
336
|
-
truncate: 1,
|
|
337
|
-
color: "inherit",
|
|
338
|
-
as: "div",
|
|
339
|
-
children: text
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
371
|
var createDefaultTrackingEvent = function createDefaultTrackingEvent() {
|
|
343
372
|
if (eventFormat === "google-analytics-4") {
|
|
344
373
|
return {
|
|
@@ -354,6 +383,25 @@ var Button = function Button(props) {
|
|
|
354
383
|
};
|
|
355
384
|
}
|
|
356
385
|
};
|
|
386
|
+
var defaultIconSize = props.small ? SMALL_ICON_SIZE : ICON_SIZE;
|
|
387
|
+
var spinnerSizeRem = (0, _css).pxToRem(props.small ? SMALL_SPINNER_SIZE : SPINNER_SIZE);
|
|
388
|
+
var renderText = function renderText(element) {
|
|
389
|
+
return props.small ? /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text, {
|
|
390
|
+
size: 14,
|
|
391
|
+
lineHeight: 20,
|
|
392
|
+
weight: "medium",
|
|
393
|
+
truncate: 1,
|
|
394
|
+
color: "inherit",
|
|
395
|
+
as: "div",
|
|
396
|
+
children: element
|
|
397
|
+
}) : /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text3, {
|
|
398
|
+
medium: true,
|
|
399
|
+
truncate: 1,
|
|
400
|
+
color: "inherit",
|
|
401
|
+
as: "div",
|
|
402
|
+
children: element
|
|
403
|
+
});
|
|
404
|
+
};
|
|
357
405
|
var _trackingEvent;
|
|
358
406
|
var _obj;
|
|
359
407
|
var commonProps = {
|
|
@@ -371,16 +419,24 @@ var Button = function Button(props) {
|
|
|
371
419
|
/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
372
420
|
"aria-hidden": showSpinner ? true : undefined,
|
|
373
421
|
className: classes.textContent,
|
|
374
|
-
children:
|
|
422
|
+
children: renderButtonContent({
|
|
423
|
+
content: props.children,
|
|
424
|
+
defaultIconSize: defaultIconSize,
|
|
425
|
+
renderText: renderText
|
|
426
|
+
})
|
|
375
427
|
}),
|
|
376
428
|
/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
377
429
|
className: classes.loadingFiller,
|
|
378
430
|
"aria-hidden": true,
|
|
379
431
|
style: {
|
|
380
432
|
paddingLeft: spinnerSizeRem,
|
|
381
|
-
paddingRight:
|
|
433
|
+
paddingRight: ICON_MARGIN_PX + 2 * (props.small ? X_SMALL_PADDING_PX : X_PADDING_PX)
|
|
382
434
|
},
|
|
383
|
-
children:
|
|
435
|
+
children: renderButtonContent({
|
|
436
|
+
content: loadingText,
|
|
437
|
+
defaultIconSize: defaultIconSize,
|
|
438
|
+
renderText: renderText
|
|
439
|
+
})
|
|
384
440
|
}),
|
|
385
441
|
/*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
|
|
386
442
|
"aria-hidden": showSpinner ? undefined : true,
|
|
@@ -405,7 +461,11 @@ var Button = function Button(props) {
|
|
|
405
461
|
}),
|
|
406
462
|
loadingText ? /*#__PURE__*/ (0, _jsxRuntime).jsx(_box.default, {
|
|
407
463
|
paddingLeft: 8,
|
|
408
|
-
children:
|
|
464
|
+
children: renderButtonContent({
|
|
465
|
+
content: loadingText,
|
|
466
|
+
defaultIconSize: defaultIconSize,
|
|
467
|
+
renderText: renderText
|
|
468
|
+
})
|
|
409
469
|
}) : null
|
|
410
470
|
]
|
|
411
471
|
})
|
|
@@ -482,6 +542,14 @@ var useButtonLinkStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
482
542
|
}),
|
|
483
543
|
"&[disabled]": disabledStyle
|
|
484
544
|
},
|
|
545
|
+
textContent: {
|
|
546
|
+
display: "flex",
|
|
547
|
+
alignItems: "center",
|
|
548
|
+
justifyContent: "center",
|
|
549
|
+
"& svg": {
|
|
550
|
+
display: "block"
|
|
551
|
+
}
|
|
552
|
+
},
|
|
485
553
|
inverse: {
|
|
486
554
|
color: theme.colors.textLinkInverse,
|
|
487
555
|
"&:enabled:active": {
|
|
@@ -518,17 +586,27 @@ var ButtonLink = /*#__PURE__*/ React.forwardRef(function(props, ref) {
|
|
|
518
586
|
};
|
|
519
587
|
}
|
|
520
588
|
};
|
|
589
|
+
var renderText = function renderText(element) {
|
|
590
|
+
return /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
|
|
591
|
+
medium: true,
|
|
592
|
+
truncate: 1,
|
|
593
|
+
color: "inherit",
|
|
594
|
+
children: element
|
|
595
|
+
});
|
|
596
|
+
};
|
|
521
597
|
var _trackingEvent;
|
|
522
598
|
var _obj;
|
|
523
599
|
var commonProps = {
|
|
524
600
|
className: (0, _classnames).default(classes.link, (_obj = {}, _defineProperty(_obj, classes.inverse, isInverse), _defineProperty(_obj, classes.aligned, props.aligned), _obj)),
|
|
525
601
|
trackingEvent: (_trackingEvent = props.trackingEvent) !== null && _trackingEvent !== void 0 ? _trackingEvent : props.trackEvent ? createDefaultTrackingEvent() : undefined,
|
|
526
602
|
dataAttributes: props.dataAttributes,
|
|
527
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
603
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
604
|
+
className: classes.textContent,
|
|
605
|
+
children: renderButtonContent({
|
|
606
|
+
content: props.children,
|
|
607
|
+
defaultIconSize: SMALL_ICON_SIZE,
|
|
608
|
+
renderText: renderText
|
|
609
|
+
})
|
|
532
610
|
}),
|
|
533
611
|
disabled: props.disabled || formStatus === "sending"
|
|
534
612
|
};
|
package/dist/dialog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
interface
|
|
2
|
+
interface BaseDialogProps {
|
|
3
3
|
className?: string;
|
|
4
4
|
title?: string;
|
|
5
5
|
icon?: React.ReactElement;
|
|
@@ -11,11 +11,24 @@ interface DialogProps {
|
|
|
11
11
|
showCancel?: boolean;
|
|
12
12
|
destructive?: boolean;
|
|
13
13
|
}
|
|
14
|
+
interface AlertProps extends BaseDialogProps {
|
|
15
|
+
extra?: undefined;
|
|
16
|
+
forceWeb?: undefined;
|
|
17
|
+
}
|
|
18
|
+
interface ConfirmProps extends BaseDialogProps {
|
|
19
|
+
extra?: undefined;
|
|
20
|
+
forceWeb?: undefined;
|
|
21
|
+
}
|
|
22
|
+
interface ExtendedDialogProps extends BaseDialogProps {
|
|
23
|
+
extra: React.ReactNode;
|
|
24
|
+
forceWeb?: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare type DialogProps = AlertProps | ConfirmProps | ExtendedDialogProps;
|
|
14
27
|
declare type DialogRootProps = {
|
|
15
28
|
children?: React.ReactNode;
|
|
16
29
|
};
|
|
17
30
|
declare type DialogRootState = {
|
|
18
|
-
dialogProps:
|
|
31
|
+
dialogProps: BaseDialogProps | null;
|
|
19
32
|
isClosing: boolean;
|
|
20
33
|
instanceNumber: number;
|
|
21
34
|
};
|
|
@@ -35,9 +48,13 @@ export default class DialogRoot extends React.Component<DialogRootProps, DialogR
|
|
|
35
48
|
/**
|
|
36
49
|
* Shows alert dialog with supplied props
|
|
37
50
|
*/
|
|
38
|
-
export declare const alert: (props:
|
|
51
|
+
export declare const alert: (props: AlertProps) => void;
|
|
39
52
|
/**
|
|
40
53
|
* Shows confirm dialog with supplied props
|
|
41
54
|
*/
|
|
42
|
-
export declare const confirm: (props:
|
|
55
|
+
export declare const confirm: (props: ConfirmProps) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Shows dialog with supplied props
|
|
58
|
+
*/
|
|
59
|
+
export declare const dialog: (props: ExtendedDialogProps) => void;
|
|
43
60
|
export {};
|
package/dist/dialog.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.confirm = exports.alert = exports.default = void 0;
|
|
5
|
+
exports.dialog = exports.confirm = exports.alert = exports.default = void 0;
|
|
6
6
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -21,6 +21,7 @@ var _keyCodes = require("./utils/key-codes");
|
|
|
21
21
|
var _box = _interopRequireDefault(require("./box"));
|
|
22
22
|
var _platform = require("./utils/platform");
|
|
23
23
|
var _modalContextProvider = require("./modal-context-provider");
|
|
24
|
+
var _stack = _interopRequireDefault(require("./stack"));
|
|
24
25
|
function _interopRequireDefault(obj) {
|
|
25
26
|
return obj && obj.__esModule ? obj : {
|
|
26
27
|
default: obj
|
|
@@ -270,7 +271,7 @@ var useDialogStyles = (0, _jss).createUseStyles(function(theme) {
|
|
|
270
271
|
});
|
|
271
272
|
var Dialog = function Dialog(props) {
|
|
272
273
|
var ref = (0, _hooks).useTheme(), texts = ref.texts, colors = ref.colors;
|
|
273
|
-
var className = props.className, title = props.title, message = props.message, icon = props.icon, _cancelText = props.cancelText, cancelText = _cancelText === void 0 ? texts.dialogCancelButton : _cancelText, _acceptText = props.acceptText, acceptText = _acceptText === void 0 ? texts.dialogAcceptButton : _acceptText, handleCancel = props.onCancel, handleAccept = props.onAccept, _showCancel = props.showCancel, showCancel = _showCancel === void 0 ? false : _showCancel, _destructive = props.destructive, destructive = _destructive === void 0 ? false : _destructive;
|
|
274
|
+
var className = props.className, title = props.title, message = props.message, icon = props.icon, extra = props.extra, _cancelText = props.cancelText, cancelText = _cancelText === void 0 ? texts.dialogCancelButton : _cancelText, _acceptText = props.acceptText, acceptText = _acceptText === void 0 ? texts.dialogAcceptButton : _acceptText, handleCancel = props.onCancel, handleAccept = props.onAccept, _showCancel = props.showCancel, showCancel = _showCancel === void 0 ? false : _showCancel, _destructive = props.destructive, destructive = _destructive === void 0 ? false : _destructive;
|
|
274
275
|
var isTabletOrSmaller = (0, _hooks).useScreenSize().isTabletOrSmaller;
|
|
275
276
|
var withSecondaryButton = showCancel && !!handleCancel;
|
|
276
277
|
var classes = useDialogStyles({
|
|
@@ -299,10 +300,16 @@ var Dialog = function Dialog(props) {
|
|
|
299
300
|
}),
|
|
300
301
|
/*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
301
302
|
className: classes.dialogContent,
|
|
302
|
-
children: /*#__PURE__*/ (0, _jsxRuntime).
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
children: /*#__PURE__*/ (0, _jsxRuntime).jsxs(_stack.default, {
|
|
304
|
+
space: 16,
|
|
305
|
+
children: [
|
|
306
|
+
/*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text3, {
|
|
307
|
+
color: colors.textSecondary,
|
|
308
|
+
light: true,
|
|
309
|
+
children: message
|
|
310
|
+
}),
|
|
311
|
+
extra
|
|
312
|
+
]
|
|
306
313
|
})
|
|
307
314
|
}),
|
|
308
315
|
/*#__PURE__*/ (0, _jsxRuntime).jsx(_box.default, {
|
|
@@ -372,6 +379,19 @@ var useNativeDialog = function useNativeDialog(param) {
|
|
|
372
379
|
renderNative
|
|
373
380
|
]);
|
|
374
381
|
};
|
|
382
|
+
var NativeModalDialog = function NativeModalDialog(props) {
|
|
383
|
+
useNativeDialog({
|
|
384
|
+
renderNative: true,
|
|
385
|
+
acceptText: props.acceptText || props.dialogAcceptButton,
|
|
386
|
+
cancelText: props.cancelText || props.dialogCancelButton,
|
|
387
|
+
showCancel: props.showCancel,
|
|
388
|
+
message: props.message,
|
|
389
|
+
title: props.title,
|
|
390
|
+
onAccept: props.onAccept,
|
|
391
|
+
onCancel: props.onCancel
|
|
392
|
+
});
|
|
393
|
+
return null;
|
|
394
|
+
};
|
|
375
395
|
var ModalDialog = function ModalDialog(props) {
|
|
376
396
|
var platformOverrides = (0, _hooks).useTheme().platformOverrides;
|
|
377
397
|
var context = React.useContext(_themeContext.default);
|
|
@@ -383,7 +403,7 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
383
403
|
if (!context) {
|
|
384
404
|
throw Error("To use @telefonica/mistica components you must instantiate <ThemeContextProvider> as their parent.");
|
|
385
405
|
}
|
|
386
|
-
var renderNative = (0, _webviewBridge).isWebViewBridgeAvailable();
|
|
406
|
+
var renderNative = !props.forceWeb && (0, _webviewBridge).isWebViewBridgeAvailable();
|
|
387
407
|
var onAccept = props.onAccept, isClosing = props.isClosing, onCancel = props.onCancel, onCloseTransitionEnd = props.onCloseTransitionEnd, dialogProps = _objectWithoutProperties(props, [
|
|
388
408
|
"onAccept",
|
|
389
409
|
"isClosing",
|
|
@@ -427,16 +447,6 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
427
447
|
}, [
|
|
428
448
|
handleKeyDown
|
|
429
449
|
]);
|
|
430
|
-
useNativeDialog({
|
|
431
|
-
renderNative: renderNative,
|
|
432
|
-
acceptText: props.acceptText || context.texts.dialogAcceptButton,
|
|
433
|
-
cancelText: props.cancelText || context.texts.dialogCancelButton,
|
|
434
|
-
showCancel: props.showCancel,
|
|
435
|
-
message: props.message,
|
|
436
|
-
title: props.title,
|
|
437
|
-
onAccept: props.onAccept,
|
|
438
|
-
onCancel: props.onCancel
|
|
439
|
-
});
|
|
440
450
|
React.useEffect(function() {
|
|
441
451
|
if (!animationsSupported(platformOverrides)) {
|
|
442
452
|
addKeyDownListener();
|
|
@@ -468,7 +478,10 @@ var ModalDialog = function ModalDialog(props) {
|
|
|
468
478
|
setModalState
|
|
469
479
|
]);
|
|
470
480
|
var _modalClose;
|
|
471
|
-
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-static-element-interactions */ return renderNative ?
|
|
481
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-static-element-interactions */ return renderNative ? /*#__PURE__*/ (0, _jsxRuntime).jsx(NativeModalDialog, _objectSpread({}, props, {
|
|
482
|
+
dialogAcceptButton: context.texts.dialogAcceptButton,
|
|
483
|
+
dialogCancelButton: context.texts.dialogCancelButton
|
|
484
|
+
})) : /*#__PURE__*/ (0, _jsxRuntime).jsx(_portal.Portal, {
|
|
472
485
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
|
|
473
486
|
className: classes.wrapper,
|
|
474
487
|
children: /*#__PURE__*/ (0, _jsxRuntime).jsx(_focusTrap.default, {
|
|
@@ -606,13 +619,13 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
|
|
|
606
619
|
};
|
|
607
620
|
_proto.render = function render() {
|
|
608
621
|
var _state = this.state, isClosing = _state.isClosing, dialogProps = _state.dialogProps;
|
|
609
|
-
var
|
|
622
|
+
var dialog1 = null;
|
|
610
623
|
if (dialogProps && this.state.instanceNumber === 1) {
|
|
611
624
|
var onCancel = dialogProps.onCancel, onAccept = dialogProps.onAccept, rest = _objectWithoutProperties(dialogProps, [
|
|
612
625
|
"onCancel",
|
|
613
626
|
"onAccept"
|
|
614
627
|
]);
|
|
615
|
-
|
|
628
|
+
dialog1 = /*#__PURE__*/ (0, _jsxRuntime).jsx(ModalDialog, _objectSpread({
|
|
616
629
|
onCancel: this.createCancelHandler(onCancel),
|
|
617
630
|
onAccept: this.createAcceptHandler(onAccept),
|
|
618
631
|
isClosing: isClosing,
|
|
@@ -622,25 +635,37 @@ var DialogRoot = /*#__PURE__*/ function(_Component) {
|
|
|
622
635
|
return /*#__PURE__*/ (0, _jsxRuntime).jsxs(_jsxRuntime.Fragment, {
|
|
623
636
|
children: [
|
|
624
637
|
this.props.children,
|
|
625
|
-
|
|
638
|
+
dialog1
|
|
626
639
|
]
|
|
627
640
|
});
|
|
628
641
|
};
|
|
629
642
|
return DialogRoot1;
|
|
630
643
|
}(React.Component);
|
|
631
644
|
exports.default = DialogRoot;
|
|
632
|
-
var showDialog = function showDialog() {
|
|
633
|
-
var showCancel =
|
|
645
|
+
var showDialog = function showDialog(param) {
|
|
646
|
+
var showCancel = param.showCancel, forceWeb = param.forceWeb;
|
|
634
647
|
return function(props) {
|
|
635
648
|
if (!dialogInstance) {
|
|
636
649
|
throw Error("Tried to show a dialog but the DialogRoot component was not mounted (mount <ThemeContextProvider>)");
|
|
637
650
|
}
|
|
638
651
|
dialogInstance.show(_objectSpread({
|
|
639
|
-
showCancel: showCancel
|
|
652
|
+
showCancel: showCancel,
|
|
653
|
+
forceWeb: forceWeb
|
|
640
654
|
}, props));
|
|
641
655
|
};
|
|
642
656
|
};
|
|
643
|
-
var alert = showDialog(
|
|
657
|
+
var alert = showDialog({
|
|
658
|
+
showCancel: false,
|
|
659
|
+
forceWeb: false
|
|
660
|
+
});
|
|
644
661
|
exports.alert = alert;
|
|
645
|
-
var confirm = showDialog(
|
|
662
|
+
var confirm = showDialog({
|
|
663
|
+
showCancel: true,
|
|
664
|
+
forceWeb: false
|
|
665
|
+
});
|
|
646
666
|
exports.confirm = confirm;
|
|
667
|
+
var dialog = showDialog({
|
|
668
|
+
showCancel: false,
|
|
669
|
+
forceWeb: true
|
|
670
|
+
});
|
|
671
|
+
exports.dialog = dialog;
|