@telefonica/mistica 11.7.0 → 11.10.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.
Files changed (57) hide show
  1. package/dist/avatar.d.ts +14 -0
  2. package/dist/avatar.js +239 -0
  3. package/dist/avatar.js.flow +16 -0
  4. package/dist/badge.d.ts +2 -0
  5. package/dist/badge.js +24 -7
  6. package/dist/badge.js.flow +2 -0
  7. package/dist/button.js +35 -10
  8. package/dist/image.d.ts +2 -0
  9. package/dist/image.js +68 -5
  10. package/dist/image.js.flow +2 -0
  11. package/dist/index.d.ts +5 -2
  12. package/dist/index.js +29 -2
  13. package/dist/index.js.flow +5 -2
  14. package/dist/package-version.js +1 -1
  15. package/dist/password-field.js +9 -8
  16. package/dist/placeholder.d.ts +0 -4
  17. package/dist/placeholder.js +1 -13
  18. package/dist/placeholder.js.flow +0 -4
  19. package/dist/section-title.d.ts +3 -0
  20. package/dist/section-title.js +3 -1
  21. package/dist/section-title.js.flow +3 -0
  22. package/dist/text-link.js +17 -5
  23. package/dist/text.js +8 -2
  24. package/dist/theme-context-provider.js +13 -8
  25. package/dist/theme.d.ts +3 -0
  26. package/dist/theme.js.flow +3 -0
  27. package/dist/title.d.ts +13 -0
  28. package/dist/title.js +87 -0
  29. package/dist/title.js.flow +18 -0
  30. package/dist/utils/__tests__/analytics-test.js +74 -0
  31. package/dist/utils/analytics.d.ts +14 -0
  32. package/dist/utils/analytics.js +50 -1
  33. package/dist/utils/analytics.js.flow +14 -0
  34. package/dist-es/avatar.js +208 -0
  35. package/dist-es/badge.js +24 -7
  36. package/dist-es/button.js +36 -11
  37. package/dist-es/image.js +69 -5
  38. package/dist-es/index.js +4 -1
  39. package/dist-es/package-version.js +1 -1
  40. package/dist-es/password-field.js +9 -8
  41. package/dist-es/placeholder.js +0 -11
  42. package/dist-es/section-title.js +3 -1
  43. package/dist-es/text-link.js +18 -6
  44. package/dist-es/text.js +8 -2
  45. package/dist-es/theme-context-provider.js +13 -8
  46. package/dist-es/title.js +54 -0
  47. package/dist-es/utils/__tests__/analytics-test.js +47 -0
  48. package/dist-es/utils/analytics.js +27 -0
  49. package/package.json +3 -3
  50. package/dist/icons/icon-visibility-off.d.ts +0 -7
  51. package/dist/icons/icon-visibility-off.js +0 -49
  52. package/dist/icons/icon-visibility-off.js.flow +0 -9
  53. package/dist/icons/icon-visibility.d.ts +0 -7
  54. package/dist/icons/icon-visibility.js +0 -49
  55. package/dist/icons/icon-visibility.js.flow +0 -9
  56. package/dist-es/icons/icon-visibility-off.js +0 -22
  57. package/dist-es/icons/icon-visibility.js +0 -22
@@ -91,6 +91,7 @@ import TabFocus from "./tab-focus";
91
91
  import ModalContextProvider from "./modal-context-provider";
92
92
  import { DocumentVisibilityProvider } from "./utils/document-visibility";
93
93
  import { AspectRatioSupportProvider } from "./utils/aspect-ratio-support";
94
+ import { TrackingConfig } from "./utils/analytics";
94
95
  var darkModeMedia = "(prefers-color-scheme: dark)";
95
96
  export var useIsOsDarkModeEnabled = function() {
96
97
  var ref = _slicedToArray(React.useState(false), 2), isDarkMode = ref[0], setIsDarkMode = ref[1];
@@ -173,7 +174,8 @@ var ThemeContextProvider = function(param) {
173
174
  analytics: _objectSpread({
174
175
  logEvent: function() {
175
176
  return Promise.resolve();
176
- }
177
+ },
178
+ eventFormat: "universal-analytics"
177
179
  }, theme.analytics),
178
180
  dimensions: _objectSpread({}, dimensions, theme.dimensions),
179
181
  mq: createMediaQueries((_mediaQueries = theme.mediaQueries) !== null && _mediaQueries !== void 0 ? _mediaQueries : mediaQueriesConfig),
@@ -196,13 +198,16 @@ var ThemeContextProvider = function(param) {
196
198
  children: /*#__PURE__*/ _jsx(ModalContextProvider, {
197
199
  children: /*#__PURE__*/ _jsx(ThemeContext.Provider, {
198
200
  value: contextTheme,
199
- children: /*#__PURE__*/ _jsx(AspectRatioSupportProvider, {
200
- children: /*#__PURE__*/ _jsx(DocumentVisibilityProvider, {
201
- children: /*#__PURE__*/ _jsx(AriaIdGetterContext.Provider, {
202
- value: getAriaId,
203
- children: /*#__PURE__*/ _jsx(ScreenSizeContextProvider, {
204
- children: /*#__PURE__*/ _jsx(DialogRoot, {
205
- children: children
201
+ children: /*#__PURE__*/ _jsx(TrackingConfig, {
202
+ eventFormat: contextTheme.analytics.eventFormat,
203
+ children: /*#__PURE__*/ _jsx(AspectRatioSupportProvider, {
204
+ children: /*#__PURE__*/ _jsx(DocumentVisibilityProvider, {
205
+ children: /*#__PURE__*/ _jsx(AriaIdGetterContext.Provider, {
206
+ value: getAriaId,
207
+ children: /*#__PURE__*/ _jsx(ScreenSizeContextProvider, {
208
+ children: /*#__PURE__*/ _jsx(DialogRoot, {
209
+ children: children
210
+ })
206
211
  })
207
212
  })
208
213
  })
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Text1, Text2, Text5 } from "./text";
4
+ import { useTheme } from "./hooks";
5
+ import Inline from "./inline";
6
+ import Box from "./box";
7
+ var TitleLayout = function(param) {
8
+ var title = param.title, right = param.right;
9
+ if (!right) {
10
+ return title;
11
+ }
12
+ return /*#__PURE__*/ _jsxs(Inline, {
13
+ space: "between",
14
+ alignItems: "baseline",
15
+ children: [
16
+ title,
17
+ /*#__PURE__*/ _jsx(Box, {
18
+ paddingLeft: 16,
19
+ children: /*#__PURE__*/ _jsx(Text2, {
20
+ regular: true,
21
+ children: right
22
+ })
23
+ })
24
+ ]
25
+ });
26
+ };
27
+ export var Title1 = function(param) {
28
+ var children = param.children, _as = param.as, as = _as === void 0 ? "h3" : _as, id = param.id, right = param.right, dataAttributes = param.dataAttributes;
29
+ var theme = useTheme();
30
+ return /*#__PURE__*/ _jsx(TitleLayout, {
31
+ title: /*#__PURE__*/ _jsx(Text1, {
32
+ color: theme.colors.textSecondary,
33
+ transform: "uppercase",
34
+ medium: true,
35
+ as: as,
36
+ id: id,
37
+ dataAttributes: dataAttributes,
38
+ children: children
39
+ }),
40
+ right: right
41
+ });
42
+ };
43
+ export var Title2 = function(param) {
44
+ var children = param.children, _as = param.as, as = _as === void 0 ? "h3" : _as, id = param.id, right = param.right, dataAttributes = param.dataAttributes;
45
+ return /*#__PURE__*/ _jsx(TitleLayout, {
46
+ title: /*#__PURE__*/ _jsx(Text5, {
47
+ as: as,
48
+ id: id,
49
+ dataAttributes: dataAttributes,
50
+ children: children
51
+ }),
52
+ right: right
53
+ });
54
+ };
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import ThemeContextProvider from "../../theme-context-provider";
4
+ import { render, screen } from "@testing-library/react";
5
+ import { makeTheme } from "../../__tests__/test-utils";
6
+ import { TrackingConfig, useTrackingConfig } from "../analytics";
7
+ var PrintEventFormat = function(param) {
8
+ var prefix = param.prefix;
9
+ var eventFormat = useTrackingConfig().eventFormat;
10
+ return /*#__PURE__*/ _jsx("div", {
11
+ children: "".concat(prefix, ": ").concat(eventFormat)
12
+ });
13
+ };
14
+ test("TrackingConfig context providers", function() {
15
+ render(/*#__PURE__*/ _jsxs(ThemeContextProvider, {
16
+ theme: makeTheme({
17
+ analytics: {
18
+ logEvent: function() {
19
+ return Promise.resolve();
20
+ },
21
+ eventFormat: "google-analytics-4"
22
+ }
23
+ }),
24
+ children: [
25
+ /*#__PURE__*/ _jsx(PrintEventFormat, {
26
+ prefix: "test1"
27
+ }),
28
+ /*#__PURE__*/ _jsxs(TrackingConfig, {
29
+ eventFormat: "universal-analytics",
30
+ children: [
31
+ /*#__PURE__*/ _jsx(PrintEventFormat, {
32
+ prefix: "test2"
33
+ }),
34
+ /*#__PURE__*/ _jsx(TrackingConfig, {
35
+ eventFormat: "google-analytics-4",
36
+ children: /*#__PURE__*/ _jsx(PrintEventFormat, {
37
+ prefix: "test3"
38
+ })
39
+ })
40
+ ]
41
+ })
42
+ ]
43
+ }));
44
+ expect(screen.getByText("test1: google-analytics-4")).toBeInTheDocument();
45
+ expect(screen.getByText("test2: universal-analytics")).toBeInTheDocument();
46
+ expect(screen.getByText("test3: google-analytics-4")).toBeInTheDocument();
47
+ });
@@ -1,6 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ // Universal Analytics (legacy)
1
4
  export var eventCategories = {
2
5
  userInteraction: "user_interaction"
3
6
  };
4
7
  export var eventActions = {
5
8
  linkTapped: "link_tapped"
6
9
  };
10
+ // Google analytics 4
11
+ export var eventNames = {
12
+ userInteraction: "user_interaction"
13
+ };
14
+ var TrackingContext = /*#__PURE__*/ React.createContext({
15
+ eventFormat: "universal-analytics"
16
+ });
17
+ export var TrackingConfig = function(param) {
18
+ var children = param.children, eventFormat = param.eventFormat;
19
+ var value = React.useMemo(function() {
20
+ return {
21
+ eventFormat: eventFormat
22
+ };
23
+ }, [
24
+ eventFormat
25
+ ]);
26
+ return /*#__PURE__*/ _jsx(TrackingContext.Provider, {
27
+ value: value,
28
+ children: children
29
+ });
30
+ };
31
+ export var useTrackingConfig = function() {
32
+ return React.useContext(TrackingContext);
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telefonica/mistica",
3
- "version": "11.7.0",
3
+ "version": "11.10.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,7 +77,7 @@
77
77
  "@swc/core": "^1.2.160",
78
78
  "@swc/jest": "^0.2.20",
79
79
  "@telefonica/acceptance-testing": "^2.7.0",
80
- "@telefonica/eslint-config": "^1.0.3",
80
+ "@telefonica/eslint-config": "^1.0.7",
81
81
  "@telefonica/prettier-config": "^1.1.0",
82
82
  "@telefonica/ts-to-flow": "1.2.0",
83
83
  "@testing-library/jest-dom": "^5.16.3",
@@ -123,7 +123,7 @@
123
123
  },
124
124
  "dependencies": {
125
125
  "@juggle/resize-observer": "^3.3.1",
126
- "@tef-novum/webview-bridge": "^3.4.0",
126
+ "@tef-novum/webview-bridge": "^3.7.0",
127
127
  "@telefonica/libphonenumber": "^2.8.1",
128
128
  "classnames": "^2.3.1",
129
129
  "jss": "^10.9.0",
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- declare type Props = {
3
- role?: string;
4
- size?: number;
5
- };
6
- declare const IconVisibilityOff: React.FC<Props>;
7
- export default IconVisibilityOff;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = void 0;
6
- var _jsxRuntime = require("react/jsx-runtime");
7
- var React = _interopRequireWildcard(require("react"));
8
- function _interopRequireWildcard(obj) {
9
- if (obj && obj.__esModule) {
10
- return obj;
11
- } else {
12
- var newObj = {};
13
- if (obj != null) {
14
- for(var key in obj){
15
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
16
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
17
- if (desc.get || desc.set) {
18
- Object.defineProperty(newObj, key, desc);
19
- } else {
20
- newObj[key] = obj[key];
21
- }
22
- }
23
- }
24
- }
25
- newObj.default = obj;
26
- return newObj;
27
- }
28
- }
29
- var IconVisibilityOff = function IconVisibilityOff(param) {
30
- var _role = param.role, role = _role === void 0 ? "presentation" : _role, _size = param.size, size = _size === void 0 ? 24 : _size;
31
- return /*#__PURE__*/ (0, _jsxRuntime).jsxs("svg", {
32
- role: role,
33
- width: size,
34
- height: size,
35
- viewBox: "0 0 ".concat(size, " ").concat(size),
36
- children: [
37
- /*#__PURE__*/ (0, _jsxRuntime).jsx("path", {
38
- d: "M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z",
39
- fill: "none"
40
- }),
41
- /*#__PURE__*/ (0, _jsxRuntime).jsx("path", {
42
- fill: "#757575",
43
- d: "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"
44
- })
45
- ]
46
- });
47
- };
48
- var _default = IconVisibilityOff;
49
- exports.default = _default;
@@ -1,9 +0,0 @@
1
- // @flow
2
-
3
- import * as React from "react";
4
- declare type Props = {
5
- role?: string,
6
- size?: number,
7
- };
8
- declare var IconVisibilityOff: React.ComponentType<Props>;
9
- declare export default typeof IconVisibilityOff;
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- declare type Props = {
3
- role?: string;
4
- size?: number;
5
- };
6
- declare const IconVisibility: React.FC<Props>;
7
- export default IconVisibility;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- exports.default = void 0;
6
- var _jsxRuntime = require("react/jsx-runtime");
7
- var React = _interopRequireWildcard(require("react"));
8
- function _interopRequireWildcard(obj) {
9
- if (obj && obj.__esModule) {
10
- return obj;
11
- } else {
12
- var newObj = {};
13
- if (obj != null) {
14
- for(var key in obj){
15
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
16
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
17
- if (desc.get || desc.set) {
18
- Object.defineProperty(newObj, key, desc);
19
- } else {
20
- newObj[key] = obj[key];
21
- }
22
- }
23
- }
24
- }
25
- newObj.default = obj;
26
- return newObj;
27
- }
28
- }
29
- var IconVisibility = function IconVisibility(param) {
30
- var _role = param.role, role = _role === void 0 ? "presentation" : _role, _size = param.size, size = _size === void 0 ? 24 : _size;
31
- return /*#__PURE__*/ (0, _jsxRuntime).jsxs("svg", {
32
- role: role,
33
- width: size,
34
- height: size,
35
- viewBox: "0 0 ".concat(size, " ").concat(size),
36
- children: [
37
- /*#__PURE__*/ (0, _jsxRuntime).jsx("path", {
38
- d: "M0 0h24v24H0z",
39
- fill: "none"
40
- }),
41
- /*#__PURE__*/ (0, _jsxRuntime).jsx("path", {
42
- fill: "#757575",
43
- d: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
44
- })
45
- ]
46
- });
47
- };
48
- var _default = IconVisibility;
49
- exports.default = _default;
@@ -1,9 +0,0 @@
1
- // @flow
2
-
3
- import * as React from "react";
4
- declare type Props = {
5
- role?: string,
6
- size?: number,
7
- };
8
- declare var IconVisibility: React.ComponentType<Props>;
9
- declare export default typeof IconVisibility;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- var IconVisibilityOff = function(param) {
4
- var _role = param.role, role = _role === void 0 ? "presentation" : _role, _size = param.size, size = _size === void 0 ? 24 : _size;
5
- return /*#__PURE__*/ _jsxs("svg", {
6
- role: role,
7
- width: size,
8
- height: size,
9
- viewBox: "0 0 ".concat(size, " ").concat(size),
10
- children: [
11
- /*#__PURE__*/ _jsx("path", {
12
- d: "M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z",
13
- fill: "none"
14
- }),
15
- /*#__PURE__*/ _jsx("path", {
16
- fill: "#757575",
17
- d: "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"
18
- })
19
- ]
20
- });
21
- };
22
- export default IconVisibilityOff;
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- var IconVisibility = function(param) {
4
- var _role = param.role, role = _role === void 0 ? "presentation" : _role, _size = param.size, size = _size === void 0 ? 24 : _size;
5
- return /*#__PURE__*/ _jsxs("svg", {
6
- role: role,
7
- width: size,
8
- height: size,
9
- viewBox: "0 0 ".concat(size, " ").concat(size),
10
- children: [
11
- /*#__PURE__*/ _jsx("path", {
12
- d: "M0 0h24v24H0z",
13
- fill: "none"
14
- }),
15
- /*#__PURE__*/ _jsx("path", {
16
- fill: "#757575",
17
- d: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
18
- })
19
- ]
20
- });
21
- };
22
- export default IconVisibility;