@foxford/ui 2.116.0 → 2.117.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 (88) hide show
  1. package/components/AccordionItem/AccordionItem.js +1 -1
  2. package/components/AccordionItem/AccordionItem.js.map +1 -1
  3. package/components/AccordionItem/AccordionItem.mjs +1 -1
  4. package/components/AccordionItem/AccordionItem.mjs.map +1 -1
  5. package/components/AccordionItem/style.js +1 -1
  6. package/components/AccordionItem/style.js.map +1 -1
  7. package/components/AccordionItem/style.mjs +1 -1
  8. package/components/AccordionItem/style.mjs.map +1 -1
  9. package/components/ActionBtn/ActionBtn.js +1 -1
  10. package/components/ActionBtn/ActionBtn.js.map +1 -1
  11. package/components/ActionBtn/ActionBtn.mjs +1 -1
  12. package/components/ActionBtn/ActionBtn.mjs.map +1 -1
  13. package/components/Anchor/Anchor.js +1 -1
  14. package/components/Anchor/Anchor.js.map +1 -1
  15. package/components/Anchor/Anchor.mjs +1 -1
  16. package/components/Anchor/Anchor.mjs.map +1 -1
  17. package/components/Badge/Badge.js +1 -1
  18. package/components/Badge/Badge.js.map +1 -1
  19. package/components/Badge/Badge.mjs +1 -1
  20. package/components/Badge/Badge.mjs.map +1 -1
  21. package/components/Button/Button.js +1 -1
  22. package/components/Button/Button.js.map +1 -1
  23. package/components/Button/Button.mjs +1 -1
  24. package/components/Button/Button.mjs.map +1 -1
  25. package/components/Chip/Chip.js +1 -1
  26. package/components/Chip/Chip.js.map +1 -1
  27. package/components/Chip/Chip.mjs +1 -1
  28. package/components/Chip/Chip.mjs.map +1 -1
  29. package/components/Dropdown/Dropdown.js +1 -1
  30. package/components/Dropdown/Dropdown.js.map +1 -1
  31. package/components/Dropdown/Dropdown.mjs +1 -1
  32. package/components/Dropdown/Dropdown.mjs.map +1 -1
  33. package/components/Dropdown/DropdownMenuNoOptions.js +1 -1
  34. package/components/Dropdown/DropdownMenuNoOptions.js.map +1 -1
  35. package/components/Dropdown/DropdownMenuNoOptions.mjs +1 -1
  36. package/components/Dropdown/DropdownMenuNoOptions.mjs.map +1 -1
  37. package/components/Dropdown/style.js +1 -1
  38. package/components/Dropdown/style.js.map +1 -1
  39. package/components/Dropdown/style.mjs +1 -1
  40. package/components/Dropdown/style.mjs.map +1 -1
  41. package/components/Icon/style.js +1 -1
  42. package/components/Icon/style.js.map +1 -1
  43. package/components/Icon/style.mjs +1 -1
  44. package/components/Icon/style.mjs.map +1 -1
  45. package/components/ListItem/ListItem.js +1 -1
  46. package/components/ListItem/ListItem.js.map +1 -1
  47. package/components/ListItem/ListItem.mjs +1 -1
  48. package/components/ListItem/ListItem.mjs.map +1 -1
  49. package/components/TabList/TabList.js +1 -1
  50. package/components/TabList/TabList.js.map +1 -1
  51. package/components/TabList/TabList.mjs +1 -1
  52. package/components/TabList/TabList.mjs.map +1 -1
  53. package/components/TabList/TabListMenuTab.js +1 -1
  54. package/components/TabList/TabListMenuTab.js.map +1 -1
  55. package/components/TabList/TabListMenuTab.mjs +1 -1
  56. package/components/TabList/TabListMenuTab.mjs.map +1 -1
  57. package/components/TabList/style.js +1 -1
  58. package/components/TabList/style.js.map +1 -1
  59. package/components/TabList/style.mjs +1 -1
  60. package/components/TabList/style.mjs.map +1 -1
  61. package/dts/index.d.ts +36 -694
  62. package/icon-pack/src/collection.json.js +1 -1
  63. package/icon-pack/src/collection.json.mjs +1 -1
  64. package/icon-pack/src/icons/ChevronUp/index.js +2 -0
  65. package/icon-pack/src/icons/ChevronUp/index.js.map +1 -0
  66. package/icon-pack/src/icons/ChevronUp/index.mjs +2 -0
  67. package/icon-pack/src/icons/ChevronUp/index.mjs.map +1 -0
  68. package/icon-pack/src/icons/Undo/index.js +2 -0
  69. package/icon-pack/src/icons/Undo/index.js.map +1 -0
  70. package/icon-pack/src/icons/Undo/index.mjs +2 -0
  71. package/icon-pack/src/icons/Undo/index.mjs.map +1 -0
  72. package/package.json +2 -2
  73. package/icon-pack/src/icons/ChevronDown/index.js +0 -2
  74. package/icon-pack/src/icons/ChevronDown/index.js.map +0 -1
  75. package/icon-pack/src/icons/ChevronDown/index.mjs +0 -2
  76. package/icon-pack/src/icons/ChevronDown/index.mjs.map +0 -1
  77. package/icon-pack/src/icons/ChevronLeft/index.js +0 -2
  78. package/icon-pack/src/icons/ChevronLeft/index.js.map +0 -1
  79. package/icon-pack/src/icons/ChevronLeft/index.mjs +0 -2
  80. package/icon-pack/src/icons/ChevronLeft/index.mjs.map +0 -1
  81. package/icon-pack/src/icons/ChevronRight/index.js +0 -2
  82. package/icon-pack/src/icons/ChevronRight/index.js.map +0 -1
  83. package/icon-pack/src/icons/ChevronRight/index.mjs +0 -2
  84. package/icon-pack/src/icons/ChevronRight/index.mjs.map +0 -1
  85. package/icon-pack/src/icons/Redo/index.js +0 -2
  86. package/icon-pack/src/icons/Redo/index.js.map +0 -1
  87. package/icon-pack/src/icons/Redo/index.mjs +0 -2
  88. package/icon-pack/src/icons/Redo/index.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Anchor.mjs","sources":["../../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import { useTheme } from 'styled-components'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { useClassname } from 'hooks/useClassname'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport { isNil } from 'shared/utils/isNil'\nimport { SIZES } from './constants'\nimport type { AnchorProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Anchor'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<a\\>).\n */\nconst Anchor = createPolymorphicComponentWithRef<'a', AnchorProps>((props, ref) => {\n const theme = useTheme()\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, AnchorProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: SIZES,\n })\n\n const {\n component,\n size = 'inherit',\n autoRel = true,\n textProps = {},\n iconProps = {},\n icon,\n children,\n content,\n ...restProps\n } = mergedProps\n\n const rootNode = () => {\n let root: React.ElementType | undefined = 'a'\n\n if (restProps.to) {\n root = theme.link\n }\n if (restProps.pseudo) {\n root = 'div'\n }\n if (restProps.disabled) {\n root = 'span'\n }\n if (restProps.as) {\n root = restProps.as\n }\n if (component) {\n root = component\n }\n\n return root\n }\n\n const className = useClassname(COMPONENT_NAME, restProps.className)\n\n const relBuilder = theme.utils?.relBuilder\n\n const getRel = () => {\n if (!isNil(restProps.rel)) {\n return restProps.rel\n }\n\n const href = restProps.href ?? restProps.to\n if (autoRel && relBuilder && typeof href === 'string') {\n const target = restProps.target\n if (typeof target === 'string' || target === undefined) {\n return relBuilder(href, target)\n }\n }\n\n return undefined\n }\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const baseTextProps: TextProps = {\n as: 'span',\n size: 'inherit',\n color: 'inherit',\n underline: restProps.underline,\n marginLeft: before ? '0.20em' : undefined,\n marginRight: after ? '0.20em' : undefined,\n }\n\n const iconBaseProps: IconProps = { as: 'span', color: 'inherit' }\n\n return (\n <Styled.Root\n {...restProps}\n ref={ref}\n as={rootNode()}\n className={className}\n size={size}\n rel={getRel()}\n data-disabled={restProps.disabled}\n >\n {typeof children === 'function' ? (\n children({ baseTextProps, textProps, iconBaseProps, iconProps, icon })\n ) : restProps.preset === 'brand' ? (\n <>\n {before ? (\n <Icon\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconBaseProps}\n {...iconProps}\n />\n ) : null}\n <Text {...baseTextProps} {...textProps}>\n {children || content}\n </Text>\n {after ? (\n <Icon\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconBaseProps}\n {...iconProps}\n />\n ) : null}\n </>\n ) : (\n children || content\n )}\n </Styled.Root>\n )\n})\n\nconst AnchorDoc: React.FC<AnchorProps> = () => null\n\nexport { AnchorDoc, Anchor, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Anchor","createPolymorphicComponentWithRef","props","ref","theme","useTheme","mergedProps","useMergedProps","componentName","sizes","SIZES","component","size","autoRel","textProps","iconProps","icon","children","content","restProps","className","useClassname","relBuilder","utils","before","after","Array","isArray","baseTextProps","as","color","underline","marginLeft","undefined","marginRight","iconBaseProps","_jsx","Styled","rootNode","root","to","link","pseudo","disabled","rel","getRel","isNil","href","target","preset","_jsxs","_Fragment","Icon","name","Text"],"mappings":"0eAcA,MAAMA,eAAiB,SAUvB,MAAMC,OAASC,kCAAoD,CAACC,EAAOC,KACzE,MAAMC,EAAQC,WACd,MAAMC,EAAcC,eAAiEL,EAAO,CAC1FM,cAbmB,SAcnBC,MAAOC,QAGT,MAAMC,UACJA,EAASC,KACTA,EAAO,UAASC,QAChBA,GAAU,EAAIC,UACdA,EAAY,CAAA,EAAEC,UACdA,EAAY,CAAA,EAAEC,KACdA,EAAIC,SACJA,EAAQC,QACRA,KACGC,GACDb,EAwBJ,MAAMc,EAAYC,aAnDG,SAmD0BF,EAAUC,WAEzD,MAAME,EAAalB,EAAMmB,OAAOD,WAkBhC,MAAOE,EAAQC,GAASC,MAAMC,QAAQX,GAAQA,EAAO,CAACA,GAEtD,MAAMY,EAA2B,CAC/BC,GAAI,OACJjB,KAAM,UACNkB,MAAO,UACPC,UAAWZ,EAAUY,UACrBC,WAAYR,EAAS,cAAWS,EAChCC,YAAaT,EAAQ,cAAWQ,GAGlC,MAAME,EAA2B,CAAEN,GAAI,OAAQC,MAAO,WAEtD,OACEM,IAACC,KAAW,IACNlB,EACJhB,IAAKA,EACL0B,GA3DaS,MACf,IAAIC,EAAsC,IAkB1C,OAhBIpB,EAAUqB,KACZD,EAAOnC,EAAMqC,MAEXtB,EAAUuB,SACZH,EAAO,OAELpB,EAAUwB,WACZJ,EAAO,QAELpB,EAAUU,KACZU,EAAOpB,EAAUU,IAEflB,IACF4B,EAAO5B,GAGF4B,GAwCDD,GACJlB,UAAWA,EACXR,KAAMA,EACNgC,IApCWC,MACb,IAAKC,MAAM3B,EAAUyB,KACnB,OAAOzB,EAAUyB,IAGnB,MAAMG,EAAO5B,EAAU4B,MAAQ5B,EAAUqB,GACzC,GAAI3B,GAAWS,UAAqByB,GAAS,SAAU,CACrD,MAAMC,EAAS7B,EAAU6B,OACzB,UAAWA,GAAW,UAAYA,SAAWf,EAC3C,OAAOX,EAAWyB,EAAMC,EAE5B,GAyBOH,GACL,gBAAe1B,EAAUwB,SAAS1B,gBAE1BA,GAAa,WACnBA,EAAS,CAAEW,gBAAed,YAAWqB,gBAAepB,YAAWC,SAC7DG,EAAU8B,SAAW,QACvBC,KAAAC,SAAA,CAAAlC,SAAA,CACGO,EACCY,IAACgB,KAAI,CACHC,YAAa7B,GAAW,SAAWA,OAASS,EAC5CjB,YAAaQ,GAAW,SAAWA,OAASS,KACxCE,KACApB,IAEJ,KACJqB,IAACkB,KAAI,IAAK1B,KAAmBd,EAASG,SACnCA,GAAYC,IAEdO,EACCW,IAACgB,KAAI,CACHC,YAAa5B,GAAU,SAAWA,OAAQQ,EAC1CjB,YAAaS,GAAU,SAAWA,OAAQQ,KACtCE,KACApB,IAEJ,QAGNE,GAAYC"}
1
+ {"version":3,"file":"Anchor.mjs","sources":["../../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import { useTheme } from 'styled-components'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { useClassname } from 'hooks/useClassname'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport { isNil } from 'shared/utils/isNil'\nimport { SIZES } from './constants'\nimport type { AnchorProps } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Anchor'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<a\\>).\n */\nconst Anchor = createPolymorphicComponentWithRef<'a', AnchorProps>((props, ref) => {\n const theme = useTheme()\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, AnchorProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: SIZES,\n })\n\n const {\n component,\n size = 'inherit',\n autoRel = true,\n textProps = {},\n iconProps = {},\n leftIconProps = {},\n rightIconProps = {},\n icon,\n children,\n content,\n ...restProps\n } = mergedProps\n\n const rootNode = () => {\n let root: React.ElementType | undefined = 'a'\n\n if (restProps.to) {\n root = theme.link\n }\n if (restProps.pseudo) {\n root = 'div'\n }\n if (restProps.disabled) {\n root = 'span'\n }\n if (restProps.as) {\n root = restProps.as\n }\n if (component) {\n root = component\n }\n\n return root\n }\n\n const className = useClassname(COMPONENT_NAME, restProps.className)\n\n const relBuilder = theme.utils?.relBuilder\n\n const getRel = () => {\n if (!isNil(restProps.rel)) {\n return restProps.rel\n }\n\n const href = restProps.href ?? restProps.to\n if (autoRel && relBuilder && typeof href === 'string') {\n const target = restProps.target\n if (typeof target === 'string' || target === undefined) {\n return relBuilder(href, target)\n }\n }\n\n return undefined\n }\n\n const [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const baseTextProps: TextProps = {\n as: 'span',\n size: 'inherit',\n color: 'inherit',\n underline: restProps.underline,\n marginLeft: before ? '0.20em' : undefined,\n marginRight: after ? '0.20em' : undefined,\n }\n\n const iconBaseProps: IconProps = { as: 'span', color: 'inherit' }\n\n return (\n <Styled.Root\n {...restProps}\n ref={ref}\n as={rootNode()}\n className={className}\n size={size}\n rel={getRel()}\n data-disabled={restProps.disabled}\n >\n {typeof children === 'function' ? (\n children({ baseTextProps, textProps, iconBaseProps, iconProps, icon })\n ) : restProps.preset === 'brand' ? (\n <>\n {before ? (\n <Icon\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconBaseProps}\n {...iconProps}\n {...leftIconProps}\n />\n ) : null}\n <Text {...baseTextProps} {...textProps}>\n {children || content}\n </Text>\n {after ? (\n <Icon\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconBaseProps}\n {...iconProps}\n {...rightIconProps}\n />\n ) : null}\n </>\n ) : (\n children || content\n )}\n </Styled.Root>\n )\n})\n\nconst AnchorDoc: React.FC<AnchorProps> = () => null\n\nexport { AnchorDoc, Anchor, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Anchor","createPolymorphicComponentWithRef","props","ref","theme","useTheme","mergedProps","useMergedProps","componentName","sizes","SIZES","component","size","autoRel","textProps","iconProps","leftIconProps","rightIconProps","icon","children","content","restProps","className","useClassname","relBuilder","utils","before","after","Array","isArray","baseTextProps","as","color","underline","marginLeft","undefined","marginRight","iconBaseProps","_jsx","Styled","rootNode","root","to","link","pseudo","disabled","rel","getRel","isNil","href","target","preset","_jsxs","_Fragment","Icon","name","Text"],"mappings":"0eAcA,MAAMA,eAAiB,SAUvB,MAAMC,OAASC,kCAAoD,CAACC,EAAOC,KACzE,MAAMC,EAAQC,WACd,MAAMC,EAAcC,eAAiEL,EAAO,CAC1FM,cAbmB,SAcnBC,MAAOC,QAGT,MAAMC,UACJA,EAASC,KACTA,EAAO,UAASC,QAChBA,GAAU,EAAIC,UACdA,EAAY,CAAA,EAAEC,UACdA,EAAY,CAAA,EAAEC,cACdA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EAAEC,KACnBA,EAAIC,SACJA,EAAQC,QACRA,KACGC,GACDf,EAwBJ,MAAMgB,EAAYC,aArDG,SAqD0BF,EAAUC,WAEzD,MAAME,EAAapB,EAAMqB,OAAOD,WAkBhC,MAAOE,EAAQC,GAASC,MAAMC,QAAQX,GAAQA,EAAO,CAACA,GAEtD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 -1,2 +1,2 @@
1
- 'use strict';var createPolymorphicComponentWithRef=require('../../shared/utils/createPolymorphicComponentWithRef.js');var useMergedProps=require('../../hooks/useMergedProps.js');var style=require('./style.js');var sizes=require('./sizes.js');var jsxRuntime=require('react/jsx-runtime');var Slot=require('../Slot/Slot.js');var Icon=require('../Icon/Icon.js');var Text=require('../Text/Text.js');const Badge=createPolymorphicComponentWithRef.createPolymorphicComponentWithRef((e,s)=>{const o=useMergedProps.useMergedProps(e,{componentName:"Badge",sizes:e=>e.shape==='rounded'?sizes.SIZES_ROUNDED:e.round||e.shape==='circular'?sizes.SIZES_CIRCULAR:e.borderRadius!==void 0?sizes.SIZES_BASE:sizes.SIZES_SQUARE});const{size:r="s",borderRadius:i=3,textProps:t={},iconProps:n={},shape:c="square",component:a="div",children:p,addonLeft:d,addonRight:u,content:S,icon:x,sizeXXS:z,sizeXS:j,sizeS:l,sizeM:m,sizeL:h,sizeXL:R,...P}=o;const v={size:r,sizeXXS:z,sizeXS:j,sizeS:l,sizeM:m,sizeL:h,sizeXL:R};const[g,I]=Array.isArray(x)?x:[x];const y={...v,as:'span',appearance:'caption',color:'inherit',whiteSpace:'nowrap',sizes:sizes.SIZES_TEXT,...t};const f={...v,color:'inherit',sizes:sizes.SIZES_ICON,...n};return jsxRuntime.jsx(style.Root,{...P,...v,as:a,size:r,borderRadius:i,shape:c,ref:s,children:typeof p=='function'?p({textProps:y,iconProps:f}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{props:{iconProps:f},render:d??(g?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...f,name:typeof g=='string'?g:void 0,icon:typeof g!='string'?g:void 0}):void 0)}),p||S?jsxRuntime.jsx(Text.Text,{...y,children:p||S}):null,jsxRuntime.jsx(Slot.Slot,{props:{iconProps:f},render:u??(I?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...f,name:typeof I=='string'?I:void 0,icon:typeof I!='string'?I:void 0}):void 0)})]})})});exports.Badge=Badge,exports.COMPONENT_NAME="Badge";
1
+ 'use strict';var createPolymorphicComponentWithRef=require('../../shared/utils/createPolymorphicComponentWithRef.js');var useMergedProps=require('../../hooks/useMergedProps.js');var style=require('./style.js');var sizes=require('./sizes.js');var jsxRuntime=require('react/jsx-runtime');var Slot=require('../Slot/Slot.js');var Icon=require('../Icon/Icon.js');var Text=require('../Text/Text.js');const Badge=createPolymorphicComponentWithRef.createPolymorphicComponentWithRef((e,s)=>{const o=useMergedProps.useMergedProps(e,{componentName:"Badge",sizes:e=>e.shape==='rounded'?sizes.SIZES_ROUNDED:e.round||e.shape==='circular'?sizes.SIZES_CIRCULAR:e.borderRadius!==void 0?sizes.SIZES_BASE:sizes.SIZES_SQUARE});const{size:r="s",borderRadius:i=3,textProps:t={},iconProps:n={},shape:c="square",component:a="div",leftIconProps:p={},rightIconProps:d={},children:u,addonLeft:S,addonRight:x,content:z,icon:l,sizeXXS:j,sizeXS:m,sizeS:h,sizeM:R,sizeL:P,sizeXL:I,...g}=o;const v={size:r,sizeXXS:j,sizeXS:m,sizeS:h,sizeM:R,sizeL:P,sizeXL:I};const[y,f]=Array.isArray(l)?l:[l];const E={...v,as:'span',appearance:'caption',color:'inherit',whiteSpace:'nowrap',sizes:sizes.SIZES_TEXT,...t};const q={...v,color:'inherit',sizes:sizes.SIZES_ICON,...n};return jsxRuntime.jsx(style.Root,{...g,...v,as:a,size:r,borderRadius:i,shape:c,ref:s,children:typeof u=='function'?u({textProps:E,iconProps:q}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{props:{iconProps:q},render:S??(y?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...q,...p,name:typeof y=='string'?y:void 0,icon:typeof y!='string'?y:void 0}):void 0)}),u||z?jsxRuntime.jsx(Text.Text,{...E,children:u||z}):null,jsxRuntime.jsx(Slot.Slot,{props:{iconProps:q},render:x??(f?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...q,...d,name:typeof f=='string'?f:void 0,icon:typeof f!='string'?f:void 0}):void 0)})]})})});exports.Badge=Badge,exports.COMPONENT_NAME="Badge";
2
2
  //# sourceMappingURL=Badge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { Slot } from 'components/Slot'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport * as Styled from './style'\nimport { SIZES_BASE, SIZES_SQUARE, SIZES_ICON, SIZES_CIRCULAR, SIZES_ROUNDED, SIZES_TEXT } from './sizes'\nimport type { BadgeProps } from './types'\n\nconst COMPONENT_NAME = 'Badge'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для маркировки свойств сущности.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Badge = createPolymorphicComponentWithRef<'div', BadgeProps>((props, ref) => {\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, BadgeProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (p) => {\n if (p.shape === 'rounded') {\n return SIZES_ROUNDED\n }\n\n if (p.round || p.shape === 'circular') {\n return SIZES_CIRCULAR\n }\n\n if (p.borderRadius !== undefined) {\n return SIZES_BASE\n }\n\n return SIZES_SQUARE\n },\n })\n\n const {\n size = 's',\n borderRadius = 3,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n shape = 'square',\n component = 'div',\n children,\n addonLeft,\n addonRight,\n content,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = mergedProps\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n whiteSpace: 'nowrap',\n sizes: SIZES_TEXT,\n ...textPropsProp,\n }\n\n const iconProps: IconProps = { ...sizeProps, color: 'inherit', sizes: SIZES_ICON, ...iconPropsProp }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={component}\n size={size}\n borderRadius={borderRadius}\n shape={shape}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n <Slot\n props={{ iconProps }}\n render={\n addonLeft ??\n (iconBefore\n ? (addonLeftProps) => (\n <Icon\n {...addonLeftProps.iconProps}\n {...iconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n )\n : undefined)\n }\n />\n\n {children || content ? <Text {...textProps}>{children || content}</Text> : null}\n\n <Slot\n props={{ iconProps }}\n render={\n addonRight ??\n (iconAfter\n ? (addonRightProps) => (\n <Icon\n {...addonRightProps.iconProps}\n {...iconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n )\n : undefined)\n }\n />\n </>\n )}\n </Styled.Root>\n )\n})\n\nconst BadgeDoc: React.FC<BadgeProps> = () => null\n\nexport { BadgeDoc, Badge, COMPONENT_NAME }\n"],"names":["Badge","createPolymorphicComponentWithRef","props","ref","mergedProps","useMergedProps","componentName","sizes","p","shape","SIZES_ROUNDED","round","SIZES_CIRCULAR","borderRadius","undefined","SIZES_BASE","SIZES_SQUARE","size","textProps","textPropsProp","iconProps","iconPropsProp","component","children","addonLeft","addonRight","content","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","sizeProps","iconBefore","iconAfter","Array","isArray","as","appearance","color","whiteSpace","SIZES_TEXT","SIZES_ICON","_jsx","Styled","_jsxs","_Fragment","Slot","render","addonLeftProps","Icon","name","Text","addonRightProps"],"mappings":"0YAwBA,MAAMA,MAAQC,kCAAAA,kCAAqD,CAACC,EAAOC,KACzE,MAAMC,EAAcC,eAAAA,eAAgEH,EAAO,CACzFI,cAdmB,QAenBC,MAAQC,GACFA,EAAEC,QAAU,UACPC,MAAAA,cAGLF,EAAEG,OAASH,EAAEC,QAAU,WAClBG,MAAAA,eAGLJ,EAAEK,oBAAiBC,EACdC,MAAAA,WAGFC,MAAAA,eAIX,MAAMC,KACJA,EAAO,IAAGJ,aACVA,EAAe,EACfK,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAAEZ,MAC7BA,EAAQ,SAAQa,UAChBA,EAAY,MAAKC,SACjBA,EAAQC,UACRA,EAASC,WACTA,EAAUC,QACVA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,KACGC,GACD9B,EAEJ,MAAM+B,EAAY,CAChBlB,OACAW,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAOG,EAAYC,GAAaC,MAAMC,QAAQZ,GAAQA,EAAO,CAACA,GAE9D,MAAMT,EAAuB,IACxBiB,EACHK,GAAI,OACJC,WAAY,UACZC,MAAO,UACPC,WAAY,SACZpC,MAAOqC,MAAAA,cACJzB,GAGL,MAAMC,EAAuB,IAAKe,EAAWO,MAAO,UAAWnC,MAAOsC,MAAAA,cAAexB,GAErF,OACEyB,WAAAA,IAACC,MAAAA,KAAW,IACNb,KACAC,EACJK,GAAIlB,EACJL,KAAMA,EACNJ,aAAcA,EACdJ,MAAOA,EACPN,IAAKA,EAAIoB,gBAEDA,GAAa,WACnBA,EAAS,CAAEL,YAAWE,cAEtB4B,WAAAA,KAAAC,oBAAA,CAAA1B,SAAA,CACEuB,WAAAA,IAACI,UAAI,CACHhD,MAAO,CAAEkB,aACT+B,OACE3B,IACCY,EACIgB,GACCN,WAAAA,IAACO,KAAAA,KAAI,IACCD,EAAehC,aACfA,EACJkC,YAAalB,GAAe,SAAWA,OAAatB,EACpDa,YAAaS,GAAe,SAAWA,OAAatB,SAGxDA,KAIPS,GAAYG,EAAUoB,WAAAA,IAACS,KAAAA,KAAI,IAAKrC,EAASK,SAAGA,GAAYG,IAAkB,KAE3EoB,WAAAA,IAACI,UAAI,CACHhD,MAAO,CAAEkB,aACT+B,OACE1B,IACCY,EACImB,GACCV,WAAAA,IAACO,KAAAA,KAAI,IACCG,EAAgBpC,aAChBA,EACJkC,YAAajB,GAAc,SAAWA,OAAYvB,EAClDa,YAAaU,GAAc,SAAWA,OAAYvB,SAGtDA,uDA3HK"}
1
+ {"version":3,"file":"Badge.js","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { Slot } from 'components/Slot'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport * as Styled from './style'\nimport { SIZES_BASE, SIZES_SQUARE, SIZES_ICON, SIZES_CIRCULAR, SIZES_ROUNDED, SIZES_TEXT } from './sizes'\nimport type { BadgeProps } from './types'\n\nconst COMPONENT_NAME = 'Badge'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для маркировки свойств сущности.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Badge = createPolymorphicComponentWithRef<'div', BadgeProps>((props, ref) => {\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, BadgeProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (p) => {\n if (p.shape === 'rounded') {\n return SIZES_ROUNDED\n }\n\n if (p.round || p.shape === 'circular') {\n return SIZES_CIRCULAR\n }\n\n if (p.borderRadius !== undefined) {\n return SIZES_BASE\n }\n\n return SIZES_SQUARE\n },\n })\n\n const {\n size = 's',\n borderRadius = 3,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n shape = 'square',\n component = 'div',\n leftIconProps = {},\n rightIconProps = {},\n children,\n addonLeft,\n addonRight,\n content,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = mergedProps\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n whiteSpace: 'nowrap',\n sizes: SIZES_TEXT,\n ...textPropsProp,\n }\n\n const iconProps: IconProps = { ...sizeProps, color: 'inherit', sizes: SIZES_ICON, ...iconPropsProp }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={component}\n size={size}\n borderRadius={borderRadius}\n shape={shape}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n <Slot\n props={{ iconProps }}\n render={\n addonLeft ??\n (iconBefore\n ? (addonLeftProps) => (\n <Icon\n {...addonLeftProps.iconProps}\n {...iconProps}\n {...leftIconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n )\n : undefined)\n }\n />\n\n {children || content ? <Text {...textProps}>{children || content}</Text> : null}\n\n <Slot\n props={{ iconProps }}\n render={\n addonRight ??\n (iconAfter\n ? (addonRightProps) => (\n <Icon\n {...addonRightProps.iconProps}\n {...iconProps}\n {...rightIconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n )\n : undefined)\n }\n />\n </>\n )}\n </Styled.Root>\n )\n})\n\nconst BadgeDoc: React.FC<BadgeProps> = () => null\n\nexport { BadgeDoc, Badge, COMPONENT_NAME }\n"],"names":["Badge","createPolymorphicComponentWithRef","props","ref","mergedProps","useMergedProps","componentName","sizes","p","shape","SIZES_ROUNDED","round","SIZES_CIRCULAR","borderRadius","undefined","SIZES_BASE","SIZES_SQUARE","size","textProps","textPropsProp","iconProps","iconPropsProp","component","leftIconProps","rightIconProps","children","addonLeft","addonRight","content","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","sizeProps","iconBefore","iconAfter","Array","isArray","as","appearance","color","whiteSpace","SIZES_TEXT","SIZES_ICON","_jsx","Styled","_jsxs","_Fragment","Slot","render","addonLeftProps","Icon","name","Text","addonRightProps"],"mappings":"0YAwBA,MAAMA,MAAQC,kCAAAA,kCAAqD,CAACC,EAAOC,KACzE,MAAMC,EAAcC,eAAAA,eAAgEH,EAAO,CACzFI,cAdmB,QAenBC,MAAQC,GACFA,EAAEC,QAAU,UACPC,MAAAA,cAGLF,EAAEG,OAASH,EAAEC,QAAU,WAClBG,MAAAA,eAGLJ,EAAEK,oBAAiBC,EACdC,MAAAA,WAGFC,MAAAA,eAIX,MAAMC,KACJA,EAAO,IAAGJ,aACVA,EAAe,EACfK,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAAEZ,MAC7BA,EAAQ,SAAQa,UAChBA,EAAY,MAAKC,cACjBA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EAAEC,SACnBA,EAAQC,UACRA,EAASC,WACTA,EAAUC,QACVA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,KACGC,GACDhC,EAEJ,MAAMiC,EAAY,CAChBpB,OACAa,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAOG,EAAYC,GAAaC,MAAMC,QAAQZ,GAAQA,EAAO,CAACA,GAE9D,MAAMX,EAAuB,IACxBmB,EACHK,GAAI,OACJC,WAAY,UACZC,MAAO,UACPC,WAAY,SACZtC,MAAOuC,MAAAA,cACJ3B,GAGL,MAAMC,EAAuB,IAAKiB,EAAWO,MAAO,UAAWrC,MAAOwC,MAAAA,cAAe1B,GAErF,OACE2B,WAAAA,IAACC,MAAAA,KAAW,IACNb,KACAC,EACJK,GAAIpB,EACJL,KAAMA,EACNJ,aAAcA,EACdJ,MAAOA,EACPN,IAAKA,EAAIsB,gBAEDA,GAAa,WACnBA,EAAS,CAAEP,YAAWE,cAEtB8B,WAAAA,KAAAC,oBAAA,CAAA1B,SAAA,CACEuB,WAAAA,IAACI,UAAI,CACHlD,MAAO,CAAEkB,aACTiC,OACE3B,IACCY,EACIgB,GACCN,WAAAA,IAACO,KAAAA,KAAI,IACCD,EAAelC,aACfA,KACAG,EACJiC,YAAalB,GAAe,SAAWA,OAAaxB,EACpDe,YAAaS,GAAe,SAAWA,OAAaxB,SAGxDA,KAIPW,GAAYG,EAAUoB,WAAAA,IAACS,KAAAA,KAAI,IAAKvC,EAASO,SAAGA,GAAYG,IAAkB,KAE3EoB,WAAAA,IAACI,UAAI,CACHlD,MAAO,CAAEkB,aACTiC,OACE1B,IACCY,EACImB,GACCV,WAAAA,IAACO,KAAAA,KAAI,IACCG,EAAgBtC,aAChBA,KACAI,EACJgC,YAAajB,GAAc,SAAWA,OAAYzB,EAClDe,YAAaU,GAAc,SAAWA,OAAYzB,SAGtDA,uDA/HK"}
@@ -1,2 +1,2 @@
1
- import{createPolymorphicComponentWithRef}from'../../shared/utils/createPolymorphicComponentWithRef.mjs';import{useMergedProps}from'../../hooks/useMergedProps.mjs';import{Root}from'./style.mjs';import{SIZES_ROUNDED,SIZES_CIRCULAR,SIZES_BASE,SIZES_SQUARE,SIZES_ICON,SIZES_TEXT}from'./sizes.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Slot}from'../Slot/Slot.mjs';import{Icon}from'../Icon/Icon.mjs';import{Text}from'../Text/Text.mjs';const COMPONENT_NAME='Badge';const Badge=createPolymorphicComponentWithRef((o,e)=>{const s=useMergedProps(o,{componentName:"Badge",sizes:o=>o.shape==='rounded'?SIZES_ROUNDED:o.round||o.shape==='circular'?SIZES_CIRCULAR:o.borderRadius!==void 0?SIZES_BASE:SIZES_SQUARE});const{size:r="s",borderRadius:i=3,textProps:t={},iconProps:n={},shape:p="square",component:c="div",children:S,addonLeft:m,addonRight:a,content:d,icon:E,sizeXXS:I,sizeXS:h,sizeS:f,sizeM:l,sizeL:z,sizeXL:j,...x}=s;const R={size:r,sizeXXS:I,sizeXS:h,sizeS:f,sizeM:l,sizeL:z,sizeXL:j};const[P,u]=Array.isArray(E)?E:[E];const g={...R,as:'span',appearance:'caption',color:'inherit',whiteSpace:'nowrap',sizes:SIZES_TEXT,...t};const _={...R,color:'inherit',sizes:SIZES_ICON,...n};return jsx(Root,{...x,...R,as:c,size:r,borderRadius:i,shape:p,ref:e,children:typeof S=='function'?S({textProps:g,iconProps:_}):jsxs(Fragment,{children:[jsx(Slot,{props:{iconProps:_},render:m??(P?o=>jsx(Icon,{...o.iconProps,..._,name:typeof P=='string'?P:void 0,icon:typeof P!='string'?P:void 0}):void 0)}),S||d?jsx(Text,{...g,children:S||d}):null,jsx(Slot,{props:{iconProps:_},render:a??(u?o=>jsx(Icon,{...o.iconProps,..._,name:typeof u=='string'?u:void 0,icon:typeof u!='string'?u:void 0}):void 0)})]})})});export{Badge,COMPONENT_NAME};
1
+ import{createPolymorphicComponentWithRef}from'../../shared/utils/createPolymorphicComponentWithRef.mjs';import{useMergedProps}from'../../hooks/useMergedProps.mjs';import{Root}from'./style.mjs';import{SIZES_ROUNDED,SIZES_CIRCULAR,SIZES_BASE,SIZES_SQUARE,SIZES_ICON,SIZES_TEXT}from'./sizes.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Slot}from'../Slot/Slot.mjs';import{Icon}from'../Icon/Icon.mjs';import{Text}from'../Text/Text.mjs';const COMPONENT_NAME='Badge';const Badge=createPolymorphicComponentWithRef((o,e)=>{const s=useMergedProps(o,{componentName:"Badge",sizes:o=>o.shape==='rounded'?SIZES_ROUNDED:o.round||o.shape==='circular'?SIZES_CIRCULAR:o.borderRadius!==void 0?SIZES_BASE:SIZES_SQUARE});const{size:r="s",borderRadius:i=3,textProps:t={},iconProps:n={},shape:p="square",component:c="div",leftIconProps:S={},rightIconProps:m={},children:a,addonLeft:d,addonRight:E,content:I,icon:h,sizeXXS:f,sizeXS:l,sizeS:z,sizeM:P,sizeL:j,sizeXL:x,...R}=s;const g={size:r,sizeXXS:f,sizeXS:l,sizeS:z,sizeM:P,sizeL:j,sizeXL:x};const[u,_]=Array.isArray(h)?h:[h];const Z={...g,as:'span',appearance:'caption',color:'inherit',whiteSpace:'nowrap',sizes:SIZES_TEXT,...t};const y={...g,color:'inherit',sizes:SIZES_ICON,...n};return jsx(Root,{...R,...g,as:c,size:r,borderRadius:i,shape:p,ref:e,children:typeof a=='function'?a({textProps:Z,iconProps:y}):jsxs(Fragment,{children:[jsx(Slot,{props:{iconProps:y},render:d??(u?o=>jsx(Icon,{...o.iconProps,...y,...S,name:typeof u=='string'?u:void 0,icon:typeof u!='string'?u:void 0}):void 0)}),a||I?jsx(Text,{...Z,children:a||I}):null,jsx(Slot,{props:{iconProps:y},render:E??(_?o=>jsx(Icon,{...o.iconProps,...y,...m,name:typeof _=='string'?_:void 0,icon:typeof _!='string'?_:void 0}):void 0)})]})})});export{Badge,COMPONENT_NAME};
2
2
  //# sourceMappingURL=Badge.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.mjs","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { Slot } from 'components/Slot'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport * as Styled from './style'\nimport { SIZES_BASE, SIZES_SQUARE, SIZES_ICON, SIZES_CIRCULAR, SIZES_ROUNDED, SIZES_TEXT } from './sizes'\nimport type { BadgeProps } from './types'\n\nconst COMPONENT_NAME = 'Badge'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для маркировки свойств сущности.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Badge = createPolymorphicComponentWithRef<'div', BadgeProps>((props, ref) => {\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, BadgeProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (p) => {\n if (p.shape === 'rounded') {\n return SIZES_ROUNDED\n }\n\n if (p.round || p.shape === 'circular') {\n return SIZES_CIRCULAR\n }\n\n if (p.borderRadius !== undefined) {\n return SIZES_BASE\n }\n\n return SIZES_SQUARE\n },\n })\n\n const {\n size = 's',\n borderRadius = 3,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n shape = 'square',\n component = 'div',\n children,\n addonLeft,\n addonRight,\n content,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = mergedProps\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n whiteSpace: 'nowrap',\n sizes: SIZES_TEXT,\n ...textPropsProp,\n }\n\n const iconProps: IconProps = { ...sizeProps, color: 'inherit', sizes: SIZES_ICON, ...iconPropsProp }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={component}\n size={size}\n borderRadius={borderRadius}\n shape={shape}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n <Slot\n props={{ iconProps }}\n render={\n addonLeft ??\n (iconBefore\n ? (addonLeftProps) => (\n <Icon\n {...addonLeftProps.iconProps}\n {...iconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n )\n : undefined)\n }\n />\n\n {children || content ? <Text {...textProps}>{children || content}</Text> : null}\n\n <Slot\n props={{ iconProps }}\n render={\n addonRight ??\n (iconAfter\n ? (addonRightProps) => (\n <Icon\n {...addonRightProps.iconProps}\n {...iconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n )\n : undefined)\n }\n />\n </>\n )}\n </Styled.Root>\n )\n})\n\nconst BadgeDoc: React.FC<BadgeProps> = () => null\n\nexport { BadgeDoc, Badge, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Badge","createPolymorphicComponentWithRef","props","ref","mergedProps","useMergedProps","componentName","sizes","p","shape","SIZES_ROUNDED","round","SIZES_CIRCULAR","borderRadius","undefined","SIZES_BASE","SIZES_SQUARE","size","textProps","textPropsProp","iconProps","iconPropsProp","component","children","addonLeft","addonRight","content","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","sizeProps","iconBefore","iconAfter","Array","isArray","as","appearance","color","whiteSpace","SIZES_TEXT","SIZES_ICON","_jsx","Styled","_jsxs","_Fragment","Slot","render","addonLeftProps","Icon","name","Text","addonRightProps"],"mappings":"+bAYA,MAAMA,eAAiB,QAYvB,MAAMC,MAAQC,kCAAqD,CAACC,EAAOC,KACzE,MAAMC,EAAcC,eAAgEH,EAAO,CACzFI,cAdmB,QAenBC,MAAQC,GACFA,EAAEC,QAAU,UACPC,cAGLF,EAAEG,OAASH,EAAEC,QAAU,WAClBG,eAGLJ,EAAEK,oBAAiBC,EACdC,WAGFC,eAIX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DA"}
1
+ {"version":3,"file":"Badge.mjs","sources":["../../../../src/components/Badge/Badge.tsx"],"sourcesContent":["import { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { Text } from 'components/Text'\nimport type { TextProps } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport type { IconProps } from 'components/Icon'\nimport { Slot } from 'components/Slot'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport * as Styled from './style'\nimport { SIZES_BASE, SIZES_SQUARE, SIZES_ICON, SIZES_CIRCULAR, SIZES_ROUNDED, SIZES_TEXT } from './sizes'\nimport type { BadgeProps } from './types'\n\nconst COMPONENT_NAME = 'Badge'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для маркировки свойств сущности.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Badge = createPolymorphicComponentWithRef<'div', BadgeProps>((props, ref) => {\n const mergedProps = useMergedProps<PolymorphicProps<React.ElementType, BadgeProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (p) => {\n if (p.shape === 'rounded') {\n return SIZES_ROUNDED\n }\n\n if (p.round || p.shape === 'circular') {\n return SIZES_CIRCULAR\n }\n\n if (p.borderRadius !== undefined) {\n return SIZES_BASE\n }\n\n return SIZES_SQUARE\n },\n })\n\n const {\n size = 's',\n borderRadius = 3,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n shape = 'square',\n component = 'div',\n leftIconProps = {},\n rightIconProps = {},\n children,\n addonLeft,\n addonRight,\n content,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = mergedProps\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n whiteSpace: 'nowrap',\n sizes: SIZES_TEXT,\n ...textPropsProp,\n }\n\n const iconProps: IconProps = { ...sizeProps, color: 'inherit', sizes: SIZES_ICON, ...iconPropsProp }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={component}\n size={size}\n borderRadius={borderRadius}\n shape={shape}\n ref={ref}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n <Slot\n props={{ iconProps }}\n render={\n addonLeft ??\n (iconBefore\n ? (addonLeftProps) => (\n <Icon\n {...addonLeftProps.iconProps}\n {...iconProps}\n {...leftIconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n )\n : undefined)\n }\n />\n\n {children || content ? <Text {...textProps}>{children || content}</Text> : null}\n\n <Slot\n props={{ iconProps }}\n render={\n addonRight ??\n (iconAfter\n ? (addonRightProps) => (\n <Icon\n {...addonRightProps.iconProps}\n {...iconProps}\n {...rightIconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n )\n : undefined)\n }\n />\n </>\n )}\n </Styled.Root>\n )\n})\n\nconst BadgeDoc: React.FC<BadgeProps> = () => null\n\nexport { BadgeDoc, Badge, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Badge","createPolymorphicComponentWithRef","props","ref","mergedProps","useMergedProps","componentName","sizes","p","shape","SIZES_ROUNDED","round","SIZES_CIRCULAR","borderRadius","undefined","SIZES_BASE","SIZES_SQUARE","size","textProps","textPropsProp","iconProps","iconPropsProp","component","leftIconProps","rightIconProps","children","addonLeft","addonRight","content","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","sizeProps","iconBefore","iconAfter","Array","isArray","as","appearance","color","whiteSpace","SIZES_TEXT","SIZES_ICON","_jsx","Styled","_jsxs","_Fragment","Slot","render","addonLeftProps","Icon","name","Text","addonRightProps"],"mappings":"+bAYA,MAAMA,eAAiB,QAYvB,MAAMC,MAAQC,kCAAqD,CAACC,EAAOC,KACzE,MAAMC,EAAcC,eAAgEH,EAAO,CACzFI,cAdmB,QAenBC,MAAQC,GACFA,EAAEC,QAAU,UACPC,cAGLF,EAAEG,OAASH,EAAEC,QAAU,WAClBG,eAGLJ,EAAEK,oBAAiBC,EACdC,WAGFC,eAIX,MAAMC,KACJA,EAAO,IAAGJ,aACVA,EAAe,EACfK,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAAEZ,MAC7BA,EAAQ,SAAQa,UAChBA,EAAY,MAAKC,cACjBA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EAAEC,SACnBA,EAAQC,UACRA,EAASC,WACTA,EAAUC,QACVA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,KACGC,GACDhC,EAEJ,MAAMiC,EAAY,CAChBpB,OACAa,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAOG,EAAYC,GAAaC,MAAMC,QAAQZ,GAAQA,EAAO,CAACA,GAE9D,MAAMX,EAAuB,IACxBmB,EACHK,GAAI,OACJC,WAAY,UACZC,MAAO,UACPC,WAAY,SACZtC,MAAOuC,cACJ3B,GAGL,MAAMC,EAAuB,IAAKiB,EAAWO,MAAO,UAAWrC,MAAOwC,cAAe1B,GAErF,OACE2B,IAACC,KAAW,IACNb,KACAC,EACJK,GAAIpB,EACJL,KAAMA,EACNJ,aAAcA,EACdJ,MAAOA,EACPN,IAAKA,EAAIsB,gBAEDA,GAAa,WACnBA,EAAS,CAAEP,YAAWE,cAEtB8B,KAAAC,SAAA,CAAA1B,SAAA,CACEuB,IAACI,KAAI,CACHlD,MAAO,CAAEkB,aACTiC,OACE3B,IACCY,EACIgB,GACCN,IAACO,KAAI,IACCD,EAAelC,aACfA,KACAG,EACJiC,YAAalB,GAAe,SAAWA,OAAaxB,EACpDe,YAAaS,GAAe,SAAWA,OAAaxB,SAGxDA,KAIPW,GAAYG,EAAUoB,IAACS,KAAI,IAAKvC,EAASO,SAAGA,GAAYG,IAAkB,KAE3EoB,IAACI,KAAI,CACHlD,MAAO,CAAEkB,aACTiC,OACE1B,IACCY,EACImB,GACCV,IAACO,KAAI,IACCG,EAAgBtC,aAChBA,KACAI,EACJgC,YAAajB,GAAc,SAAWA,OAAYzB,EAClDe,YAAaU,GAAc,SAAWA,OAAYzB,SAGtDA"}
@@ -1,2 +1,2 @@
1
- 'use strict';var React=require('react');var styled=require('styled-components');var useClassname=require('../../hooks/useClassname.js');var withMergedProps=require('../../hocs/withMergedProps.js');var hooks=require('./hooks.js');var sizes=require('./sizes.js');var sizesDefault=require('./sizes-default.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text=require('../Text/Text.js');var Icon=require('../Icon/Icon.js');var index=require('../../icon-pack/src/icons/CheckFill/index.js');var index$1=require('../../icon-pack/src/icons/LoaderFill/index.js');const Button=withMergedProps.withMergedProps(React.forwardRef((e,s)=>{let{size:t="m",inline:n=!0,rounded:i=!0,color:r="accent",fontColor:o="white",showContentOnStatus:a,textProps:c={},iconProps:l={},as:u,sizeXXS:d,sizeXS:x,sizeS:p,sizeM:m,sizeL:j,sizeXL:S,className:z,children:h,content:I,fontWeight:R,icon:f,innerRef:y,...E}=e;const v=styled.useTheme();E.preset!=='default'||typeof t!='string'||E.round||(E={...sizesDefault.PROPS_BY_SIZE[t]??{},...E}),E.href&&(u='a'),E.to&&(u=v.link),E.disabled&&(u='button'),E.primary&&(r='primary'),E.secondary&&(r='atlantis');const C=useClassname.useClassname("Button",z);const _=useClassname.useClassname("Button");const g=hooks.useComputedRel(v,E);const N=hooks.useComputedLinkProps(u,E);let[T,q]=Array.isArray(f)?f:[f];const D={size:t,sizeXXS:d,sizeXS:x,sizeS:p,sizeM:m,sizeL:j,sizeXL:S};const P={...D,as:'span',color:'inherit',weight:R??(E.preset==='brand'?800:600),lineHeight:E.preset==='brand'?1.2:1,sizes:E.preset==='brand'?sizes.SIZES_TEXT:sizesDefault.SIZES_TEXT_DEFAULT};const Z={...D,color:'inherit',preset:E.preset,sizes:sizes.SIZES_ICON};const k=E.preset==='brand'&&E.success;const L=E.preset==='brand'&&E.loading;const X=typeof h!='function'&&(h||I)?jsxRuntime.jsx(Text.Text,{className:`${_}__content`,...P,...c,children:h||I}):null;return jsxRuntime.jsx(style.Root,{...E,...N,...D,inline:n,color:r,fontColor:o,rounded:i,rel:g,as:u,className:C,ref:s??y,children:typeof h=='function'?h({textProps:P,iconProps:Z}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k||L?jsxRuntime.jsxs(style.ContentWithStatus,{children:[k?jsxRuntime.jsx(Icon.Icon,{...Z,...l,icon:jsxRuntime.jsx(index.CheckFill,{})}):jsxRuntime.jsx(style.IconAnimation,{children:jsxRuntime.jsx(Icon.Icon,{...Z,...l,icon:jsxRuntime.jsx(index$1.LoaderFill,{})})}),a?X:null]}):null,jsxRuntime.jsxs(style.Content,{"aria-hidden":k||L,children:[T?jsxRuntime.jsx(Icon.Icon,{className:"icon",name:typeof T=='string'?T:void 0,icon:typeof T!='string'?T:void 0,...Z,...l}):null,X,q?jsxRuntime.jsx(Icon.Icon,{className:"icon",name:typeof q=='string'?q:void 0,icon:typeof q!='string'?q:void 0,...Z,...l}):null]})]})})}),{displayName:"Button",sizes:e=>{let s=e.preset==='brand'?sizes.SIZES:sizesDefault.SIZES_DEFAULT;return e.round&&(s=e.preset==='brand'?sizes.SIZES_ROUND:sizesDefault.SIZES_ROUND_DEFAULT),s}});exports.SIZES=sizes.SIZES,exports.SIZES_ROUND=sizes.SIZES_ROUND,exports.Button=Button,exports.COMPONENT_NAME="Button";
1
+ 'use strict';var React=require('react');var styled=require('styled-components');var useClassname=require('../../hooks/useClassname.js');var withMergedProps=require('../../hocs/withMergedProps.js');var hooks=require('./hooks.js');var sizes=require('./sizes.js');var sizesDefault=require('./sizes-default.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Text=require('../Text/Text.js');var Icon=require('../Icon/Icon.js');var index=require('../../icon-pack/src/icons/CheckFill/index.js');var index$1=require('../../icon-pack/src/icons/LoaderFill/index.js');const Button=withMergedProps.withMergedProps(React.forwardRef((e,s)=>{let{size:t="m",inline:n=!0,rounded:i=!0,color:r="accent",fontColor:o="white",showContentOnStatus:a,textProps:c={},iconProps:l={},leftIconProps:u={},rightIconProps:d={},as:x,sizeXXS:p,sizeXS:m,sizeS:j,sizeM:S,sizeL:h,sizeXL:z,className:I,children:f,content:R,fontWeight:y,icon:E,innerRef:v,...C}=e;const g=styled.useTheme();C.preset!=='default'||typeof t!='string'||C.round||(C={...sizesDefault.PROPS_BY_SIZE[t]??{},...C}),C.href&&(x='a'),C.to&&(x=g.link),C.disabled&&(x='button'),C.primary&&(r='primary'),C.secondary&&(r='atlantis');const _=useClassname.useClassname("Button",I);const N=useClassname.useClassname("Button");const P=hooks.useComputedRel(g,C);const T=hooks.useComputedLinkProps(x,C);let[q,D]=Array.isArray(E)?E:[E];const Z={size:t,sizeXXS:p,sizeXS:m,sizeS:j,sizeM:S,sizeL:h,sizeXL:z};const k={...Z,as:'span',color:'inherit',weight:y??(C.preset==='brand'?800:600),lineHeight:C.preset==='brand'?1.2:1,sizes:C.preset==='brand'?sizes.SIZES_TEXT:sizesDefault.SIZES_TEXT_DEFAULT};const L={...Z,color:'inherit',preset:C.preset,sizes:sizes.SIZES_ICON};const X=C.preset==='brand'&&C.success;const b=C.preset==='brand'&&C.loading;const O=typeof f!='function'&&(f||R)?jsxRuntime.jsx(Text.Text,{className:`${N}__content`,...k,...c,children:f||R}):null;return jsxRuntime.jsx(style.Root,{...C,...T,...Z,inline:n,color:r,fontColor:o,rounded:i,rel:P,as:x,className:_,ref:s??v,children:typeof f=='function'?f({textProps:k,iconProps:L}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[X||b?jsxRuntime.jsxs(style.ContentWithStatus,{children:[X?jsxRuntime.jsx(Icon.Icon,{...L,...l,icon:jsxRuntime.jsx(index.CheckFill,{})}):jsxRuntime.jsx(style.IconAnimation,{children:jsxRuntime.jsx(Icon.Icon,{...L,...l,icon:jsxRuntime.jsx(index$1.LoaderFill,{})})}),a?O:null]}):null,jsxRuntime.jsxs(style.Content,{"aria-hidden":X||b,children:[q?jsxRuntime.jsx(Icon.Icon,{className:"icon",name:typeof q=='string'?q:void 0,icon:typeof q!='string'?q:void 0,...L,...l,...u}):null,O,D?jsxRuntime.jsx(Icon.Icon,{className:"icon",name:typeof D=='string'?D:void 0,icon:typeof D!='string'?D:void 0,...L,...l,...d}):null]})]})})}),{displayName:"Button",sizes:e=>{let s=e.preset==='brand'?sizes.SIZES:sizesDefault.SIZES_DEFAULT;return e.round&&(s=e.preset==='brand'?sizes.SIZES_ROUND:sizesDefault.SIZES_ROUND_DEFAULT),s}});exports.SIZES=sizes.SIZES,exports.SIZES_ROUND=sizes.SIZES_ROUND,exports.Button=Button,exports.COMPONENT_NAME="Button";
2
2
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable prefer-const */\nimport { forwardRef } from 'react'\nimport { useTheme } from 'styled-components'\nimport { CheckFill, LoaderFill } from '@foxford/icon-pack'\nimport { useClassname } from 'hooks/useClassname'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Text } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { TextProps } from 'components/Text'\nimport { useComputedRel, useComputedLinkProps } from './hooks'\nimport { SIZES, SIZES_ROUND, SIZES_ICON, SIZES_TEXT } from './sizes'\nimport { SIZES_DEFAULT, SIZES_ROUND_DEFAULT, PROPS_BY_SIZE, SIZES_TEXT_DEFAULT } from './sizes-default'\nimport type { ButtonProps, Size } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Button'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<button\\> элемента.\n */\nconst Button: React.ForwardRefExoticComponent<ButtonProps> = withMergedProps<ButtonProps, HTMLButtonElement>(\n forwardRef<HTMLButtonElement, MergedProps<ButtonProps>>((props, ref) => {\n let {\n size = 'm',\n inline = true,\n rounded = true,\n color = 'accent',\n fontColor = 'white',\n showContentOnStatus,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n as: _as,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n className,\n children,\n content,\n fontWeight,\n icon,\n innerRef,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n if (restProps.preset === 'default' && typeof size === 'string' && !restProps.round) {\n const propsBySize = PROPS_BY_SIZE[size as Size] ?? {}\n restProps = { ...propsBySize, ...restProps }\n }\n\n if (restProps.href) _as = 'a'\n if (restProps.to) _as = theme.link\n if (restProps.disabled) _as = 'button'\n\n if (restProps.primary) color = 'primary'\n if (restProps.secondary) color = 'atlantis'\n\n const rootClassName = useClassname(COMPONENT_NAME, className)\n const textClassName = useClassname(COMPONENT_NAME)\n const rel = useComputedRel(theme, restProps)\n const linkProps = useComputedLinkProps(_as, restProps)\n\n let [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n color: 'inherit',\n weight: fontWeight ?? (restProps.preset === 'brand' ? 800 : 600),\n lineHeight: restProps.preset === 'brand' ? 1.2 : 1,\n sizes: restProps.preset === 'brand' ? SIZES_TEXT : SIZES_TEXT_DEFAULT,\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n color: 'inherit',\n preset: restProps.preset,\n sizes: SIZES_ICON,\n }\n\n const success = restProps.preset === 'brand' && restProps.success\n const loading = restProps.preset === 'brand' && restProps.loading\n\n const mainContent =\n typeof children !== 'function' && (children || content) ? (\n <Text className={`${textClassName}__content`} {...textProps} {...textPropsProp}>\n {children || content}\n </Text>\n ) : null\n\n return (\n <Styled.Root\n {...restProps}\n {...linkProps}\n {...sizeProps}\n inline={inline}\n color={color}\n fontColor={fontColor}\n rounded={rounded}\n rel={rel}\n as={_as}\n className={rootClassName}\n ref={ref ?? innerRef}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n {success || loading ? (\n <Styled.ContentWithStatus>\n {success ? (\n <Icon {...iconProps} {...iconPropsProp} icon={<CheckFill />} />\n ) : (\n <Styled.IconAnimation>\n <Icon {...iconProps} {...iconPropsProp} icon={<LoaderFill />} />\n </Styled.IconAnimation>\n )}\n {showContentOnStatus ? mainContent : null}\n </Styled.ContentWithStatus>\n ) : null}\n <Styled.Content aria-hidden={success || loading}>\n {before ? (\n <Icon\n className='icon'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n {...iconPropsProp}\n />\n ) : null}\n {mainContent}\n {after ? (\n <Icon\n className='icon'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n {...iconPropsProp}\n />\n ) : null}\n </Styled.Content>\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n let sizes = props.preset === 'brand' ? SIZES : SIZES_DEFAULT\n if (props.round) sizes = props.preset === 'brand' ? SIZES_ROUND : SIZES_ROUND_DEFAULT\n\n return sizes\n },\n }\n)\n\nexport { Button, COMPONENT_NAME, SIZES, SIZES_ROUND }\n\nexport type { ButtonProps }\n"],"names":["Button","withMergedProps","forwardRef","props","ref","size","inline","rounded","color","fontColor","showContentOnStatus","textProps","textPropsProp","iconProps","iconPropsProp","as","_as","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","className","children","content","fontWeight","icon","innerRef","restProps","theme","useTheme","preset","round","PROPS_BY_SIZE","href","to","link","disabled","primary","secondary","rootClassName","useClassname","textClassName","rel","useComputedRel","linkProps","useComputedLinkProps","before","after","Array","isArray","sizeProps","weight","lineHeight","sizes","SIZES_TEXT","SIZES_TEXT_DEFAULT","SIZES_ICON","success","loading","mainContent","_jsx","Text","Styled","_jsxs","_Fragment","Icon","CheckFill","LoaderFill","name","undefined","displayName","SIZES","SIZES_DEFAULT","SIZES_ROUND","SIZES_ROUND_DEFAULT"],"mappings":"+kBAyBA,MAAMA,OAAuDC,gBAAAA,gBAC3DC,MAAAA,WAAwD,CAACC,EAAOC,KAC9D,IAAIC,KACFA,EAAO,IAAGC,OACVA,GAAS,EAAIC,QACbA,GAAU,EAAIC,MACdA,EAAQ,SAAQC,UAChBA,EAAY,QAAOC,oBACnBA,EACAC,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAC3BC,GAAIC,EAAGC,QACPA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,WACPA,EAAUC,KACVA,EAAIC,SACJA,KACGC,GACD1B,EAEJ,MAAM2B,EAAQC,OAAAA,WAEVF,EAAUG,SAAW,kBAAoB3B,GAAS,UAAawB,EAAUI,QAE3EJ,EAAY,IADQK,aAAAA,cAAc7B,IAAiB,CAAA,KAClBwB,IAG/BA,EAAUM,OAAMnB,EAAM,KACtBa,EAAUO,KAAIpB,EAAMc,EAAMO,MAC1BR,EAAUS,WAAUtB,EAAM,UAE1Ba,EAAUU,UAAS/B,EAAQ,WAC3BqB,EAAUW,YAAWhC,EAAQ,YAEjC,MAAMiC,EAAgBC,aAAAA,aAjDH,SAiDgCnB,GACnD,MAAMoB,EAAgBD,aAAAA,aAlDH,UAmDnB,MAAME,EAAMC,MAAAA,eAAef,EAAOD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EAAea,KAAMmC,WAAAA,IAACO,QAAAA,WAAU,CAAA,OAG5D3D,EAAsBmD,EAAc,QAErC,KACJI,WAAAA,KAACD,cAAc,CAAC,cAAaL,GAAWC,EAAQpC,SAAA,CAC7CwB,EACCc,WAAAA,IAACK,UAAI,CACH5C,UAAU,OACV+C,YAAatB,GAAW,SAAWA,OAASuB,EAC5C5C,YAAaqB,GAAW,SAAWA,OAASuB,KACxC1D,KACAC,IAEJ,KACH+C,EACAZ,EACCa,WAAAA,IAACK,KAAAA,KAAI,CACH5C,UAAU,OACV+C,YAAarB,GAAU,SAAWA,OAAQsB,EAC1C5C,YAAasB,GAAU,SAAWA,OAAQsB,KACtC1D,KACAC,IAEJ,eAOhB,CACE0D,YArJmB,SAsJnBjB,MAAQpD,IACN,IAAIoD,EAAQpD,EAAM6B,SAAW,QAAUyC,MAAAA,MAAQC,aAAAA,cAG/C,OAFIvE,EAAM8B,QAAOsB,EAAQpD,EAAM6B,SAAW,QAAU2C,MAAAA,YAAcC,aAAAA,qBAE3DrB,kHA1JU"}
1
+ {"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable prefer-const */\nimport { forwardRef } from 'react'\nimport { useTheme } from 'styled-components'\nimport { CheckFill, LoaderFill } from '@foxford/icon-pack'\nimport { useClassname } from 'hooks/useClassname'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Text } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { TextProps } from 'components/Text'\nimport { useComputedRel, useComputedLinkProps } from './hooks'\nimport { SIZES, SIZES_ROUND, SIZES_ICON, SIZES_TEXT } from './sizes'\nimport { SIZES_DEFAULT, SIZES_ROUND_DEFAULT, PROPS_BY_SIZE, SIZES_TEXT_DEFAULT } from './sizes-default'\nimport type { ButtonProps, Size } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Button'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<button\\> элемента.\n */\nconst Button: React.ForwardRefExoticComponent<ButtonProps> = withMergedProps<ButtonProps, HTMLButtonElement>(\n forwardRef<HTMLButtonElement, MergedProps<ButtonProps>>((props, ref) => {\n let {\n size = 'm',\n inline = true,\n rounded = true,\n color = 'accent',\n fontColor = 'white',\n showContentOnStatus,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n leftIconProps = {},\n rightIconProps = {},\n as: _as,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n className,\n children,\n content,\n fontWeight,\n icon,\n innerRef,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n if (restProps.preset === 'default' && typeof size === 'string' && !restProps.round) {\n const propsBySize = PROPS_BY_SIZE[size as Size] ?? {}\n restProps = { ...propsBySize, ...restProps }\n }\n\n if (restProps.href) _as = 'a'\n if (restProps.to) _as = theme.link\n if (restProps.disabled) _as = 'button'\n\n if (restProps.primary) color = 'primary'\n if (restProps.secondary) color = 'atlantis'\n\n const rootClassName = useClassname(COMPONENT_NAME, className)\n const textClassName = useClassname(COMPONENT_NAME)\n const rel = useComputedRel(theme, restProps)\n const linkProps = useComputedLinkProps(_as, restProps)\n\n let [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n color: 'inherit',\n weight: fontWeight ?? (restProps.preset === 'brand' ? 800 : 600),\n lineHeight: restProps.preset === 'brand' ? 1.2 : 1,\n sizes: restProps.preset === 'brand' ? SIZES_TEXT : SIZES_TEXT_DEFAULT,\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n color: 'inherit',\n preset: restProps.preset,\n sizes: SIZES_ICON,\n }\n\n const success = restProps.preset === 'brand' && restProps.success\n const loading = restProps.preset === 'brand' && restProps.loading\n\n const mainContent =\n typeof children !== 'function' && (children || content) ? (\n <Text className={`${textClassName}__content`} {...textProps} {...textPropsProp}>\n {children || content}\n </Text>\n ) : null\n\n return (\n <Styled.Root\n {...restProps}\n {...linkProps}\n {...sizeProps}\n inline={inline}\n color={color}\n fontColor={fontColor}\n rounded={rounded}\n rel={rel}\n as={_as}\n className={rootClassName}\n ref={ref ?? innerRef}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n {success || loading ? (\n <Styled.ContentWithStatus>\n {success ? (\n <Icon {...iconProps} {...iconPropsProp} icon={<CheckFill />} />\n ) : (\n <Styled.IconAnimation>\n <Icon {...iconProps} {...iconPropsProp} icon={<LoaderFill />} />\n </Styled.IconAnimation>\n )}\n {showContentOnStatus ? mainContent : null}\n </Styled.ContentWithStatus>\n ) : null}\n <Styled.Content aria-hidden={success || loading}>\n {before ? (\n <Icon\n className='icon'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n {...iconPropsProp}\n {...leftIconProps}\n />\n ) : null}\n {mainContent}\n {after ? (\n <Icon\n className='icon'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n {...iconPropsProp}\n {...rightIconProps}\n />\n ) : null}\n </Styled.Content>\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n let sizes = props.preset === 'brand' ? SIZES : SIZES_DEFAULT\n if (props.round) sizes = props.preset === 'brand' ? SIZES_ROUND : SIZES_ROUND_DEFAULT\n\n return sizes\n },\n }\n)\n\nexport { Button, COMPONENT_NAME, SIZES, SIZES_ROUND }\n\nexport type { ButtonProps }\n"],"names":["Button","withMergedProps","forwardRef","props","ref","size","inline","rounded","color","fontColor","showContentOnStatus","textProps","textPropsProp","iconProps","iconPropsProp","leftIconProps","rightIconProps","as","_as","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","className","children","content","fontWeight","icon","innerRef","restProps","theme","useTheme","preset","round","PROPS_BY_SIZE","href","to","link","disabled","primary","secondary","rootClassName","useClassname","textClassName","rel","useComputedRel","linkProps","useComputedLinkProps","before","after","Array","isArray","sizeProps","weight","lineHeight","sizes","SIZES_TEXT","SIZES_TEXT_DEFAULT","SIZES_ICON","success","loading","mainContent","_jsx","Text","Styled","_jsxs","_Fragment","Icon","CheckFill","LoaderFill","name","undefined","displayName","SIZES","SIZES_DEFAULT","SIZES_ROUND","SIZES_ROUND_DEFAULT"],"mappings":"+kBAyBA,MAAMA,OAAuDC,gBAAAA,gBAC3DC,MAAAA,WAAwD,CAACC,EAAOC,KAC9D,IAAIC,KACFA,EAAO,IAAGC,OACVA,GAAS,EAAIC,QACbA,GAAU,EAAIC,MACdA,EAAQ,SAAQC,UAChBA,EAAY,QAAOC,oBACnBA,EACAC,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAAEC,cAC7BA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EACjBC,GAAIC,EAAGC,QACPA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,WACPA,EAAUC,KACVA,EAAIC,SACJA,KACGC,GACD5B,EAEJ,MAAM6B,EAAQC,OAAAA,WAEVF,EAAUG,SAAW,kBAAoB7B,GAAS,UAAa0B,EAAUI,QAE3EJ,EAAY,IADQK,aAAAA,cAAc/B,IAAiB,CAAA,KAClB0B,IAG/BA,EAAUM,OAAMnB,EAAM,KACtBa,EAAUO,KAAIpB,EAAMc,EAAMO,MAC1BR,EAAUS,WAAUtB,EAAM,UAE1Ba,EAAUU,UAASjC,EAAQ,WAC3BuB,EAAUW,YAAWlC,EAAQ,YAEjC,MAAMmC,EAAgBC,aAAAA,aAnDH,SAmDgCnB,GACnD,MAAMoB,EAAgBD,aAAAA,aApDH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BsC,WAAAA,IAACK,UAAI,IAAKxD,KAAeC,EAAee,KAAMmC,WAAAA,IAACO,QAAAA,WAAU,CAAA,OAG5D7D,EAAsBqD,EAAc,QAErC,KACJI,WAAAA,KAACD,cAAc,CAAC,cAAaL,GAAWC,EAAQpC,SAAA,CAC7CwB,EACCc,WAAAA,IAACK,UAAI,CACH5C,UAAU,OACV+C,YAAatB,GAAW,SAAWA,OAASuB,EAC5C5C,YAAaqB,GAAW,SAAWA,OAASuB,KACxC5D,KACAC,KACAC,IAEJ,KACHgD,EACAZ,EACCa,WAAAA,IAACK,KAAAA,KAAI,CACH5C,UAAU,OACV+C,YAAarB,GAAU,SAAWA,OAAQsB,EAC1C5C,YAAasB,GAAU,SAAWA,OAAQsB,KACtC5D,KACAC,KACAE,IAEJ,eAOhB,CACE0D,YAzJmB,SA0JnBjB,MAAQtD,IACN,IAAIsD,EAAQtD,EAAM+B,SAAW,QAAUyC,MAAAA,MAAQC,aAAAA,cAG/C,OAFIzE,EAAMgC,QAAOsB,EAAQtD,EAAM+B,SAAW,QAAU2C,MAAAA,YAAcC,aAAAA,qBAE3DrB,kHA9JU"}
@@ -1,2 +1,2 @@
1
- import{forwardRef}from'react';import{useTheme}from'styled-components';import{useClassname}from'../../hooks/useClassname.mjs';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useComputedRel,useComputedLinkProps}from'./hooks.mjs';import{SIZES,SIZES_ROUND,SIZES_TEXT,SIZES_ICON}from'./sizes.mjs';import{SIZES_DEFAULT,SIZES_ROUND_DEFAULT,PROPS_BY_SIZE,SIZES_TEXT_DEFAULT}from'./sizes-default.mjs';import{Root,ContentWithStatus,IconAnimation,Content}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Text}from'../Text/Text.mjs';import{Icon}from'../Icon/Icon.mjs';import{CheckFill}from'../../icon-pack/src/icons/CheckFill/index.mjs';import{LoaderFill}from'../../icon-pack/src/icons/LoaderFill/index.mjs';const COMPONENT_NAME='Button';const Button=withMergedProps(forwardRef((e,s)=>{let{size:o="m",inline:t=!0,rounded:n=!0,color:r="accent",fontColor:i="white",showContentOnStatus:c,textProps:a={},iconProps:m={},as:l,sizeXXS:p,sizeXS:d,sizeS:S,sizeM:u,sizeL:f,sizeXL:E,className:h,children:I,content:j,fontWeight:_,icon:x,innerRef:C,...T}=e;const z=useTheme();T.preset!=='default'||typeof o!='string'||T.round||(T={...PROPS_BY_SIZE[o]??{},...T}),T.href&&(l='a'),T.to&&(l=z.link),T.disabled&&(l='button'),T.primary&&(r='primary'),T.secondary&&(r='atlantis');const N=useClassname("Button",h);const Z=useClassname("Button");const y=useComputedRel(z,T);const L=useComputedLinkProps(l,T);let[P,g]=Array.isArray(x)?x:[x];const F={size:o,sizeXXS:p,sizeXS:d,sizeS:S,sizeM:u,sizeL:f,sizeXL:E};const O={...F,as:'span',color:'inherit',weight:_??(T.preset==='brand'?800:600),lineHeight:T.preset==='brand'?1.2:1,sizes:T.preset==='brand'?SIZES_TEXT:SIZES_TEXT_DEFAULT};const R={...F,color:'inherit',preset:T.preset,sizes:SIZES_ICON};const A=T.preset==='brand'&&T.success;const X=T.preset==='brand'&&T.loading;const D=typeof I!='function'&&(I||j)?jsx(Text,{className:`${Z}__content`,...O,...a,children:I||j}):null;return jsx(Root,{...T,...L,...F,inline:t,color:r,fontColor:i,rounded:n,rel:y,as:l,className:N,ref:s??C,children:typeof I=='function'?I({textProps:O,iconProps:R}):jsxs(Fragment,{children:[A||X?jsxs(ContentWithStatus,{children:[A?jsx(Icon,{...R,...m,icon:jsx(CheckFill,{})}):jsx(IconAnimation,{children:jsx(Icon,{...R,...m,icon:jsx(LoaderFill,{})})}),c?D:null]}):null,jsxs(Content,{"aria-hidden":A||X,children:[P?jsx(Icon,{className:"icon",name:typeof P=='string'?P:void 0,icon:typeof P!='string'?P:void 0,...R,...m}):null,D,g?jsx(Icon,{className:"icon",name:typeof g=='string'?g:void 0,icon:typeof g!='string'?g:void 0,...R,...m}):null]})]})})}),{displayName:"Button",sizes:e=>{let s=e.preset==='brand'?SIZES:SIZES_DEFAULT;return e.round&&(s=e.preset==='brand'?SIZES_ROUND:SIZES_ROUND_DEFAULT),s}});export{Button,COMPONENT_NAME,SIZES,SIZES_ROUND};
1
+ import{forwardRef}from'react';import{useTheme}from'styled-components';import{useClassname}from'../../hooks/useClassname.mjs';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{useComputedRel,useComputedLinkProps}from'./hooks.mjs';import{SIZES,SIZES_ROUND,SIZES_TEXT,SIZES_ICON}from'./sizes.mjs';import{SIZES_DEFAULT,SIZES_ROUND_DEFAULT,PROPS_BY_SIZE,SIZES_TEXT_DEFAULT}from'./sizes-default.mjs';import{Root,ContentWithStatus,IconAnimation,Content}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Text}from'../Text/Text.mjs';import{Icon}from'../Icon/Icon.mjs';import{CheckFill}from'../../icon-pack/src/icons/CheckFill/index.mjs';import{LoaderFill}from'../../icon-pack/src/icons/LoaderFill/index.mjs';const COMPONENT_NAME='Button';const Button=withMergedProps(forwardRef((e,o)=>{let{size:s="m",inline:t=!0,rounded:n=!0,color:r="accent",fontColor:i="white",showContentOnStatus:c,textProps:a={},iconProps:l={},leftIconProps:m={},rightIconProps:p={},as:d,sizeXXS:S,sizeXS:u,sizeS:f,sizeM:E,sizeL:I,sizeXL:h,className:j,children:_,content:x,fontWeight:C,icon:T,innerRef:z,...N}=e;const Z=useTheme();N.preset!=='default'||typeof s!='string'||N.round||(N={...PROPS_BY_SIZE[s]??{},...N}),N.href&&(d='a'),N.to&&(d=Z.link),N.disabled&&(d='button'),N.primary&&(r='primary'),N.secondary&&(r='atlantis');const P=useClassname("Button",j);const g=useClassname("Button");const y=useComputedRel(Z,N);const L=useComputedLinkProps(d,N);let[F,O]=Array.isArray(T)?T:[T];const R={size:s,sizeXXS:S,sizeXS:u,sizeS:f,sizeM:E,sizeL:I,sizeXL:h};const A={...R,as:'span',color:'inherit',weight:C??(N.preset==='brand'?800:600),lineHeight:N.preset==='brand'?1.2:1,sizes:N.preset==='brand'?SIZES_TEXT:SIZES_TEXT_DEFAULT};const X={...R,color:'inherit',preset:N.preset,sizes:SIZES_ICON};const D=N.preset==='brand'&&N.success;const U=N.preset==='brand'&&N.loading;const k=typeof _!='function'&&(_||x)?jsx(Text,{className:`${g}__content`,...A,...a,children:_||x}):null;return jsx(Root,{...N,...L,...R,inline:t,color:r,fontColor:i,rounded:n,rel:y,as:d,className:P,ref:o??z,children:typeof _=='function'?_({textProps:A,iconProps:X}):jsxs(Fragment,{children:[D||U?jsxs(ContentWithStatus,{children:[D?jsx(Icon,{...X,...l,icon:jsx(CheckFill,{})}):jsx(IconAnimation,{children:jsx(Icon,{...X,...l,icon:jsx(LoaderFill,{})})}),c?k:null]}):null,jsxs(Content,{"aria-hidden":D||U,children:[F?jsx(Icon,{className:"icon",name:typeof F=='string'?F:void 0,icon:typeof F!='string'?F:void 0,...X,...l,...m}):null,k,O?jsx(Icon,{className:"icon",name:typeof O=='string'?O:void 0,icon:typeof O!='string'?O:void 0,...X,...l,...p}):null]})]})})}),{displayName:"Button",sizes:e=>{let o=e.preset==='brand'?SIZES:SIZES_DEFAULT;return e.round&&(o=e.preset==='brand'?SIZES_ROUND:SIZES_ROUND_DEFAULT),o}});export{Button,COMPONENT_NAME,SIZES,SIZES_ROUND};
2
2
  //# sourceMappingURL=Button.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.mjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable prefer-const */\nimport { forwardRef } from 'react'\nimport { useTheme } from 'styled-components'\nimport { CheckFill, LoaderFill } from '@foxford/icon-pack'\nimport { useClassname } from 'hooks/useClassname'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Text } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { TextProps } from 'components/Text'\nimport { useComputedRel, useComputedLinkProps } from './hooks'\nimport { SIZES, SIZES_ROUND, SIZES_ICON, SIZES_TEXT } from './sizes'\nimport { SIZES_DEFAULT, SIZES_ROUND_DEFAULT, PROPS_BY_SIZE, SIZES_TEXT_DEFAULT } from './sizes-default'\nimport type { ButtonProps, Size } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Button'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<button\\> элемента.\n */\nconst Button: React.ForwardRefExoticComponent<ButtonProps> = withMergedProps<ButtonProps, HTMLButtonElement>(\n forwardRef<HTMLButtonElement, MergedProps<ButtonProps>>((props, ref) => {\n let {\n size = 'm',\n inline = true,\n rounded = true,\n color = 'accent',\n fontColor = 'white',\n showContentOnStatus,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n as: _as,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n className,\n children,\n content,\n fontWeight,\n icon,\n innerRef,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n if (restProps.preset === 'default' && typeof size === 'string' && !restProps.round) {\n const propsBySize = PROPS_BY_SIZE[size as Size] ?? {}\n restProps = { ...propsBySize, ...restProps }\n }\n\n if (restProps.href) _as = 'a'\n if (restProps.to) _as = theme.link\n if (restProps.disabled) _as = 'button'\n\n if (restProps.primary) color = 'primary'\n if (restProps.secondary) color = 'atlantis'\n\n const rootClassName = useClassname(COMPONENT_NAME, className)\n const textClassName = useClassname(COMPONENT_NAME)\n const rel = useComputedRel(theme, restProps)\n const linkProps = useComputedLinkProps(_as, restProps)\n\n let [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n color: 'inherit',\n weight: fontWeight ?? (restProps.preset === 'brand' ? 800 : 600),\n lineHeight: restProps.preset === 'brand' ? 1.2 : 1,\n sizes: restProps.preset === 'brand' ? SIZES_TEXT : SIZES_TEXT_DEFAULT,\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n color: 'inherit',\n preset: restProps.preset,\n sizes: SIZES_ICON,\n }\n\n const success = restProps.preset === 'brand' && restProps.success\n const loading = restProps.preset === 'brand' && restProps.loading\n\n const mainContent =\n typeof children !== 'function' && (children || content) ? (\n <Text className={`${textClassName}__content`} {...textProps} {...textPropsProp}>\n {children || content}\n </Text>\n ) : null\n\n return (\n <Styled.Root\n {...restProps}\n {...linkProps}\n {...sizeProps}\n inline={inline}\n color={color}\n fontColor={fontColor}\n rounded={rounded}\n rel={rel}\n as={_as}\n className={rootClassName}\n ref={ref ?? innerRef}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n {success || loading ? (\n <Styled.ContentWithStatus>\n {success ? (\n <Icon {...iconProps} {...iconPropsProp} icon={<CheckFill />} />\n ) : (\n <Styled.IconAnimation>\n <Icon {...iconProps} {...iconPropsProp} icon={<LoaderFill />} />\n </Styled.IconAnimation>\n )}\n {showContentOnStatus ? mainContent : null}\n </Styled.ContentWithStatus>\n ) : null}\n <Styled.Content aria-hidden={success || loading}>\n {before ? (\n <Icon\n className='icon'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n {...iconPropsProp}\n />\n ) : null}\n {mainContent}\n {after ? (\n <Icon\n className='icon'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n {...iconPropsProp}\n />\n ) : null}\n </Styled.Content>\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n let sizes = props.preset === 'brand' ? SIZES : SIZES_DEFAULT\n if (props.round) sizes = props.preset === 'brand' ? SIZES_ROUND : SIZES_ROUND_DEFAULT\n\n return sizes\n },\n }\n)\n\nexport { Button, COMPONENT_NAME, SIZES, SIZES_ROUND }\n\nexport type { ButtonProps }\n"],"names":["COMPONENT_NAME","Button","withMergedProps","forwardRef","props","ref","size","inline","rounded","color","fontColor","showContentOnStatus","textProps","textPropsProp","iconProps","iconPropsProp","as","_as","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","className","children","content","fontWeight","icon","innerRef","restProps","theme","useTheme","preset","round","PROPS_BY_SIZE","href","to","link","disabled","primary","secondary","rootClassName","useClassname","textClassName","rel","useComputedRel","linkProps","useComputedLinkProps","before","after","Array","isArray","sizeProps","weight","lineHeight","sizes","SIZES_TEXT","SIZES_TEXT_DEFAULT","SIZES_ICON","success","loading","mainContent","_jsx","Text","Styled","_jsxs","_Fragment","Icon","CheckFill","LoaderFill","name","undefined","displayName","SIZES","SIZES_DEFAULT","SIZES_ROUND","SIZES_ROUND_DEFAULT"],"mappings":"ouBAiBA,MAAMA,eAAiB,SAQvB,MAAMC,OAAuDC,gBAC3DC,WAAwD,CAACC,EAAOC,KAC9D,IAAIC,KACFA,EAAO,IAAGC,OACVA,GAAS,EAAIC,QACbA,GAAU,EAAIC,MACdA,EAAQ,SAAQC,UAChBA,EAAY,QAAOC,oBACnBA,EACAC,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAC3BC,GAAIC,EAAGC,QACPA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,WACPA,EAAUC,KACVA,EAAIC,SACJA,KACGC,GACD1B,EAEJ,MAAM2B,EAAQC,WAEVF,EAAUG,SAAW,kBAAoB3B,GAAS,UAAawB,EAAUI,QAE3EJ,EAAY,IADQK,cAAc7B,IAAiB,CAAA,KAClBwB,IAG/BA,EAAUM,OAAMnB,EAAM,KACtBa,EAAUO,KAAIpB,EAAMc,EAAMO,MAC1BR,EAAUS,WAAUtB,EAAM,UAE1Ba,EAAUU,UAAS/B,EAAQ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,IAACK,KAAI,IAAKtD,KAAeC,EAAea,KAAMmC,IAACO,WAAU,CAAA,OAG5D3D,EAAsBmD,EAAc,QAErC,KACJI,KAACD,QAAc,CAAC,cAAaL,GAAWC,EAAQpC,SAAA,CAC7CwB,EACCc,IAACK,KAAI,CACH5C,UAAU,OACV+C,YAAatB,GAAW,SAAWA,OAASuB,EAC5C5C,YAAaqB,GAAW,SAAWA,OAASuB,KACxC1D,KACAC,IAEJ,KACH+C,EACAZ,EACCa,IAACK,KAAI,CACH5C,UAAU,OACV+C,YAAarB,GAAU,SAAWA,OAAQsB,EAC1C5C,YAAasB,GAAU,SAAWA,OAAQsB,KACtC1D,KACAC,IAEJ,eAOhB,CACE0D,YArJmB,SAsJnBjB,MAAQpD,IACN,IAAIoD,EAAQpD,EAAM6B,SAAW,QAAUyC,MAAQC,cAG/C,OAFIvE,EAAM8B,QAAOsB,EAAQpD,EAAM6B,SAAW,QAAU2C,YAAcC,qBAE3DrB"}
1
+ {"version":3,"file":"Button.mjs","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["/* eslint-disable prefer-const */\nimport { forwardRef } from 'react'\nimport { useTheme } from 'styled-components'\nimport { CheckFill, LoaderFill } from '@foxford/icon-pack'\nimport { useClassname } from 'hooks/useClassname'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { Icon } from 'components/Icon'\nimport { Text } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { TextProps } from 'components/Text'\nimport { useComputedRel, useComputedLinkProps } from './hooks'\nimport { SIZES, SIZES_ROUND, SIZES_ICON, SIZES_TEXT } from './sizes'\nimport { SIZES_DEFAULT, SIZES_ROUND_DEFAULT, PROPS_BY_SIZE, SIZES_TEXT_DEFAULT } from './sizes-default'\nimport type { ButtonProps, Size } from './types'\nimport * as Styled from './style'\n\nconst COMPONENT_NAME = 'Button'\n\n/**\n *\n * Контрол многоцелевого назначения.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<button\\> элемента.\n */\nconst Button: React.ForwardRefExoticComponent<ButtonProps> = withMergedProps<ButtonProps, HTMLButtonElement>(\n forwardRef<HTMLButtonElement, MergedProps<ButtonProps>>((props, ref) => {\n let {\n size = 'm',\n inline = true,\n rounded = true,\n color = 'accent',\n fontColor = 'white',\n showContentOnStatus,\n textProps: textPropsProp = {},\n iconProps: iconPropsProp = {},\n leftIconProps = {},\n rightIconProps = {},\n as: _as,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n className,\n children,\n content,\n fontWeight,\n icon,\n innerRef,\n ...restProps\n } = props\n\n const theme = useTheme()\n\n if (restProps.preset === 'default' && typeof size === 'string' && !restProps.round) {\n const propsBySize = PROPS_BY_SIZE[size as Size] ?? {}\n restProps = { ...propsBySize, ...restProps }\n }\n\n if (restProps.href) _as = 'a'\n if (restProps.to) _as = theme.link\n if (restProps.disabled) _as = 'button'\n\n if (restProps.primary) color = 'primary'\n if (restProps.secondary) color = 'atlantis'\n\n const rootClassName = useClassname(COMPONENT_NAME, className)\n const textClassName = useClassname(COMPONENT_NAME)\n const rel = useComputedRel(theme, restProps)\n const linkProps = useComputedLinkProps(_as, restProps)\n\n let [before, after] = Array.isArray(icon) ? icon : [icon]\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const textProps: TextProps = {\n ...sizeProps,\n as: 'span',\n color: 'inherit',\n weight: fontWeight ?? (restProps.preset === 'brand' ? 800 : 600),\n lineHeight: restProps.preset === 'brand' ? 1.2 : 1,\n sizes: restProps.preset === 'brand' ? SIZES_TEXT : SIZES_TEXT_DEFAULT,\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n color: 'inherit',\n preset: restProps.preset,\n sizes: SIZES_ICON,\n }\n\n const success = restProps.preset === 'brand' && restProps.success\n const loading = restProps.preset === 'brand' && restProps.loading\n\n const mainContent =\n typeof children !== 'function' && (children || content) ? (\n <Text className={`${textClassName}__content`} {...textProps} {...textPropsProp}>\n {children || content}\n </Text>\n ) : null\n\n return (\n <Styled.Root\n {...restProps}\n {...linkProps}\n {...sizeProps}\n inline={inline}\n color={color}\n fontColor={fontColor}\n rounded={rounded}\n rel={rel}\n as={_as}\n className={rootClassName}\n ref={ref ?? innerRef}\n >\n {typeof children === 'function' ? (\n children({ textProps, iconProps })\n ) : (\n <>\n {success || loading ? (\n <Styled.ContentWithStatus>\n {success ? (\n <Icon {...iconProps} {...iconPropsProp} icon={<CheckFill />} />\n ) : (\n <Styled.IconAnimation>\n <Icon {...iconProps} {...iconPropsProp} icon={<LoaderFill />} />\n </Styled.IconAnimation>\n )}\n {showContentOnStatus ? mainContent : null}\n </Styled.ContentWithStatus>\n ) : null}\n <Styled.Content aria-hidden={success || loading}>\n {before ? (\n <Icon\n className='icon'\n name={typeof before === 'string' ? before : undefined}\n icon={typeof before !== 'string' ? before : undefined}\n {...iconProps}\n {...iconPropsProp}\n {...leftIconProps}\n />\n ) : null}\n {mainContent}\n {after ? (\n <Icon\n className='icon'\n name={typeof after === 'string' ? after : undefined}\n icon={typeof after !== 'string' ? after : undefined}\n {...iconProps}\n {...iconPropsProp}\n {...rightIconProps}\n />\n ) : null}\n </Styled.Content>\n </>\n )}\n </Styled.Root>\n )\n }),\n {\n displayName: COMPONENT_NAME,\n sizes: (props) => {\n let sizes = props.preset === 'brand' ? SIZES : SIZES_DEFAULT\n if (props.round) sizes = props.preset === 'brand' ? SIZES_ROUND : SIZES_ROUND_DEFAULT\n\n return sizes\n },\n }\n)\n\nexport { Button, COMPONENT_NAME, SIZES, SIZES_ROUND }\n\nexport type { ButtonProps }\n"],"names":["COMPONENT_NAME","Button","withMergedProps","forwardRef","props","ref","size","inline","rounded","color","fontColor","showContentOnStatus","textProps","textPropsProp","iconProps","iconPropsProp","leftIconProps","rightIconProps","as","_as","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","className","children","content","fontWeight","icon","innerRef","restProps","theme","useTheme","preset","round","PROPS_BY_SIZE","href","to","link","disabled","primary","secondary","rootClassName","useClassname","textClassName","rel","useComputedRel","linkProps","useComputedLinkProps","before","after","Array","isArray","sizeProps","weight","lineHeight","sizes","SIZES_TEXT","SIZES_TEXT_DEFAULT","SIZES_ICON","success","loading","mainContent","_jsx","Text","Styled","_jsxs","_Fragment","Icon","CheckFill","LoaderFill","name","undefined","displayName","SIZES","SIZES_DEFAULT","SIZES_ROUND","SIZES_ROUND_DEFAULT"],"mappings":"ouBAiBA,MAAMA,eAAiB,SAQvB,MAAMC,OAAuDC,gBAC3DC,WAAwD,CAACC,EAAOC,KAC9D,IAAIC,KACFA,EAAO,IAAGC,OACVA,GAAS,EAAIC,QACbA,GAAU,EAAIC,MACdA,EAAQ,SAAQC,UAChBA,EAAY,QAAOC,oBACnBA,EACAC,UAAWC,EAAgB,CAAA,EAC3BC,UAAWC,EAAgB,CAAA,EAAEC,cAC7BA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EACjBC,GAAIC,EAAGC,QACPA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,EAAMC,UACNA,EAASC,SACTA,EAAQC,QACRA,EAAOC,WACPA,EAAUC,KACVA,EAAIC,SACJA,KACGC,GACD5B,EAEJ,MAAM6B,EAAQC,WAEVF,EAAUG,SAAW,kBAAoB7B,GAAS,UAAa0B,EAAUI,QAE3EJ,EAAY,IADQK,cAAc/B,IAAiB,CAAA,KAClB0B,IAG/BA,EAAUM,OAAMnB,EAAM,KACtBa,EAAUO,KAAIpB,EAAMc,EAAMO,MAC1BR,EAAUS,WAAUtB,EAAM,UAE1Ba,EAAUU,UAASjC,EAAQ,WAC3BuB,EAAUW,YAAWlC,EAAQ,YAEjC,MAAMmC,EAAgBC,aAnDH,SAmDgCnB,GACnD,MAAMoB,EAAgBD,aApDH,UAqDnB,MAAME,EAAMC,eAAef,EAAOD,GAClC,MAAMiB,EAAYC,q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,KAAI,CACH5C,UAAU,OACV+C,YAAatB,GAAW,SAAWA,OAASuB,EAC5C5C,YAAaqB,GAAW,SAAWA,OAASuB,KACxC5D,KACAC,KACAC,IAEJ,KACHgD,EACAZ,EACCa,IAACK,KAAI,CACH5C,UAAU,OACV+C,YAAarB,GAAU,SAAWA,OAAQsB,EAC1C5C,YAAasB,GAAU,SAAWA,OAAQsB,KACtC5D,KACAC,KACAE,IAEJ,eAOhB,CACE0D,YAzJmB,SA0JnBjB,MAAQtD,IACN,IAAIsD,EAAQtD,EAAM+B,SAAW,QAAUyC,MAAQC,cAG/C,OAFIzE,EAAMgC,QAAOsB,EAAQtD,EAAM+B,SAAW,QAAU2C,YAAcC,qBAE3DrB"}
@@ -1,2 +1,2 @@
1
- 'use strict';var createPolymorphicComponentWithRef=require('../../shared/utils/createPolymorphicComponentWithRef.js');var useMergedProps=require('../../hooks/useMergedProps.js');var isNil=require('../../shared/utils/isNil.js');var sizes=require('./sizes.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Slot=require('../Slot/Slot.js');var Icon=require('../Icon/Icon.js');var Avatar=require('../Avatar/Avatar.js');var Text=require('../Text/Text.js');var Indicator=require('../Indicator/Indicator.js');var IconButton=require('../IconButton/IconButton.js');var index=require('../../icon-pack/src/icons/Close/index.js');const Chip=createPolymorphicComponentWithRef.createPolymorphicComponentWithRef((i,s)=>{const{size:e="m",primary:t=!0,textProps:r={},captionProps:n={},iconProps:o={},avatarProps:a={},indicatorProps:c={},discardButtonProps:l={},component:p,root:u,content:d,title:x,description:j,addonLeft:m,addonRight:S,children:I,text:P,caption:R,icon:h,sizeXXS:z,sizeXS:v,sizeS:N,sizeM:g,sizeL:C,sizeXL:f,...y}=useMergedProps.useMergedProps(i,{componentName:"Chip",sizes:i=>{const s=!isNil.isNil(i.title)||!isNil.isNil(i.text)||!isNil.isNil(i.children)&&typeof i.children!='function';const e=!isNil.isNil(i.description)||!isNil.isNil(i.caption);return s&&e?sizes.SIZES_WITH_DESCRIPTION:sizes.SIZES}});let T='div';y.onClick&&(T='button'),l.onClick&&(T='div'),p&&(T=p);const b={size:e,sizeXXS:z,sizeXS:v,sizeS:N,sizeM:g,sizeL:C,sizeXL:f};const[q,A]=Array.isArray(h)?h:[h];const E={...b,sizes:sizes.SIZES_TEXT,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const _={...b,sizes:sizes.SIZES_DESCRIPTION,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const k={...b,sizes:sizes.SIZES_ICON,preset:'brand'};const B={...b,sizes:sizes.SIZES_CHIP_ICON_BUTTON,icon:jsxRuntime.jsx(index.Close,{}),disabled:y.disabled,square:!0};const X={...b,sizes:sizes.SIZES_CHIP_AVATAR,preset:'brand',square:!0};const Z={...b,sizes:sizes.SIZES_CHIP_INDICATOR};return jsxRuntime.jsx(style.Root,{...y,...b,as:T,type:y.type??(T==='button'?'button':void 0),"data-disabled":y.disabled,primary:t,ref:s,children:jsxRuntime.jsx(Slot.Slot,{render:u,props:{titleProps:E,descriptionProps:_,iconProps:k,iconButtonProps:B,avatarProps:X,indicatorProps:Z},fallback:()=>typeof I=='function'?I({textProps:E,captionProps:_,discardButtonProps:B}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{render:m,props:{iconProps:k,iconButtonProps:B,avatarProps:X,indicatorProps:{...Z,marginLeft:'var(--chip-margin)'}},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[q?jsxRuntime.jsx(Icon.Icon,{...k,...o,name:typeof q=='string'?q:void 0,icon:typeof q!='string'?q:void 0}):null,a.src||a.text?jsxRuntime.jsx(Avatar.Avatar,{...X,...a}):null]})}),jsxRuntime.jsx(style.Content,{...b,sizes:sizes.SIZES_CONTENT,children:jsxRuntime.jsx(Slot.Slot,{render:d,props:{titleProps:E,descriptionProps:_},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{render:x,props:E,fallback:isNil.isNil(I)&&isNil.isNil(P)?null:jsxRuntime.jsx(Text.Text,{...E,...r,children:I??P})}),jsxRuntime.jsx(Slot.Slot,{render:j,props:_,fallback:isNil.isNil(R)?null:jsxRuntime.jsx(Text.Text,{..._,...n,children:R})})]})})}),jsxRuntime.jsx(Slot.Slot,{render:S,props:{iconProps:k,iconButtonProps:B,avatarProps:X,indicatorProps:{...Z,marginRight:'var(--chip-margin)'}},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c.children||c.text?jsxRuntime.jsx(Indicator.Indicator,{marginRight:"var(--chip-margin)",...Z,...c}):null,A?jsxRuntime.jsx(Icon.Icon,{...k,...o,name:typeof A=='string'?A:void 0,icon:typeof A!='string'?A:void 0}):null,l.onClick?jsxRuntime.jsx(IconButton.IconButton,{...B,...l}):null]})})]})})})});exports.Chip=Chip;
1
+ 'use strict';var createPolymorphicComponentWithRef=require('../../shared/utils/createPolymorphicComponentWithRef.js');var useMergedProps=require('../../hooks/useMergedProps.js');var isNil=require('../../shared/utils/isNil.js');var sizes=require('./sizes.js');var style=require('./style.js');var jsxRuntime=require('react/jsx-runtime');var Slot=require('../Slot/Slot.js');var Icon=require('../Icon/Icon.js');var Avatar=require('../Avatar/Avatar.js');var Text=require('../Text/Text.js');var Indicator=require('../Indicator/Indicator.js');var IconButton=require('../IconButton/IconButton.js');var index=require('../../icon-pack/src/icons/Close/index.js');const Chip=createPolymorphicComponentWithRef.createPolymorphicComponentWithRef((i,s)=>{const{size:e="m",primary:t=!0,textProps:r={},captionProps:n={},iconProps:o={},avatarProps:a={},indicatorProps:c={},discardButtonProps:l={},leftIconProps:p={},rightIconProps:u={},component:d,root:x,content:j,title:m,description:S,addonLeft:I,addonRight:P,children:R,text:h,caption:z,icon:v,sizeXXS:N,sizeXS:g,sizeS:C,sizeM:f,sizeL:y,sizeXL:T,...b}=useMergedProps.useMergedProps(i,{componentName:"Chip",sizes:i=>{const s=!isNil.isNil(i.title)||!isNil.isNil(i.text)||!isNil.isNil(i.children)&&typeof i.children!='function';const e=!isNil.isNil(i.description)||!isNil.isNil(i.caption);return s&&e?sizes.SIZES_WITH_DESCRIPTION:sizes.SIZES}});let q='div';b.onClick&&(q='button'),l.onClick&&(q='div'),d&&(q=d);const A={size:e,sizeXXS:N,sizeXS:g,sizeS:C,sizeM:f,sizeL:y,sizeXL:T};const[E,_]=Array.isArray(v)?v:[v];const k={...A,sizes:sizes.SIZES_TEXT,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const B={...A,sizes:sizes.SIZES_DESCRIPTION,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const X={...A,sizes:sizes.SIZES_ICON,preset:'brand'};const Z={...A,sizes:sizes.SIZES_CHIP_ICON_BUTTON,icon:jsxRuntime.jsx(index.Close,{}),disabled:b.disabled,square:!0};const O={...A,sizes:sizes.SIZES_CHIP_AVATAR,preset:'brand',square:!0};const L={...A,sizes:sizes.SIZES_CHIP_INDICATOR};return jsxRuntime.jsx(style.Root,{...b,...A,as:q,type:b.type??(q==='button'?'button':void 0),"data-disabled":b.disabled,primary:t,ref:s,children:jsxRuntime.jsx(Slot.Slot,{render:x,props:{titleProps:k,descriptionProps:B,iconProps:X,iconButtonProps:Z,avatarProps:O,indicatorProps:L},fallback:()=>typeof R=='function'?R({textProps:k,captionProps:B,discardButtonProps:Z}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{render:I,props:{iconProps:X,iconButtonProps:Z,avatarProps:O,indicatorProps:{...L,marginLeft:'var(--chip-margin)'}},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[E?jsxRuntime.jsx(Icon.Icon,{...X,...o,...p,name:typeof E=='string'?E:void 0,icon:typeof E!='string'?E:void 0}):null,a.src||a.text?jsxRuntime.jsx(Avatar.Avatar,{...O,...a}):null]})}),jsxRuntime.jsx(style.Content,{...A,sizes:sizes.SIZES_CONTENT,children:jsxRuntime.jsx(Slot.Slot,{render:j,props:{titleProps:k,descriptionProps:B},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Slot.Slot,{render:m,props:k,fallback:isNil.isNil(R)&&isNil.isNil(h)?null:jsxRuntime.jsx(Text.Text,{...k,...r,children:R??h})}),jsxRuntime.jsx(Slot.Slot,{render:S,props:B,fallback:isNil.isNil(z)?null:jsxRuntime.jsx(Text.Text,{...B,...n,children:z})})]})})}),jsxRuntime.jsx(Slot.Slot,{render:P,props:{iconProps:X,iconButtonProps:Z,avatarProps:O,indicatorProps:{...L,marginRight:'var(--chip-margin)'}},fallback:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c.children||c.text?jsxRuntime.jsx(Indicator.Indicator,{marginRight:"var(--chip-margin)",...L,...c}):null,_?jsxRuntime.jsx(Icon.Icon,{...X,...o,...u,name:typeof _=='string'?_:void 0,icon:typeof _!='string'?_:void 0}):null,l.onClick?jsxRuntime.jsx(IconButton.IconButton,{...Z,...l}):null]})})]})})})});exports.Chip=Chip;
2
2
  //# sourceMappingURL=Chip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.js","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Close } from '@foxford/icon-pack'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { isNil } from 'shared/utils/isNil'\nimport { Slot } from 'components/Slot'\nimport { Text } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport { Avatar } from 'components/Avatar'\nimport { Indicator } from 'components/Indicator'\nimport { IconButton } from 'components/IconButton'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport type { ComponentElementType } from 'shared/types'\nimport type { TextProps } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { IconButtonProps } from 'components/IconButton'\nimport type { AvatarProps } from 'components/Avatar'\nimport type { IndicatorProps } from 'components/Indicator'\nimport {\n SIZES,\n SIZES_WITH_DESCRIPTION,\n SIZES_CONTENT,\n SIZES_TEXT,\n SIZES_DESCRIPTION,\n SIZES_ICON,\n SIZES_CHIP_INDICATOR,\n SIZES_CHIP_AVATAR,\n SIZES_CHIP_ICON_BUTTON,\n} from './sizes'\nimport * as Styled from './style'\nimport type { ChipProps } from './types'\n\nconst COMPONENT_NAME = 'Chip'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для представления данных, атрибутов или действий в компактной форме.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Chip = createPolymorphicComponentWithRef<'div', ChipProps>((props, ref) => {\n const {\n size = 'm',\n primary = true,\n textProps: titlePropsProp = {},\n captionProps: descriptionPropsProp = {},\n iconProps: iconPropsProp = {},\n avatarProps: avatarPropsProp = {},\n indicatorProps: indicatorPropsProp = {},\n discardButtonProps: iconButtonPropsProp = {},\n component,\n root,\n content,\n title,\n description,\n addonLeft,\n addonRight,\n children,\n text,\n caption,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = useMergedProps<PolymorphicProps<React.ElementType, ChipProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (chipProps) => {\n const hasTitle =\n !isNil(chipProps.title) ||\n !isNil(chipProps.text) ||\n (!isNil(chipProps.children) && typeof chipProps.children !== 'function')\n\n const hasDescription = !isNil(chipProps.description) || !isNil(chipProps.caption)\n\n return hasTitle && hasDescription ? SIZES_WITH_DESCRIPTION : SIZES\n },\n })\n\n let asProp: ComponentElementType = 'div'\n\n if (restProps.onClick) asProp = 'button'\n if (iconButtonPropsProp.onClick) asProp = 'div'\n if (component) asProp = component\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const titleProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_TEXT,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const descriptionProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_DESCRIPTION,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n sizes: SIZES_ICON,\n preset: 'brand',\n }\n\n const iconButtonProps: IconButtonProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_ICON_BUTTON,\n icon: <Close />,\n disabled: restProps.disabled,\n square: true,\n }\n\n const avatarProps: AvatarProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_AVATAR,\n preset: 'brand',\n square: true,\n }\n\n const indicatorProps: IndicatorProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_INDICATOR,\n }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={asProp}\n type={restProps.type ?? (asProp === 'button' ? 'button' : undefined)}\n data-disabled={restProps.disabled}\n primary={primary}\n ref={ref}\n >\n <Slot\n render={root}\n props={{\n titleProps,\n descriptionProps,\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps,\n }}\n fallback={() =>\n typeof children === 'function' ? (\n children({\n textProps: titleProps,\n captionProps: descriptionProps,\n discardButtonProps: iconButtonProps,\n })\n ) : (\n <>\n <Slot\n render={addonLeft}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginLeft: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {iconBefore ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n ) : null}\n {avatarPropsProp.src || avatarPropsProp.text ? (\n <Avatar {...avatarProps} {...avatarPropsProp} />\n ) : null}\n </>\n }\n />\n <Styled.Content {...sizeProps} sizes={SIZES_CONTENT}>\n <Slot\n render={content}\n props={{\n titleProps,\n descriptionProps,\n }}\n fallback={\n <>\n <Slot\n render={title}\n props={titleProps}\n fallback={\n !isNil(children) || !isNil(text) ? (\n <Text {...titleProps} {...titlePropsProp}>\n {children ?? text}\n </Text>\n ) : null\n }\n />\n <Slot\n render={description}\n props={descriptionProps}\n fallback={\n !isNil(caption) ? (\n <Text {...descriptionProps} {...descriptionPropsProp}>\n {caption}\n </Text>\n ) : null\n }\n />\n </>\n }\n />\n </Styled.Content>\n <Slot\n render={addonRight}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginRight: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {indicatorPropsProp.children || indicatorPropsProp.text ? (\n <Indicator marginRight='var(--chip-margin)' {...indicatorProps} {...indicatorPropsProp} />\n ) : null}\n {iconAfter ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n ) : null}\n {iconButtonPropsProp.onClick ? <IconButton {...iconButtonProps} {...iconButtonPropsProp} /> : null}\n </>\n }\n />\n </>\n )\n }\n />\n </Styled.Root>\n )\n})\n\nconst ChipDoc: React.FC<ChipProps> = () => null\n\nexport { ChipDoc, Chip }\n"],"names":["Chip","createPolymorphicComponentWithRef","props","ref","size","primary","textProps","titlePropsProp","captionProps","descriptionPropsProp","iconProps","iconPropsProp","avatarProps","avatarPropsProp","indicatorProps","indicatorPropsProp","discardButtonProps","iconButtonPropsProp","component","root","content","title","description","addonLeft","addonRight","children","text","caption","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","useMergedProps","componentName","sizes","chipProps","hasTitle","isNil","hasDescription","SIZES_WITH_DESCRIPTION","SIZES","asProp","onClick","sizeProps","iconBefore","iconAfter","Array","isArray","titleProps","SIZES_TEXT","as","appearance","color","textAlign","descriptionProps","SIZES_DESCRIPTION","SIZES_ICON","preset","iconButtonProps","SIZES_CHIP_ICON_BUTTON","_jsx","Close","disabled","square","SIZES_CHIP_AVATAR","SIZES_CHIP_INDICATOR","Styled","type","undefined","Slot","render","fallback","_jsxs","_Fragment","marginLeft","Icon","name","src","Avatar","SIZES_CONTENT","Text","marginRight","Indicator","IconButton"],"mappings":"4oBA2CA,MAAMA,KAAOC,kCAAAA,kCAAoD,CAACC,EAAOC,KACvE,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EACVC,UAAWC,EAAiB,CAAA,EAC5BC,aAAcC,EAAuB,CAAA,EACrCC,UAAWC,EAAgB,CAAA,EAC3BC,YAAaC,EAAkB,CAAA,EAC/BC,eAAgBC,EAAqB,CAAA,EACrCC,mBAAoBC,EAAsB,CAAA,EAAEC,UAC5CA,EAASC,KACTA,EAAIC,QACJA,EAAOC,MACPA,EAAKC,YACLA,EAAWC,UACXA,EAASC,WACTA,EAAUC,SACVA,EAAQC,KACRA,EAAIC,QACJA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,KACGC,GACDC,eAAAA,eAA+DlC,EAAO,CACxEmC,cAzCmB,OA0CnBC,MAAQC,IACN,MAAMC,GACHC,YAAMF,EAAUlB,SAChBoB,MAAAA,MAAMF,EAAUb,QACfe,MAAAA,MAAMF,EAAUd,kBAAoBc,EAAUd,UAAa,WAE/D,MAAMiB,GAAkBD,MAAAA,MAAMF,EAAUjB,eAAiBmB,MAAAA,MAAMF,EAAUZ,SAEzE,OAAOa,GAAYE,EAAiBC,MAAAA,uBAAyBC,MAAAA,SAIjE,IAAIC,EAA+B,MAE/BV,EAAUW,UAASD,EAAS,UAC5B5B,EAAoB6B,UAASD,EAAS,OACtC3B,IAAW2B,EAAS3B,GAExB,MAAM6B,EAAY,CAChB3C,OACAyB,UACAC,SACAC,QACAC,QACAC,QACAC,UAGF,MAAOc,EAAYC,GAAaC,MAAMC,QAAQvB,GAAQA,EAAO,CAACA,GAE9D,MAAMwB,EAAwB,IACzBL,EACHT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,IAACkB,cAAM,IAAKtE,KAAiBC,IAC3B,UAIVmD,WAAAA,IAACM,cAAc,IAAKvB,EAAWT,MAAO6C,MAAAA,cAAc1D,SAClDuC,WAAAA,IAACS,UAAI,CACHC,OAAQtD,EACRlB,MAAO,CACLkD,aACAM,oBAEFiB,SACEC,WAAAA,KAAAC,oBAAA,CAAApD,SAAA,CACEuC,WAAAA,IAACS,UAAI,CACHC,OAAQrD,EACRnB,MAAOkD,EACPuB,SACGlC,MAAAA,MAAMhB,IAAcgB,MAAAA,MAAMf,GAIvB,KAHFsC,WAAAA,IAACoB,UAAI,IAAKhC,KAAgB7C,EAAckB,SACrCA,GAAYC,MAKrBsC,WAAAA,IAACS,UAAI,CACHC,OAAQpD,EACRpB,MAAOwD,EACPiB,SACGlC,MAAAA,MAAMd,GAIH,KAHFqC,WAAAA,IAACoB,KAAAA,KAAI,IAAK1B,KAAsBjD,EAAoBgB,SACjDE,aASjBqC,WAAAA,IAACS,UAAI,CACHC,OAAQlD,EACRtB,MAAO,CACLQ,YACAoD,kBACAlD,cACAE,eAAgB,IACXA,EACHuE,YAAa,uBAGjBV,SACEC,WAAAA,KAAAC,oBAAA,CAAApD,SAAA,CACGV,EAAmBU,UAAYV,EAAmBW,KACjDsC,WAAAA,IAACsB,oBAAS,CAACD,YAAY,wBAAyBvE,KAAoBC,IAClE,KACHkC,EACCe,WAAAA,IAACe,KAAAA,KAAI,IACCrE,KACAC,EACJqE,YAAa/B,GAAc,SAAWA,OAAYuB,EAClD5C,YAAaqB,GAAc,SAAWA,OAAYuB,IAElD,KACHvD,EAAoB6B,QAAUkB,WAAAA,IAACuB,WAAAA,WAAU,IAAKzB,KAAqB7C,IAA0B"}
1
+ {"version":3,"file":"Chip.js","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Close } from '@foxford/icon-pack'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { isNil } from 'shared/utils/isNil'\nimport { Slot } from 'components/Slot'\nimport { Text } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport { Avatar } from 'components/Avatar'\nimport { Indicator } from 'components/Indicator'\nimport { IconButton } from 'components/IconButton'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport type { ComponentElementType } from 'shared/types'\nimport type { TextProps } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { IconButtonProps } from 'components/IconButton'\nimport type { AvatarProps } from 'components/Avatar'\nimport type { IndicatorProps } from 'components/Indicator'\nimport {\n SIZES,\n SIZES_WITH_DESCRIPTION,\n SIZES_CONTENT,\n SIZES_TEXT,\n SIZES_DESCRIPTION,\n SIZES_ICON,\n SIZES_CHIP_INDICATOR,\n SIZES_CHIP_AVATAR,\n SIZES_CHIP_ICON_BUTTON,\n} from './sizes'\nimport * as Styled from './style'\nimport type { ChipProps } from './types'\n\nconst COMPONENT_NAME = 'Chip'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для представления данных, атрибутов или действий в компактной форме.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Chip = createPolymorphicComponentWithRef<'div', ChipProps>((props, ref) => {\n const {\n size = 'm',\n primary = true,\n textProps: titlePropsProp = {},\n captionProps: descriptionPropsProp = {},\n iconProps: iconPropsProp = {},\n avatarProps: avatarPropsProp = {},\n indicatorProps: indicatorPropsProp = {},\n discardButtonProps: iconButtonPropsProp = {},\n leftIconProps = {},\n rightIconProps = {},\n component,\n root,\n content,\n title,\n description,\n addonLeft,\n addonRight,\n children,\n text,\n caption,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = useMergedProps<PolymorphicProps<React.ElementType, ChipProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (chipProps) => {\n const hasTitle =\n !isNil(chipProps.title) ||\n !isNil(chipProps.text) ||\n (!isNil(chipProps.children) && typeof chipProps.children !== 'function')\n\n const hasDescription = !isNil(chipProps.description) || !isNil(chipProps.caption)\n\n return hasTitle && hasDescription ? SIZES_WITH_DESCRIPTION : SIZES\n },\n })\n\n let asProp: ComponentElementType = 'div'\n\n if (restProps.onClick) asProp = 'button'\n if (iconButtonPropsProp.onClick) asProp = 'div'\n if (component) asProp = component\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const titleProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_TEXT,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const descriptionProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_DESCRIPTION,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n sizes: SIZES_ICON,\n preset: 'brand',\n }\n\n const iconButtonProps: IconButtonProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_ICON_BUTTON,\n icon: <Close />,\n disabled: restProps.disabled,\n square: true,\n }\n\n const avatarProps: AvatarProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_AVATAR,\n preset: 'brand',\n square: true,\n }\n\n const indicatorProps: IndicatorProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_INDICATOR,\n }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={asProp}\n type={restProps.type ?? (asProp === 'button' ? 'button' : undefined)}\n data-disabled={restProps.disabled}\n primary={primary}\n ref={ref}\n >\n <Slot\n render={root}\n props={{\n titleProps,\n descriptionProps,\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps,\n }}\n fallback={() =>\n typeof children === 'function' ? (\n children({\n textProps: titleProps,\n captionProps: descriptionProps,\n discardButtonProps: iconButtonProps,\n })\n ) : (\n <>\n <Slot\n render={addonLeft}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginLeft: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {iconBefore ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n {...leftIconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n ) : null}\n {avatarPropsProp.src || avatarPropsProp.text ? (\n <Avatar {...avatarProps} {...avatarPropsProp} />\n ) : null}\n </>\n }\n />\n <Styled.Content {...sizeProps} sizes={SIZES_CONTENT}>\n <Slot\n render={content}\n props={{\n titleProps,\n descriptionProps,\n }}\n fallback={\n <>\n <Slot\n render={title}\n props={titleProps}\n fallback={\n !isNil(children) || !isNil(text) ? (\n <Text {...titleProps} {...titlePropsProp}>\n {children ?? text}\n </Text>\n ) : null\n }\n />\n <Slot\n render={description}\n props={descriptionProps}\n fallback={\n !isNil(caption) ? (\n <Text {...descriptionProps} {...descriptionPropsProp}>\n {caption}\n </Text>\n ) : null\n }\n />\n </>\n }\n />\n </Styled.Content>\n <Slot\n render={addonRight}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginRight: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {indicatorPropsProp.children || indicatorPropsProp.text ? (\n <Indicator marginRight='var(--chip-margin)' {...indicatorProps} {...indicatorPropsProp} />\n ) : null}\n {iconAfter ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n {...rightIconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n ) : null}\n {iconButtonPropsProp.onClick ? <IconButton {...iconButtonProps} {...iconButtonPropsProp} /> : null}\n </>\n }\n />\n </>\n )\n }\n />\n </Styled.Root>\n )\n})\n\nconst ChipDoc: React.FC<ChipProps> = () => null\n\nexport { ChipDoc, Chip }\n"],"names":["Chip","createPolymorphicComponentWithRef","props","ref","size","primary","textProps","titlePropsProp","captionProps","descriptionPropsProp","iconProps","iconPropsProp","avatarProps","avatarPropsProp","indicatorProps","indicatorPropsProp","discardButtonProps","iconButtonPropsProp","leftIconProps","rightIconProps","component","root","content","title","description","addonLeft","addonRight","children","text","caption","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","useMergedProps","componentName","sizes","chipProps","hasTitle","isNil","hasDescription","SIZES_WITH_DESCRIPTION","SIZES","asProp","onClick","sizeProps","iconBefore","iconAfter","Array","isArray","titleProps","SIZES_TEXT","as","appearance","color","textAlign","descriptionProps","SIZES_DESCRIPTION","SIZES_ICON","preset","iconButtonProps","SIZES_CHIP_ICON_BUTTON","_jsx","Close","disabled","square","SIZES_CHIP_AVATAR","SIZES_CHIP_INDICATOR","Styled","type","undefined","Slot","render","fallback","_jsxs","_Fragment","marginLeft","Icon","name","src","Avatar","SIZES_CONTENT","Text","marginRight","Indicator","IconButton"],"mappings":"4oBA2CA,MAAMA,KAAOC,kCAAAA,kCAAoD,CAACC,EAAOC,KACvE,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EACVC,UAAWC,EAAiB,CAAA,EAC5BC,aAAcC,EAAuB,CAAA,EACrCC,UAAWC,EAAgB,CAAA,EAC3BC,YAAaC,EAAkB,CAAA,EAC/BC,eAAgBC,EAAqB,CAAA,EACrCC,mBAAoBC,EAAsB,CAAA,EAAEC,cAC5CA,EAAgB,CAAA,EAAEC,eAClBA,EAAiB,CAAA,EAAEC,UACnBA,EAASC,KACTA,EAAIC,QACJA,EAAOC,MACPA,EAAKC,YACLA,EAAWC,UACXA,EAASC,WACTA,EAAUC,SACVA,EAAQC,KACRA,EAAIC,QACJA,EAAOC,KACPA,EAAIC,QACJA,EAAOC,OACPA,EAAMC,MACNA,EAAKC,MACLA,EAAKC,MACLA,EAAKC,OACLA,KACGC,GACDC,eAAAA,eAA+DpC,EAAO,CACxEqC,cA3CmB,OA4CnBC,MAAQC,IACN,MAA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AAA,CAAApD,SAAA,CACGZ,EAAmBY,UAAYZ,EAAmBa,KACjDsC,WAAAA,IAACsB,oBAAS,CAACD,YAAY,wBAAyBzE,KAAoBC,IAClE,KACHoC,EACCe,WAAAA,IAACe,KAAAA,KAAI,IACCvE,KACAC,KACAQ,EACJ+D,YAAa/B,GAAc,SAAWA,OAAYuB,EAClD5C,YAAaqB,GAAc,SAAWA,OAAYuB,IAElD,KACHzD,EAAoB+B,QAAUkB,WAAAA,IAACuB,WAAAA,WAAU,IAAKzB,KAAqB/C,IAA0B"}
@@ -1,2 +1,2 @@
1
- import{createPolymorphicComponentWithRef}from'../../shared/utils/createPolymorphicComponentWithRef.mjs';import{useMergedProps}from'../../hooks/useMergedProps.mjs';import{isNil}from'../../shared/utils/isNil.mjs';import{SIZES_WITH_DESCRIPTION,SIZES,SIZES_CHIP_INDICATOR,SIZES_CHIP_AVATAR,SIZES_CHIP_ICON_BUTTON,SIZES_ICON,SIZES_DESCRIPTION,SIZES_TEXT,SIZES_CONTENT}from'./sizes.mjs';import{Root,Content}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Slot}from'../Slot/Slot.mjs';import{Icon}from'../Icon/Icon.mjs';import{Avatar}from'../Avatar/Avatar.mjs';import{Text}from'../Text/Text.mjs';import{Indicator}from'../Indicator/Indicator.mjs';import{IconButton}from'../IconButton/IconButton.mjs';import{Close}from'../../icon-pack/src/icons/Close/index.mjs';const Chip=createPolymorphicComponentWithRef((o,t)=>{const{size:r="m",primary:i=!0,textProps:s={},captionProps:n={},iconProps:e={},avatarProps:a={},indicatorProps:c={},discardButtonProps:p={},component:l,root:m,content:d,title:I,description:S,addonLeft:P,addonRight:x,children:j,text:f,caption:h,icon:C,sizeXXS:u,sizeXS:N,sizeS:T,sizeM:E,sizeL:_,sizeXL:g,...z}=useMergedProps(o,{componentName:"Chip",sizes:o=>{const t=!isNil(o.title)||!isNil(o.text)||!isNil(o.children)&&typeof o.children!='function';const r=!isNil(o.description)||!isNil(o.caption);return t&&r?SIZES_WITH_DESCRIPTION:SIZES}});let v='div';z.onClick&&(v='button'),p.onClick&&(v='div'),l&&(v=l);const Z={size:r,sizeXXS:u,sizeXS:N,sizeS:T,sizeM:E,sizeL:_,sizeXL:g};const[y,A]=Array.isArray(C)?C:[C];const R={...Z,sizes:SIZES_TEXT,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const b={...Z,sizes:SIZES_DESCRIPTION,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const O={...Z,sizes:SIZES_ICON,preset:'brand'};const k={...Z,sizes:SIZES_CHIP_ICON_BUTTON,icon:jsx(Close,{}),disabled:z.disabled,square:!0};const B={...Z,sizes:SIZES_CHIP_AVATAR,preset:'brand',square:!0};const X={...Z,sizes:SIZES_CHIP_INDICATOR};return jsx(Root,{...z,...Z,as:v,type:z.type??(v==='button'?'button':void 0),"data-disabled":z.disabled,primary:i,ref:t,children:jsx(Slot,{render:m,props:{titleProps:R,descriptionProps:b,iconProps:O,iconButtonProps:k,avatarProps:B,indicatorProps:X},fallback:()=>typeof j=='function'?j({textProps:R,captionProps:b,discardButtonProps:k}):jsxs(Fragment,{children:[jsx(Slot,{render:P,props:{iconProps:O,iconButtonProps:k,avatarProps:B,indicatorProps:{...X,marginLeft:'var(--chip-margin)'}},fallback:jsxs(Fragment,{children:[y?jsx(Icon,{...O,...e,name:typeof y=='string'?y:void 0,icon:typeof y!='string'?y:void 0}):null,a.src||a.text?jsx(Avatar,{...B,...a}):null]})}),jsx(Content,{...Z,sizes:SIZES_CONTENT,children:jsx(Slot,{render:d,props:{titleProps:R,descriptionProps:b},fallback:jsxs(Fragment,{children:[jsx(Slot,{render:I,props:R,fallback:isNil(j)&&isNil(f)?null:jsx(Text,{...R,...s,children:j??f})}),jsx(Slot,{render:S,props:b,fallback:isNil(h)?null:jsx(Text,{...b,...n,children:h})})]})})}),jsx(Slot,{render:x,props:{iconProps:O,iconButtonProps:k,avatarProps:B,indicatorProps:{...X,marginRight:'var(--chip-margin)'}},fallback:jsxs(Fragment,{children:[c.children||c.text?jsx(Indicator,{marginRight:"var(--chip-margin)",...X,...c}):null,A?jsx(Icon,{...O,...e,name:typeof A=='string'?A:void 0,icon:typeof A!='string'?A:void 0}):null,p.onClick?jsx(IconButton,{...k,...p}):null]})})]})})})});export{Chip};
1
+ import{createPolymorphicComponentWithRef}from'../../shared/utils/createPolymorphicComponentWithRef.mjs';import{useMergedProps}from'../../hooks/useMergedProps.mjs';import{isNil}from'../../shared/utils/isNil.mjs';import{SIZES_WITH_DESCRIPTION,SIZES,SIZES_CHIP_INDICATOR,SIZES_CHIP_AVATAR,SIZES_CHIP_ICON_BUTTON,SIZES_ICON,SIZES_DESCRIPTION,SIZES_TEXT,SIZES_CONTENT}from'./sizes.mjs';import{Root,Content}from'./style.mjs';import{jsx,jsxs,Fragment}from'react/jsx-runtime';import{Slot}from'../Slot/Slot.mjs';import{Icon}from'../Icon/Icon.mjs';import{Avatar}from'../Avatar/Avatar.mjs';import{Text}from'../Text/Text.mjs';import{Indicator}from'../Indicator/Indicator.mjs';import{IconButton}from'../IconButton/IconButton.mjs';import{Close}from'../../icon-pack/src/icons/Close/index.mjs';const Chip=createPolymorphicComponentWithRef((o,t)=>{const{size:r="m",primary:s=!0,textProps:i={},captionProps:n={},iconProps:e={},avatarProps:c={},indicatorProps:a={},discardButtonProps:p={},leftIconProps:l={},rightIconProps:m={},component:d,root:I,content:S,title:P,description:x,addonLeft:j,addonRight:f,children:h,text:C,caption:u,icon:N,sizeXXS:T,sizeXS:E,sizeS:_,sizeM:g,sizeL:z,sizeXL:v,...Z}=useMergedProps(o,{componentName:"Chip",sizes:o=>{const t=!isNil(o.title)||!isNil(o.text)||!isNil(o.children)&&typeof o.children!='function';const r=!isNil(o.description)||!isNil(o.caption);return t&&r?SIZES_WITH_DESCRIPTION:SIZES}});let y='div';Z.onClick&&(y='button'),p.onClick&&(y='div'),d&&(y=d);const A={size:r,sizeXXS:T,sizeXS:E,sizeS:_,sizeM:g,sizeL:z,sizeXL:v};const[R,b]=Array.isArray(N)?N:[N];const O={...A,sizes:SIZES_TEXT,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const k={...A,sizes:SIZES_DESCRIPTION,as:'span',appearance:'caption',color:'inherit',textAlign:'center'};const B={...A,sizes:SIZES_ICON,preset:'brand'};const X={...A,sizes:SIZES_CHIP_ICON_BUTTON,icon:jsx(Close,{}),disabled:Z.disabled,square:!0};const H={...A,sizes:SIZES_CHIP_AVATAR,preset:'brand',square:!0};const D={...A,sizes:SIZES_CHIP_INDICATOR};return jsx(Root,{...Z,...A,as:y,type:Z.type??(y==='button'?'button':void 0),"data-disabled":Z.disabled,primary:s,ref:t,children:jsx(Slot,{render:I,props:{titleProps:O,descriptionProps:k,iconProps:B,iconButtonProps:X,avatarProps:H,indicatorProps:D},fallback:()=>typeof h=='function'?h({textProps:O,captionProps:k,discardButtonProps:X}):jsxs(Fragment,{children:[jsx(Slot,{render:j,props:{iconProps:B,iconButtonProps:X,avatarProps:H,indicatorProps:{...D,marginLeft:'var(--chip-margin)'}},fallback:jsxs(Fragment,{children:[R?jsx(Icon,{...B,...e,...l,name:typeof R=='string'?R:void 0,icon:typeof R!='string'?R:void 0}):null,c.src||c.text?jsx(Avatar,{...H,...c}):null]})}),jsx(Content,{...A,sizes:SIZES_CONTENT,children:jsx(Slot,{render:S,props:{titleProps:O,descriptionProps:k},fallback:jsxs(Fragment,{children:[jsx(Slot,{render:P,props:O,fallback:isNil(h)&&isNil(C)?null:jsx(Text,{...O,...i,children:h??C})}),jsx(Slot,{render:x,props:k,fallback:isNil(u)?null:jsx(Text,{...k,...n,children:u})})]})})}),jsx(Slot,{render:f,props:{iconProps:B,iconButtonProps:X,avatarProps:H,indicatorProps:{...D,marginRight:'var(--chip-margin)'}},fallback:jsxs(Fragment,{children:[a.children||a.text?jsx(Indicator,{marginRight:"var(--chip-margin)",...D,...a}):null,b?jsx(Icon,{...B,...e,...m,name:typeof b=='string'?b:void 0,icon:typeof b!='string'?b:void 0}):null,p.onClick?jsx(IconButton,{...X,...p}):null]})})]})})})});export{Chip};
2
2
  //# sourceMappingURL=Chip.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chip.mjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Close } from '@foxford/icon-pack'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { isNil } from 'shared/utils/isNil'\nimport { Slot } from 'components/Slot'\nimport { Text } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport { Avatar } from 'components/Avatar'\nimport { Indicator } from 'components/Indicator'\nimport { IconButton } from 'components/IconButton'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport type { ComponentElementType } from 'shared/types'\nimport type { TextProps } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { IconButtonProps } from 'components/IconButton'\nimport type { AvatarProps } from 'components/Avatar'\nimport type { IndicatorProps } from 'components/Indicator'\nimport {\n SIZES,\n SIZES_WITH_DESCRIPTION,\n SIZES_CONTENT,\n SIZES_TEXT,\n SIZES_DESCRIPTION,\n SIZES_ICON,\n SIZES_CHIP_INDICATOR,\n SIZES_CHIP_AVATAR,\n SIZES_CHIP_ICON_BUTTON,\n} from './sizes'\nimport * as Styled from './style'\nimport type { ChipProps } from './types'\n\nconst COMPONENT_NAME = 'Chip'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для представления данных, атрибутов или действий в компактной форме.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Chip = createPolymorphicComponentWithRef<'div', ChipProps>((props, ref) => {\n const {\n size = 'm',\n primary = true,\n textProps: titlePropsProp = {},\n captionProps: descriptionPropsProp = {},\n iconProps: iconPropsProp = {},\n avatarProps: avatarPropsProp = {},\n indicatorProps: indicatorPropsProp = {},\n discardButtonProps: iconButtonPropsProp = {},\n component,\n root,\n content,\n title,\n description,\n addonLeft,\n addonRight,\n children,\n text,\n caption,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = useMergedProps<PolymorphicProps<React.ElementType, ChipProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (chipProps) => {\n const hasTitle =\n !isNil(chipProps.title) ||\n !isNil(chipProps.text) ||\n (!isNil(chipProps.children) && typeof chipProps.children !== 'function')\n\n const hasDescription = !isNil(chipProps.description) || !isNil(chipProps.caption)\n\n return hasTitle && hasDescription ? SIZES_WITH_DESCRIPTION : SIZES\n },\n })\n\n let asProp: ComponentElementType = 'div'\n\n if (restProps.onClick) asProp = 'button'\n if (iconButtonPropsProp.onClick) asProp = 'div'\n if (component) asProp = component\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const titleProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_TEXT,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const descriptionProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_DESCRIPTION,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n sizes: SIZES_ICON,\n preset: 'brand',\n }\n\n const iconButtonProps: IconButtonProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_ICON_BUTTON,\n icon: <Close />,\n disabled: restProps.disabled,\n square: true,\n }\n\n const avatarProps: AvatarProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_AVATAR,\n preset: 'brand',\n square: true,\n }\n\n const indicatorProps: IndicatorProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_INDICATOR,\n }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={asProp}\n type={restProps.type ?? (asProp === 'button' ? 'button' : undefined)}\n data-disabled={restProps.disabled}\n primary={primary}\n ref={ref}\n >\n <Slot\n render={root}\n props={{\n titleProps,\n descriptionProps,\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps,\n }}\n fallback={() =>\n typeof children === 'function' ? (\n children({\n textProps: titleProps,\n captionProps: descriptionProps,\n discardButtonProps: iconButtonProps,\n })\n ) : (\n <>\n <Slot\n render={addonLeft}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginLeft: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {iconBefore ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n ) : null}\n {avatarPropsProp.src || avatarPropsProp.text ? (\n <Avatar {...avatarProps} {...avatarPropsProp} />\n ) : null}\n </>\n }\n />\n <Styled.Content {...sizeProps} sizes={SIZES_CONTENT}>\n <Slot\n render={content}\n props={{\n titleProps,\n descriptionProps,\n }}\n fallback={\n <>\n <Slot\n render={title}\n props={titleProps}\n fallback={\n !isNil(children) || !isNil(text) ? (\n <Text {...titleProps} {...titlePropsProp}>\n {children ?? text}\n </Text>\n ) : null\n }\n />\n <Slot\n render={description}\n props={descriptionProps}\n fallback={\n !isNil(caption) ? (\n <Text {...descriptionProps} {...descriptionPropsProp}>\n {caption}\n </Text>\n ) : null\n }\n />\n </>\n }\n />\n </Styled.Content>\n <Slot\n render={addonRight}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginRight: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {indicatorPropsProp.children || indicatorPropsProp.text ? (\n <Indicator marginRight='var(--chip-margin)' {...indicatorProps} {...indicatorPropsProp} />\n ) : null}\n {iconAfter ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n ) : null}\n {iconButtonPropsProp.onClick ? <IconButton {...iconButtonProps} {...iconButtonPropsProp} /> : null}\n </>\n }\n />\n </>\n )\n }\n />\n </Styled.Root>\n )\n})\n\nconst ChipDoc: React.FC<ChipProps> = () => null\n\nexport { ChipDoc, Chip }\n"],"names":["Chip","createPolymorphicComponentWithRef","props","ref","size","primary","textProps","titlePropsProp","captionProps","descriptionPropsProp","iconProps","iconPropsProp","avatarProps","avatarPropsProp","indicatorProps","indicatorPropsProp","discardButtonProps","iconButtonPropsProp","component","root","content","title","description","addonLeft","addonRight","children","text","caption","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","useMergedProps","componentName","sizes","chipProps","hasTitle","isNil","hasDescription","SIZES_WITH_DESCRIPTION","SIZES","asProp","onClick","sizeProps","iconBefore","iconAfter","Array","isArray","titleProps","SIZES_TEXT","as","appearance","color","textAlign","descriptionProps","SIZES_DESCRIPTION","SIZES_ICON","preset","iconButtonProps","SIZES_CHIP_ICON_BUTTON","_jsx","Close","disabled","square","SIZES_CHIP_AVATAR","SIZES_CHIP_INDICATOR","Styled","type","undefined","Slot","render","fallback","_jsxs","_Fragment","marginLeft","Icon","name","src","Avatar","SIZES_CONTENT","Text","marginRight","Indicator","IconButton"],"mappings":"0wBA2CA,MAAMA,KAAOC,kCAAoD,CAACC,EAAOC,KACvE,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EACVC,UAAWC,EAAiB,CAAA,EAC5BC,aAAcC,EAAuB,CAAA,EACrCC,UAAWC,EAAgB,CAAA,EAC3BC,YAAaC,EAAkB,CAAA,EAC/BC,eAAgBC,EAAqB,CAAA,EACrCC,mBAAoBC,EAAsB,CAAA,EAAEC,UAC5CA,EAASC,KACTA,EAAIC,QACJA,EAAOC,MACPA,EAAKC,YACLA,EAAWC,UACXA,EAASC,WACTA,EAAUC,SACVA,EAAQC,KACRA,EAAIC,QACJA,EAA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kC,EACCe,IAACe,KAAI,IACCrE,KACAC,EACJqE,YAAa/B,GAAc,SAAWA,OAAYuB,EAClD5C,YAAaqB,GAAc,SAAWA,OAAYuB,IAElD,KACHvD,EAAoB6B,QAAUkB,IAACuB,WAAU,IAAKzB,KAAqB7C,IAA0B"}
1
+ {"version":3,"file":"Chip.mjs","sources":["../../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import { Close } from '@foxford/icon-pack'\nimport { createPolymorphicComponentWithRef } from 'shared/utils/createPolymorphicComponentWithRef'\nimport { useMergedProps } from 'hooks/useMergedProps'\nimport { isNil } from 'shared/utils/isNil'\nimport { Slot } from 'components/Slot'\nimport { Text } from 'components/Text'\nimport { Icon } from 'components/Icon'\nimport { Avatar } from 'components/Avatar'\nimport { Indicator } from 'components/Indicator'\nimport { IconButton } from 'components/IconButton'\nimport type { PolymorphicProps } from 'shared/interfaces'\nimport type { ComponentElementType } from 'shared/types'\nimport type { TextProps } from 'components/Text'\nimport type { IconProps } from 'components/Icon'\nimport type { IconButtonProps } from 'components/IconButton'\nimport type { AvatarProps } from 'components/Avatar'\nimport type { IndicatorProps } from 'components/Indicator'\nimport {\n SIZES,\n SIZES_WITH_DESCRIPTION,\n SIZES_CONTENT,\n SIZES_TEXT,\n SIZES_DESCRIPTION,\n SIZES_ICON,\n SIZES_CHIP_INDICATOR,\n SIZES_CHIP_AVATAR,\n SIZES_CHIP_ICON_BUTTON,\n} from './sizes'\nimport * as Styled from './style'\nimport type { ChipProps } from './types'\n\nconst COMPONENT_NAME = 'Chip'\n\n/**\n *\n * *v1.0.0*\n *\n * Компонент для представления данных, атрибутов или действий в компактной форме.\n *\n * Полиморфный компонент.\n *\n * Можно передать \"ref\" и атрибуты выбранного HTML-элемента (по умолчанию \\<div\\>).\n */\nconst Chip = createPolymorphicComponentWithRef<'div', ChipProps>((props, ref) => {\n const {\n size = 'm',\n primary = true,\n textProps: titlePropsProp = {},\n captionProps: descriptionPropsProp = {},\n iconProps: iconPropsProp = {},\n avatarProps: avatarPropsProp = {},\n indicatorProps: indicatorPropsProp = {},\n discardButtonProps: iconButtonPropsProp = {},\n leftIconProps = {},\n rightIconProps = {},\n component,\n root,\n content,\n title,\n description,\n addonLeft,\n addonRight,\n children,\n text,\n caption,\n icon,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n ...restProps\n } = useMergedProps<PolymorphicProps<React.ElementType, ChipProps>>(props, {\n componentName: COMPONENT_NAME,\n sizes: (chipProps) => {\n const hasTitle =\n !isNil(chipProps.title) ||\n !isNil(chipProps.text) ||\n (!isNil(chipProps.children) && typeof chipProps.children !== 'function')\n\n const hasDescription = !isNil(chipProps.description) || !isNil(chipProps.caption)\n\n return hasTitle && hasDescription ? SIZES_WITH_DESCRIPTION : SIZES\n },\n })\n\n let asProp: ComponentElementType = 'div'\n\n if (restProps.onClick) asProp = 'button'\n if (iconButtonPropsProp.onClick) asProp = 'div'\n if (component) asProp = component\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const [iconBefore, iconAfter] = Array.isArray(icon) ? icon : [icon]\n\n const titleProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_TEXT,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const descriptionProps: TextProps = {\n ...sizeProps,\n sizes: SIZES_DESCRIPTION,\n as: 'span',\n appearance: 'caption',\n color: 'inherit',\n textAlign: 'center',\n }\n\n const iconProps: IconProps = {\n ...sizeProps,\n sizes: SIZES_ICON,\n preset: 'brand',\n }\n\n const iconButtonProps: IconButtonProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_ICON_BUTTON,\n icon: <Close />,\n disabled: restProps.disabled,\n square: true,\n }\n\n const avatarProps: AvatarProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_AVATAR,\n preset: 'brand',\n square: true,\n }\n\n const indicatorProps: IndicatorProps = {\n ...sizeProps,\n sizes: SIZES_CHIP_INDICATOR,\n }\n\n return (\n <Styled.Root\n {...restProps}\n {...sizeProps}\n as={asProp}\n type={restProps.type ?? (asProp === 'button' ? 'button' : undefined)}\n data-disabled={restProps.disabled}\n primary={primary}\n ref={ref}\n >\n <Slot\n render={root}\n props={{\n titleProps,\n descriptionProps,\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps,\n }}\n fallback={() =>\n typeof children === 'function' ? (\n children({\n textProps: titleProps,\n captionProps: descriptionProps,\n discardButtonProps: iconButtonProps,\n })\n ) : (\n <>\n <Slot\n render={addonLeft}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginLeft: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {iconBefore ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n {...leftIconProps}\n name={typeof iconBefore === 'string' ? iconBefore : undefined}\n icon={typeof iconBefore !== 'string' ? iconBefore : undefined}\n />\n ) : null}\n {avatarPropsProp.src || avatarPropsProp.text ? (\n <Avatar {...avatarProps} {...avatarPropsProp} />\n ) : null}\n </>\n }\n />\n <Styled.Content {...sizeProps} sizes={SIZES_CONTENT}>\n <Slot\n render={content}\n props={{\n titleProps,\n descriptionProps,\n }}\n fallback={\n <>\n <Slot\n render={title}\n props={titleProps}\n fallback={\n !isNil(children) || !isNil(text) ? (\n <Text {...titleProps} {...titlePropsProp}>\n {children ?? text}\n </Text>\n ) : null\n }\n />\n <Slot\n render={description}\n props={descriptionProps}\n fallback={\n !isNil(caption) ? (\n <Text {...descriptionProps} {...descriptionPropsProp}>\n {caption}\n </Text>\n ) : null\n }\n />\n </>\n }\n />\n </Styled.Content>\n <Slot\n render={addonRight}\n props={{\n iconProps,\n iconButtonProps,\n avatarProps,\n indicatorProps: {\n ...indicatorProps,\n marginRight: 'var(--chip-margin)',\n },\n }}\n fallback={\n <>\n {indicatorPropsProp.children || indicatorPropsProp.text ? (\n <Indicator marginRight='var(--chip-margin)' {...indicatorProps} {...indicatorPropsProp} />\n ) : null}\n {iconAfter ? (\n <Icon\n {...iconProps}\n {...iconPropsProp}\n {...rightIconProps}\n name={typeof iconAfter === 'string' ? iconAfter : undefined}\n icon={typeof iconAfter !== 'string' ? iconAfter : undefined}\n />\n ) : null}\n {iconButtonPropsProp.onClick ? <IconButton {...iconButtonProps} {...iconButtonPropsProp} /> : null}\n </>\n }\n />\n </>\n )\n }\n />\n </Styled.Root>\n )\n})\n\nconst ChipDoc: React.FC<ChipProps> = () => null\n\nexport { ChipDoc, Chip }\n"],"names":["Chip","createPolymorphicComponentWithRef","props","ref","size","primary","textProps","titlePropsProp","captionProps","descriptionPropsProp","iconProps","iconPropsProp","avatarProps","avatarPropsProp","indicatorProps","indicatorPropsProp","discardButtonProps","iconButtonPropsProp","leftIconProps","rightIconProps","component","root","content","title","description","addonLeft","addonRight","children","text","caption","icon","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","restProps","useMergedProps","componentName","sizes","chipProps","hasTitle","isNil","hasDescription","SIZES_WITH_DESCRIPTION","SIZES","asProp","onClick","sizeProps","iconBefore","iconAfter","Array","isArray","titleProps","SIZES_TEXT","as","appearance","color","textAlign","descriptionProps","SIZES_DESCRIPTION","SIZES_ICON","preset","iconButtonProps","SIZES_CHIP_ICON_BUTTON","_jsx","Close","disabled","square","SIZES_CHIP_AVATAR","SIZES_CHIP_INDICATOR","Styled","type","undefined","Slot","render","fallback","_jsxs","_Fragment","marginLeft","Icon","name","src","Avatar","SIZES_CONTENT","Text","marginRight","Indicator","IconButton"],"mappings":"0wBA2CA,MAAMA,KAAOC,kCAAoD,CAACC,EAAOC,KACvE,MAAMC,KACJA,EAAO,IAAGC,QACVA,GAAU,EACVC,UAAWC,EAAiB,CAAA,EAC5BC,aAAcC,EAAuB,CAAA,EACrCC,UAAWC,EAAgB,CAAA,EAC3BC,YAAaC,EAAkB,CAAA,EAC/BC,eAAgBC,EAAqB,CAAA,EACrCC,mBAAoBC,EAAsB,CAA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xB,MAAO,CACLQ,YACAsD,kBACApD,cACAE,eAAgB,IACXA,EACHyE,YAAa,uBAGjBV,SACEC,KAAAC,SAAA,CAAApD,SAAA,CACGZ,EAAmBY,UAAYZ,EAAmBa,KACjDsC,IAACsB,UAAS,CAACD,YAAY,wBAAyBzE,KAAoBC,IAClE,KACHoC,EACCe,IAACe,KAAI,IACCvE,KACAC,KACAQ,EACJ+D,YAAa/B,GAAc,SAAWA,OAAYuB,EAClD5C,YAAaqB,GAAc,SAAWA,OAAYuB,IAElD,KACHzD,EAAoB+B,QAAUkB,IAACuB,WAAU,IAAKzB,KAAqB/C,IAA0B"}
@@ -1,2 +1,2 @@
1
- 'use strict';var React=require('react');var nanoid=require('nanoid');var withMergedProps=require('../../hocs/withMergedProps.js');var useScrollMonitor=require('../../hooks/useScrollMonitor.js');var dom=require('../../shared/utils/dom.js');var misc=require('../../shared/utils/misc.js');var constants=require('../../shared/constants.js');var DropdownMenu=require('./DropdownMenu.js');var hooks=require('./hooks.js');var sizes=require('./sizes.js');var utils=require('./utils.js');var style=require('./style.js');var DropdownMenuMultiple=require('./DropdownMenuMultiple.js');var DropdownMenuSingle=require('./DropdownMenuSingle.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');var Chip=require('../Chip/Chip.js');var IconButton=require('../IconButton/IconButton.js');var index=require('../../icon-pack/src/icons/Close/index.js');var index$1=require('../../icon-pack/src/icons/ChevronDown/index.js');var Icon=require('../Icon/Icon.js');var FormInput=require('../FormInput/FormInput.js');const Dropdown=withMergedProps.withMergedProps(React.forwardRef((e,o)=>{const{size:n="m",name:t="fox-dropdown",labelPosition:r="dynamic",searchable:s=!0,primary:a=!0,optionsMultiToggle:i=!0,iconProps:l={},menuProps:c={},loadingIconProps:u={},optionsEmptyIconProps:d={},loading:p,autoFocus:b,disableAutoScrollToSelectedOption:g,closeMenuOnScroll:m,scrollMonitorTarget:f,contrast:v,selectedOption:x,defaultSelectedOption:y,icon:D,addonLeft:w,inputMode:j,loadingMessage:C,loadingIcon:M,maxLength:R,multiple:I,clearable:h,onChangeInput:k,onCloseMenu:S,onOpenMenu:T,onSelectOption:O,options:P,loadOptions:F,renderOption:q,groupSelectedOptions:L,optionsMultiToggleCaption:z,optionsEmptyMessage:E,optionsEmptyIcon:B,palette:K,placeholder:X,readOnly:A,required:H,status:N,sizeXXS:$,sizeXS:U,sizeS:Z,sizeM:_,sizeL:G,sizeXL:J,form:Q,label:V,...W}=e;const Y={size:n,sizeXXS:$,sizeXS:U,sizeS:Z,sizeM:_,sizeL:G,sizeXL:J};const ee=React.useMemo(()=>W.id??`${t}-${nanoid.nanoid()}`,[t,W.id]);const oe=React.useMemo(()=>nanoid.nanoid(),[]);const ne=React.useMemo(()=>nanoid.nanoid(),[]);const[te,re]=hooks.useFilteredOptions({options:P});const[se,ae,ie]=hooks.useLoadedOptions({loadOptions:F,options:P});const[le,ce]=React.useState(()=>utils.getDropdownSelectedOption(x!==void 0?x:y,I));const[ue,de]=React.useState(()=>utils.getDropdownInputText(le,I));const[pe,be]=React.useState(!1);const[ge,me]=React.useState(!1);const fe=F?se:te;const ve=F?p??ae:p;const xe=ge&&!W.disabled;const ye=H&&le.length===0;const De=Boolean(xe||ue||pe);const we=React.useRef(null);const[je,Ce]=React.useState(null);const Me=React.useRef(null);const Re=React.useRef(null);const Ie=React.useRef(xe);const he=React.useCallback(e=>{de(e),k&&k(e)},[k]);const ke=React.useCallback(e=>{F?ie(e):re(e)},[F,ie,re]);const Se=React.useMemo(()=>misc.createDebouncedCallback(ke,150),[ke]);const preventBlur=e=>{e.target!==we.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&xe&&je&&je.contains(e.target))&&e.preventDefault()};return useScrollMonitor.useScrollMonitor({target:f,onScrollStart:()=>{m&&xe&&(we.current?.focus(),me(!1))}}),React.useLayoutEffect(()=>{x!==void 0&&(I||xe||he(utils.getDropdownInputText(x)),ce(utils.getDropdownSelectedOption(x,I)))},[I,x,xe,he]),React.useEffect(()=>{xe!==Ie.current&&(xe&&T&&T(),!xe&&S&&S(),Ie.current=xe)},[xe,S,T]),React.useEffect(()=>{if(!I&&!g&&xe&&!ve&&ue.length===0&&je&&Re.current){const e=je.getBoundingClientRect();const o=Re.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout(()=>{je&&Re.current&&je.scrollTo(0,Re.current.offsetTop)},0)}},[I,g,xe,ve,ue,je]),React.useEffect(()=>{W.disabled&&be(!1)},[W.disabled]),jsxRuntime.jsx(FormInputLabel.FormInputLabel,{...W,...Y,ref:o,id:ee,onColored:v,primary:a,error:N==='error',success:N==='success',focus:pe,palette:{color:W.disabled?K.labelColorDisabled:K.labelColor,backgroundColor:W.disabled?K.backgroundColorDisabled:K.backgroundColor,backgroundColorHover:W.disabled?K.backgroundColorDisabled:K.backgroundColorHover,borderColor:W.disabled?K.borderColorDisabled:K.borderColor},onClick:e=>{W.onClick&&W.onClick(e),W.disabled||(we.current?.focus(),xe?je&&e.target instanceof Node&&!je.contains(e.target)&&(me(!1),he(utils.getDropdownInputText(le,I))):(me(!0),ke(''),s&&he('')))},onPointerDown:e=>{W.onPointerDown&&W.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{W.onMouseDown&&W.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{W.onFocus&&W.onFocus(e),be(!0),we.current&&e.target===we.current&&s&&!I&&!xe&&he('')},onBlur:e=>{W.onBlur&&W.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&xe&&je&&je.contains(e.relatedTarget)||(be(!1),he(utils.getDropdownInputText(le,I)),me(!1))},input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!ye||s||A?null:jsxRuntime.jsx(style.InputMimic,{required:!0,type:"text",inputMode:"none",form:Q,tabIndex:-1,onFocus:()=>{we.current?.focus()}}),jsxRuntime.jsx(FormInput.FormInput,{...Y,ref:we,role:"combobox","aria-controls":ne,"aria-expanded":xe,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",active:De,label:V,labelId:oe,labelPosition:r,form:Q,autoFocus:b,inputMode:s?j:'none',maxLength:R,placeholder:X,readOnly:A||!s,required:ye,disabled:W.disabled,value:ue,palette:{color:K.color,colorDisabled:K.colorDisabled,placeholderColor:K.placeholderColor,placeholderColorDisabled:K.placeholderColorDisabled},onClick:e=>{xe&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;he(o),Se(o),me(!0)},onKeyDown:e=>{if(constants.keyboardKeys.Enter.validate(e.key)&&(he(utils.getDropdownInputText(le,I)),me(!1)),!constants.keyboardKeys.Space.validate(e.key)||xe&&e.currentTarget.selectionStart!==0||(e.preventDefault(),xe||(ke(''),s&&he('')),me(e=>!e)),constants.keyboardKeys.Esc.validate(e.key)&&me(!1),constants.keyboardKeys.Tab.validate(e.key)&&xe&&(e.preventDefault(),me(!1)),constants.keyboardKeys.ArrowDown.validate(e.key)&&xe&&Me.current)if(e.preventDefault(),!I&&Re.current){const e=[...Me.current.children];const o=e.findIndex(e=>e.contains(Re.current));const n=e[o+1]??e[0];n instanceof HTMLElement&&dom.focusFirstFocusable(n)}else dom.focusFirstFocusable(Me.current);if(constants.keyboardKeys.ArrowUp.validate(e.key)&&xe&&Me.current)if(e.preventDefault(),!I&&Re.current){const e=[...Me.current.children];const o=e.findIndex(e=>e.contains(Re.current));const n=e[o-1]??e[e.length-1];n instanceof HTMLElement&&dom.focusFirstFocusable(n)}else dom.focusLastFocusable(Me.current)}}),le.map(e=>jsxRuntime.jsx("input",{type:"hidden",name:t,value:e.value,form:Q,disabled:W.disabled||e.disabled},e.value))]}),addonLeft:w??(D?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...l,name:typeof D=='string'?D:void 0,icon:typeof D!='string'?D:void 0}):void 0),addonRight:e=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I&&le.length>0?jsxRuntime.jsx(Chip.Chip,{size:"xs",active:!0,black:!0,disabled:W.disabled,cursor:W.disabled?'not-allowed':void 0,title:le.length,palette:W.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},addonRight:e=>jsxRuntime.jsx(IconButton.IconButton,{...e.iconButtonProps,contrast:!W.disabled,onClick:e=>{e.stopPropagation(),A||(x===void 0&&ce([]),O&&O([]),we.current?.focus(),he(''),ke(''),me(!0))}})}):null,!I&&h&&le.length>0?jsxRuntime.jsx(IconButton.IconButton,{icon:jsxRuntime.jsx(index.Close,{}),size:"l",square:!0,disabled:W.disabled,onClick:e=>{e.stopPropagation(),A||(x===void 0&&ce([]),O&&O(null),we.current?.focus(),he(''),ke(''),me(!0))}}):null,jsxRuntime.jsx(style.IconAnimated,{...e.iconProps,...l,icon:jsxRuntime.jsx(index$1.ChevronDown,{}),up:xe})]}),dropdown:e=>jsxRuntime.jsx(DropdownMenu.DropdownMenu,{...c,setRef:Ce,open:xe,popperReferenceId:ee,secondary:!v,elevated:v,disableAutoFocus:!0,palette:{backgroundColor:K.menuBackgroundColor,borderColor:K.menuBorderColor},empty:fe.length===0,loading:ve,loadingMessage:C,loadingIcon:M,loadingIconProps:{...e.iconProps,...u},emptyMessage:E,emptyIcon:B,emptyIconProps:{...e.iconProps,...d},onKeyDown:e=>{constants.keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),we.current?.focus(),me(!1)),constants.keyboardKeys.Enter.validate(e.key)&&(we.current?.focus(),he(utils.getDropdownInputText(le,I)),me(!1)),constants.keyboardKeys.Esc.validate(e.key)&&(we.current?.focus(),me(!1)),constants.keyboardKeys.Backspace.validate(e.key)&&!A&&(I||!I&&h)&&(x===void 0&&ce([]),O&&O(I?[]:null),he(''),ke(''))},children:I?jsxRuntime.jsx(DropdownMenuMultiple.DropdownMenuMultiple,{...Y,ref:Me,inputRef:we,label:V,name:t,disabled:W.disabled,readOnly:A,menuListId:ne,inputLabelId:oe,menuOptions:fe,dropdownSelectedOption:le,inputText:ue,optionsMultiToggle:i,groupSelectedOptions:L,optionsMultiToggleCaption:z,renderOption:q,onChange:e=>{x===void 0&&ce(e),O&&O(e)}}):jsxRuntime.jsx(DropdownMenuSingle.DropdownMenuSingle,{...Y,ref:Me,label:V,readOnly:A,multiple:I,disabled:W.disabled,status:N,menuListId:ne,inputLabelId:oe,menuOptions:fe,dropdownSelectedOption:le,selectedOptionRef:Re,renderOption:q,onChange:e=>{const o={...e};x===void 0&&(he(utils.getDropdownInputText(o)),ce(utils.getDropdownSelectedOption(o))),O&&O(o),we.current?.focus(),me(!1)}})})})}),{sizes:sizes.SIZES,displayName:"Dropdown"});exports.COMPONENT_NAME="Dropdown",exports.Dropdown=Dropdown;
1
+ 'use strict';var React=require('react');var nanoid=require('nanoid');var withMergedProps=require('../../hocs/withMergedProps.js');var useScrollMonitor=require('../../hooks/useScrollMonitor.js');var dom=require('../../shared/utils/dom.js');var misc=require('../../shared/utils/misc.js');var constants=require('../../shared/constants.js');var DropdownMenu=require('./DropdownMenu.js');var hooks=require('./hooks.js');var sizes=require('./sizes.js');var utils=require('./utils.js');var style=require('./style.js');var DropdownMenuMultiple=require('./DropdownMenuMultiple.js');var DropdownMenuSingle=require('./DropdownMenuSingle.js');var jsxRuntime=require('react/jsx-runtime');var FormInputLabel=require('../FormInputLabel/FormInputLabel.js');var Chip=require('../Chip/Chip.js');var IconButton=require('../IconButton/IconButton.js');var index=require('../../icon-pack/src/icons/Close/index.js');var Icon=require('../Icon/Icon.js');var FormInput=require('../FormInput/FormInput.js');const Dropdown=withMergedProps.withMergedProps(React.forwardRef((e,o)=>{const{size:n="m",name:t="fox-dropdown",labelPosition:r="dynamic",searchable:s=!0,primary:a=!0,optionsMultiToggle:i=!0,iconProps:l={},menuProps:c={},loadingIconProps:u={},optionsEmptyIconProps:d={},loading:p,autoFocus:b,disableAutoScrollToSelectedOption:g,closeMenuOnScroll:m,scrollMonitorTarget:f,contrast:v,selectedOption:x,defaultSelectedOption:y,icon:D,addonLeft:w,inputMode:j,loadingMessage:M,loadingIcon:C,maxLength:R,multiple:I,clearable:h,onChangeInput:k,onCloseMenu:S,onOpenMenu:T,onSelectOption:O,options:P,loadOptions:F,renderOption:q,groupSelectedOptions:L,optionsMultiToggleCaption:z,optionsEmptyMessage:E,optionsEmptyIcon:B,palette:K,placeholder:X,readOnly:A,required:H,status:N,sizeXXS:$,sizeXS:U,sizeS:Z,sizeM:_,sizeL:G,sizeXL:J,form:Q,label:V,...W}=e;const Y={size:n,sizeXXS:$,sizeXS:U,sizeS:Z,sizeM:_,sizeL:G,sizeXL:J};const ee=React.useMemo(()=>W.id??`${t}-${nanoid.nanoid()}`,[t,W.id]);const oe=React.useMemo(()=>nanoid.nanoid(),[]);const ne=React.useMemo(()=>nanoid.nanoid(),[]);const[te,re]=hooks.useFilteredOptions({options:P});const[se,ae,ie]=hooks.useLoadedOptions({loadOptions:F,options:P});const[le,ce]=React.useState(()=>utils.getDropdownSelectedOption(x!==void 0?x:y,I));const[ue,de]=React.useState(()=>utils.getDropdownInputText(le,I));const[pe,be]=React.useState(!1);const[ge,me]=React.useState(!1);const fe=F?se:te;const ve=F?p??ae:p;const xe=ge&&!W.disabled;const ye=H&&le.length===0;const De=Boolean(xe||ue||pe);const we=React.useRef(null);const[je,Me]=React.useState(null);const Ce=React.useRef(null);const Re=React.useRef(null);const Ie=React.useRef(xe);const he=React.useCallback(e=>{de(e),k&&k(e)},[k]);const ke=React.useCallback(e=>{F?ie(e):re(e)},[F,ie,re]);const Se=React.useMemo(()=>misc.createDebouncedCallback(ke,150),[ke]);const preventBlur=e=>{e.target!==we.current&&e.target instanceof Node&&(e.currentTarget.contains(e.target)||c.renderInPortal&&xe&&je&&je.contains(e.target))&&e.preventDefault()};return useScrollMonitor.useScrollMonitor({target:f,onScrollStart:()=>{m&&xe&&(we.current?.focus(),me(!1))}}),React.useLayoutEffect(()=>{x!==void 0&&(I||xe||he(utils.getDropdownInputText(x)),ce(utils.getDropdownSelectedOption(x,I)))},[I,x,xe,he]),React.useEffect(()=>{xe!==Ie.current&&(xe&&T&&T(),!xe&&S&&S(),Ie.current=xe)},[xe,S,T]),React.useEffect(()=>{if(!I&&!g&&xe&&!ve&&ue.length===0&&je&&Re.current){const e=je.getBoundingClientRect();const o=Re.current.getBoundingClientRect();(o.top<e.top||o.bottom>e.bottom)&&setTimeout(()=>{je&&Re.current&&je.scrollTo(0,Re.current.offsetTop)},0)}},[I,g,xe,ve,ue,je]),React.useEffect(()=>{W.disabled&&be(!1)},[W.disabled]),jsxRuntime.jsx(FormInputLabel.FormInputLabel,{...W,...Y,ref:o,id:ee,onColored:v,primary:a,error:N==='error',success:N==='success',focus:pe,palette:{color:W.disabled?K.labelColorDisabled:K.labelColor,backgroundColor:W.disabled?K.backgroundColorDisabled:K.backgroundColor,backgroundColorHover:W.disabled?K.backgroundColorDisabled:K.backgroundColorHover,borderColor:W.disabled?K.borderColorDisabled:K.borderColor},onClick:e=>{W.onClick&&W.onClick(e),W.disabled||(we.current?.focus(),xe?je&&e.target instanceof Node&&!je.contains(e.target)&&(me(!1),he(utils.getDropdownInputText(le,I))):(me(!0),ke(''),s&&he('')))},onPointerDown:e=>{W.onPointerDown&&W.onPointerDown(e),preventBlur(e)},onMouseDown:e=>{W.onMouseDown&&W.onMouseDown(e),window.PointerEvent||preventBlur(e)},onFocus:e=>{W.onFocus&&W.onFocus(e),be(!0),we.current&&e.target===we.current&&s&&!I&&!xe&&he('')},onBlur:e=>{W.onBlur&&W.onBlur(e),e.currentTarget.contains(e.relatedTarget)||c.renderInPortal&&xe&&je&&je.contains(e.relatedTarget)||(be(!1),he(utils.getDropdownInputText(le,I)),me(!1))},input:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!ye||s||A?null:jsxRuntime.jsx(style.InputMimic,{required:!0,type:"text",inputMode:"none",form:Q,tabIndex:-1,onFocus:()=>{we.current?.focus()}}),jsxRuntime.jsx(FormInput.FormInput,{...Y,ref:we,role:"combobox","aria-controls":ne,"aria-expanded":xe,type:"text",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:"false",active:De,label:V,labelId:oe,labelPosition:r,form:Q,autoFocus:b,inputMode:s?j:'none',maxLength:R,placeholder:X,readOnly:A||!s,required:ye,disabled:W.disabled,value:ue,palette:{color:K.color,colorDisabled:K.colorDisabled,placeholderColor:K.placeholderColor,placeholderColorDisabled:K.placeholderColorDisabled},onClick:e=>{xe&&e.currentTarget.selectionStart!==e.currentTarget.selectionEnd&&e.stopPropagation()},onChange:e=>{const o=e.currentTarget.value;he(o),Se(o),me(!0)},onKeyDown:e=>{if(constants.keyboardKeys.Enter.validate(e.key)&&(he(utils.getDropdownInputText(le,I)),me(!1)),!constants.keyboardKeys.Space.validate(e.key)||xe&&e.currentTarget.selectionStart!==0||(e.preventDefault(),xe||(ke(''),s&&he('')),me(e=>!e)),constants.keyboardKeys.Esc.validate(e.key)&&me(!1),constants.keyboardKeys.Tab.validate(e.key)&&xe&&(e.preventDefault(),me(!1)),constants.keyboardKeys.ArrowDown.validate(e.key)&&xe&&Ce.current)if(e.preventDefault(),!I&&Re.current){const e=[...Ce.current.children];const o=e.findIndex(e=>e.contains(Re.current));const n=e[o+1]??e[0];n instanceof HTMLElement&&dom.focusFirstFocusable(n)}else dom.focusFirstFocusable(Ce.current);if(constants.keyboardKeys.ArrowUp.validate(e.key)&&xe&&Ce.current)if(e.preventDefault(),!I&&Re.current){const e=[...Ce.current.children];const o=e.findIndex(e=>e.contains(Re.current));const n=e[o-1]??e[e.length-1];n instanceof HTMLElement&&dom.focusFirstFocusable(n)}else dom.focusLastFocusable(Ce.current)}}),le.map(e=>jsxRuntime.jsx("input",{type:"hidden",name:t,value:e.value,form:Q,disabled:W.disabled||e.disabled},e.value))]}),addonLeft:w??(D?e=>jsxRuntime.jsx(Icon.Icon,{...e.iconProps,...l,name:typeof D=='string'?D:void 0,icon:typeof D!='string'?D:void 0}):void 0),addonRight:e=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[I&&le.length>0?jsxRuntime.jsx(Chip.Chip,{size:"xs",active:!0,black:!0,disabled:W.disabled,cursor:W.disabled?'not-allowed':void 0,title:le.length,palette:W.disabled?{color:'content-disabled',colorHover:'content-disabled',backgroundColor:'bg-disabled-small',backgroundColorHover:'bg-disabled-small'}:void 0,onPointerDown:e=>{e.preventDefault()},onMouseDown:e=>{window.PointerEvent||e.preventDefault()},addonRight:e=>jsxRuntime.jsx(IconButton.IconButton,{...e.iconButtonProps,contrast:!W.disabled,onClick:e=>{e.stopPropagation(),A||(x===void 0&&ce([]),O&&O([]),we.current?.focus(),he(''),ke(''),me(!0))}})}):null,!I&&h&&le.length>0?jsxRuntime.jsx(IconButton.IconButton,{icon:jsxRuntime.jsx(index.Close,{}),size:"l",square:!0,disabled:W.disabled,onClick:e=>{e.stopPropagation(),A||(x===void 0&&ce([]),O&&O(null),we.current?.focus(),he(''),ke(''),me(!0))}}):null,jsxRuntime.jsx(style.IconAnimated,{...e.iconProps,...l,icon:jsxRuntime.jsx(style.ChevronDown,{}),rotate:xe?'180deg':'0deg'})]}),dropdown:e=>jsxRuntime.jsx(DropdownMenu.DropdownMenu,{...c,setRef:Me,open:xe,popperReferenceId:ee,secondary:!v,elevated:v,disableAutoFocus:!0,palette:{backgroundColor:K.menuBackgroundColor,borderColor:K.menuBorderColor},empty:fe.length===0,loading:ve,loadingMessage:M,loadingIcon:C,loadingIconProps:{...e.iconProps,...u},emptyMessage:E,emptyIcon:B,emptyIconProps:{...e.iconProps,...d},onKeyDown:e=>{constants.keyboardKeys.Tab.validate(e.key)&&(e.preventDefault(),we.current?.focus(),me(!1)),constants.keyboardKeys.Enter.validate(e.key)&&(we.current?.focus(),he(utils.getDropdownInputText(le,I)),me(!1)),constants.keyboardKeys.Esc.validate(e.key)&&(we.current?.focus(),me(!1)),constants.keyboardKeys.Backspace.validate(e.key)&&!A&&(I||!I&&h)&&(x===void 0&&ce([]),O&&O(I?[]:null),he(''),ke(''))},children:I?jsxRuntime.jsx(DropdownMenuMultiple.DropdownMenuMultiple,{...Y,ref:Ce,inputRef:we,label:V,name:t,disabled:W.disabled,readOnly:A,menuListId:ne,inputLabelId:oe,menuOptions:fe,dropdownSelectedOption:le,inputText:ue,optionsMultiToggle:i,groupSelectedOptions:L,optionsMultiToggleCaption:z,renderOption:q,onChange:e=>{x===void 0&&ce(e),O&&O(e)}}):jsxRuntime.jsx(DropdownMenuSingle.DropdownMenuSingle,{...Y,ref:Ce,label:V,readOnly:A,multiple:I,disabled:W.disabled,status:N,menuListId:ne,inputLabelId:oe,menuOptions:fe,dropdownSelectedOption:le,selectedOptionRef:Re,renderOption:q,onChange:e=>{const o={...e};x===void 0&&(he(utils.getDropdownInputText(o)),ce(utils.getDropdownSelectedOption(o))),O&&O(o),we.current?.focus(),me(!1)}})})})}),{sizes:sizes.SIZES,displayName:"Dropdown"});exports.COMPONENT_NAME="Dropdown",exports.Dropdown=Dropdown;
2
2
  //# sourceMappingURL=Dropdown.js.map