@doist/reactist 28.7.0 → 28.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/reactist.cjs.development.js +67 -83
  2. package/dist/reactist.cjs.development.js.map +1 -1
  3. package/dist/reactist.cjs.production.min.js +1 -1
  4. package/dist/reactist.cjs.production.min.js.map +1 -1
  5. package/es/avatar/avatar.js +1 -1
  6. package/es/avatar/avatar.js.map +1 -1
  7. package/es/badge/badge.js +1 -1
  8. package/es/badge/badge.js.map +1 -1
  9. package/es/banner/banner.js +1 -1
  10. package/es/banner/banner.js.map +1 -1
  11. package/es/base-field/base-field.js +2 -2
  12. package/es/base-field/base-field.js.map +1 -1
  13. package/es/box/box.js +11 -13
  14. package/es/box/box.js.map +1 -1
  15. package/es/button/button.js +2 -2
  16. package/es/button/button.js.map +1 -1
  17. package/es/checkbox-field/checkbox-field.js +2 -4
  18. package/es/checkbox-field/checkbox-field.js.map +1 -1
  19. package/es/components/deprecated-button/deprecated-button.js +1 -1
  20. package/es/components/deprecated-button/deprecated-button.js.map +1 -1
  21. package/es/components/keyboard-shortcut/keyboard-shortcut.js +2 -2
  22. package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  23. package/es/components/progress-bar/progress-bar.js +2 -2
  24. package/es/components/progress-bar/progress-bar.js.map +1 -1
  25. package/es/components/time/time-utils.js +3 -3
  26. package/es/components/time/time-utils.js.map +1 -1
  27. package/es/heading/heading.js +1 -1
  28. package/es/heading/heading.js.map +1 -1
  29. package/es/icons/banner-icon.js +1 -1
  30. package/es/icons/banner-icon.js.map +1 -1
  31. package/es/loading/loading.js +1 -3
  32. package/es/loading/loading.js.map +1 -1
  33. package/es/menu/menu.js +2 -2
  34. package/es/menu/menu.js.map +1 -1
  35. package/es/switch-field/switch-field.js +5 -7
  36. package/es/switch-field/switch-field.js.map +1 -1
  37. package/es/tabs/tabs.js +16 -20
  38. package/es/tabs/tabs.js.map +1 -1
  39. package/es/text/text.js +1 -1
  40. package/es/text/text.js.map +1 -1
  41. package/es/toast/toast-animation.js +2 -2
  42. package/es/toast/toast-animation.js.map +1 -1
  43. package/es/toast/use-toasts.js +2 -6
  44. package/es/toast/use-toasts.js.map +1 -1
  45. package/es/tooltip/tooltip.js +2 -2
  46. package/es/tooltip/tooltip.js.map +1 -1
  47. package/es/utils/common-helpers.js +2 -2
  48. package/es/utils/common-helpers.js.map +1 -1
  49. package/es/utils/responsive-props.js +4 -4
  50. package/es/utils/responsive-props.js.map +1 -1
  51. package/lib/avatar/avatar.js +1 -1
  52. package/lib/avatar/avatar.js.map +1 -1
  53. package/lib/badge/badge.js.map +1 -1
  54. package/lib/banner/banner.js +1 -1
  55. package/lib/banner/banner.js.map +1 -1
  56. package/lib/base-field/base-field.js +1 -1
  57. package/lib/base-field/base-field.js.map +1 -1
  58. package/lib/box/box.js +1 -1
  59. package/lib/box/box.js.map +1 -1
  60. package/lib/button/button.js.map +1 -1
  61. package/lib/checkbox-field/checkbox-field.js +1 -1
  62. package/lib/checkbox-field/checkbox-field.js.map +1 -1
  63. package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
  64. package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
  65. package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  66. package/lib/components/progress-bar/progress-bar.js +1 -1
  67. package/lib/components/progress-bar/progress-bar.js.map +1 -1
  68. package/lib/components/time/time-utils.js +1 -1
  69. package/lib/components/time/time-utils.js.map +1 -1
  70. package/lib/heading/heading.js.map +1 -1
  71. package/lib/loading/loading.js +1 -1
  72. package/lib/loading/loading.js.map +1 -1
  73. package/lib/menu/menu.js +1 -1
  74. package/lib/menu/menu.js.map +1 -1
  75. package/lib/switch-field/switch-field.js +1 -1
  76. package/lib/switch-field/switch-field.js.map +1 -1
  77. package/lib/tabs/tabs.js +1 -1
  78. package/lib/tabs/tabs.js.map +1 -1
  79. package/lib/text/text.js +1 -1
  80. package/lib/text/text.js.map +1 -1
  81. package/lib/toast/toast-animation.js +1 -1
  82. package/lib/toast/toast-animation.js.map +1 -1
  83. package/lib/toast/use-toasts.js +1 -1
  84. package/lib/toast/use-toasts.js.map +1 -1
  85. package/lib/tooltip/tooltip.js +1 -1
  86. package/lib/tooltip/tooltip.js.map +1 -1
  87. package/lib/utils/common-helpers.js +1 -1
  88. package/lib/utils/common-helpers.js.map +1 -1
  89. package/lib/utils/responsive-props.js +1 -1
  90. package/lib/utils/responsive-props.js.map +1 -1
  91. package/package.json +3 -6
  92. package/styles/avatar.css +2 -2
  93. package/styles/badge.css +2 -2
  94. package/styles/banner.css +4 -4
  95. package/styles/banner.module.css.css +1 -1
  96. package/styles/base-field.css +3 -3
  97. package/styles/box.css +2 -2
  98. package/styles/box.module.css.css +1 -1
  99. package/styles/button.css +3 -3
  100. package/styles/checkbox-field.css +2 -2
  101. package/styles/columns.css +2 -2
  102. package/styles/divider.css +2 -2
  103. package/styles/heading.css +2 -2
  104. package/styles/hidden-visually.css +2 -2
  105. package/styles/hidden.css +2 -2
  106. package/styles/index.css +3 -3
  107. package/styles/loading.css +3 -3
  108. package/styles/modal.css +4 -4
  109. package/styles/modal.module.css.css +1 -1
  110. package/styles/notice.css +2 -2
  111. package/styles/password-field.css +3 -3
  112. package/styles/prose.css +2 -2
  113. package/styles/reactist.css +6 -6
  114. package/styles/select-field.css +3 -3
  115. package/styles/spinner.css +1 -1
  116. package/styles/static-toast.css +3 -3
  117. package/styles/switch-field.css +3 -3
  118. package/styles/tabs.css +2 -2
  119. package/styles/text-area.css +3 -3
  120. package/styles/text-field.css +3 -3
  121. package/styles/text-link.css +2 -2
  122. package/styles/text.css +2 -2
  123. package/styles/tooltip.css +2 -2
  124. package/styles/use-toasts.css +3 -3
  125. package/styles/width.module.css.css +1 -1
@@ -22,7 +22,7 @@ function Avatar(_ref) {
22
22
  const userInitials = getInitials(user.name) || getInitials(user.email);
23
23
  const avatarSize = size ? size : 'l';
24
24
  const style = avatarUrl ? {
25
- backgroundImage: "url(" + avatarUrl + ")",
25
+ backgroundImage: `url(${avatarUrl})`,
26
26
  textIndent: '-9999px' // hide the initials
27
27
 
28
28
  } : {
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sources":["../../src/avatar/avatar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { getInitials, emailToIndex } from './utils'\n\nimport { getClassNames, ResponsiveProp } from '../utils/responsive-props'\nimport styles from './avatar.module.css'\nimport { Box } from '../box'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\nconst AVATAR_COLORS = [\n '#fcc652',\n '#e9952c',\n '#e16b2d',\n '#d84b40',\n '#e8435a',\n '#e5198a',\n '#ad3889',\n '#86389c',\n '#a8a8a8',\n '#98be2f',\n '#5d9d50',\n '#5f9f85',\n '#5bbcb6',\n '#32a3bf',\n '#2bafeb',\n '#2d88c3',\n '#3863cc',\n '#5e5e5e',\n]\n\ntype AvatarSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl'\n\ntype Props = ObfuscatedClassName & {\n /** @deprecated Please use `exceptionallySetClassName` */\n className?: string\n /** @deprecated */\n colorList?: string[]\n size?: ResponsiveProp<AvatarSize>\n avatarUrl?: string\n user: { name?: string; email: string }\n}\n\nfunction Avatar({\n user,\n avatarUrl,\n size = 'l',\n className,\n colorList = AVATAR_COLORS,\n exceptionallySetClassName,\n ...props\n}: Props) {\n const userInitials = getInitials(user.name) || getInitials(user.email)\n const avatarSize = size ? size : 'l'\n\n const style = avatarUrl\n ? {\n backgroundImage: `url(${avatarUrl})`,\n textIndent: '-9999px', // hide the initials\n }\n : {\n backgroundColor: colorList[emailToIndex(user.email, colorList.length)],\n }\n\n const sizeClassName = getClassNames(styles, 'size', avatarSize)\n\n return (\n <Box\n className={[className, styles.avatar, sizeClassName, exceptionallySetClassName]}\n style={style}\n {...props}\n >\n {userInitials}\n </Box>\n )\n}\nAvatar.displayName = 'Avatar'\n\nexport { Avatar }\n"],"names":["AVATAR_COLORS","Avatar","user","avatarUrl","size","className","colorList","exceptionallySetClassName","props","userInitials","getInitials","name","email","avatarSize","style","backgroundImage","textIndent","backgroundColor","emailToIndex","length","sizeClassName","getClassNames","styles","React","createElement","Box","_objectSpread","avatar","displayName"],"mappings":";;;;;;;;AASA,MAAMA,aAAa,GAAG,CAClB,SADkB,EAElB,SAFkB,EAGlB,SAHkB,EAIlB,SAJkB,EAKlB,SALkB,EAMlB,SANkB,EAOlB,SAPkB,EAQlB,SARkB,EASlB,SATkB,EAUlB,SAVkB,EAWlB,SAXkB,EAYlB,SAZkB,EAalB,SAbkB,EAclB,SAdkB,EAelB,SAfkB,EAgBlB,SAhBkB,EAiBlB,SAjBkB,EAkBlB,SAlBkB,CAAtB,CAAA;;AAiCA,SAASC,MAAT,CAQQ,IAAA,EAAA;EAAA,IARQ;IACZC,IADY;IAEZC,SAFY;AAGZC,IAAAA,IAAI,GAAG,GAHK;IAIZC,SAJY;AAKZC,IAAAA,SAAS,GAAGN,aALA;AAMZO,IAAAA,yBAAAA;GAEI,GAAA,IAAA;AAAA,MADDC,KACC,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACJ,EAAA,MAAMC,YAAY,GAAGC,WAAW,CAACR,IAAI,CAACS,IAAN,CAAX,IAA0BD,WAAW,CAACR,IAAI,CAACU,KAAN,CAA1D,CAAA;AACA,EAAA,MAAMC,UAAU,GAAGT,IAAI,GAAGA,IAAH,GAAU,GAAjC,CAAA;EAEA,MAAMU,KAAK,GAAGX,SAAS,GACjB;IACIY,eAAe,EAAA,MAAA,GAASZ,SAAT,GADnB,GAAA;IAEIa,UAAU,EAAE,SAFhB;;AAAA,GADiB,GAKjB;AACIC,IAAAA,eAAe,EAAEX,SAAS,CAACY,YAAY,CAAChB,IAAI,CAACU,KAAN,EAAaN,SAAS,CAACa,MAAvB,CAAb,CAAA;GANpC,CAAA;EASA,MAAMC,aAAa,GAAGC,aAAa,CAACC,gBAAD,EAAS,MAAT,EAAiBT,UAAjB,CAAnC,CAAA;AAEA,EAAA,oBACIU,KAAC,CAAAC,aAAD,CAACC,GAAD,EAAAC,cAAA,CAAA;IACIrB,SAAS,EAAE,CAACA,SAAD,EAAYiB,gBAAM,CAACK,MAAnB,EAA2BP,aAA3B,EAA0Cb,yBAA1C,CADf;AAEIO,IAAAA,KAAK,EAAEA,KAAAA;GACHN,EAAAA,KAHR,CAKKC,EAAAA,YALL,CADJ,CAAA;AASH,CAAA;;AACDR,MAAM,CAAC2B,WAAP,GAAqB,QAArB;;;;"}
1
+ {"version":3,"file":"avatar.js","sources":["../../src/avatar/avatar.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { getInitials, emailToIndex } from './utils'\n\nimport { getClassNames, ResponsiveProp } from '../utils/responsive-props'\nimport styles from './avatar.module.css'\nimport { Box } from '../box'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\nconst AVATAR_COLORS = [\n '#fcc652',\n '#e9952c',\n '#e16b2d',\n '#d84b40',\n '#e8435a',\n '#e5198a',\n '#ad3889',\n '#86389c',\n '#a8a8a8',\n '#98be2f',\n '#5d9d50',\n '#5f9f85',\n '#5bbcb6',\n '#32a3bf',\n '#2bafeb',\n '#2d88c3',\n '#3863cc',\n '#5e5e5e',\n]\n\ntype AvatarSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' | 'xxxl'\n\ntype Props = ObfuscatedClassName & {\n /** @deprecated Please use `exceptionallySetClassName` */\n className?: string\n /** @deprecated */\n colorList?: string[]\n size?: ResponsiveProp<AvatarSize>\n avatarUrl?: string\n user: { name?: string; email: string }\n}\n\nfunction Avatar({\n user,\n avatarUrl,\n size = 'l',\n className,\n colorList = AVATAR_COLORS,\n exceptionallySetClassName,\n ...props\n}: Props) {\n const userInitials = getInitials(user.name) || getInitials(user.email)\n const avatarSize = size ? size : 'l'\n\n const style = avatarUrl\n ? {\n backgroundImage: `url(${avatarUrl})`,\n textIndent: '-9999px', // hide the initials\n }\n : {\n backgroundColor: colorList[emailToIndex(user.email, colorList.length)],\n }\n\n const sizeClassName = getClassNames(styles, 'size', avatarSize)\n\n return (\n <Box\n className={[className, styles.avatar, sizeClassName, exceptionallySetClassName]}\n style={style}\n {...props}\n >\n {userInitials}\n </Box>\n )\n}\nAvatar.displayName = 'Avatar'\n\nexport { Avatar }\n"],"names":["AVATAR_COLORS","Avatar","user","avatarUrl","size","className","colorList","exceptionallySetClassName","props","userInitials","getInitials","name","email","avatarSize","style","backgroundImage","textIndent","backgroundColor","emailToIndex","length","sizeClassName","getClassNames","styles","React","createElement","Box","_objectSpread","avatar","displayName"],"mappings":";;;;;;;;AASA,MAAMA,aAAa,GAAG,CAClB,SADkB,EAElB,SAFkB,EAGlB,SAHkB,EAIlB,SAJkB,EAKlB,SALkB,EAMlB,SANkB,EAOlB,SAPkB,EAQlB,SARkB,EASlB,SATkB,EAUlB,SAVkB,EAWlB,SAXkB,EAYlB,SAZkB,EAalB,SAbkB,EAclB,SAdkB,EAelB,SAfkB,EAgBlB,SAhBkB,EAiBlB,SAjBkB,EAkBlB,SAlBkB,CAAtB,CAAA;;AAiCA,SAASC,MAAT,CAQQ,IAAA,EAAA;EAAA,IARQ;IACZC,IADY;IAEZC,SAFY;AAGZC,IAAAA,IAAI,GAAG,GAHK;IAIZC,SAJY;AAKZC,IAAAA,SAAS,GAAGN,aALA;AAMZO,IAAAA,yBAAAA;GAEI,GAAA,IAAA;AAAA,MADDC,KACC,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACJ,EAAA,MAAMC,YAAY,GAAGC,WAAW,CAACR,IAAI,CAACS,IAAN,CAAX,IAA0BD,WAAW,CAACR,IAAI,CAACU,KAAN,CAA1D,CAAA;AACA,EAAA,MAAMC,UAAU,GAAGT,IAAI,GAAGA,IAAH,GAAU,GAAjC,CAAA;EAEA,MAAMU,KAAK,GAAGX,SAAS,GACjB;IACIY,eAAe,EAAS,CAAAZ,IAAAA,EAAAA,SAAY,CADxC,CAAA,CAAA;IAEIa,UAAU,EAAE,SAFhB;;AAAA,GADiB,GAKjB;AACIC,IAAAA,eAAe,EAAEX,SAAS,CAACY,YAAY,CAAChB,IAAI,CAACU,KAAN,EAAaN,SAAS,CAACa,MAAvB,CAAb,CAAA;GANpC,CAAA;EASA,MAAMC,aAAa,GAAGC,aAAa,CAACC,gBAAD,EAAS,MAAT,EAAiBT,UAAjB,CAAnC,CAAA;AAEA,EAAA,oBACIU,KAAC,CAAAC,aAAD,CAACC,GAAD,EAAAC,cAAA,CAAA;IACIrB,SAAS,EAAE,CAACA,SAAD,EAAYiB,gBAAM,CAACK,MAAnB,EAA2BP,aAA3B,EAA0Cb,yBAA1C,CADf;AAEIO,IAAAA,KAAK,EAAEA,KAAAA;GACHN,EAAAA,KAHR,CAKKC,EAAAA,YALL,CADJ,CAAA;AASH,CAAA;;AACDR,MAAM,CAAC2B,WAAP,GAAqB,QAArB;;;;"}
package/es/badge/badge.js CHANGED
@@ -16,7 +16,7 @@ function Badge(_ref) {
16
16
  as: "span" // It enables putting the badge inside a button (https://stackoverflow.com/a/12982334)
17
17
  ,
18
18
  display: "inline",
19
- className: [modules_33c7c985.badge, modules_33c7c985["badge-" + tone]]
19
+ className: [modules_33c7c985.badge, modules_33c7c985[`badge-${tone}`]]
20
20
  }), label);
21
21
  }
22
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"badge.js","sources":["../../src/badge/badge.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Box } from '../box'\n\nimport styles from './badge.module.css'\n\ntype BadgeTone = 'info' | 'positive' | 'promote' | 'attention' | 'warning'\n\ntype BadgeProps = {\n /**\n * The label to show inside the badge element.\n */\n label: string\n /**\n * The tone of the badge.\n */\n tone: BadgeTone\n}\n\nfunction Badge({ tone, label, ...props }: BadgeProps) {\n return (\n <Box\n {...props}\n as=\"span\" // It enables putting the badge inside a button (https://stackoverflow.com/a/12982334)\n display=\"inline\"\n className={[styles.badge, styles[`badge-${tone}`]]}\n >\n {label}\n </Box>\n )\n}\n\nexport { Badge }\nexport type { BadgeProps }\n"],"names":["Badge","tone","label","props","React","createElement","Box","as","display","className","styles","badge"],"mappings":";;;;;;;AAmBA,SAASA,KAAT,CAAoD,IAAA,EAAA;EAAA,IAArC;IAAEC,IAAF;AAAQC,IAAAA,KAAAA;GAA6B,GAAA,IAAA;AAAA,MAAnBC,KAAmB,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAChD,EAAA,oBACIC,KAAC,CAAAC,aAAD,CAACC,GAAD,oCACQH,KADR,CAAA,EAAA,EAAA,EAAA;IAEII,EAAE,EAAC,MAFP;AAAA;AAGIC,IAAAA,OAAO,EAAC,QAHZ;IAIIC,SAAS,EAAE,CAACC,gBAAM,CAACC,KAAR,EAAeD,gBAAM,CAAUT,QAAAA,GAAAA,IAAV,CAArB,CAAA;AAJf,GAAA,CAAA,EAMKC,KANL,CADJ,CAAA;AAUH;;;;"}
1
+ {"version":3,"file":"badge.js","sources":["../../src/badge/badge.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Box } from '../box'\n\nimport styles from './badge.module.css'\n\ntype BadgeTone = 'info' | 'positive' | 'promote' | 'attention' | 'warning'\n\ntype BadgeProps = {\n /**\n * The label to show inside the badge element.\n */\n label: string\n /**\n * The tone of the badge.\n */\n tone: BadgeTone\n}\n\nfunction Badge({ tone, label, ...props }: BadgeProps) {\n return (\n <Box\n {...props}\n as=\"span\" // It enables putting the badge inside a button (https://stackoverflow.com/a/12982334)\n display=\"inline\"\n className={[styles.badge, styles[`badge-${tone}`]]}\n >\n {label}\n </Box>\n )\n}\n\nexport { Badge }\nexport type { BadgeProps }\n"],"names":["Badge","tone","label","props","React","createElement","Box","as","display","className","styles","badge"],"mappings":";;;;;;;AAmBA,SAASA,KAAT,CAAoD,IAAA,EAAA;EAAA,IAArC;IAAEC,IAAF;AAAQC,IAAAA,KAAAA;GAA6B,GAAA,IAAA;AAAA,MAAnBC,KAAmB,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAChD,EAAA,oBACIC,KAAC,CAAAC,aAAD,CAACC,GAAD,oCACQH,KADR,CAAA,EAAA,EAAA,EAAA;IAEII,EAAE,EAAC,MAFP;AAAA;AAGIC,IAAAA,OAAO,EAAC,QAHZ;IAIIC,SAAS,EAAE,CAACC,gBAAM,CAACC,KAAR,EAAeD,gBAAM,CAAC,CAAA,MAAA,EAAST,IAAM,CAAA,CAAhB,CAArB,CAAA;AAJf,GAAA,CAAA,EAMKC,KANL,CADJ,CAAA;AAUH;;;;"}
@@ -42,7 +42,7 @@ const Banner = /*#__PURE__*/React.forwardRef(function Banner(_ref, ref) {
42
42
  variant: "quaternary",
43
43
  onClick: onClose,
44
44
  icon: /*#__PURE__*/React.createElement(CloseIcon, null),
45
- "aria-label": closeLabel != null ? closeLabel : 'Close banner'
45
+ "aria-label": closeLabel ?? 'Close banner'
46
46
  }) : null;
47
47
  return /*#__PURE__*/React.createElement(Box, _objectSpread2(_objectSpread2({}, props), {}, {
48
48
  ref: ref,
@@ -1 +1 @@
1
- {"version":3,"file":"banner.js","sources":["../../src/banner/banner.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { useId } from '../utils/common-helpers'\n\nimport styles from './banner.module.css'\nimport { Button, ButtonProps, IconButton } from '../button'\nimport { CloseIcon } from '../icons/close-icon'\nimport { BannerIcon } from '../icons/banner-icon'\nimport { TextLink } from '../text-link'\n\n/**\n * Represents the type of a banner.\n * 'neutral' accepts a custom icon, the rest do not.\n * @default 'neutral'\n */\nexport type BannerType = 'neutral' | SystemBannerType\n\n/**\n * Predefined system types for banners.\n * Each type has its own preset icon.\n */\nexport type SystemBannerType = 'info' | 'upgrade' | 'experiment' | 'warning' | 'error' | 'success'\n\ntype BaseAction = {\n variant: 'primary' | 'tertiary'\n label: string\n} & Pick<ButtonProps, 'loading' | 'disabled'>\ntype ActionButton = BaseAction & { type: 'button' } & Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'className'\n >\ntype ActionLink = BaseAction & { type: 'link' } & Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'className'\n >\n/**\n * Represents an action that can be taken from the banner.\n * Can be either a button or a link, sharing common properties from BaseAction.\n */\ntype Action = ActionButton | ActionLink\n\n/**\n * Configuration for inline links within the banner description.\n * Extends TextLink component props with a required label.\n */\ntype InlineLink = { label: string } & React.ComponentProps<typeof TextLink>\n\ntype WithCloseButton = {\n closeLabel?: string\n onClose: () => void\n}\ntype WithoutCloseButton = {\n closeLabel?: never\n onClose?: never\n}\n/**\n * Controls the close button behavior.\n * If none is provided, the banner will not have a close button.\n */\ntype CloseButton = WithCloseButton | WithoutCloseButton\n\ntype BaseBanner = {\n id?: string\n title?: React.ReactNode\n description: Exclude<React.ReactNode, null | undefined | boolean>\n action?: Action | React.ReactNode\n inlineLinks?: InlineLink[]\n} & CloseButton\n\n/**\n * Configuration for neutral banners.\n * Can include either an image, an icon, or neither, but never both.\n */\ntype NeutralBanner = BaseBanner & {\n type: Extract<BannerType, 'neutral'>\n} & (\n | { image: React.ReactElement; icon?: never }\n | { icon: React.ReactElement; image?: never }\n | { image?: never; icon?: never }\n )\n\n/**\n * Configuration for system banners.\n * Cannot include custom images or icons as they use preset ones.\n */\ntype SystemBanner = BaseBanner & {\n type: SystemBannerType\n image?: never\n icon?: never\n}\n\ntype BannerProps = NeutralBanner | SystemBanner\n\n/**\n * Type guard to check if the action is an Action object (button or link)\n */\nfunction isActionObject(action: Action | React.ReactNode): action is Action {\n return (\n typeof action === 'object' &&\n action !== null &&\n 'type' in action &&\n (action.type === 'button' || action.type === 'link')\n )\n}\n\nconst Banner = React.forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n id,\n type,\n title,\n description,\n action,\n icon,\n image,\n inlineLinks,\n closeLabel,\n onClose,\n ...props\n }: BannerProps,\n ref,\n) {\n const titleId = useId()\n const descriptionId = useId()\n\n const closeButton = onClose ? (\n <IconButton\n exceptionallySetClassName={styles.closeButton}\n variant=\"quaternary\"\n onClick={onClose}\n icon={<CloseIcon />}\n aria-label={closeLabel ?? 'Close banner'}\n />\n ) : null\n\n return (\n <Box\n {...props}\n ref={ref}\n id={id}\n display=\"flex\"\n flexDirection=\"column\"\n justifyContent=\"center\"\n role=\"status\"\n aria-labelledby={title ? titleId : descriptionId}\n aria-describedby={title ? descriptionId : undefined}\n aria-live=\"polite\"\n tabIndex={0}\n borderRadius=\"full\"\n className={styles.banner}\n >\n {image ? <Box className={styles.image}>{image}</Box> : null}\n\n <Box className={styles.content} display=\"flex\" gap=\"small\" alignItems=\"center\">\n <Box className={styles.staticContent} display=\"flex\" gap=\"small\" flexGrow={1}>\n <Box className={styles.icon}>\n {type === 'neutral' ? icon : <BannerIcon type={type} />}\n {closeButton}\n </Box>\n\n <Box className={styles.copy} display=\"flex\" flexDirection=\"column\">\n {title ? (\n <Box id={titleId} className={styles.title}>\n {title}\n </Box>\n ) : null}\n <Box\n id={descriptionId}\n className={[styles.description, title ? styles.secondary : null]}\n >\n {description}\n {inlineLinks?.map(({ label, ...props }, index) => {\n return (\n <React.Fragment key={index}>\n <TextLink\n {...props}\n exceptionallySetClassName={styles.inlineLink}\n >\n {label}\n </TextLink>\n {index < inlineLinks.length - 1 ? <span> · </span> : ''}\n </React.Fragment>\n )\n })}\n </Box>\n </Box>\n </Box>\n\n {action || closeButton ? (\n <Box className={styles.actions} display=\"flex\" gap=\"small\">\n {action ? (\n isActionObject(action) ? (\n action.type === 'button' ? (\n <ActionButton {...action} />\n ) : (\n <ActionLink {...action} />\n )\n ) : (\n action\n )\n ) : null}\n {closeButton}\n </Box>\n ) : null}\n </Box>\n </Box>\n )\n})\n\nfunction ActionButton({ type, label, ...props }: ActionButton) {\n return <Button {...props}>{label}</Button>\n}\n\nfunction ActionLink({ type, label, variant, ...props }: ActionLink) {\n return (\n <Button\n variant={variant}\n render={<a rel=\"noopener noreferrer\" target=\"_blank\" {...props} />}\n >\n {label}\n </Button>\n )\n}\n\nexport { Banner }\nexport type { BannerProps }\n"],"names":["isActionObject","action","type","Banner","React","forwardRef","ref","id","title","description","icon","image","inlineLinks","closeLabel","onClose","props","titleId","useId","descriptionId","closeButton","createElement","IconButton","exceptionallySetClassName","styles","variant","onClick","CloseIcon","Box","display","flexDirection","justifyContent","role","undefined","tabIndex","borderRadius","className","banner","content","gap","alignItems","staticContent","flexGrow","BannerIcon","copy","secondary","map","index","label","Fragment","key","TextLink","inlineLink","length","actions","ActionButton","_objectSpread","ActionLink","Button","render","rel","target"],"mappings":";;;;;;;;;;;;;;AA6FA;;AAEG;;AACH,SAASA,cAAT,CAAwBC,MAAxB,EAAwD;EACpD,OACI,OAAOA,MAAP,KAAkB,QAAlB,IACAA,MAAM,KAAK,IADX,IAEA,MAAUA,IAAAA,MAFV,KAGCA,MAAM,CAACC,IAAP,KAAgB,QAAhB,IAA4BD,MAAM,CAACC,IAAP,KAAgB,MAH7C,CADJ,CAAA;AAMH,CAAA;;AAEKC,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAA8C,SAASF,MAAT,CAczDG,IAAAA,EAAAA,GAdyD,EActD;EAAA,IAbH;IACIC,EADJ;IAEIL,IAFJ;IAGIM,KAHJ;IAIIC,WAJJ;IAKIR,MALJ;IAMIS,IANJ;IAOIC,KAPJ;IAQIC,WARJ;IASIC,UATJ;AAUIC,IAAAA,OAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAEH,MAAMC,OAAO,GAAGC,KAAK,EAArB,CAAA;EACA,MAAMC,aAAa,GAAGD,KAAK,EAA3B,CAAA;EAEA,MAAME,WAAW,GAAGL,OAAO,gBACvBV,KAAA,CAAAgB,aAAA,CAACC,UAAD,EAAW;IACPC,yBAAyB,EAAEC,gBAAM,CAACJ,WAD3B;AAEPK,IAAAA,OAAO,EAAC,YAFD;AAGPC,IAAAA,OAAO,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,IAAF;IAAQ6C,KAAR;AAAevB,IAAAA,OAAAA;GAA+B,GAAA,KAAA;AAAA,MAAnBT,KAAmB,GAAA,wBAAA,CAAA,KAAA,EAAA,UAAA,CAAA,CAAA;;AAC9D,EAAA,oBACIX,KAAC,CAAAgB,aAAD,CAACqC,MAAD,EACI;AAAAjC,IAAAA,OAAO,EAAEA,OAAT;AACAkC,IAAAA,MAAM,eAAEtD,KAAG,CAAAgB,aAAH,CAAG,GAAH,EAAAmC,cAAA,CAAA;AAAGI,MAAAA,GAAG,EAAC,qBAAP;AAA6BC,MAAAA,MAAM,EAAC,QAAA;AAApC,KAAA,EAAiD7C,KAAjD,CAAA,CAAA;GAFZ,EAIKgC,KAJL,CADJ,CAAA;AAQH;;;;"}
1
+ {"version":3,"file":"banner.js","sources":["../../src/banner/banner.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { useId } from '../utils/common-helpers'\n\nimport styles from './banner.module.css'\nimport { Button, ButtonProps, IconButton } from '../button'\nimport { CloseIcon } from '../icons/close-icon'\nimport { BannerIcon } from '../icons/banner-icon'\nimport { TextLink } from '../text-link'\n\n/**\n * Represents the type of a banner.\n * 'neutral' accepts a custom icon, the rest do not.\n * @default 'neutral'\n */\nexport type BannerType = 'neutral' | SystemBannerType\n\n/**\n * Predefined system types for banners.\n * Each type has its own preset icon.\n */\nexport type SystemBannerType = 'info' | 'upgrade' | 'experiment' | 'warning' | 'error' | 'success'\n\ntype BaseAction = {\n variant: 'primary' | 'tertiary'\n label: string\n} & Pick<ButtonProps, 'loading' | 'disabled'>\ntype ActionButton = BaseAction & { type: 'button' } & Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'className'\n >\ntype ActionLink = BaseAction & { type: 'link' } & Omit<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n 'className'\n >\n/**\n * Represents an action that can be taken from the banner.\n * Can be either a button or a link, sharing common properties from BaseAction.\n */\ntype Action = ActionButton | ActionLink\n\n/**\n * Configuration for inline links within the banner description.\n * Extends TextLink component props with a required label.\n */\ntype InlineLink = { label: string } & React.ComponentProps<typeof TextLink>\n\ntype WithCloseButton = {\n closeLabel?: string\n onClose: () => void\n}\ntype WithoutCloseButton = {\n closeLabel?: never\n onClose?: never\n}\n/**\n * Controls the close button behavior.\n * If none is provided, the banner will not have a close button.\n */\ntype CloseButton = WithCloseButton | WithoutCloseButton\n\ntype BaseBanner = {\n id?: string\n title?: React.ReactNode\n description: Exclude<React.ReactNode, null | undefined | boolean>\n action?: Action | React.ReactNode\n inlineLinks?: InlineLink[]\n} & CloseButton\n\n/**\n * Configuration for neutral banners.\n * Can include either an image, an icon, or neither, but never both.\n */\ntype NeutralBanner = BaseBanner & {\n type: Extract<BannerType, 'neutral'>\n} & (\n | { image: React.ReactElement; icon?: never }\n | { icon: React.ReactElement; image?: never }\n | { image?: never; icon?: never }\n )\n\n/**\n * Configuration for system banners.\n * Cannot include custom images or icons as they use preset ones.\n */\ntype SystemBanner = BaseBanner & {\n type: SystemBannerType\n image?: never\n icon?: never\n}\n\ntype BannerProps = NeutralBanner | SystemBanner\n\n/**\n * Type guard to check if the action is an Action object (button or link)\n */\nfunction isActionObject(action: Action | React.ReactNode): action is Action {\n return (\n typeof action === 'object' &&\n action !== null &&\n 'type' in action &&\n (action.type === 'button' || action.type === 'link')\n )\n}\n\nconst Banner = React.forwardRef<HTMLDivElement, BannerProps>(function Banner(\n {\n id,\n type,\n title,\n description,\n action,\n icon,\n image,\n inlineLinks,\n closeLabel,\n onClose,\n ...props\n }: BannerProps,\n ref,\n) {\n const titleId = useId()\n const descriptionId = useId()\n\n const closeButton = onClose ? (\n <IconButton\n exceptionallySetClassName={styles.closeButton}\n variant=\"quaternary\"\n onClick={onClose}\n icon={<CloseIcon />}\n aria-label={closeLabel ?? 'Close banner'}\n />\n ) : null\n\n return (\n <Box\n {...props}\n ref={ref}\n id={id}\n display=\"flex\"\n flexDirection=\"column\"\n justifyContent=\"center\"\n role=\"status\"\n aria-labelledby={title ? titleId : descriptionId}\n aria-describedby={title ? descriptionId : undefined}\n aria-live=\"polite\"\n tabIndex={0}\n borderRadius=\"full\"\n className={styles.banner}\n >\n {image ? <Box className={styles.image}>{image}</Box> : null}\n\n <Box className={styles.content} display=\"flex\" gap=\"small\" alignItems=\"center\">\n <Box className={styles.staticContent} display=\"flex\" gap=\"small\" flexGrow={1}>\n <Box className={styles.icon}>\n {type === 'neutral' ? icon : <BannerIcon type={type} />}\n {closeButton}\n </Box>\n\n <Box className={styles.copy} display=\"flex\" flexDirection=\"column\">\n {title ? (\n <Box id={titleId} className={styles.title}>\n {title}\n </Box>\n ) : null}\n <Box\n id={descriptionId}\n className={[styles.description, title ? styles.secondary : null]}\n >\n {description}\n {inlineLinks?.map(({ label, ...props }, index) => {\n return (\n <React.Fragment key={index}>\n <TextLink\n {...props}\n exceptionallySetClassName={styles.inlineLink}\n >\n {label}\n </TextLink>\n {index < inlineLinks.length - 1 ? <span> · </span> : ''}\n </React.Fragment>\n )\n })}\n </Box>\n </Box>\n </Box>\n\n {action || closeButton ? (\n <Box className={styles.actions} display=\"flex\" gap=\"small\">\n {action ? (\n isActionObject(action) ? (\n action.type === 'button' ? (\n <ActionButton {...action} />\n ) : (\n <ActionLink {...action} />\n )\n ) : (\n action\n )\n ) : null}\n {closeButton}\n </Box>\n ) : null}\n </Box>\n </Box>\n )\n})\n\nfunction ActionButton({ type, label, ...props }: ActionButton) {\n return <Button {...props}>{label}</Button>\n}\n\nfunction ActionLink({ type, label, variant, ...props }: ActionLink) {\n return (\n <Button\n variant={variant}\n render={<a rel=\"noopener noreferrer\" target=\"_blank\" {...props} />}\n >\n {label}\n </Button>\n )\n}\n\nexport { Banner }\nexport type { BannerProps }\n"],"names":["isActionObject","action","type","Banner","React","forwardRef","ref","id","title","description","icon","image","inlineLinks","closeLabel","onClose","props","titleId","useId","descriptionId","closeButton","createElement","IconButton","exceptionallySetClassName","styles","variant","onClick","CloseIcon","Box","display","flexDirection","justifyContent","role","undefined","tabIndex","borderRadius","className","banner","content","gap","alignItems","staticContent","flexGrow","BannerIcon","copy","secondary","map","index","label","Fragment","key","TextLink","inlineLink","length","actions","ActionButton","_objectSpread","ActionLink","Button","render","rel","target"],"mappings":";;;;;;;;;;;;;;AA6FA;;AAEG;;AACH,SAASA,cAAT,CAAwBC,MAAxB,EAAwD;EACpD,OACI,OAAOA,MAAP,KAAkB,QAAlB,IACAA,MAAM,KAAK,IADX,IAEA,MAAUA,IAAAA,MAFV,KAGCA,MAAM,CAACC,IAAP,KAAgB,QAAhB,IAA4BD,MAAM,CAACC,IAAP,KAAgB,MAH7C,CADJ,CAAA;AAMH,CAAA;;AAEKC,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAA8C,SAASF,MAAT,CAczDG,IAAAA,EAAAA,GAdyD,EActD;EAAA,IAbH;IACIC,EADJ;IAEIL,IAFJ;IAGIM,KAHJ;IAIIC,WAJJ;IAKIR,MALJ;IAMIS,IANJ;IAOIC,KAPJ;IAQIC,WARJ;IASIC,UATJ;AAUIC,IAAAA,OAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;EAEH,MAAMC,OAAO,GAAGC,KAAK,EAArB,CAAA;EACA,MAAMC,aAAa,GAAGD,KAAK,EAA3B,CAAA;EAEA,MAAME,WAAW,GAAGL,OAAO,gBACvBV,KAAA,CAAAgB,aAAA,CAACC,UAAD,EAAW;IACPC,yBAAyB,EAAEC,gBAAM,CAACJ,WAD3B;AAEPK,IAAAA,OAAO,EAAC,YAFD;AAGPC,IAAAA,OAAO,EAAEX,OAHF;IAIPJ,IAAI,eAAEN,KAAA,CAAAgB,aAAA,CAACM,SAAD,EAAa,IAAb,CAJC;AAIY,IAAA,YAAA,EACPb,UAAU,IAAI,cAAA;GAL9B,CADuB,GAQvB,IARJ,CAAA;AAUA,EAAA,oBACIT,KAAA,CAAAgB,aAAA,CAACO,GAAD,oCACQ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C,IAAAA,MAAM,eAAEtD,KAAG,CAAAgB,aAAH,CAAG,GAAH,EAAAmC,cAAA,CAAA;AAAGI,MAAAA,GAAG,EAAC,qBAAP;AAA6BC,MAAAA,MAAM,EAAC,QAAA;AAApC,KAAA,EAAiD7C,KAAjD,CAAA,CAAA;GAFZ,EAIKgC,KAJL,CADJ,CAAA;AAQH;;;;"}
@@ -60,7 +60,7 @@ function validateInputLength({
60
60
  const currentLength = String(value || '').length;
61
61
  const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD;
62
62
  return {
63
- count: currentLength + "/" + maxLength,
63
+ count: `${currentLength}/${maxLength}`,
64
64
  tone: isNearMaxLength ? 'error' : 'neutral'
65
65
  };
66
66
  }
@@ -95,7 +95,7 @@ function BaseField({
95
95
  });
96
96
  const [characterCount, setCharacterCount] = React.useState(inputLength.count);
97
97
  const [characterCountTone, setCharacterCountTone] = React.useState(inputLength.tone);
98
- const ariaDescribedBy = originalAriaDescribedBy != null ? originalAriaDescribedBy : message ? messageId : null;
98
+ const ariaDescribedBy = originalAriaDescribedBy ?? (message ? messageId : null);
99
99
  const renderCharacterCountBelow = characterCountPosition === 'below' && characterCount !== null;
100
100
  const renderCharacterCountInline = characterCountPosition === 'inline' && characterCount !== null;
101
101
 
@@ -1 +1 @@
1
- {"version":3,"file":"base-field.js","sources":["../../src/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../utils/common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../utils/common-types'\nimport { Spinner } from '../spinner'\nimport { Column, Columns } from '../columns'\n\n// Define the remaining characters before the character count turns red\n// See: https://twist.com/a/1585/ch/765851/t/6664583/c/93631846 for latest spec\nconst MAX_LENGTH_THRESHOLD = 0\n\ntype FieldTone = 'neutral' | 'success' | 'error' | 'loading'\n\ntype FieldMessageProps = {\n id: string\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction fieldToneToTextTone(tone: FieldTone) {\n return tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'secondary'\n}\n\nfunction FieldMessage({ id, children, tone }: FieldMessageProps) {\n return (\n <Text as=\"p\" tone={fieldToneToTextTone(tone)} size=\"copy\" id={id}>\n {tone === 'loading' ? (\n <Box\n as=\"span\"\n marginRight=\"xsmall\"\n display=\"inlineFlex\"\n className={styles.loadingIcon}\n >\n <Spinner size={16} />\n </Box>\n ) : null}\n {children}\n </Text>\n )\n}\n\ntype FieldCharacterCountProps = {\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction FieldCharacterCount({ children, tone }: FieldCharacterCountProps) {\n return (\n <Text tone={fieldToneToTextTone(tone)} size=\"copy\">\n {children}\n </Text>\n )\n}\n\ntype ValidateInputLengthProps = {\n value?: React.InputHTMLAttributes<unknown>['value']\n maxLength?: number\n}\n\ntype ValidateInputLengthResult = {\n count: string | null\n tone: FieldTone\n}\n\nfunction validateInputLength({\n value,\n maxLength,\n}: ValidateInputLengthProps): ValidateInputLengthResult {\n if (!maxLength) {\n return {\n count: null,\n tone: 'neutral',\n }\n }\n\n const currentLength = String(value || '').length\n const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD\n\n return {\n count: `${currentLength}/${maxLength}`,\n tone: isNearMaxLength ? 'error' : 'neutral',\n }\n}\n\n//\n// BaseField\n//\n\ntype ChildrenRenderProps = {\n id: string\n value?: React.InputHTMLAttributes<unknown>['value']\n 'aria-describedby'?: string\n 'aria-invalid'?: true\n onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>\n characterCountElement?: React.ReactNode | null\n}\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldVariant = 'default' | 'bordered'\ntype BaseFieldVariantProps = {\n /**\n * Provides alternative visual layouts or modes that the field can be rendered in.\n *\n * Namely, there are two variants supported:\n *\n * - the default one\n * - a \"bordered\" variant, where the border of the field surrounds also the labels, instead\n * of just surrounding the actual field element\n *\n * In both cases, the message and description texts for the field lie outside the bordered\n * area.\n */\n variant?: BaseFieldVariant\n}\n\nexport type BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'maxLength' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * This prop is not optional. Consumers of field components must be explicit about not\n * wanting a label by passing `label=\"\"` or `label={null}`. In those situations, consumers\n * should make sure that fields are properly labelled semantically by other means (e.g using\n * `aria-labelledby`, or rendering a `<label />` element referencing the field by id).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see BaseFieldProps['auxiliaryLabel']\n */\n label: React.ReactNode\n\n /**\n * The initial value for this field element.\n *\n * This prop is used to calculate the character count for the initial value, and is then\n * passed to the underlying child element.\n */\n value?: React.InputHTMLAttributes<unknown>['value']\n\n /**\n * An optional extra element to be placed to the right of the main label.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see BaseFieldProps['label']\n *\n * @deprecated The usage of this element is discouraged given that it was removed from the\n * latest form field spec revision.\n */\n auxiliaryLabel?: React.ReactNode\n\n /**\n * A message associated with the field. It is rendered below the field, and with an\n * appearance that conveys the tone of the field (e.g. coloured red for errors, green for\n * success, etc).\n *\n * The message element is associated to the field via the `aria-describedby` attribute.\n *\n * In the future, when `aria-errormessage` gets better user agent support, we should use it\n * to associate the filed with a message when tone is `\"error\"`.\n *\n * @see BaseFieldProps['tone']\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid\n */\n message?: React.ReactNode\n\n /**\n * The tone with which the message, if any, is presented.\n *\n * If the tone is `\"error\"`, the field border turns red, and the message, if any, is also\n * red.\n *\n * When the tone is `\"loading\"`, it is recommended that you also disable the field. However,\n * this is not enforced by the component. It is only a recommendation.\n *\n * @see BaseFieldProps['message']\n * @see BaseFieldProps['hint']\n */\n tone?: FieldTone\n\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n\n /**\n * The maximum number of characters that the input field can accept.\n * When this limit is reached, the input field will not accept any more characters.\n * The counter element will turn red when the number of characters is within 10 of the maximum limit.\n */\n maxLength?: number\n\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: ChildrenRenderProps) => React.ReactNode\n\n /**\n * The position of the character count element.\n * It can be shown below the field or inline with the field.\n *\n * @default 'below'\n */\n characterCountPosition?: 'below' | 'inline' | 'hidden'\n } & (\n | {\n supportsStartAndEndSlots?: false\n endSlot?: never\n endSlotPosition?: never\n }\n | {\n supportsStartAndEndSlots: true\n endSlot?: React.ReactElement | string | number\n /**\n * This is solely for `bordered` variants of TextField. When set to `bottom` (the default),\n * the endSlot will be placed inline with the input field. When set to `fullHeight`, the endSlot\n * will be placed to the side of both the input field and the label.\n */\n endSlotPosition?: 'bottom' | 'fullHeight'\n }\n )\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<\n BaseFieldProps,\n 'children' | 'className' | 'fieldRef' | 'variant'\n> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\n/**\n * BaseField is a base component that provides a consistent structure for form fields.\n */\nfunction BaseField({\n variant = 'default',\n label,\n value,\n auxiliaryLabel,\n message,\n tone = 'neutral',\n className,\n children,\n maxWidth,\n maxLength,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n characterCountPosition = 'below',\n endSlot,\n endSlotPosition = 'bottom',\n}: BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const messageId = useId()\n\n const inputLength = validateInputLength({ value, maxLength })\n\n const [characterCount, setCharacterCount] = React.useState<string | null>(inputLength.count)\n const [characterCountTone, setCharacterCountTone] = React.useState<FieldTone>(inputLength.tone)\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (message ? messageId : null)\n\n const renderCharacterCountBelow = characterCountPosition === 'below' && characterCount !== null\n const renderCharacterCountInline =\n characterCountPosition === 'inline' && characterCount !== null\n\n function renderCharacterCount() {\n return <FieldCharacterCount tone={characterCountTone}>{characterCount}</FieldCharacterCount>\n }\n\n const childrenProps: ChildrenRenderProps = {\n id,\n value,\n ...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),\n 'aria-invalid': tone === 'error' ? true : undefined,\n onChange(event) {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value: event.currentTarget.value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n // If the character count is inline, we pass it as a prop to the children element so it can be rendered inline\n characterCountElement: renderCharacterCountInline ? renderCharacterCount() : null,\n }\n\n React.useEffect(\n function updateCharacterCountOnPropChange() {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n [maxLength, value],\n )\n\n return (\n <Stack space=\"xsmall\" hidden={hidden}>\n <Box\n display=\"flex\"\n flexDirection=\"row\"\n className={[\n className,\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n alignItems=\"center\"\n >\n <Box flexGrow={1}>\n {label || auxiliaryLabel ? (\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n >\n <Text\n size={variant === 'bordered' ? 'caption' : 'body'}\n as=\"label\"\n htmlFor={id}\n >\n {label ? (\n <span className={styles.primaryLabel}>{label}</span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n ) : null}\n {children(childrenProps)}\n </Box>\n {endSlot && endSlotPosition === 'fullHeight' ? endSlot : null}\n </Box>\n\n {message || renderCharacterCountBelow ? (\n <Columns align=\"right\" space=\"small\" maxWidth={maxWidth}>\n {message ? (\n <Column width=\"auto\">\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n </Column>\n ) : null}\n\n {/* If the character count is below the field, we render it, if it's inline,\n we pass it as a prop to the children element so it can be rendered inline */}\n {characterCountPosition === 'below' ? (\n <Column width=\"content\">{renderCharacterCount()}</Column>\n ) : null}\n </Columns>\n ) : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldMessage }\nexport type { BaseFieldVariant, BaseFieldVariantProps, FieldComponentProps }\n"],"names":["MAX_LENGTH_THRESHOLD","fieldToneToTextTone","tone","FieldMessage","id","children","React","Text","as","size","createElement","Box","marginRight","display","className","styles","loadingIcon","Spinner","FieldCharacterCount","validateInputLength","value","maxLength","count","currentLength","String","length","isNearMaxLength","BaseField","variant","label","auxiliaryLabel","message","maxWidth","hidden","originalAriaDescribedBy","originalId","characterCountPosition","endSlot","endSlotPosition","useId","messageId","inputLength","characterCount","setCharacterCount","useState","characterCountTone","setCharacterCountTone","ariaDescribedBy","renderCharacterCountBelow","renderCharacterCountInline","renderCharacterCount","childrenProps","_objectSpread","undefined","onChange","event","currentTarget","characterCountElement","useEffect","updateCharacterCountOnPropChange","Stack","space","flexDirection","container","error","bordered","alignItems","flexGrow","justifyContent","htmlFor","primaryLabel","paddingLeft","Columns","align","Column","width"],"mappings":";;;;;;;;;;AAYA;;AACA,MAAMA,oBAAoB,GAAG,CAA7B,CAAA;;AAUA,SAASC,mBAAT,CAA6BC,IAA7B,EAA4C;AACxC,EAAA,OAAOA,IAAI,KAAK,OAAT,GAAmB,QAAnB,GAA8BA,IAAI,KAAK,SAAT,GAAqB,UAArB,GAAkC,WAAvE,CAAA;AACH,CAAA;;AAED,SAASC,YAAT,CAAsB;EAAEC,EAAF;EAAMC,QAAN;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A;GAHb,EAKKyB,KAAK,gBACFvB,KAAA,CAAAI,aAAA,CAAA,MAAA,EAAA;IAAMI,SAAS,EAAEC,gBAAM,CAACuD,YAAAA;AAAxB,GAAA,EAAuCzC,KAAvC,CADE,GAEF,IAPR,CANJ,EAeKC,cAAc,gBACXxB,KAAC,CAAAI,aAAD,CAACC,GAAD,EAAK;IAAAG,SAAS,EAAEC,gBAAM,CAACe,cAAlB;AAAkCyC,IAAAA,WAAW,EAAC,OAAA;AAA9C,GAAL,EACKzC,cADL,CADW,GAIX,IAnBR,CADH,GAsBG,IAvBR,EAwBKzB,QAAQ,CAAC8C,aAAD,CAxBb,CAZJ,EAsCKd,OAAO,IAAIC,eAAe,KAAK,YAA/B,GAA8CD,OAA9C,GAAwD,IAtC7D,CADJ,EA0CKN,OAAO,IAAIiB,yBAAX,gBACG1C,mBAAA,CAACkE,OAAD,EAAQ;AAACC,IAAAA,KAAK,EAAC,OAAP;AAAeZ,IAAAA,KAAK,EAAC,OAArB;AAA6B7B,IAAAA,QAAQ,EAAEA,QAAAA;GAA/C,EACKD,OAAO,gBACJzB,mBAAA,CAACoE,MAAD,EAAO;AAACC,IAAAA,KAAK,EAAC,MAAA;AAAP,GAAP,eACIrE,KAAA,CAAAI,aAAA,CAACP,YAAD,EAAc;AAAAC,IAAAA,EAAE,EAAEoC,SAAJ;AAAetC,IAAAA,IAAI,EAAEA,IAAAA;AAArB,GAAd,EACK6B,OADL,CADJ,CADI,GAMJ,IAPR,EAWKK,sBAAsB,KAAK,OAA3B,gBACG9B,KAAC,CAAAI,aAAD,CAACgE,MAAD,EAAQ;AAAAC,IAAAA,KAAK,EAAC,SAAA;GAAd,EAAyBzB,oBAAoB,EAA7C,CADH,GAEG,IAbR,CADH,GAgBG,IA1DR,CADJ,CAAA;AA8DH;;;;"}
1
+ {"version":3,"file":"base-field.js","sources":["../../src/base-field/base-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box, BoxProps } from '../box'\nimport { useId } from '../utils/common-helpers'\nimport { Text } from '../text'\nimport styles from './base-field.module.css'\nimport { Stack } from '../stack'\n\nimport type { WithEnhancedClassName } from '../utils/common-types'\nimport { Spinner } from '../spinner'\nimport { Column, Columns } from '../columns'\n\n// Define the remaining characters before the character count turns red\n// See: https://twist.com/a/1585/ch/765851/t/6664583/c/93631846 for latest spec\nconst MAX_LENGTH_THRESHOLD = 0\n\ntype FieldTone = 'neutral' | 'success' | 'error' | 'loading'\n\ntype FieldMessageProps = {\n id: string\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction fieldToneToTextTone(tone: FieldTone) {\n return tone === 'error' ? 'danger' : tone === 'success' ? 'positive' : 'secondary'\n}\n\nfunction FieldMessage({ id, children, tone }: FieldMessageProps) {\n return (\n <Text as=\"p\" tone={fieldToneToTextTone(tone)} size=\"copy\" id={id}>\n {tone === 'loading' ? (\n <Box\n as=\"span\"\n marginRight=\"xsmall\"\n display=\"inlineFlex\"\n className={styles.loadingIcon}\n >\n <Spinner size={16} />\n </Box>\n ) : null}\n {children}\n </Text>\n )\n}\n\ntype FieldCharacterCountProps = {\n children: React.ReactNode\n tone: FieldTone\n}\n\nfunction FieldCharacterCount({ children, tone }: FieldCharacterCountProps) {\n return (\n <Text tone={fieldToneToTextTone(tone)} size=\"copy\">\n {children}\n </Text>\n )\n}\n\ntype ValidateInputLengthProps = {\n value?: React.InputHTMLAttributes<unknown>['value']\n maxLength?: number\n}\n\ntype ValidateInputLengthResult = {\n count: string | null\n tone: FieldTone\n}\n\nfunction validateInputLength({\n value,\n maxLength,\n}: ValidateInputLengthProps): ValidateInputLengthResult {\n if (!maxLength) {\n return {\n count: null,\n tone: 'neutral',\n }\n }\n\n const currentLength = String(value || '').length\n const isNearMaxLength = maxLength - currentLength <= MAX_LENGTH_THRESHOLD\n\n return {\n count: `${currentLength}/${maxLength}`,\n tone: isNearMaxLength ? 'error' : 'neutral',\n }\n}\n\n//\n// BaseField\n//\n\ntype ChildrenRenderProps = {\n id: string\n value?: React.InputHTMLAttributes<unknown>['value']\n 'aria-describedby'?: string\n 'aria-invalid'?: true\n onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>\n characterCountElement?: React.ReactNode | null\n}\n\ntype HtmlInputProps<T extends HTMLElement> = React.DetailedHTMLProps<\n React.InputHTMLAttributes<T>,\n T\n>\n\ntype BaseFieldVariant = 'default' | 'bordered'\ntype BaseFieldVariantProps = {\n /**\n * Provides alternative visual layouts or modes that the field can be rendered in.\n *\n * Namely, there are two variants supported:\n *\n * - the default one\n * - a \"bordered\" variant, where the border of the field surrounds also the labels, instead\n * of just surrounding the actual field element\n *\n * In both cases, the message and description texts for the field lie outside the bordered\n * area.\n */\n variant?: BaseFieldVariant\n}\n\nexport type BaseFieldProps = WithEnhancedClassName &\n Pick<HtmlInputProps<HTMLInputElement>, 'id' | 'hidden' | 'maxLength' | 'aria-describedby'> & {\n /**\n * The main label for this field element.\n *\n * This prop is not optional. Consumers of field components must be explicit about not\n * wanting a label by passing `label=\"\"` or `label={null}`. In those situations, consumers\n * should make sure that fields are properly labelled semantically by other means (e.g using\n * `aria-labelledby`, or rendering a `<label />` element referencing the field by id).\n *\n * Avoid providing interactive elements in the label. Prefer `auxiliaryLabel` for that.\n *\n * @see BaseFieldProps['auxiliaryLabel']\n */\n label: React.ReactNode\n\n /**\n * The initial value for this field element.\n *\n * This prop is used to calculate the character count for the initial value, and is then\n * passed to the underlying child element.\n */\n value?: React.InputHTMLAttributes<unknown>['value']\n\n /**\n * An optional extra element to be placed to the right of the main label.\n *\n * This extra element is not included in the accessible name of the field element. Its only\n * purpose is either visual, or functional (if you include interactive elements in it).\n *\n * @see BaseFieldProps['label']\n *\n * @deprecated The usage of this element is discouraged given that it was removed from the\n * latest form field spec revision.\n */\n auxiliaryLabel?: React.ReactNode\n\n /**\n * A message associated with the field. It is rendered below the field, and with an\n * appearance that conveys the tone of the field (e.g. coloured red for errors, green for\n * success, etc).\n *\n * The message element is associated to the field via the `aria-describedby` attribute.\n *\n * In the future, when `aria-errormessage` gets better user agent support, we should use it\n * to associate the filed with a message when tone is `\"error\"`.\n *\n * @see BaseFieldProps['tone']\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid\n */\n message?: React.ReactNode\n\n /**\n * The tone with which the message, if any, is presented.\n *\n * If the tone is `\"error\"`, the field border turns red, and the message, if any, is also\n * red.\n *\n * When the tone is `\"loading\"`, it is recommended that you also disable the field. However,\n * this is not enforced by the component. It is only a recommendation.\n *\n * @see BaseFieldProps['message']\n * @see BaseFieldProps['hint']\n */\n tone?: FieldTone\n\n /**\n * The maximum width that the input field can expand to.\n */\n maxWidth?: BoxProps['maxWidth']\n\n /**\n * The maximum number of characters that the input field can accept.\n * When this limit is reached, the input field will not accept any more characters.\n * The counter element will turn red when the number of characters is within 10 of the maximum limit.\n */\n maxLength?: number\n\n /**\n * Used internally by components composed using `BaseField`. It is not exposed as part of\n * the public props of such components.\n */\n children: (props: ChildrenRenderProps) => React.ReactNode\n\n /**\n * The position of the character count element.\n * It can be shown below the field or inline with the field.\n *\n * @default 'below'\n */\n characterCountPosition?: 'below' | 'inline' | 'hidden'\n } & (\n | {\n supportsStartAndEndSlots?: false\n endSlot?: never\n endSlotPosition?: never\n }\n | {\n supportsStartAndEndSlots: true\n endSlot?: React.ReactElement | string | number\n /**\n * This is solely for `bordered` variants of TextField. When set to `bottom` (the default),\n * the endSlot will be placed inline with the input field. When set to `fullHeight`, the endSlot\n * will be placed to the side of both the input field and the label.\n */\n endSlotPosition?: 'bottom' | 'fullHeight'\n }\n )\n\ntype FieldComponentProps<T extends HTMLElement> = Omit<\n BaseFieldProps,\n 'children' | 'className' | 'fieldRef' | 'variant'\n> &\n Omit<HtmlInputProps<T>, 'className' | 'style'>\n\n/**\n * BaseField is a base component that provides a consistent structure for form fields.\n */\nfunction BaseField({\n variant = 'default',\n label,\n value,\n auxiliaryLabel,\n message,\n tone = 'neutral',\n className,\n children,\n maxWidth,\n maxLength,\n hidden,\n 'aria-describedby': originalAriaDescribedBy,\n id: originalId,\n characterCountPosition = 'below',\n endSlot,\n endSlotPosition = 'bottom',\n}: BaseFieldProps & BaseFieldVariantProps & WithEnhancedClassName) {\n const id = useId(originalId)\n const messageId = useId()\n\n const inputLength = validateInputLength({ value, maxLength })\n\n const [characterCount, setCharacterCount] = React.useState<string | null>(inputLength.count)\n const [characterCountTone, setCharacterCountTone] = React.useState<FieldTone>(inputLength.tone)\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (message ? messageId : null)\n\n const renderCharacterCountBelow = characterCountPosition === 'below' && characterCount !== null\n const renderCharacterCountInline =\n characterCountPosition === 'inline' && characterCount !== null\n\n function renderCharacterCount() {\n return <FieldCharacterCount tone={characterCountTone}>{characterCount}</FieldCharacterCount>\n }\n\n const childrenProps: ChildrenRenderProps = {\n id,\n value,\n ...(ariaDescribedBy ? { 'aria-describedby': ariaDescribedBy } : {}),\n 'aria-invalid': tone === 'error' ? true : undefined,\n onChange(event) {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value: event.currentTarget.value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n // If the character count is inline, we pass it as a prop to the children element so it can be rendered inline\n characterCountElement: renderCharacterCountInline ? renderCharacterCount() : null,\n }\n\n React.useEffect(\n function updateCharacterCountOnPropChange() {\n if (!maxLength) {\n return\n }\n\n const inputLength = validateInputLength({\n value,\n maxLength,\n })\n\n setCharacterCount(inputLength.count)\n setCharacterCountTone(inputLength.tone)\n },\n [maxLength, value],\n )\n\n return (\n <Stack space=\"xsmall\" hidden={hidden}>\n <Box\n display=\"flex\"\n flexDirection=\"row\"\n className={[\n className,\n styles.container,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n alignItems=\"center\"\n >\n <Box flexGrow={1}>\n {label || auxiliaryLabel ? (\n <Box\n as=\"span\"\n display=\"flex\"\n justifyContent=\"spaceBetween\"\n alignItems=\"flexEnd\"\n >\n <Text\n size={variant === 'bordered' ? 'caption' : 'body'}\n as=\"label\"\n htmlFor={id}\n >\n {label ? (\n <span className={styles.primaryLabel}>{label}</span>\n ) : null}\n </Text>\n {auxiliaryLabel ? (\n <Box className={styles.auxiliaryLabel} paddingLeft=\"small\">\n {auxiliaryLabel}\n </Box>\n ) : null}\n </Box>\n ) : null}\n {children(childrenProps)}\n </Box>\n {endSlot && endSlotPosition === 'fullHeight' ? endSlot : null}\n </Box>\n\n {message || renderCharacterCountBelow ? (\n <Columns align=\"right\" space=\"small\" maxWidth={maxWidth}>\n {message ? (\n <Column width=\"auto\">\n <FieldMessage id={messageId} tone={tone}>\n {message}\n </FieldMessage>\n </Column>\n ) : null}\n\n {/* If the character count is below the field, we render it, if it's inline,\n we pass it as a prop to the children element so it can be rendered inline */}\n {characterCountPosition === 'below' ? (\n <Column width=\"content\">{renderCharacterCount()}</Column>\n ) : null}\n </Columns>\n ) : null}\n </Stack>\n )\n}\n\nexport { BaseField, FieldMessage }\nexport type { BaseFieldVariant, BaseFieldVariantProps, FieldComponentProps }\n"],"names":["MAX_LENGTH_THRESHOLD","fieldToneToTextTone","tone","FieldMessage","id","children","React","Text","as","size","createElement","Box","marginRight","display","className","styles","loadingIcon","Spinner","FieldCharacterCount","validateInputLength","value","maxLength","count","currentLength","String","length","isNearMaxLength","BaseField","variant","label","auxiliaryLabel","message","maxWidth","hidden","originalAriaDescribedBy","originalId","characterCountPosition","endSlot","endSlotPosition","useId","messageId","inputLength","characterCount","setCharacterCount","useState","characterCountTone","setCharacterCountTone","ariaDescribedBy","renderCharacterCountBelow","renderCharacterCountInline","renderCharacterCount","childrenProps","_objectSpread","undefined","onChange","event","currentTarget","characterCountElement","useEffect","updateCharacterCountOnPropChange","Stack","space","flexDirection","container","error","bordered","alignItems","flexGrow","justifyContent","htmlFor","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IAPR,EAWKK,sBAAsB,KAAK,OAA3B,gBACG9B,KAAC,CAAAI,aAAD,CAACgE,MAAD,EAAQ;AAAAC,IAAAA,KAAK,EAAC,SAAA;GAAd,EAAyBzB,oBAAoB,EAA7C,CADH,GAEG,IAbR,CADH,GAgBG,IA1DR,CADJ,CAAA;AA8DH;;;;"}
package/es/box/box.js CHANGED
@@ -48,16 +48,14 @@ function getBoxClassNames({
48
48
  overlayScroll,
49
49
  className
50
50
  }) {
51
- var _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
52
-
53
- const resolvedPaddingTop = (_ref = paddingTop != null ? paddingTop : paddingY) != null ? _ref : padding;
54
- const resolvedPaddingRight = (_ref2 = paddingRight != null ? paddingRight : paddingX) != null ? _ref2 : padding;
55
- const resolvedPaddingBottom = (_ref3 = paddingBottom != null ? paddingBottom : paddingY) != null ? _ref3 : padding;
56
- const resolvedPaddingLeft = (_ref4 = paddingLeft != null ? paddingLeft : paddingX) != null ? _ref4 : padding;
57
- const resolvedMarginTop = (_ref5 = marginTop != null ? marginTop : marginY) != null ? _ref5 : margin;
58
- const resolvedMarginRight = (_ref6 = marginRight != null ? marginRight : marginX) != null ? _ref6 : margin;
59
- const resolvedMarginBottom = (_ref7 = marginBottom != null ? marginBottom : marginY) != null ? _ref7 : margin;
60
- const resolvedMarginLeft = (_ref8 = marginLeft != null ? marginLeft : marginX) != null ? _ref8 : margin;
51
+ const resolvedPaddingTop = paddingTop ?? paddingY ?? padding;
52
+ const resolvedPaddingRight = paddingRight ?? paddingX ?? padding;
53
+ const resolvedPaddingBottom = paddingBottom ?? paddingY ?? padding;
54
+ const resolvedPaddingLeft = paddingLeft ?? paddingX ?? padding;
55
+ const resolvedMarginTop = marginTop ?? marginY ?? margin;
56
+ const resolvedMarginRight = marginRight ?? marginX ?? margin;
57
+ const resolvedMarginBottom = marginBottom ?? marginY ?? margin;
58
+ const resolvedMarginLeft = marginLeft ?? marginX ?? margin;
61
59
  const omitFlex = !display || typeof display === 'string' && display !== 'flex' && display !== 'inlineFlex';
62
60
  return classNames(className, modules_54d944f2.box, display ? getClassNames(modules_54d944f2, 'display', display) : null, position !== 'static' ? getClassNames(modules_54d944f2, 'position', position) : null, minWidth != null ? getClassNames(modules_89b7671c, 'minWidth', String(minWidth)) : null, getClassNames(modules_89b7671c, 'maxWidth', maxWidth), getClassNames(modules_54d944f2, 'textAlign', textAlign), // padding
63
61
  getClassNames(modules_b537a8ee, 'paddingTop', resolvedPaddingTop), getClassNames(modules_b537a8ee, 'paddingRight', resolvedPaddingRight), getClassNames(modules_b537a8ee, 'paddingBottom', resolvedPaddingBottom), getClassNames(modules_b537a8ee, 'paddingLeft', resolvedPaddingLeft), // margin
@@ -66,7 +64,7 @@ function getBoxClassNames({
66
64
  getClassNames(modules_54d944f2, 'overflow', overflow), width != null ? getClassNames(modules_89b7671c, 'width', String(width)) : null, getClassNames(modules_54d944f2, 'height', height), getClassNames(modules_54d944f2, 'bg', background), borderRadius !== 'none' ? getClassNames(modules_54d944f2, 'borderRadius', borderRadius) : null, border !== 'none' ? getClassNames(modules_54d944f2, 'border', border) : null, overlayScroll ? modules_54d944f2.overlayScroll : null);
67
65
  }
68
66
 
69
- const Box = /*#__PURE__*/polymorphicComponent(function Box(_ref9, ref) {
67
+ const Box = /*#__PURE__*/polymorphicComponent(function Box(_ref, ref) {
70
68
  let {
71
69
  as: component = 'div',
72
70
  position = 'static',
@@ -105,8 +103,8 @@ const Box = /*#__PURE__*/polymorphicComponent(function Box(_ref9, ref) {
105
103
  overlayScroll,
106
104
  className,
107
105
  children
108
- } = _ref9,
109
- props = _objectWithoutProperties(_ref9, _excluded);
106
+ } = _ref,
107
+ props = _objectWithoutProperties(_ref, _excluded);
110
108
 
111
109
  return /*#__PURE__*/React.createElement(component, _objectSpread2(_objectSpread2({}, props), {}, {
112
110
  className: getBoxClassNames({
package/es/box/box.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"box.js","sources":["../../src/box/box.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { polymorphicComponent } from '../utils/polymorphism'\nimport { getClassNames } from '../utils/responsive-props'\n\nimport type { ResponsiveProp } from '../utils/responsive-props'\nimport type {\n DividerWeight,\n Space,\n SpaceWithNegatives,\n WithEnhancedClassName,\n} from '../utils/common-types'\n\nimport styles from './box.module.css'\nimport paddingStyles from './padding.module.css'\nimport marginStyles from './margin.module.css'\nimport widthStyles from './width.module.css'\nimport gapStyles from './gap.module.css'\n\ninterface BoxPaddingProps {\n padding?: ResponsiveProp<Space>\n paddingX?: ResponsiveProp<Space>\n paddingY?: ResponsiveProp<Space>\n paddingTop?: ResponsiveProp<Space>\n paddingRight?: ResponsiveProp<Space>\n paddingBottom?: ResponsiveProp<Space>\n paddingLeft?: ResponsiveProp<Space>\n}\n\ninterface BoxMarginProps {\n margin?: ResponsiveProp<SpaceWithNegatives>\n marginX?: ResponsiveProp<SpaceWithNegatives>\n marginY?: ResponsiveProp<SpaceWithNegatives>\n marginTop?: ResponsiveProp<SpaceWithNegatives>\n marginRight?: ResponsiveProp<SpaceWithNegatives>\n marginBottom?: ResponsiveProp<SpaceWithNegatives>\n marginLeft?: ResponsiveProp<SpaceWithNegatives>\n}\n\ntype BoxDisplay = 'block' | 'flex' | 'inline' | 'inlineBlock' | 'inlineFlex' | 'none'\ntype BoxFlexDirection = 'column' | 'row'\ntype BoxFlexWrap = 'nowrap' | 'wrap'\ntype BoxAlignItems = 'center' | 'flexEnd' | 'flexStart' | 'baseline'\ntype BoxJustifyContent =\n | 'center'\n | 'flexEnd'\n | 'flexStart'\n | 'spaceAround'\n | 'spaceBetween'\n | 'spaceEvenly'\ntype BoxAlignSelf = 'flexStart' | 'flexEnd' | 'center' | 'baseline' | 'stretch'\ntype BoxOverflow = 'hidden' | 'auto' | 'visible' | 'scroll'\n\ntype BoxMaxMinWidth = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge'\ntype BoxMinWidth = 0 | BoxMaxMinWidth\ntype BoxMaxWidth = BoxMaxMinWidth | 'full'\ntype BoxWidth = 0 | BoxMaxMinWidth | 'full' | 'auto' | 'maxContent' | 'minContent' | 'fitContent'\ntype BoxBackground = 'default' | 'aside' | 'highlight' | 'selected' | 'toast'\ntype BoxBorderRadius = 'standard' | 'none' | 'full'\n\ninterface BorderProps {\n borderRadius?: BoxBorderRadius\n border?: DividerWeight\n}\n\ninterface ReusableBoxProps extends BorderProps, BoxPaddingProps {\n minWidth?: BoxMinWidth\n maxWidth?: BoxMaxWidth\n width?: BoxWidth\n background?: BoxBackground\n flexGrow?: 0 | 1\n flexShrink?: 0\n}\n\ntype BoxPosition = 'absolute' | 'fixed' | 'relative' | 'static' | 'sticky'\ntype BoxTextAlign = 'start' | 'center' | 'end' | 'justify'\n\ninterface BoxProps extends WithEnhancedClassName, ReusableBoxProps, BoxMarginProps {\n position?: ResponsiveProp<BoxPosition>\n display?: ResponsiveProp<BoxDisplay>\n flexDirection?: ResponsiveProp<BoxFlexDirection>\n flexWrap?: BoxFlexWrap\n gap?: ResponsiveProp<Space | 'none'>\n alignItems?: ResponsiveProp<BoxAlignItems>\n alignSelf?: ResponsiveProp<BoxAlignSelf>\n justifyContent?: ResponsiveProp<BoxJustifyContent>\n overflow?: BoxOverflow\n height?: 'full'\n textAlign?: ResponsiveProp<BoxTextAlign>\n /**\n * The `overlayScroll` prop enables a modern scrollbar experience where the scrollbar is hidden\n * by default and appears on hover. This provides a cleaner interface while maintaining full scrollability.\n *\n * Scrollbar appearance may be affected by macOS system settings,\n * such as \"Show scroll bars: Automatically/When scrolling/Always\".\n * This can override or change the effect of these styles on Mac devices.\n */\n overlayScroll?: boolean\n}\n\nfunction getBoxClassNames({\n position = 'static',\n display,\n flexDirection = 'row',\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n}: BoxProps) {\n const resolvedPaddingTop = paddingTop ?? paddingY ?? padding\n const resolvedPaddingRight = paddingRight ?? paddingX ?? padding\n const resolvedPaddingBottom = paddingBottom ?? paddingY ?? padding\n const resolvedPaddingLeft = paddingLeft ?? paddingX ?? padding\n\n const resolvedMarginTop = marginTop ?? marginY ?? margin\n const resolvedMarginRight = marginRight ?? marginX ?? margin\n const resolvedMarginBottom = marginBottom ?? marginY ?? margin\n const resolvedMarginLeft = marginLeft ?? marginX ?? margin\n\n const omitFlex =\n !display || (typeof display === 'string' && display !== 'flex' && display !== 'inlineFlex')\n\n return classNames(\n className,\n styles.box,\n display ? getClassNames(styles, 'display', display) : null,\n position !== 'static' ? getClassNames(styles, 'position', position) : null,\n minWidth != null ? getClassNames(widthStyles, 'minWidth', String(minWidth)) : null,\n getClassNames(widthStyles, 'maxWidth', maxWidth),\n getClassNames(styles, 'textAlign', textAlign),\n // padding\n getClassNames(paddingStyles, 'paddingTop', resolvedPaddingTop),\n getClassNames(paddingStyles, 'paddingRight', resolvedPaddingRight),\n getClassNames(paddingStyles, 'paddingBottom', resolvedPaddingBottom),\n getClassNames(paddingStyles, 'paddingLeft', resolvedPaddingLeft),\n // margin\n getClassNames(marginStyles, 'marginTop', resolvedMarginTop),\n getClassNames(marginStyles, 'marginRight', resolvedMarginRight),\n getClassNames(marginStyles, 'marginBottom', resolvedMarginBottom),\n getClassNames(marginStyles, 'marginLeft', resolvedMarginLeft),\n // flex props\n omitFlex ? null : getClassNames(styles, 'flexDirection', flexDirection),\n omitFlex ? null : getClassNames(styles, 'flexWrap', flexWrap),\n omitFlex ? null : getClassNames(styles, 'alignItems', alignItems),\n omitFlex ? null : getClassNames(styles, 'justifyContent', justifyContent),\n alignSelf != null ? getClassNames(styles, 'alignSelf', alignSelf) : null,\n flexShrink != null ? getClassNames(styles, 'flexShrink', String(flexShrink)) : null,\n flexGrow != null ? getClassNames(styles, 'flexGrow', String(flexGrow)) : null,\n gap ? getClassNames(gapStyles, 'gap', gap) : null,\n // other props\n getClassNames(styles, 'overflow', overflow),\n width != null ? getClassNames(widthStyles, 'width', String(width)) : null,\n getClassNames(styles, 'height', height),\n getClassNames(styles, 'bg', background),\n borderRadius !== 'none' ? getClassNames(styles, 'borderRadius', borderRadius) : null,\n border !== 'none' ? getClassNames(styles, 'border', border) : null,\n overlayScroll ? styles.overlayScroll : null,\n )\n}\n\nconst Box = polymorphicComponent<'div', BoxProps, 'keepClassName'>(function Box(\n {\n as: component = 'div',\n position = 'static',\n display,\n flexDirection = 'row',\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n children,\n ...props\n },\n ref,\n) {\n return React.createElement(\n component,\n {\n ...props,\n className: getBoxClassNames({\n position,\n display,\n flexDirection,\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n }),\n ref,\n },\n children,\n )\n})\n\nexport type {\n BoxProps,\n BoxPaddingProps,\n BoxMarginProps,\n ReusableBoxProps,\n BoxMinWidth,\n BoxMaxWidth,\n BoxDisplay,\n BoxPosition,\n BoxFlexDirection,\n BoxFlexWrap,\n BoxAlignItems,\n BoxJustifyContent,\n BoxOverflow,\n BoxTextAlign,\n BoxBackground,\n BoxBorderRadius,\n}\n\nexport { Box, getBoxClassNames }\n"],"names":["getBoxClassNames","position","display","flexDirection","flexWrap","flexGrow","flexShrink","gap","alignItems","justifyContent","alignSelf","overflow","width","height","background","border","borderRadius","minWidth","maxWidth","textAlign","padding","paddingY","paddingX","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginY","marginX","marginTop","marginRight","marginBottom","marginLeft","overlayScroll","className","resolvedPaddingTop","resolvedPaddingRight","resolvedPaddingBottom","resolvedPaddingLeft","resolvedMarginTop","resolvedMarginRight","resolvedMarginBottom","resolvedMarginLeft","omitFlex","classNames","styles","box","getClassNames","widthStyles","String","paddingStyles","marginStyles","gapStyles","Box","polymorphicComponent","ref","as","component","children","props","React","createElement"],"mappings":";;;;;;;;;;;;;AAoGA,SAASA,gBAAT,CAA0B;AACtBC,EAAAA,QAAQ,GAAG,QADW;EAEtBC,OAFsB;AAGtBC,EAAAA,aAAa,GAAG,KAHM;EAItBC,QAJsB;EAKtBC,QALsB;EAMtBC,UANsB;EAOtBC,GAPsB;EAQtBC,UARsB;EAStBC,cATsB;EAUtBC,SAVsB;EAWtBC,QAXsB;EAYtBC,KAZsB;EAatBC,MAbsB;EActBC,UAdsB;EAetBC,MAfsB;EAgBtBC,YAhBsB;EAiBtBC,QAjBsB;EAkBtBC,QAlBsB;EAmBtBC,SAnBsB;EAoBtBC,OApBsB;EAqBtBC,QArBsB;EAsBtBC,QAtBsB;EAuBtBC,UAvBsB;EAwBtBC,YAxBsB;EAyBtBC,aAzBsB;EA0BtBC,WA1BsB;EA2BtBC,MA3BsB;EA4BtBC,OA5BsB;EA6BtBC,OA7BsB;EA8BtBC,SA9BsB;EA+BtBC,WA/BsB;EAgCtBC,YAhCsB;EAiCtBC,UAjCsB;EAkCtBC,aAlCsB;AAmCtBC,EAAAA,SAAAA;AAnCsB,CAA1B,EAoCW;AAAA,EAAA,IAAA,IAAA,EAAA,K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OA7BwB;MA8BxBC,SA9BwB;MA+BxBC,WA/BwB;MAgCxBC,YAhCwB;MAiCxBC,UAjCwB;MAkCxBC,aAlCwB;AAmCxBC,MAAAA,SAAAA;AAnCwB,KAAD,CAJ5B;AAyCCqB,IAAAA,GAAAA;AAzCD,GAAA,CAAA,EA2CHG,QA3CG,CAAP,CAAA;AA6CH,CAxF+B;;;;"}
1
+ {"version":3,"file":"box.js","sources":["../../src/box/box.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { polymorphicComponent } from '../utils/polymorphism'\nimport { getClassNames } from '../utils/responsive-props'\n\nimport type { ResponsiveProp } from '../utils/responsive-props'\nimport type {\n DividerWeight,\n Space,\n SpaceWithNegatives,\n WithEnhancedClassName,\n} from '../utils/common-types'\n\nimport styles from './box.module.css'\nimport paddingStyles from './padding.module.css'\nimport marginStyles from './margin.module.css'\nimport widthStyles from './width.module.css'\nimport gapStyles from './gap.module.css'\n\ninterface BoxPaddingProps {\n padding?: ResponsiveProp<Space>\n paddingX?: ResponsiveProp<Space>\n paddingY?: ResponsiveProp<Space>\n paddingTop?: ResponsiveProp<Space>\n paddingRight?: ResponsiveProp<Space>\n paddingBottom?: ResponsiveProp<Space>\n paddingLeft?: ResponsiveProp<Space>\n}\n\ninterface BoxMarginProps {\n margin?: ResponsiveProp<SpaceWithNegatives>\n marginX?: ResponsiveProp<SpaceWithNegatives>\n marginY?: ResponsiveProp<SpaceWithNegatives>\n marginTop?: ResponsiveProp<SpaceWithNegatives>\n marginRight?: ResponsiveProp<SpaceWithNegatives>\n marginBottom?: ResponsiveProp<SpaceWithNegatives>\n marginLeft?: ResponsiveProp<SpaceWithNegatives>\n}\n\ntype BoxDisplay = 'block' | 'flex' | 'inline' | 'inlineBlock' | 'inlineFlex' | 'none'\ntype BoxFlexDirection = 'column' | 'row'\ntype BoxFlexWrap = 'nowrap' | 'wrap'\ntype BoxAlignItems = 'center' | 'flexEnd' | 'flexStart' | 'baseline'\ntype BoxJustifyContent =\n | 'center'\n | 'flexEnd'\n | 'flexStart'\n | 'spaceAround'\n | 'spaceBetween'\n | 'spaceEvenly'\ntype BoxAlignSelf = 'flexStart' | 'flexEnd' | 'center' | 'baseline' | 'stretch'\ntype BoxOverflow = 'hidden' | 'auto' | 'visible' | 'scroll'\n\ntype BoxMaxMinWidth = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge'\ntype BoxMinWidth = 0 | BoxMaxMinWidth\ntype BoxMaxWidth = BoxMaxMinWidth | 'full'\ntype BoxWidth = 0 | BoxMaxMinWidth | 'full' | 'auto' | 'maxContent' | 'minContent' | 'fitContent'\ntype BoxBackground = 'default' | 'aside' | 'highlight' | 'selected' | 'toast'\ntype BoxBorderRadius = 'standard' | 'none' | 'full'\n\ninterface BorderProps {\n borderRadius?: BoxBorderRadius\n border?: DividerWeight\n}\n\ninterface ReusableBoxProps extends BorderProps, BoxPaddingProps {\n minWidth?: BoxMinWidth\n maxWidth?: BoxMaxWidth\n width?: BoxWidth\n background?: BoxBackground\n flexGrow?: 0 | 1\n flexShrink?: 0\n}\n\ntype BoxPosition = 'absolute' | 'fixed' | 'relative' | 'static' | 'sticky'\ntype BoxTextAlign = 'start' | 'center' | 'end' | 'justify'\n\ninterface BoxProps extends WithEnhancedClassName, ReusableBoxProps, BoxMarginProps {\n position?: ResponsiveProp<BoxPosition>\n display?: ResponsiveProp<BoxDisplay>\n flexDirection?: ResponsiveProp<BoxFlexDirection>\n flexWrap?: BoxFlexWrap\n gap?: ResponsiveProp<Space | 'none'>\n alignItems?: ResponsiveProp<BoxAlignItems>\n alignSelf?: ResponsiveProp<BoxAlignSelf>\n justifyContent?: ResponsiveProp<BoxJustifyContent>\n overflow?: BoxOverflow\n height?: 'full'\n textAlign?: ResponsiveProp<BoxTextAlign>\n /**\n * The `overlayScroll` prop enables a modern scrollbar experience where the scrollbar is hidden\n * by default and appears on hover. This provides a cleaner interface while maintaining full scrollability.\n *\n * Scrollbar appearance may be affected by macOS system settings,\n * such as \"Show scroll bars: Automatically/When scrolling/Always\".\n * This can override or change the effect of these styles on Mac devices.\n */\n overlayScroll?: boolean\n}\n\nfunction getBoxClassNames({\n position = 'static',\n display,\n flexDirection = 'row',\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n}: BoxProps) {\n const resolvedPaddingTop = paddingTop ?? paddingY ?? padding\n const resolvedPaddingRight = paddingRight ?? paddingX ?? padding\n const resolvedPaddingBottom = paddingBottom ?? paddingY ?? padding\n const resolvedPaddingLeft = paddingLeft ?? paddingX ?? padding\n\n const resolvedMarginTop = marginTop ?? marginY ?? margin\n const resolvedMarginRight = marginRight ?? marginX ?? margin\n const resolvedMarginBottom = marginBottom ?? marginY ?? margin\n const resolvedMarginLeft = marginLeft ?? marginX ?? margin\n\n const omitFlex =\n !display || (typeof display === 'string' && display !== 'flex' && display !== 'inlineFlex')\n\n return classNames(\n className,\n styles.box,\n display ? getClassNames(styles, 'display', display) : null,\n position !== 'static' ? getClassNames(styles, 'position', position) : null,\n minWidth != null ? getClassNames(widthStyles, 'minWidth', String(minWidth)) : null,\n getClassNames(widthStyles, 'maxWidth', maxWidth),\n getClassNames(styles, 'textAlign', textAlign),\n // padding\n getClassNames(paddingStyles, 'paddingTop', resolvedPaddingTop),\n getClassNames(paddingStyles, 'paddingRight', resolvedPaddingRight),\n getClassNames(paddingStyles, 'paddingBottom', resolvedPaddingBottom),\n getClassNames(paddingStyles, 'paddingLeft', resolvedPaddingLeft),\n // margin\n getClassNames(marginStyles, 'marginTop', resolvedMarginTop),\n getClassNames(marginStyles, 'marginRight', resolvedMarginRight),\n getClassNames(marginStyles, 'marginBottom', resolvedMarginBottom),\n getClassNames(marginStyles, 'marginLeft', resolvedMarginLeft),\n // flex props\n omitFlex ? null : getClassNames(styles, 'flexDirection', flexDirection),\n omitFlex ? null : getClassNames(styles, 'flexWrap', flexWrap),\n omitFlex ? null : getClassNames(styles, 'alignItems', alignItems),\n omitFlex ? null : getClassNames(styles, 'justifyContent', justifyContent),\n alignSelf != null ? getClassNames(styles, 'alignSelf', alignSelf) : null,\n flexShrink != null ? getClassNames(styles, 'flexShrink', String(flexShrink)) : null,\n flexGrow != null ? getClassNames(styles, 'flexGrow', String(flexGrow)) : null,\n gap ? getClassNames(gapStyles, 'gap', gap) : null,\n // other props\n getClassNames(styles, 'overflow', overflow),\n width != null ? getClassNames(widthStyles, 'width', String(width)) : null,\n getClassNames(styles, 'height', height),\n getClassNames(styles, 'bg', background),\n borderRadius !== 'none' ? getClassNames(styles, 'borderRadius', borderRadius) : null,\n border !== 'none' ? getClassNames(styles, 'border', border) : null,\n overlayScroll ? styles.overlayScroll : null,\n )\n}\n\nconst Box = polymorphicComponent<'div', BoxProps, 'keepClassName'>(function Box(\n {\n as: component = 'div',\n position = 'static',\n display,\n flexDirection = 'row',\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n children,\n ...props\n },\n ref,\n) {\n return React.createElement(\n component,\n {\n ...props,\n className: getBoxClassNames({\n position,\n display,\n flexDirection,\n flexWrap,\n flexGrow,\n flexShrink,\n gap,\n alignItems,\n justifyContent,\n alignSelf,\n overflow,\n width,\n height,\n background,\n border,\n borderRadius,\n minWidth,\n maxWidth,\n textAlign,\n padding,\n paddingY,\n paddingX,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n margin,\n marginY,\n marginX,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n overlayScroll,\n className,\n }),\n ref,\n },\n children,\n )\n})\n\nexport type {\n BoxProps,\n BoxPaddingProps,\n BoxMarginProps,\n ReusableBoxProps,\n BoxMinWidth,\n BoxMaxWidth,\n BoxDisplay,\n BoxPosition,\n BoxFlexDirection,\n BoxFlexWrap,\n BoxAlignItems,\n BoxJustifyContent,\n BoxOverflow,\n BoxTextAlign,\n BoxBackground,\n BoxBorderRadius,\n}\n\nexport { Box, getBoxClassNames }\n"],"names":["getBoxClassNames","position","display","flexDirection","flexWrap","flexGrow","flexShrink","gap","alignItems","justifyContent","alignSelf","overflow","width","height","background","border","borderRadius","minWidth","maxWidth","textAlign","padding","paddingY","paddingX","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginY","marginX","marginTop","marginRight","marginBottom","marginLeft","overlayScroll","className","resolvedPaddingTop","resolvedPaddingRight","resolvedPaddingBottom","resolvedPaddingLeft","resolvedMarginTop","resolvedMarginRight","resolvedMarginBottom","resolvedMarginLeft","omitFlex","classNames","styles","box","getClassNames","widthStyles","String","paddingStyles","marginStyles","gapStyles","Box","polymorphicComponent","ref","as","component","children","props","React","createElement"],"mappings":";;;;;;;;;;;;;AAoGA,SAASA,gBAAT,CAA0B;AACtBC,EAAAA,QAAQ,GAAG,QADW;EAEtBC,OAFsB;AAGtBC,EAAAA,aAAa,GAAG,KAHM;EAItBC,QAJsB;EAKtBC,QALsB;EAMtBC,UANsB;EAOtBC,GAPsB;EAQtBC,UARsB;EAStBC,cATsB;EAUtBC,SAVsB;EAWtBC,QAXsB;EAYtBC,KAZsB;EAatBC,MAbsB;EActBC,UAdsB;EAetBC,MAfsB;EAgBtBC,YAhBsB;EAiBtBC,QAjBsB;EAkBtBC,QAlBsB;EAmBtBC,SAnBsB;EAoBtBC,OApBsB;EAqBtBC,QArBsB;EAsBtBC,QAtBsB;EAuBtBC,UAvB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xBC,SA9BwB;MA+BxBC,WA/BwB;MAgCxBC,YAhCwB;MAiCxBC,UAjCwB;MAkCxBC,aAlCwB;AAmCxBC,MAAAA,SAAAA;AAnCwB,KAAD,CAJ5B;AAyCCqB,IAAAA,GAAAA;AAzCD,GAAA,CAAA,EA2CHG,QA3CG,CAAP,CAAA;AA6CH,CAxF+B;;;;"}
@@ -49,7 +49,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
49
49
  onClick: isDisabled ? preventDefault : onClick,
50
50
  className: classNames([getBoxClassNames({
51
51
  width
52
- }), exceptionallySetClassName, modules_5357ebb8.baseButton, modules_5357ebb8["variant-" + variant], modules_5357ebb8["tone-" + tone], modules_5357ebb8["size-" + size], shape === 'rounded' ? modules_5357ebb8['shape-rounded'] : null, disabled ? modules_5357ebb8.disabled : null])
52
+ }), exceptionallySetClassName, modules_5357ebb8.baseButton, modules_5357ebb8[`variant-${variant}`], modules_5357ebb8[`tone-${tone}`], modules_5357ebb8[`size-${size}`], shape === 'rounded' ? modules_5357ebb8['shape-rounded'] : null, disabled ? modules_5357ebb8.disabled : null])
53
53
  }), /*#__PURE__*/React.createElement(React.Fragment, null, startIcon ? /*#__PURE__*/React.createElement(Box, {
54
54
  display: "flex",
55
55
  className: modules_5357ebb8.startIcon,
@@ -100,7 +100,7 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(_ref2, ref)
100
100
  ref: ref,
101
101
  "aria-disabled": isDisabled,
102
102
  onClick: isDisabled ? preventDefault : onClick,
103
- className: classNames([exceptionallySetClassName, modules_5357ebb8.baseButton, modules_5357ebb8["variant-" + variant], modules_5357ebb8["tone-" + tone], modules_5357ebb8["size-" + size], shape === 'rounded' ? modules_5357ebb8['shape-rounded'] : null, modules_5357ebb8.iconButton, disabled ? modules_5357ebb8.disabled : null])
103
+ className: classNames([exceptionallySetClassName, modules_5357ebb8.baseButton, modules_5357ebb8[`variant-${variant}`], modules_5357ebb8[`tone-${tone}`], modules_5357ebb8[`size-${size}`], shape === 'rounded' ? modules_5357ebb8['shape-rounded'] : null, modules_5357ebb8.iconButton, disabled ? modules_5357ebb8.disabled : null])
104
104
  }), loading && /*#__PURE__*/React.createElement(Spinner, null) || icon);
105
105
  const tooltipContent = tooltip === undefined ? props['aria-label'] : tooltip;
106
106
  return tooltipContent ? /*#__PURE__*/React.createElement(Tooltip, {
@@ -1 +1 @@
1
- {"version":3,"file":"button.js","sources":["../../src/button/button.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { Role, RoleProps } from '@ariakit/react'\n\nimport { Box, getBoxClassNames } from '../box'\nimport { Spinner } from '../spinner'\nimport { Tooltip, TooltipProps } from '../tooltip'\n\nimport styles from './button.module.css'\n\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactElement | string\n\ninterface CommonButtonProps\n extends ObfuscatedClassName,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'className'>,\n Pick<RoleProps, 'render'> {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n\n /**\n * The button's tone.\n *\n * @default 'normal'\n */\n tone?: ButtonTone\n\n /**\n * The button's size.\n *\n * @default 'normal'\n */\n size?: ButtonSize\n\n /**\n * Controls the shape of the button.\n *\n * Specifically, it allows to make it have slightly curved corners (the default) vs. having them\n * fully curved to the point that they are as round as possible.\n *\n * In icon-only buttons this allows to have the button be circular.\n *\n * @default 'normal'\n */\n shape?: 'normal' | 'rounded'\n\n /**\n * Whether the button is disabled or not.\n *\n * Buttons are disabled using aria-disabled, rather than the HTML disabled attribute. This\n * allows the buttons to be focusable, which can aid discoverability. This way, users can tab to\n * the button and read its label, even if they can't activate it.\n *\n * It is also convenient when buttons are rendered as a link. Links cannot normally be disabled,\n * but by using aria-disabled, we can make them behave as if they were.\n *\n * The `onClick` handler is automatically prevented when the button is disabled in this way, to\n * mimic the behavior of a native disabled attribute.\n *\n * @default false\n */\n disabled?: boolean\n\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n\n /**\n * The type of the button.\n *\n * @default 'button'\n */\n type?: 'button' | 'submit' | 'reset'\n}\n\ninterface ButtonProps extends CommonButtonProps {\n /**\n * The button label content.\n */\n children?: React.ReactNode\n\n /**\n * The icon to display at the start of the button (before the label).\n */\n startIcon?: IconElement\n\n /**\n * The icon to display at the end of the button (after the label).\n */\n endIcon?: IconElement\n\n /**\n * The width of the button.\n *\n * - `'auto'`: The button will be as wide as its content.\n * - `'full'`: The button will be as wide as its container.\n *\n * @default 'auto'\n */\n width?: 'auto' | 'full'\n\n /**\n * The alignment of the button label inside the button.\n *\n * @default 'center'\n */\n align?: 'start' | 'center' | 'end'\n}\n\n/**\n * A button element that displays a text label and optionally a start or end icon. It follows the\n * [WAI-ARIA Button Pattern](https://www.w3.org/TR/wai-aria-practices/#button).\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant,\n tone = 'normal',\n size = 'normal',\n shape = 'normal',\n type = 'button',\n disabled = false,\n loading = false,\n tooltip,\n render,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n width = 'auto',\n align = 'center',\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Role.button\n {...props}\n render={render}\n type={render != null ? undefined : type}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={classNames([\n getBoxClassNames({ width }),\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n shape === 'rounded' ? styles['shape-rounded'] : null,\n disabled ? styles.disabled : null,\n ])}\n >\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n\n {children ? (\n <Box\n as=\"span\"\n className={styles.label}\n overflow=\"hidden\"\n width={width === 'full' ? 'full' : undefined}\n textAlign={width === 'auto' ? 'center' : align}\n >\n {children}\n </Box>\n ) : null}\n\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n </Role.button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{buttonElement}</Tooltip> : buttonElement\n})\n\ninterface IconButtonProps extends CommonButtonProps {\n /**\n * The icon to display inside the button.\n */\n icon: IconElement\n\n /**\n * The button label.\n *\n * It is used for assistive technologies, and it is also shown as a tooltip (if not tooltip is\n * provided explicitly).\n */\n 'aria-label': string\n}\n\n/**\n * A button element that displays an icon only, visually, though it is semantically labelled. It\n * also makes sure to always show a tooltip with its label. It follows the\n * [WAI-ARIA Button Pattern](https://www.w3.org/TR/wai-aria-practices/#button).\n */\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n {\n variant,\n tone = 'normal',\n size = 'normal',\n shape = 'normal',\n type = 'button',\n disabled = false,\n loading = false,\n tooltip,\n render,\n onClick,\n exceptionallySetClassName,\n children,\n icon,\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Role.button\n {...props}\n render={render}\n type={render != null ? undefined : type}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={classNames([\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n shape === 'rounded' ? styles['shape-rounded'] : null,\n styles.iconButton,\n disabled ? styles.disabled : null,\n ])}\n >\n {(loading && <Spinner />) || icon}\n </Role.button>\n )\n\n const tooltipContent = tooltip === undefined ? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n\nexport type { ButtonProps, IconButtonProps, ButtonVariant, ButtonTone }\nexport { Button, IconButton }\n"],"names":["preventDefault","event","Button","React","forwardRef","ref","variant","tone","size","shape","type","disabled","loading","tooltip","render","onClick","exceptionallySetClassName","children","startIcon","endIcon","width","align","props","isDisabled","buttonElement","createElement","Role","button","_objectSpread","undefined","className","classNames","getBoxClassNames","styles","baseButton","Fragment","Box","display","Spinner","as","label","overflow","textAlign","Tooltip","content","IconButton","icon","iconButton","tooltipContent"],"mappings":";;;;;;;;;;;;AAYA,SAASA,cAAT,CAAwBC,KAAxB,EAAmD;AAC/CA,EAAAA,KAAK,CAACD,cAAN,EAAA,CAAA;AACH,CAAA;AAoHD;;;AAGG;;;AACGE,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAAiD,SAASF,MAAT,CAoB5DG,IAAAA,EAAAA,GApB4D,EAoBzD;EAAA,IAnBH;IACIC,OADJ;AAEIC,IAAAA,IAAI,GAAG,QAFX;AAGIC,IAAAA,IAAI,GAAG,QAHX;AAIIC,IAAAA,KAAK,GAAG,QAJZ;AAKIC,IAAAA,IAAI,GAAG,QALX;AAMIC,IAAAA,QAAQ,GAAG,KANf;AAOIC,IAAAA,OAAO,GAAG,KAPd;IAQIC,OARJ;IASIC,MATJ;IAUIC,OAVJ;IAWIC,yBAXJ;IAYIC,QAZJ;IAaIC,SAbJ;IAcIC,OAdJ;AAeIC,IAAAA,KAAK,GAAG,MAfZ;AAgBIC,IAAAA,KAAK,GAAG,QAAA;GAGT,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,UAAU,GAAGX,OAAO,IAA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AACkB,OAAD;AAASC,IAAAA,OAAO,EAAEI,cAAAA;GAAlB,EAAmCxB,aAAnC,CADiB,GAGjBA,aAHJ,CAAA;AAKH,CAjDkB;;;;"}
1
+ {"version":3,"file":"button.js","sources":["../../src/button/button.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { Role, RoleProps } from '@ariakit/react'\n\nimport { Box, getBoxClassNames } from '../box'\nimport { Spinner } from '../spinner'\nimport { Tooltip, TooltipProps } from '../tooltip'\n\nimport styles from './button.module.css'\n\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\nfunction preventDefault(event: React.SyntheticEvent) {\n event.preventDefault()\n}\n\ntype ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'quaternary'\ntype ButtonTone = 'normal' | 'destructive'\ntype ButtonSize = 'small' | 'normal' | 'large'\ntype IconElement = React.ReactElement | string\n\ninterface CommonButtonProps\n extends ObfuscatedClassName,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'className'>,\n Pick<RoleProps, 'render'> {\n /**\n * The button's variant.\n */\n variant: ButtonVariant\n\n /**\n * The button's tone.\n *\n * @default 'normal'\n */\n tone?: ButtonTone\n\n /**\n * The button's size.\n *\n * @default 'normal'\n */\n size?: ButtonSize\n\n /**\n * Controls the shape of the button.\n *\n * Specifically, it allows to make it have slightly curved corners (the default) vs. having them\n * fully curved to the point that they are as round as possible.\n *\n * In icon-only buttons this allows to have the button be circular.\n *\n * @default 'normal'\n */\n shape?: 'normal' | 'rounded'\n\n /**\n * Whether the button is disabled or not.\n *\n * Buttons are disabled using aria-disabled, rather than the HTML disabled attribute. This\n * allows the buttons to be focusable, which can aid discoverability. This way, users can tab to\n * the button and read its label, even if they can't activate it.\n *\n * It is also convenient when buttons are rendered as a link. Links cannot normally be disabled,\n * but by using aria-disabled, we can make them behave as if they were.\n *\n * The `onClick` handler is automatically prevented when the button is disabled in this way, to\n * mimic the behavior of a native disabled attribute.\n *\n * @default false\n */\n disabled?: boolean\n\n /**\n * Whether the button is busy/loading.\n *\n * A button in this state is functionally and semantically disabled. Visually is does not look\n * dimmed (as disabled buttons normally do), but it shows a loading spinner instead.\n *\n * @default false\n */\n loading?: boolean\n\n /**\n * A tooltip linked to the button element.\n */\n tooltip?: TooltipProps['content']\n\n /**\n * The type of the button.\n *\n * @default 'button'\n */\n type?: 'button' | 'submit' | 'reset'\n}\n\ninterface ButtonProps extends CommonButtonProps {\n /**\n * The button label content.\n */\n children?: React.ReactNode\n\n /**\n * The icon to display at the start of the button (before the label).\n */\n startIcon?: IconElement\n\n /**\n * The icon to display at the end of the button (after the label).\n */\n endIcon?: IconElement\n\n /**\n * The width of the button.\n *\n * - `'auto'`: The button will be as wide as its content.\n * - `'full'`: The button will be as wide as its container.\n *\n * @default 'auto'\n */\n width?: 'auto' | 'full'\n\n /**\n * The alignment of the button label inside the button.\n *\n * @default 'center'\n */\n align?: 'start' | 'center' | 'end'\n}\n\n/**\n * A button element that displays a text label and optionally a start or end icon. It follows the\n * [WAI-ARIA Button Pattern](https://www.w3.org/TR/wai-aria-practices/#button).\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n variant,\n tone = 'normal',\n size = 'normal',\n shape = 'normal',\n type = 'button',\n disabled = false,\n loading = false,\n tooltip,\n render,\n onClick,\n exceptionallySetClassName,\n children,\n startIcon,\n endIcon,\n width = 'auto',\n align = 'center',\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Role.button\n {...props}\n render={render}\n type={render != null ? undefined : type}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={classNames([\n getBoxClassNames({ width }),\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n shape === 'rounded' ? styles['shape-rounded'] : null,\n disabled ? styles.disabled : null,\n ])}\n >\n <>\n {startIcon ? (\n <Box display=\"flex\" className={styles.startIcon} aria-hidden>\n {loading && !endIcon ? <Spinner /> : startIcon}\n </Box>\n ) : null}\n\n {children ? (\n <Box\n as=\"span\"\n className={styles.label}\n overflow=\"hidden\"\n width={width === 'full' ? 'full' : undefined}\n textAlign={width === 'auto' ? 'center' : align}\n >\n {children}\n </Box>\n ) : null}\n\n {endIcon || (loading && !startIcon) ? (\n <Box display=\"flex\" className={styles.endIcon} aria-hidden>\n {loading ? <Spinner /> : endIcon}\n </Box>\n ) : null}\n </>\n </Role.button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{buttonElement}</Tooltip> : buttonElement\n})\n\ninterface IconButtonProps extends CommonButtonProps {\n /**\n * The icon to display inside the button.\n */\n icon: IconElement\n\n /**\n * The button label.\n *\n * It is used for assistive technologies, and it is also shown as a tooltip (if not tooltip is\n * provided explicitly).\n */\n 'aria-label': string\n}\n\n/**\n * A button element that displays an icon only, visually, though it is semantically labelled. It\n * also makes sure to always show a tooltip with its label. It follows the\n * [WAI-ARIA Button Pattern](https://www.w3.org/TR/wai-aria-practices/#button).\n */\nconst IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n {\n variant,\n tone = 'normal',\n size = 'normal',\n shape = 'normal',\n type = 'button',\n disabled = false,\n loading = false,\n tooltip,\n render,\n onClick,\n exceptionallySetClassName,\n children,\n icon,\n ...props\n },\n ref,\n) {\n const isDisabled = loading || disabled\n const buttonElement = (\n <Role.button\n {...props}\n render={render}\n type={render != null ? undefined : type}\n ref={ref}\n aria-disabled={isDisabled}\n onClick={isDisabled ? preventDefault : onClick}\n className={classNames([\n exceptionallySetClassName,\n styles.baseButton,\n styles[`variant-${variant}`],\n styles[`tone-${tone}`],\n styles[`size-${size}`],\n shape === 'rounded' ? styles['shape-rounded'] : null,\n styles.iconButton,\n disabled ? styles.disabled : null,\n ])}\n >\n {(loading && <Spinner />) || icon}\n </Role.button>\n )\n\n const tooltipContent = tooltip === undefined ? props['aria-label'] : tooltip\n return tooltipContent ? (\n <Tooltip content={tooltipContent}>{buttonElement}</Tooltip>\n ) : (\n buttonElement\n )\n})\n\nexport type { ButtonProps, IconButtonProps, ButtonVariant, ButtonTone }\nexport { Button, IconButton }\n"],"names":["preventDefault","event","Button","React","forwardRef","ref","variant","tone","size","shape","type","disabled","loading","tooltip","render","onClick","exceptionallySetClassName","children","startIcon","endIcon","width","align","props","isDisabled","buttonElement","createElement","Role","button","_objectSpread","undefined","className","classNames","getBoxClassNames","styles","baseButton","Fragment","Box","display","Spinner","as","label","overflow","textAlign","Tooltip","content","IconButton","icon","iconButton","tooltipContent"],"mappings":";;;;;;;;;;;;AAYA,SAASA,cAAT,CAAwBC,KAAxB,EAAmD;AAC/CA,EAAAA,KAAK,CAACD,cAAN,EAAA,CAAA;AACH,CAAA;AAoHD;;;AAGG;;;AACGE,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAAiD,SAASF,MAAT,CAoB5DG,IAAAA,EAAAA,GApB4D,EAoBzD;EAAA,IAnBH;IACIC,OADJ;AAEIC,IAAAA,IAAI,GAAG,QAFX;AAGIC,IAAAA,IAAI,GAAG,QAHX;AAIIC,IAAAA,KAAK,GAAG,QAJZ;AAKIC,IAAAA,IAAI,GAAG,QALX;AAMIC,IAAAA,QAAQ,GAAG,KANf;AAOIC,IAAAA,OAAO,GAAG,KAPd;IAQIC,OARJ;IASIC,MATJ;IAUIC,OAVJ;IAWIC,yBAXJ;IAYIC,QAZJ;IAaIC,SAbJ;IAcIC,OAdJ;AAeIC,IAAAA,KAAK,GAAG,MAfZ;AAgBIC,IAAAA,KAAK,GAAG,QAAA;GAGT,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,UAAU,GAAGX,OAAO,IAAID,QAA9B,CAAA;EACA,MAAMa,aAAa,gBACfrB,KAAA,CAAAsB,aAAA,CAACC,IAAI,CAACC,MAAN,EAAAC,cAAA,CAAAA,cAAA,CAAA,EAAA,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B,EAAmCxB,aAAnC,CADiB,GAGjBA,aAHJ,CAAA;AAKH,CAjDkB;;;;"}
@@ -8,8 +8,6 @@ import { useForkRef } from './use-fork-ref.js';
8
8
 
9
9
  const _excluded = ["label", "icon", "disabled", "indeterminate", "defaultChecked", "onChange"];
10
10
  const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref, ref) {
11
- var _ref2, _props$checked, _props$checked2;
12
-
13
11
  let {
14
12
  label,
15
13
  icon,
@@ -34,8 +32,8 @@ const CheckboxField = /*#__PURE__*/React.forwardRef(function CheckboxField(_ref,
34
32
  }
35
33
 
36
34
  const [keyFocused, setKeyFocused] = React.useState(false);
37
- const [checkedState, setChecked] = React.useState((_ref2 = (_props$checked = props.checked) != null ? _props$checked : defaultChecked) != null ? _ref2 : false);
38
- const isChecked = (_props$checked2 = props.checked) != null ? _props$checked2 : checkedState;
35
+ const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false);
36
+ const isChecked = props.checked ?? checkedState;
39
37
  const internalRef = React.useRef(null);
40
38
  const combinedRef = useForkRef(internalRef, ref);
41
39
  React.useEffect(function setIndeterminate() {
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-field.js","sources":["../../src/checkbox-field/checkbox-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Text } from '../text'\nimport { CheckboxIcon } from './checkbox-icon'\n\nimport styles from './checkbox-field.module.css'\nimport { useForkRef } from './use-fork-ref'\n\ninterface CheckboxFieldProps\n extends Omit<\n JSX.IntrinsicElements['input'],\n | 'type'\n | 'className'\n | 'disabled'\n | 'aria-controls'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n > {\n 'aria-checked'?: never\n /**\n *\n * Identifies the set of checkboxes controlled by the mixed checkbox for assistive technologies.\n */\n 'aria-controls'?: string\n\n /**\n * Identifies the element (or elements) that describes the checkbox for assistive technologies.\n */\n 'aria-describedby'?: string\n\n /**\n * Defines a string value that labels the current checkbox for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current checkbox for assistive technologies.\n */\n 'aria-labelledby'?: string\n\n /**\n * Defines whether or not the checkbox is disabled.\n */\n disabled?: boolean\n\n /**\n * The label for the checkbox element.\n */\n label?: React.ReactNode\n\n /**\n * The icon that should be added to the checkbox label.\n */\n icon?: React.ReactElement | string | number\n\n /**\n * Defines whether or not the checkbox can be of a `mixed` state.\n */\n indeterminate?: boolean\n}\n\nconst CheckboxField = React.forwardRef<HTMLInputElement, CheckboxFieldProps>(function CheckboxField(\n { label, icon, disabled, indeterminate, defaultChecked, onChange, ...props },\n ref,\n) {\n const isControlledComponent = typeof props.checked === 'boolean'\n if (typeof indeterminate === 'boolean' && !isControlledComponent) {\n // eslint-disable-next-line no-console\n console.warn('Cannot use indeterminate on an uncontrolled checkbox')\n indeterminate = undefined\n }\n\n if (!label && !props['aria-label'] && !props['aria-labelledby']) {\n // eslint-disable-next-line no-console\n console.warn('A Checkbox needs a label')\n }\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useForkRef(internalRef, ref)\n React.useEffect(\n function setIndeterminate() {\n if (internalRef.current && typeof indeterminate === 'boolean') {\n internalRef.current.indeterminate = indeterminate\n }\n },\n [indeterminate],\n )\n\n return (\n <Box\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n >\n <input\n {...props}\n ref={combinedRef}\n type=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : isChecked}\n checked={isChecked}\n disabled={disabled}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n <CheckboxIcon\n checked={isChecked}\n disabled={disabled}\n indeterminate={indeterminate}\n aria-hidden\n />\n {icon ? (\n <Box display=\"flex\" className={styles.icon} aria-hidden>\n {icon}\n </Box>\n ) : null}\n {label ? (\n <Box display=\"flex\" className={styles.label}>\n <Text>{label}</Text>\n </Box>\n ) : null}\n </Box>\n )\n})\n\nexport { CheckboxField }\nexport type { CheckboxFieldProps }\n"],"names":["CheckboxField","React","forwardRef","ref","label","icon","disabled","indeterminate","defaultChecked","onChange","props","isControlledComponent","checked","console","warn","undefined","keyFocused","setKeyFocused","useState","checkedState","setChecked","isChecked","internalRef","useRef","combinedRef","useForkRef","useEffect","setIndeterminate","current","createElement","Box","as","display","alignItems","className","styles","container","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","CheckboxIcon","Text"],"mappings":";;;;;;;;;AA8DMA,MAAAA,aAAa,gBAAGC,KAAK,CAACC,UAAN,CAAuD,SAASF,aAAT,CAEzEG,IAAAA,EAAAA,GAFyE,EAEtE;AAAA,EAAA,IAAA,KAAA,EAAA,cAAA,EAAA,eAAA,CAAA;;EAAA,IADH;IAAEC,KAAF;IAASC,IAAT;IAAeC,QAAf;IAAyBC,aAAzB;IAAwCC,cAAxC;AAAwDC,IAAAA,QAAAA;GACrD,GAAA,IAAA;AAAA,MADkEC,KAClE,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,qBAAqB,GAAG,OAAOD,KAAK,CAACE,OAAb,KAAyB,SAAvD,CAAA;;AACA,EAAA,IAAI,OAAOL,aAAP,KAAyB,SAAzB,IAAsC,CAACI,qBAA3C,EAAkE;AAC9D;IACAE,OAAO,CAACC,IAAR,CAAa,sDAAb,CAAA,CAAA;AACAP,IAAAA,aAAa,GAAGQ,SAAhB,CAAA;AACH,GAAA;;AAED,EAAA,IAAI,CAACX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IAAAA,QAAQ,EAAEA,QAFD;AAGTC,IAAAA,aAAa,EAAEA,aAHN;IAKX,aAAA,EAAA,IAAA;GALF,CAjCJ,EAuCKF,IAAI,gBACDJ,mBAAA,CAAC6B,GAAD,EAAI;AAACE,IAAAA,OAAO,EAAC,MAAT;IAAgBE,SAAS,EAAEC,gBAAM,CAAC9B,IAAlC;IACC,aAAA,EAAA,IAAA;AADD,GAAJ,EACKA,IADL,CADC,GAID,IA3CR,EA4CKD,KAAK,gBACFH,mBAAA,CAAC6B,GAAD,EAAI;AAACE,IAAAA,OAAO,EAAC,MAAT;IAAgBE,SAAS,EAAEC,gBAAM,CAAC/B,KAAAA;AAAlC,GAAJ,eACIH,KAAA,CAAA4B,aAAA,CAACe,IAAD,EAAK,IAAL,EAAOxC,KAAP,CADJ,CADE,GAIF,IAhDR,CADJ,CAAA;AAoDH,CAnFqB;;;;"}
1
+ {"version":3,"file":"checkbox-field.js","sources":["../../src/checkbox-field/checkbox-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Text } from '../text'\nimport { CheckboxIcon } from './checkbox-icon'\n\nimport styles from './checkbox-field.module.css'\nimport { useForkRef } from './use-fork-ref'\n\ninterface CheckboxFieldProps\n extends Omit<\n JSX.IntrinsicElements['input'],\n | 'type'\n | 'className'\n | 'disabled'\n | 'aria-controls'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n > {\n 'aria-checked'?: never\n /**\n *\n * Identifies the set of checkboxes controlled by the mixed checkbox for assistive technologies.\n */\n 'aria-controls'?: string\n\n /**\n * Identifies the element (or elements) that describes the checkbox for assistive technologies.\n */\n 'aria-describedby'?: string\n\n /**\n * Defines a string value that labels the current checkbox for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current checkbox for assistive technologies.\n */\n 'aria-labelledby'?: string\n\n /**\n * Defines whether or not the checkbox is disabled.\n */\n disabled?: boolean\n\n /**\n * The label for the checkbox element.\n */\n label?: React.ReactNode\n\n /**\n * The icon that should be added to the checkbox label.\n */\n icon?: React.ReactElement | string | number\n\n /**\n * Defines whether or not the checkbox can be of a `mixed` state.\n */\n indeterminate?: boolean\n}\n\nconst CheckboxField = React.forwardRef<HTMLInputElement, CheckboxFieldProps>(function CheckboxField(\n { label, icon, disabled, indeterminate, defaultChecked, onChange, ...props },\n ref,\n) {\n const isControlledComponent = typeof props.checked === 'boolean'\n if (typeof indeterminate === 'boolean' && !isControlledComponent) {\n // eslint-disable-next-line no-console\n console.warn('Cannot use indeterminate on an uncontrolled checkbox')\n indeterminate = undefined\n }\n\n if (!label && !props['aria-label'] && !props['aria-labelledby']) {\n // eslint-disable-next-line no-console\n console.warn('A Checkbox needs a label')\n }\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useForkRef(internalRef, ref)\n React.useEffect(\n function setIndeterminate() {\n if (internalRef.current && typeof indeterminate === 'boolean') {\n internalRef.current.indeterminate = indeterminate\n }\n },\n [indeterminate],\n )\n\n return (\n <Box\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n >\n <input\n {...props}\n ref={combinedRef}\n type=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : isChecked}\n checked={isChecked}\n disabled={disabled}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n <CheckboxIcon\n checked={isChecked}\n disabled={disabled}\n indeterminate={indeterminate}\n aria-hidden\n />\n {icon ? (\n <Box display=\"flex\" className={styles.icon} aria-hidden>\n {icon}\n </Box>\n ) : null}\n {label ? (\n <Box display=\"flex\" className={styles.label}>\n <Text>{label}</Text>\n </Box>\n ) : null}\n </Box>\n )\n})\n\nexport { CheckboxField }\nexport type { CheckboxFieldProps }\n"],"names":["CheckboxField","React","forwardRef","ref","label","icon","disabled","indeterminate","defaultChecked","onChange","props","isControlledComponent","checked","console","warn","undefined","keyFocused","setKeyFocused","useState","checkedState","setChecked","isChecked","internalRef","useRef","combinedRef","useForkRef","useEffect","setIndeterminate","current","createElement","Box","as","display","alignItems","className","styles","container","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","CheckboxIcon","Text"],"mappings":";;;;;;;;;AA8DMA,MAAAA,aAAa,gBAAGC,KAAK,CAACC,UAAN,CAAuD,SAASF,aAAT,CAEzEG,IAAAA,EAAAA,GAFyE,EAEtE;EAAA,IADH;IAAEC,KAAF;IAASC,IAAT;IAAeC,QAAf;IAAyBC,aAAzB;IAAwCC,cAAxC;AAAwDC,IAAAA,QAAAA;GACrD,GAAA,IAAA;AAAA,MADkEC,KAClE,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,qBAAqB,GAAG,OAAOD,KAAK,CAACE,OAAb,KAAyB,SAAvD,CAAA;;AACA,EAAA,IAAI,OAAOL,aAAP,KAAyB,SAAzB,IAAsC,CAACI,qBAA3C,EAAkE;AAC9D;IACAE,OAAO,CAACC,IAAR,CAAa,sDAAb,CAAA,CAAA;AACAP,IAAAA,aAAa,GAAGQ,SAAhB,CAAA;AACH,GAAA;;AAED,EAAA,IAAI,CAACX,KAAD,IAAU,CAACM,KAAK,CAAC,YAAD,CAAhB,IAAkC,CAACA,KAAK,CAAC,iBAAD,CAA5C,EAAiE;AAC7D;IACAG,OAAO,CAACC,IAAR,CAAa,0BAAb,CAAA,CAAA;AACH,GAAA;;EAED,MAAM,CAACE,UAAD,EAAaC,aAAb,CAAA,GAA8BhB,KAAK,CAACiB,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ACE,IAAAA,OAAO,EAAC,MAAT;IAAgBE,SAAS,EAAEC,gBAAM,CAAC/B,KAAAA;AAAlC,GAAJ,eACIH,KAAA,CAAA4B,aAAA,CAACe,IAAD,EAAK,IAAL,EAAOxC,KAAP,CADJ,CADE,GAIF,IAhDR,CADJ,CAAA;AAoDH,CAnFqB;;;;"}
@@ -21,7 +21,7 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
21
21
  } = _ref,
22
22
  props = _objectWithoutProperties(_ref, _excluded);
23
23
 
24
- const className = classNames('reactist_button', variant ? "reactist_button--" + variant : null, size !== 'default' ? "reactist_button--" + size : null, {
24
+ const className = classNames('reactist_button', variant ? `reactist_button--${variant}` : null, size !== 'default' ? `reactist_button--${size}` : null, {
25
25
  'reactist_button--loading': loading
26
26
  }, props.className);
27
27
  const button = /*#__PURE__*/React.createElement("button", _objectSpread2(_objectSpread2({}, props), {}, {
@@ -1 +1 @@
1
- {"version":3,"file":"deprecated-button.js","sources":["../../../src/components/deprecated-button/deprecated-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport { Tooltip } from '../../tooltip'\n\nimport './deprecated-button.less'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\n/** @deprecated */\nexport type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'link'\n\n/** @deprecated */\nexport type ButtonSize = 'default' | 'small' | 'large'\n\n/** @deprecated */\nexport type ButtonProps = Omit<NativeButtonProps, 'title' | 'ref'> & {\n /**\n * Loading style. When true it disables the button, but it also adds a visual indication of\n * some in-progress operation going on.\n */\n loading?: boolean\n /**\n * Controls visually how the button shows up from a predefined set of kinds of buttons.\n */\n variant?: ButtonVariant\n /**\n * The size of the button. If not provided it shows up in a normal size.\n */\n size?: ButtonSize\n /**\n * Tooltip that is displayed on hover.\n *\n * This replaces `title` which is not supported for these buttons to avoid confusion.\n */\n tooltip?: React.ReactNode\n}\n\n/**\n * @deprecated\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n type = 'button',\n variant,\n size = 'default',\n loading = false,\n disabled = false,\n tooltip,\n onClick,\n children,\n ...props\n },\n ref,\n) {\n const className = classNames(\n 'reactist_button',\n variant ? `reactist_button--${variant}` : null,\n size !== 'default' ? `reactist_button--${size}` : null,\n { 'reactist_button--loading': loading },\n props.className,\n )\n\n const button = (\n <button\n {...props}\n ref={ref}\n type={type}\n className={className}\n aria-disabled={disabled || loading}\n onClick={disabled || loading ? undefined : onClick}\n >\n {children}\n </button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{button}</Tooltip> : button\n})\n\nButton.displayName = 'Button'\n\nButton.defaultProps = {\n size: 'default',\n loading: false,\n disabled: false,\n}\n\nexport { Button }\n"],"names":["Button","React","forwardRef","ref","type","variant","size","loading","disabled","tooltip","onClick","children","props","className","classNames","button","createElement","undefined","Tooltip","content","displayName","defaultProps"],"mappings":";;;;;;AAyCA;;AAEG;;AACGA,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAAiD,SAASF,MAAT,CAY5DG,IAAAA,EAAAA,GAZ4D,EAYzD;EAAA,IAXH;AACIC,IAAAA,IAAI,GAAG,QADX;IAEIC,OAFJ;AAGIC,IAAAA,IAAI,GAAG,SAHX;AAIIC,IAAAA,OAAO,GAAG,KAJd;AAKIC,IAAAA,QAAQ,GAAG,KALf;IAMIC,OANJ;IAOIC,OAPJ;AAQIC,IAAAA,QAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AAEH,EAAA,MAAMC,SAAS,GAAGC,UAAU,CACxB,iBADwB,EAExBT,OAAO,GAAuBA,mBAAAA,GAAAA,OAAvB,GAAmC,IAFlB,EAGxBC,IAAI,KAAK,SAAT,yBAAyCA,IAAzC,GAAkD,IAH1B,EAIxB;IAAE,0BAA4BC,EAAAA,OAAAA;AAA9B,GAJwB,EAKxBK,KAAK,CAACC,SALkB,CAA5B,CAAA;EAQA,MAAME,MAAM,gBACRd,KACQ,CAAAe,aADR,CACQ,QADR,oCACQJ,KADR,CAAA,EAAA,EAAA,EAAA;AAEIT,IAAAA,GAAG,EAAEA,GAFT;AAGIC,IAAAA,IAAI,EAAEA,IAHV;AAIIS,IAAAA,SAAS,EAAEA,SAJf;IAKmB,eAAAL,EAAAA,QAAQ,IAAID,OAL/B;AAMIG,IAAAA,OAAO,EAAEF,QAAQ,IAAID,OAAZ,GAAsBU,SAAtB,GAAkCP,OAAAA;AAN/C,GAAA,CAAA,EAQKC,QARL,CADJ,CAAA;AAaA,EAAA,OAAOF,OAAO,gBAAGR,KAAA,CAAAe,aAAA,CAACE,OAAD,EAAS;AAAAC,IAAAA,OAAO,EAAEV,OAAAA;AAAT,GAAT,EAA4BM,MAA5B,CAAH,GAAmDA,MAAjE,CAAA;AACH,CApCc,EAAf;AAsCAf,MAAM,CAACoB,WAAP,GAAqB,QAArB,CAAA;AAEApB,MAAM,CAACqB,YAAP,GAAsB;AAClBf,EAAAA,IAAI,EAAE,SADY;AAElBC,EAAAA,OAAO,EAAE,KAFS;AAGlBC,EAAAA,QAAQ,EAAE,KAAA;AAHQ,CAAtB;;;;"}
1
+ {"version":3,"file":"deprecated-button.js","sources":["../../../src/components/deprecated-button/deprecated-button.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\n\nimport { Tooltip } from '../../tooltip'\n\nimport './deprecated-button.less'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\n/** @deprecated */\nexport type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'link'\n\n/** @deprecated */\nexport type ButtonSize = 'default' | 'small' | 'large'\n\n/** @deprecated */\nexport type ButtonProps = Omit<NativeButtonProps, 'title' | 'ref'> & {\n /**\n * Loading style. When true it disables the button, but it also adds a visual indication of\n * some in-progress operation going on.\n */\n loading?: boolean\n /**\n * Controls visually how the button shows up from a predefined set of kinds of buttons.\n */\n variant?: ButtonVariant\n /**\n * The size of the button. If not provided it shows up in a normal size.\n */\n size?: ButtonSize\n /**\n * Tooltip that is displayed on hover.\n *\n * This replaces `title` which is not supported for these buttons to avoid confusion.\n */\n tooltip?: React.ReactNode\n}\n\n/**\n * @deprecated\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n type = 'button',\n variant,\n size = 'default',\n loading = false,\n disabled = false,\n tooltip,\n onClick,\n children,\n ...props\n },\n ref,\n) {\n const className = classNames(\n 'reactist_button',\n variant ? `reactist_button--${variant}` : null,\n size !== 'default' ? `reactist_button--${size}` : null,\n { 'reactist_button--loading': loading },\n props.className,\n )\n\n const button = (\n <button\n {...props}\n ref={ref}\n type={type}\n className={className}\n aria-disabled={disabled || loading}\n onClick={disabled || loading ? undefined : onClick}\n >\n {children}\n </button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{button}</Tooltip> : button\n})\n\nButton.displayName = 'Button'\n\nButton.defaultProps = {\n size: 'default',\n loading: false,\n disabled: false,\n}\n\nexport { Button }\n"],"names":["Button","React","forwardRef","ref","type","variant","size","loading","disabled","tooltip","onClick","children","props","className","classNames","button","createElement","undefined","Tooltip","content","displayName","defaultProps"],"mappings":";;;;;;AAyCA;;AAEG;;AACGA,MAAAA,MAAM,gBAAGC,KAAK,CAACC,UAAN,CAAiD,SAASF,MAAT,CAY5DG,IAAAA,EAAAA,GAZ4D,EAYzD;EAAA,IAXH;AACIC,IAAAA,IAAI,GAAG,QADX;IAEIC,OAFJ;AAGIC,IAAAA,IAAI,GAAG,SAHX;AAIIC,IAAAA,OAAO,GAAG,KAJd;AAKIC,IAAAA,QAAQ,GAAG,KALf;IAMIC,OANJ;IAOIC,OAPJ;AAQIC,IAAAA,QAAAA;GAGD,GAAA,IAAA;AAAA,MAFIC,KAEJ,GAAA,wBAAA,CAAA,IAAA,EAA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