@semcore/icon 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [3.1.2] - 2022-10-26
6
+
7
+ ### Fixed
8
+
9
+ - Lazy checks for necessity of `aria-label` in non production environment.
10
+
5
11
  ## [3.1.1] - 2022-10-24
6
12
 
7
13
  ### Changed
package/lib/cjs/Icon.js CHANGED
@@ -33,6 +33,10 @@ var _propsForElement = _interopRequireDefault(require("@semcore/utils/lib/propsF
33
33
 
34
34
  var _logger = _interopRequireDefault(require("@semcore/utils/lib/logger"));
35
35
 
36
+ var _ref = require("@semcore/utils/lib/ref");
37
+
38
+ var _hasLabels = _interopRequireDefault(require("@semcore/utils/lib/hasLabels"));
39
+
36
40
  var _excluded = ["keyboardFocused"];
37
41
 
38
42
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -48,16 +52,16 @@ var styles = (
48
52
  /*__reshadow_css_start__*/
49
53
  _core.sstyled.insert(
50
54
  /*__inner_css_start__*/
51
- ":root {\n\n /* DEPRECATED START\n Deprecated variables should never be used in\n components styles but preserved for backward\n compatibility if they used in projects\n like `<Badge bg=\"red\">alpha</Badge>`\n */\n /* DEPRECATED END */\n}\n\n.___SIcon_1v61m_gg_ {\n display: inline-block;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n shape-rendering: geometricPrecision;\n box-sizing: content-box;\n fill: currentColor;\n flex-shrink: 0;\n outline: none;\n color: var(--color_1v61m);\n}\n\n.___SIcon_1v61m_gg_.__keyboardFocused_1v61m_gg_ {\n box-shadow: 0 0 0 3px rgba(0, 143, 248, 0.2);\n}\n\n.___SIcon_1v61m_gg_.__interactive_1v61m_gg_ {\n cursor: pointer\n}\n\n.___SIcon_1v61m_gg_.__interactive_1v61m_gg_:hover {\n color: var(--color-interactive_1v61m);\n }\n"
55
+ ":root {\n\n /* DEPRECATED START\n Deprecated variables should never be used in\n components styles but preserved for backward\n compatibility if they used in projects\n like `<Badge bg=\"red\">alpha</Badge>`\n */\n /* DEPRECATED END */\n}\n\n.___SIcon_xbeyq_gg_ {\n display: inline-block;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n shape-rendering: geometricPrecision;\n box-sizing: content-box;\n fill: currentColor;\n flex-shrink: 0;\n outline: none;\n color: var(--color_xbeyq);\n}\n\n.___SIcon_xbeyq_gg_.__keyboardFocused_xbeyq_gg_ {\n box-shadow: 0 0 0 3px rgba(0, 143, 248, 0.2);\n}\n\n.___SIcon_xbeyq_gg_.__interactive_xbeyq_gg_ {\n cursor: pointer\n}\n\n.___SIcon_xbeyq_gg_.__interactive_xbeyq_gg_:hover {\n color: var(--color-interactive_xbeyq);\n }\n"
52
56
  /*__inner_css_end__*/
53
- , "1v61m_gg_")
57
+ , "xbeyq_gg_")
54
58
  /*__reshadow_css_end__*/
55
59
  , {
56
- "__SIcon": "___SIcon_1v61m_gg_",
57
- "--color": "--color_1v61m",
58
- "_keyboardFocused": "__keyboardFocused_1v61m_gg_",
59
- "_interactive": "__interactive_1v61m_gg_",
60
- "--color-interactive": "--color-interactive_1v61m"
60
+ "__SIcon": "___SIcon_xbeyq_gg_",
61
+ "--color": "--color_xbeyq",
62
+ "_keyboardFocused": "__keyboardFocused_xbeyq_gg_",
63
+ "_interactive": "__interactive_xbeyq_gg_",
64
+ "--color-interactive": "--color-interactive_xbeyq"
61
65
  });
62
66
 
63
67
  function Icon(props, ref) {
@@ -75,9 +79,7 @@ function Icon(props, ref) {
75
79
  other = _useBox2[1];
76
80
 
77
81
  var interactive = props.interactive,
78
- colorProps = props.color,
79
- ariaLabel = props['aria-label'],
80
- ariaLabelledby = props['aria-labelledby'];
82
+ colorProps = props.color;
81
83
  var color = (0, _color["default"])(colorProps);
82
84
 
83
85
  var _keyboardFocusEnhance = (0, _keyboardFocusEnhance2["default"])()(_objectSpread({
@@ -107,14 +109,24 @@ function Icon(props, ref) {
107
109
  }
108
110
  }
109
111
 
110
- _logger["default"].warn(interactive && !ariaLabel && !ariaLabelledby, "'aria-label' or 'aria-labelledby' are required props for interactive icons", props['data-ui-name'] || Icon.displayName);
112
+ var labelCheckRef = _react["default"].useRef();
113
+
114
+ _react["default"].useEffect(function () {
115
+ if (!interactive) return;
116
+
117
+ if (process.env.NODE_ENV !== 'production') {
118
+ _logger["default"].warn(!(0, _hasLabels["default"])(labelCheckRef.current), "'aria-label' or 'aria-labelledby' are required props for interactive icons", props['data-ui-name'] || Icon.displayName);
119
+ }
120
+ }, [interactive]);
111
121
 
122
+ var forkedRef = (0, _ref.useForkRef)(ref, labelCheckRef);
112
123
  return /*#__PURE__*/_react["default"].createElement(SIcon, (0, _extends2["default"])({}, (0, _propsForElement["default"])(propsWithKeyboardEnhance), {
113
124
  style: Object.assign({}, style, propsWithKeyboardEnhance.style, props.style),
114
125
  className: (0, _classnames["default"])(className, propsWithKeyboardEnhance.className, props.className) || undefined,
115
126
  onKeyDown: onKeyDown,
116
127
  role: interactive ? 'button' : undefined,
117
- "aria-hidden": interactive ? undefined : 'true'
128
+ "aria-hidden": interactive ? undefined : 'true',
129
+ ref: forkedRef
118
130
  }));
119
131
  }
120
132
 
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","names":["Icon","props","ref","useBox","tag","width","height","viewBox","focusable","interactive","SIcon","other","colorProps","color","ariaLabel","ariaLabelledby","resolveColor","keyboardFocusEnhance","disabled","keyboardFocused","propsWithKeyboardEnhance","sstyles","sstyled","styles","cn","shade","className","style","onKeyDown","event","code","onClick","logger","warn","displayName","propsForElement","Object","assign","undefined","createBaseComponent"],"sources":["../../src/Icon.jsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createBaseComponent, sstyled } from '@semcore/core';\nimport { useBox } from '@semcore/flex-box';\nimport resolveColor, { shade } from '@semcore/utils/lib/color';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport propsForElement from '@semcore/utils/lib/propsForElement';\nimport logger from '@semcore/utils/lib/logger';\n\nimport styles from './style/icon.shadow.css';\n\nfunction Icon(props, ref) {\n const [SIcon, other] = useBox(\n {\n tag: 'svg',\n 'data-ui-name': 'Icon',\n width: 16,\n height: 16,\n viewBox: '0 0 16 16',\n 'aria-hidden': true,\n focusable: props.interactive,\n ...props,\n },\n ref,\n );\n\n const {\n interactive,\n color: colorProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n } = props;\n const color = resolveColor(colorProps);\n const { keyboardFocused, ...propsWithKeyboardEnhance } = keyboardFocusEnhance()({\n disabled: !interactive,\n ...other,\n });\n const sstyles = sstyled(styles);\n const { className, style } = sstyles.cn('SIcon', {\n 'color-interactive': shade(color, -0.12),\n 'use:color': color,\n interactive: interactive,\n keyboardFocused: keyboardFocused,\n });\n\n function onKeyDown(event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n if (interactive && event.code === 'Enter') {\n props.onClick && props.onClick(event);\n }\n }\n\n logger.warn(\n interactive && !ariaLabel && !ariaLabelledby,\n \"'aria-label' or 'aria-labelledby' are required props for interactive icons\",\n props['data-ui-name'] || Icon.displayName,\n );\n\n return (\n <SIcon\n {...propsForElement(propsWithKeyboardEnhance)}\n style={Object.assign({}, style, propsWithKeyboardEnhance.style, props.style)}\n className={cn(className, propsWithKeyboardEnhance.className, props.className) || undefined}\n onKeyDown={onKeyDown}\n role={interactive ? 'button' : undefined}\n aria-hidden={interactive ? undefined : 'true'}\n />\n );\n}\n\nIcon.displayName = 'Icon';\n\nexport default createBaseComponent(Icon);\n"],"mapp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,IAAI5B,KAAK,CAAC2B,SAAV,EAAqB;MACnB,OAAO3B,KAAK,CAAC2B,SAAN,CAAgBC,KAAhB,CAAP;IACD;;IAED,IAAIpB,WAAW,IAAIoB,KAAK,CAACC,IAAN,KAAe,OAAlC,EAA2C;MACzC7B,KAAK,CAAC8B,OAAN,IAAiB9B,KAAK,CAAC8B,OAAN,CAAcF,KAAd,CAAjB;IACD;EACF;;EAEDG,kBAAA,CAAOC,IAAP,CACExB,WAAW,IAAI,CAACK,SAAhB,IAA6B,CAACC,cADhC,EAEE,4EAFF,EAGEd,KAAK,CAAC,cAAD,CAAL,IAAyBD,IAAI,CAACkC,WAHhC;;EAMA,oBACE,gCAAC,KAAD,gCACM,IAAAC,2BAAA,EAAgBf,wBAAhB,CADN;IAEE,KAAK,EAAEgB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBV,KAAlB,EAAyBP,wBAAwB,CAACO,KAAlD,EAAyD1B,KAAK,CAAC0B,KAA/D,CAFT;IAGE,SAAS,EAAE,IAAAH,sBAAA,EAAGE,SAAH,EAAcN,wBAAwB,CAACM,SAAvC,EAAkDzB,KAAK,CAACyB,SAAxD,KAAsEY,SAHnF;IAIE,SAAS,EAAEV,SAJb;IAKE,IAAI,EAAEnB,WAAW,GAAG,QAAH,GAAc6B,SALjC;IAME,eAAa7B,WAAW,GAAG6B,SAAH,GAAe;EANzC,GADF;AAUD;;AAEDtC,IAAI,CAACkC,WAAL,GAAmB,MAAnB;;eAEe,IAAAK,yBAAA,EAAoBvC,IAApB,C"}
1
+ {"version":3,"file":"Icon.js","names":["Icon","props","ref","useBox","tag","width","height","viewBox","focusable","interactive","SIcon","other","colorProps","color","resolveColor","keyboardFocusEnhance","disabled","keyboardFocused","propsWithKeyboardEnhance","sstyles","sstyled","styles","cn","shade","className","style","onKeyDown","event","code","onClick","labelCheckRef","React","useRef","useEffect","process","env","NODE_ENV","logger","warn","hasLabels","current","displayName","forkedRef","useForkRef","propsForElement","Object","assign","undefined","createBaseComponent"],"sources":["../../src/Icon.jsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createBaseComponent, sstyled } from '@semcore/core';\nimport { useBox } from '@semcore/flex-box';\nimport resolveColor, { shade } from '@semcore/utils/lib/color';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport propsForElement from '@semcore/utils/lib/propsForElement';\nimport logger from '@semcore/utils/lib/logger';\nimport { useForkRef } from '@semcore/utils/lib/ref';\nimport hasLabels from '@semcore/utils/lib/hasLabels';\n\nimport styles from './style/icon.shadow.css';\n\nfunction Icon(props, ref) {\n const [SIcon, other] = useBox(\n {\n tag: 'svg',\n 'data-ui-name': 'Icon',\n width: 16,\n height: 16,\n viewBox: '0 0 16 16',\n 'aria-hidden': true,\n focusable: props.interactive,\n ...props,\n },\n ref,\n );\n\n const { interactive, color: colorProps } = props;\n const color = resolveColor(colorProps);\n const { keyboardFocused, ...propsWithKeyboardEnhance } = keyboardFocusEnhance()({\n disabled: !interactive,\n ...other,\n });\n const sstyles = sstyled(styles);\n const { className, style } = sstyles.cn('SIcon', {\n 'color-interactive': shade(color, -0.12),\n 'use:color': color,\n interactive: interactive,\n keyboardFocused: keyboardFocused,\n });\n\n function onKeyDown(event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n if (interactive && event.code === 'Enter') {\n props.onClick && props.onClick(event);\n }\n }\n\n const labelCheckRef = React.useRef();\n React.useEffect(() => {\n if (!interactive) return;\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n !hasLabels(labelCheckRef.current),\n `'aria-label' or 'aria-labelledby' are required props for interactive icons`,\n props['data-ui-name'] || Icon.displayName,\n );\n }\n }, [interactive]);\n const forkedRef = useForkRef(ref, labelCheckRef);\n\n return (\n <SIcon\n {...propsForElement(propsWithKeyboardEnhance)}\n style={Object.assign({}, style, propsWithKeyboardEnhance.style, props.style)}\n className={cn(className, propsWithKeyboardEnhance.className, props.className) || undefined}\n onKeyDown={onKeyDown}\n role={interactive ? 'button' : undefined}\n aria-hidden={interactive ? undefined : 'true'}\n ref={forkedRef}\n />\n );\n}\n\nIcon.displayName = 'Icon';\n\nexport default createBaseComponent(Icon);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA;;AAFA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAASA,IAAT,CAAcC,KAAd,EAAqBC,GAArB,EAA0B;EACxB,cAAuB,IAAAC,eAAA;IAEnBC,GAAG,EAAE,KAFc;IAGnB,gBAAgB,MAHG;IAInBC,KAAK,EAAE,EAJY;IAKnBC,MAAM,EAAE,EALW;IAMnBC,OAAO,EAAE,WANU;IAOnB,eAAe,IAPI;IAQnBC,SAAS,EAAEP,KAAK,CAACQ;EARE,GAShBR,KATgB,GAWrBC,GAXqB,CAAvB;EAAA;EAAA,IAAOQ,KAAP;EAAA,IAAcC,KAAd;;EAcA,IAAQF,WAAR,GAA2CR,KAA3C,CAAQQ,WAAR;EAAA,IAA4BG,UAA5B,GAA2CX,KAA3C,CAAqBY,KAArB;EACA,IAAMA,KAAK,GAAG,IAAAC,iBAAA,EAAaF,UAAb,CAAd;;EACA,4BAAyD,IAAAG,iCAAA;IACvDC,QAAQ,EAAE,CAACP;EAD4C,GAEpDE,KAFoD,EAAzD;EAAA,IAAQM,eAAR,yBAAQA,eAAR;EAAA,IAA4BC,wBAA5B;;EAIA,IAAMC,OAAO,GAAG,IAAAC,aAAA,EAAQC,MAAR,CAAhB;;EACA,kBAA6BF,OAAO,CAACG,EAAR,CAAW,OAAX,EAAoB;IAC/C,qBAAqB,IAAAC,YAAA,EAAMV,KAAN,EAAa,CAAC,IAAd,CAD0B;IAE/C,aAAaA,KAFkC;IAG/CJ,WAAW,EAAEA,WAHkC;IAI/CQ,eAAe,EAAEA;EAJ8B,CAApB,CAA7B;EAAA,IAAQO,SAAR,eAAQA,SAAR;EAAA,IAAmBC,KAAnB,eA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EAAEL;EAPP,GADF;AAWD;;AAED1C,IAAI,CAACyC,WAAL,GAAmB,MAAnB;;eAEe,IAAAO,yBAAA,EAAoBhD,IAApB,C"}
package/lib/es6/Icon.js CHANGED
@@ -17,22 +17,24 @@ import resolveColor, { shade } from '@semcore/utils/lib/color';
17
17
  import keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';
18
18
  import propsForElement from '@semcore/utils/lib/propsForElement';
19
19
  import logger from '@semcore/utils/lib/logger';
20
+ import { useForkRef } from '@semcore/utils/lib/ref';
21
+ import hasLabels from '@semcore/utils/lib/hasLabels';
20
22
 
21
23
  /*__reshadow-styles__:"./style/icon.shadow.css"*/
22
24
  var styles = (
23
25
  /*__reshadow_css_start__*/
24
26
  _sstyled.insert(
25
27
  /*__inner_css_start__*/
26
- ":root {\n\n /* DEPRECATED START\n Deprecated variables should never be used in\n components styles but preserved for backward\n compatibility if they used in projects\n like `<Badge bg=\"red\">alpha</Badge>`\n */\n /* DEPRECATED END */\n}\n\n.___SIcon_1v61m_gg_ {\n display: inline-block;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n shape-rendering: geometricPrecision;\n box-sizing: content-box;\n fill: currentColor;\n flex-shrink: 0;\n outline: none;\n color: var(--color_1v61m);\n}\n\n.___SIcon_1v61m_gg_.__keyboardFocused_1v61m_gg_ {\n box-shadow: 0 0 0 3px rgba(0, 143, 248, 0.2);\n}\n\n.___SIcon_1v61m_gg_.__interactive_1v61m_gg_ {\n cursor: pointer\n}\n\n.___SIcon_1v61m_gg_.__interactive_1v61m_gg_:hover {\n color: var(--color-interactive_1v61m);\n }\n"
28
+ ":root {\n\n /* DEPRECATED START\n Deprecated variables should never be used in\n components styles but preserved for backward\n compatibility if they used in projects\n like `<Badge bg=\"red\">alpha</Badge>`\n */\n /* DEPRECATED END */\n}\n\n.___SIcon_xbeyq_gg_ {\n display: inline-block;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n shape-rendering: geometricPrecision;\n box-sizing: content-box;\n fill: currentColor;\n flex-shrink: 0;\n outline: none;\n color: var(--color_xbeyq);\n}\n\n.___SIcon_xbeyq_gg_.__keyboardFocused_xbeyq_gg_ {\n box-shadow: 0 0 0 3px rgba(0, 143, 248, 0.2);\n}\n\n.___SIcon_xbeyq_gg_.__interactive_xbeyq_gg_ {\n cursor: pointer\n}\n\n.___SIcon_xbeyq_gg_.__interactive_xbeyq_gg_:hover {\n color: var(--color-interactive_xbeyq);\n }\n"
27
29
  /*__inner_css_end__*/
28
- , "1v61m_gg_")
30
+ , "xbeyq_gg_")
29
31
  /*__reshadow_css_end__*/
30
32
  , {
31
- "__SIcon": "___SIcon_1v61m_gg_",
32
- "--color": "--color_1v61m",
33
- "_keyboardFocused": "__keyboardFocused_1v61m_gg_",
34
- "_interactive": "__interactive_1v61m_gg_",
35
- "--color-interactive": "--color-interactive_1v61m"
33
+ "__SIcon": "___SIcon_xbeyq_gg_",
34
+ "--color": "--color_xbeyq",
35
+ "_keyboardFocused": "__keyboardFocused_xbeyq_gg_",
36
+ "_interactive": "__interactive_xbeyq_gg_",
37
+ "--color-interactive": "--color-interactive_xbeyq"
36
38
  });
37
39
 
38
40
  function Icon(props, ref) {
@@ -50,9 +52,7 @@ function Icon(props, ref) {
50
52
  other = _useBox2[1];
51
53
 
52
54
  var interactive = props.interactive,
53
- colorProps = props.color,
54
- ariaLabel = props['aria-label'],
55
- ariaLabelledby = props['aria-labelledby'];
55
+ colorProps = props.color;
56
56
  var color = resolveColor(colorProps);
57
57
 
58
58
  var _keyboardFocusEnhance = keyboardFocusEnhance()(_objectSpread({
@@ -82,13 +82,22 @@ function Icon(props, ref) {
82
82
  }
83
83
  }
84
84
 
85
- logger.warn(interactive && !ariaLabel && !ariaLabelledby, "'aria-label' or 'aria-labelledby' are required props for interactive icons", props['data-ui-name'] || Icon.displayName);
85
+ var labelCheckRef = React.useRef();
86
+ React.useEffect(function () {
87
+ if (!interactive) return;
88
+
89
+ if (process.env.NODE_ENV !== 'production') {
90
+ logger.warn(!hasLabels(labelCheckRef.current), "'aria-label' or 'aria-labelledby' are required props for interactive icons", props['data-ui-name'] || Icon.displayName);
91
+ }
92
+ }, [interactive]);
93
+ var forkedRef = useForkRef(ref, labelCheckRef);
86
94
  return /*#__PURE__*/React.createElement(SIcon, _extends({}, propsForElement(propsWithKeyboardEnhance), {
87
95
  style: Object.assign({}, style, propsWithKeyboardEnhance.style, props.style),
88
96
  className: cn(className, propsWithKeyboardEnhance.className, props.className) || undefined,
89
97
  onKeyDown: onKeyDown,
90
98
  role: interactive ? 'button' : undefined,
91
- "aria-hidden": interactive ? undefined : 'true'
99
+ "aria-hidden": interactive ? undefined : 'true',
100
+ ref: forkedRef
92
101
  }));
93
102
  }
94
103
 
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","names":["React","cn","createBaseComponent","sstyled","useBox","resolveColor","shade","keyboardFocusEnhance","propsForElement","logger","Icon","props","ref","tag","width","height","viewBox","focusable","interactive","SIcon","other","colorProps","color","ariaLabel","ariaLabelledby","disabled","keyboardFocused","propsWithKeyboardEnhance","sstyles","styles","className","style","onKeyDown","event","code","onClick","warn","displayName","Object","assign","undefined"],"sources":["../../src/Icon.jsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createBaseComponent, sstyled } from '@semcore/core';\nimport { useBox } from '@semcore/flex-box';\nimport resolveColor, { shade } from '@semcore/utils/lib/color';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport propsForElement from '@semcore/utils/lib/propsForElement';\nimport logger from '@semcore/utils/lib/logger';\n\nimport styles from './style/icon.shadow.css';\n\nfunction Icon(props, ref) {\n const [SIcon, other] = useBox(\n {\n tag: 'svg',\n 'data-ui-name': 'Icon',\n width: 16,\n height: 16,\n viewBox: '0 0 16 16',\n 'aria-hidden': true,\n focusable: props.interactive,\n ...props,\n },\n ref,\n );\n\n const {\n interactive,\n color: colorProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n } = props;\n const color = resolveColor(colorProps);\n const { keyboardFocused, ...propsWithKeyboardEnhance } = keyboardFocusEnhance()({\n disabled: !interactive,\n ...other,\n });\n const sstyles = sstyled(styles);\n const { className, style } = sstyles.cn('SIcon', {\n 'color-interactive': shade(color, -0.12),\n 'use:color': color,\n interactive: interactive,\n keyboardFocused: keyboardFocused,\n });\n\n function onKeyDown(event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n if (interactive && event.code === 'Enter') {\n props.onClick && props.onClick(event);\n }\n }\n\n logger.warn(\n interactive && !ariaLabel && !ariaLabelledby,\n \"'aria-label' or 'aria-labelledby' are required props for interactive icons\",\n props['data-ui-name'] || Icon.displayName,\n );\n\n return (\n <SIcon\n {...propsForElement(propsWithKeyboardEnhance)}\n style={Object.assign({}, style, propsWithKeyboardEnhance.style, props.style)}\n className={cn(className, propsWithKeyboardEnhance.className, props.className) || undefined}\n onKeyDown={onKeyDown}\n role={interactive ? 'button' : undefined}\n aria-hidden={interactive ? undefined : 'true'}\n />\n );\n}\n\nIcon.displayName = 'Icon';\n\nexport default createBaseComponent(Icon);\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,EAAP,MAAe,YAAf;AACA,SAASC,mBAAT,EAA8BC,OAA9B,QAA6C,eAA7C;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,OAAOC,YAAP,IAAuBC,KAAvB,QAAoC,0BAApC;AACA,OAAOC,oBAAP,MAAiC,kDAAjC;AACA,OAAOC,eAAP,MAA4B,oCAA5B;AACA,OAAOC,MAAP,MAAmB,2BAAnB;;;;;;;;;;;;;;;;;;;AAIA,SAASC,IAAT,CAAcC,KAAd,EAAqBC,GAArB,EAA0B;EACxB,cAAuBR,MAAM;IAEzBS,GAAG,EAAE,KAFoB;IAGzB,gBAAgB,MAHS;IAIzBC,KAAK,EAAE,EAJkB;IAKzBC,MAAM,EAAE,EALiB;IAMzB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6B,CAACC,cADhC,EAEE,4EAFF,EAGEb,KAAK,CAAC,cAAD,CAAL,IAAyBD,IAAI,CAAC2B,WAHhC;EAMA,oBACE,oBAAC,KAAD,eACM7B,eAAe,CAACmB,wBAAD,CADrB;IAEE,KAAK,EAAEW,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,KAAlB,EAAyBJ,wBAAwB,CAACI,KAAlD,EAAyDpB,KAAK,CAACoB,KAA/D,CAFT;IAGE,SAAS,EAAE9B,EAAE,CAAC6B,SAAD,EAAYH,wBAAwB,CAACG,SAArC,EAAgDnB,KAAK,CAACmB,SAAtD,CAAF,IAAsEU,SAHnF;IAIE,SAAS,EAAER,SAJb;IAKE,IAAI,EAAEd,WAAW,GAAG,QAAH,GAAcsB,SALjC;IAME,eAAatB,WAAW,GAAGsB,SAAH,GAAe;EANzC,GADF;AAUD;;AAED9B,IAAI,CAAC2B,WAAL,GAAmB,MAAnB;AAEA,eAAenC,mBAAmB,CAACQ,IAAD,CAAlC"}
1
+ {"version":3,"file":"Icon.js","names":["React","cn","createBaseComponent","sstyled","useBox","resolveColor","shade","keyboardFocusEnhance","propsForElement","logger","useForkRef","hasLabels","Icon","props","ref","tag","width","height","viewBox","focusable","interactive","SIcon","other","colorProps","color","disabled","keyboardFocused","propsWithKeyboardEnhance","sstyles","styles","className","style","onKeyDown","event","code","onClick","labelCheckRef","useRef","useEffect","process","env","NODE_ENV","warn","current","displayName","forkedRef","Object","assign","undefined"],"sources":["../../src/Icon.jsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { createBaseComponent, sstyled } from '@semcore/core';\nimport { useBox } from '@semcore/flex-box';\nimport resolveColor, { shade } from '@semcore/utils/lib/color';\nimport keyboardFocusEnhance from '@semcore/utils/lib/enhances/keyboardFocusEnhance';\nimport propsForElement from '@semcore/utils/lib/propsForElement';\nimport logger from '@semcore/utils/lib/logger';\nimport { useForkRef } from '@semcore/utils/lib/ref';\nimport hasLabels from '@semcore/utils/lib/hasLabels';\n\nimport styles from './style/icon.shadow.css';\n\nfunction Icon(props, ref) {\n const [SIcon, other] = useBox(\n {\n tag: 'svg',\n 'data-ui-name': 'Icon',\n width: 16,\n height: 16,\n viewBox: '0 0 16 16',\n 'aria-hidden': true,\n focusable: props.interactive,\n ...props,\n },\n ref,\n );\n\n const { interactive, color: colorProps } = props;\n const color = resolveColor(colorProps);\n const { keyboardFocused, ...propsWithKeyboardEnhance } = keyboardFocusEnhance()({\n disabled: !interactive,\n ...other,\n });\n const sstyles = sstyled(styles);\n const { className, style } = sstyles.cn('SIcon', {\n 'color-interactive': shade(color, -0.12),\n 'use:color': color,\n interactive: interactive,\n keyboardFocused: keyboardFocused,\n });\n\n function onKeyDown(event) {\n if (props.onKeyDown) {\n return props.onKeyDown(event);\n }\n\n if (interactive && event.code === 'Enter') {\n props.onClick && props.onClick(event);\n }\n }\n\n const labelCheckRef = React.useRef();\n React.useEffect(() => {\n if (!interactive) return;\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n !hasLabels(labelCheckRef.current),\n `'aria-label' or 'aria-labelledby' are required props for interactive icons`,\n props['data-ui-name'] || Icon.displayName,\n );\n }\n }, [interactive]);\n const forkedRef = useForkRef(ref, labelCheckRef);\n\n return (\n <SIcon\n {...propsForElement(propsWithKeyboardEnhance)}\n style={Object.assign({}, style, propsWithKeyboardEnhance.style, props.style)}\n className={cn(className, propsWithKeyboardEnhance.className, props.className) || undefined}\n onKeyDown={onKeyDown}\n role={interactive ? 'button' : undefined}\n aria-hidden={interactive ? undefined : 'true'}\n ref={forkedRef}\n />\n );\n}\n\nIcon.displayName = 'Icon';\n\nexport default createBaseComponent(Icon);\n"],"mappings":";;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,EAAP,MAAe,YAAf;AACA,SAASC,mBAAT,EAA8BC,OAA9B,QAA6C,eAA7C;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,OAAOC,YAAP,IAAuBC,KAAvB,QAAo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AAlC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/icon",
3
3
  "description": "Semrush Icon Component",
4
- "version": "3.1.1",
4
+ "version": "3.1.2",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "author": "UI-kit team <ui-kit-team@semrush.com>",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@semcore/utils": "^3.15",
12
+ "@semcore/utils": "^3.40.0",
13
13
  "@semcore/flex-box": "^4",
14
14
  "classnames": "2.2.6"
15
15
  },