@pingux/astro 2.191.0-alpha.0 → 2.191.1-alpha.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.
@@ -20,6 +20,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
20
20
  var _react = _interopRequireWildcard(require("react"));
21
21
  var _hooks = require("../../hooks");
22
22
  var _index = require("../../index");
23
+ var _constants = require("../Avatar/constants");
24
+ var _getColorFromUuid = _interopRequireDefault(require("../Avatar/getColorFromUuid"));
23
25
  var _react2 = require("@emotion/react");
24
26
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
25
27
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -33,8 +35,19 @@ var IconWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
33
35
  title = props.title,
34
36
  className = props.className,
35
37
  isCircle = props.isCircle,
38
+ colorId = props.colorId,
36
39
  sx = props.sx;
37
40
  var theme = (0, _hooks.useGetTheme)();
41
+ var safeColorId = colorId || '_INTERNAL_DEFAULT_ID_';
42
+ if (process.env.NODE_ENV !== 'production') {
43
+ if (!color && !colorId) {
44
+ console.warn("[Astro] IconWrapper: No 'color' or 'colorId' provided. " + 'The component is falling back to a default generated color.');
45
+ }
46
+ }
47
+ var finalColor = (0, _react.useMemo)(function () {
48
+ if (color) return color;
49
+ return (0, _getColorFromUuid["default"])(safeColorId, _constants.avatarColors);
50
+ }, [color, safeColorId]);
38
51
  var _useTShirtSize = (0, _hooks.useTShirtSize)({
39
52
  size: size,
40
53
  sizes: theme.iconWrapperSizes
@@ -48,14 +61,14 @@ var IconWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
48
61
  ref: ref,
49
62
  variant: "iconWrapper.".concat(size),
50
63
  sx: _objectSpread({
51
- backgroundColor: "iconWrapper.wrapper.".concat(color)
64
+ backgroundColor: "iconWrapper.wrapper.".concat(finalColor)
52
65
  }, sx),
53
66
  className: classNames
54
67
  }, wrapperProps), (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
55
68
  icon: icon,
56
69
  size: sizeProps.size,
57
70
  title: title,
58
- color: "iconWrapper.icon.".concat(color)
71
+ color: "iconWrapper.icon.".concat(finalColor)
59
72
  }, iconProps)));
60
73
  });
61
74
  var _default = exports["default"] = IconWrapper;
@@ -17,7 +17,8 @@ var defaultProps = {
17
17
  name: 'earth icon'
18
18
  },
19
19
  icon: _EarthIcon["default"],
20
- size: 'md'
20
+ size: 'md',
21
+ colorId: 'test-color-id'
21
22
  };
22
23
  var getComponent = function getComponent() {
23
24
  return (0, _react2.render)((0, _react3.jsx)(_IconWrapper["default"], (0, _extends2["default"])({}, defaultProps, {
@@ -385,15 +385,13 @@ var InfiniteLoadingList = exports.InfiniteLoadingList = function InfiniteLoading
385
385
  return (0, _react2.jsx)(_2.Item, {
386
386
  key: item.name
387
387
  }, (0, _react2.jsx)(_2.ListViewItem, {
388
+ id: item.name,
388
389
  data: {
389
390
  text: item.name,
390
391
  icon: _FormSelectIcon["default"]
391
392
  },
392
393
  iconProps: {
393
394
  color: 'text.secondary'
394
- },
395
- iconWrapperProps: {
396
- color: 'cyan'
397
395
  }
398
396
  }, (0, _react2.jsx)(Controls, null)));
399
397
  }));
@@ -69,7 +69,7 @@ var ListViewItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
69
69
  name: (0, _concat["default"])(_context = "".concat(text)).call(_context, LIST_ITEM_ICON)
70
70
  },
71
71
  isCircle: true,
72
- color: "white"
72
+ colorId: others.id
73
73
  }, iconWrapperProps)) : (0, _react2.jsx)(_.Box, {
74
74
  width: "25px",
75
75
  variant: "listViewItem.iconContainer"
@@ -9,6 +9,7 @@ export interface IconWrapperProps extends StyleProps {
9
9
  size: string;
10
10
  className?: string;
11
11
  isCircle?: boolean;
12
+ colorId?: string | null;
12
13
  title?: {
13
14
  name: string;
14
15
  id?: string;
@@ -10,9 +10,11 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
10
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
11
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
13
- import React, { forwardRef } from 'react';
13
+ import React, { forwardRef, useMemo } from 'react';
14
14
  import { useGetTheme, useStatusClasses, useTShirtSize } from '../../hooks';
15
15
  import { Box, Icon } from '../../index';
16
+ import { avatarColors } from '../Avatar/constants';
17
+ import getColorFromUUID from '../Avatar/getColorFromUuid';
16
18
  import { jsx as ___EmotionJSX } from "@emotion/react";
17
19
  var IconWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
18
20
  var icon = props.icon,
@@ -23,8 +25,19 @@ var IconWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
23
25
  title = props.title,
24
26
  className = props.className,
25
27
  isCircle = props.isCircle,
28
+ colorId = props.colorId,
26
29
  sx = props.sx;
27
30
  var theme = useGetTheme();
31
+ var safeColorId = colorId || '_INTERNAL_DEFAULT_ID_';
32
+ if (process.env.NODE_ENV !== 'production') {
33
+ if (!color && !colorId) {
34
+ console.warn("[Astro] IconWrapper: No 'color' or 'colorId' provided. " + 'The component is falling back to a default generated color.');
35
+ }
36
+ }
37
+ var finalColor = useMemo(function () {
38
+ if (color) return color;
39
+ return getColorFromUUID(safeColorId, avatarColors);
40
+ }, [color, safeColorId]);
28
41
  var _useTShirtSize = useTShirtSize({
29
42
  size: size,
30
43
  sizes: theme.iconWrapperSizes
@@ -38,14 +51,14 @@ var IconWrapper = /*#__PURE__*/forwardRef(function (props, ref) {
38
51
  ref: ref,
39
52
  variant: "iconWrapper.".concat(size),
40
53
  sx: _objectSpread({
41
- backgroundColor: "iconWrapper.wrapper.".concat(color)
54
+ backgroundColor: "iconWrapper.wrapper.".concat(finalColor)
42
55
  }, sx),
43
56
  className: classNames
44
57
  }, wrapperProps), ___EmotionJSX(Icon, _extends({
45
58
  icon: icon,
46
59
  size: sizeProps.size,
47
60
  title: title,
48
- color: "iconWrapper.icon.".concat(color)
61
+ color: "iconWrapper.icon.".concat(finalColor)
49
62
  }, iconProps)));
50
63
  });
51
64
  export default IconWrapper;
@@ -14,7 +14,8 @@ var defaultProps = {
14
14
  name: 'earth icon'
15
15
  },
16
16
  icon: Earth,
17
- size: 'md'
17
+ size: 'md',
18
+ colorId: 'test-color-id'
18
19
  };
19
20
  var getComponent = function getComponent() {
20
21
  return render(___EmotionJSX(IconWrapper, _extends({}, defaultProps, {
@@ -375,15 +375,13 @@ export var InfiniteLoadingList = function InfiniteLoadingList(args) {
375
375
  return ___EmotionJSX(Item, {
376
376
  key: item.name
377
377
  }, ___EmotionJSX(ListViewItem, {
378
+ id: item.name,
378
379
  data: {
379
380
  text: item.name,
380
381
  icon: FormSelectIcon
381
382
  },
382
383
  iconProps: {
383
384
  color: 'text.secondary'
384
- },
385
- iconWrapperProps: {
386
- color: 'cyan'
387
385
  }
388
386
  }, ___EmotionJSX(Controls, null)));
389
387
  }));
@@ -57,7 +57,7 @@ var ListViewItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
57
57
  name: _concatInstanceProperty(_context = "".concat(text)).call(_context, LIST_ITEM_ICON)
58
58
  },
59
59
  isCircle: true,
60
- color: "white"
60
+ colorId: others.id
61
61
  }, iconWrapperProps)) : ___EmotionJSX(Box, {
62
62
  width: "25px",
63
63
  variant: "listViewItem.iconContainer"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.191.0-alpha.0",
3
+ "version": "2.191.1-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",