@forgedevstack/bear 1.2.6 → 1.2.8

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 (131) hide show
  1. package/README.md +6 -2
  2. package/dist/components/AppBar/AppBar.cjs +1 -1
  3. package/dist/components/AppBar/AppBar.js +37 -36
  4. package/dist/components/AppShell/AppShell.cjs +1 -0
  5. package/dist/components/AppShell/AppShell.const.cjs +1 -0
  6. package/dist/components/AppShell/AppShell.const.d.ts +19 -0
  7. package/dist/components/AppShell/AppShell.const.js +25 -0
  8. package/dist/components/AppShell/AppShell.d.ts +3 -0
  9. package/dist/components/AppShell/AppShell.js +82 -0
  10. package/dist/components/AppShell/AppShell.types.d.ts +16 -0
  11. package/dist/components/AppShell/index.d.ts +2 -0
  12. package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
  13. package/dist/components/Autocomplete/Autocomplete.js +32 -32
  14. package/dist/components/Backdrop/Backdrop.cjs +1 -1
  15. package/dist/components/Backdrop/Backdrop.const.cjs +1 -1
  16. package/dist/components/Backdrop/Backdrop.const.d.ts +2 -1
  17. package/dist/components/Backdrop/Backdrop.const.js +4 -3
  18. package/dist/components/Backdrop/Backdrop.js +36 -29
  19. package/dist/components/Backdrop/Backdrop.types.d.ts +2 -0
  20. package/dist/components/Banner/Banner.cjs +1 -0
  21. package/dist/components/Banner/Banner.const.cjs +1 -0
  22. package/dist/components/Banner/Banner.const.d.ts +21 -0
  23. package/dist/components/Banner/Banner.const.js +33 -0
  24. package/dist/components/Banner/Banner.d.ts +3 -0
  25. package/dist/components/Banner/Banner.js +70 -0
  26. package/dist/components/Banner/Banner.types.d.ts +21 -0
  27. package/dist/components/Banner/helpers/BannerErrorSvg.cjs +1 -0
  28. package/dist/components/Banner/helpers/BannerErrorSvg.d.ts +2 -0
  29. package/dist/components/Banner/helpers/BannerErrorSvg.js +22 -0
  30. package/dist/components/Banner/helpers/BannerInfoSvg.cjs +1 -0
  31. package/dist/components/Banner/helpers/BannerInfoSvg.d.ts +2 -0
  32. package/dist/components/Banner/helpers/BannerInfoSvg.js +22 -0
  33. package/dist/components/Banner/helpers/BannerSuccessSvg.cjs +1 -0
  34. package/dist/components/Banner/helpers/BannerSuccessSvg.d.ts +2 -0
  35. package/dist/components/Banner/helpers/BannerSuccessSvg.js +21 -0
  36. package/dist/components/Banner/helpers/BannerWarningSvg.cjs +1 -0
  37. package/dist/components/Banner/helpers/BannerWarningSvg.d.ts +2 -0
  38. package/dist/components/Banner/helpers/BannerWarningSvg.js +22 -0
  39. package/dist/components/Banner/helpers/index.d.ts +4 -0
  40. package/dist/components/Banner/index.d.ts +2 -0
  41. package/dist/components/Button/Button.cjs +1 -1
  42. package/dist/components/Button/Button.js +48 -48
  43. package/dist/components/Chip/Chip.cjs +1 -1
  44. package/dist/components/Chip/Chip.const.cjs +1 -1
  45. package/dist/components/Chip/Chip.const.d.ts +10 -0
  46. package/dist/components/Chip/Chip.const.js +11 -1
  47. package/dist/components/Chip/Chip.js +24 -22
  48. package/dist/components/ChipGroup/ChipGroup.cjs +1 -1
  49. package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -1
  50. package/dist/components/ChipGroup/ChipGroup.const.d.ts +6 -3
  51. package/dist/components/ChipGroup/ChipGroup.const.js +6 -3
  52. package/dist/components/ChipGroup/ChipGroup.js +83 -29
  53. package/dist/components/ChipGroup/ChipGroup.types.d.ts +5 -0
  54. package/dist/components/Drawer/Drawer.cjs +1 -1
  55. package/dist/components/Drawer/Drawer.js +57 -54
  56. package/dist/components/EmptyState/EmptyState.cjs +1 -1
  57. package/dist/components/EmptyState/EmptyState.const.cjs +1 -0
  58. package/dist/components/EmptyState/EmptyState.const.d.ts +26 -1
  59. package/dist/components/EmptyState/EmptyState.const.js +29 -0
  60. package/dist/components/EmptyState/EmptyState.js +49 -31
  61. package/dist/components/Input/Input.cjs +1 -1
  62. package/dist/components/Input/Input.const.cjs +1 -1
  63. package/dist/components/Input/Input.const.d.ts +10 -0
  64. package/dist/components/Input/Input.const.js +16 -6
  65. package/dist/components/Input/Input.js +96 -96
  66. package/dist/components/MessageList/MessageList.cjs +1 -1
  67. package/dist/components/MessageList/MessageList.js +98 -92
  68. package/dist/components/MessageList/MessageList.types.d.ts +2 -0
  69. package/dist/components/Modal/Modal.cjs +1 -1
  70. package/dist/components/Modal/Modal.const.cjs +1 -1
  71. package/dist/components/Modal/Modal.const.js +7 -8
  72. package/dist/components/Modal/Modal.js +60 -55
  73. package/dist/components/PageHeader/PageHeader.cjs +1 -0
  74. package/dist/components/PageHeader/PageHeader.const.cjs +1 -0
  75. package/dist/components/PageHeader/PageHeader.const.d.ts +6 -0
  76. package/dist/components/PageHeader/PageHeader.const.js +9 -0
  77. package/dist/components/PageHeader/PageHeader.d.ts +3 -0
  78. package/dist/components/PageHeader/PageHeader.js +57 -0
  79. package/dist/components/PageHeader/PageHeader.types.d.ts +10 -0
  80. package/dist/components/PageHeader/index.d.ts +2 -0
  81. package/dist/components/Select/Select.cjs +1 -1
  82. package/dist/components/Select/Select.js +108 -99
  83. package/dist/components/Select/Select.types.d.ts +3 -1
  84. package/dist/components/Snackbar/Snackbar.cjs +1 -1
  85. package/dist/components/Snackbar/Snackbar.js +62 -60
  86. package/dist/components/Snackbar/Snackbar.types.d.ts +2 -0
  87. package/dist/components/Tabs/Tabs.cjs +1 -1
  88. package/dist/components/Tabs/Tabs.const.cjs +1 -0
  89. package/dist/components/Tabs/Tabs.const.d.ts +2 -0
  90. package/dist/components/Tabs/Tabs.const.js +5 -0
  91. package/dist/components/Tabs/Tabs.js +40 -35
  92. package/dist/components/Tabs/Tabs.types.d.ts +1 -0
  93. package/dist/components/Toast/Toast.cjs +1 -1
  94. package/dist/components/Toast/Toast.const.cjs +1 -1
  95. package/dist/components/Toast/Toast.const.js +7 -15
  96. package/dist/components/Toast/Toast.js +99 -95
  97. package/dist/components/index.cjs +1 -1
  98. package/dist/components/index.d.ts +6 -0
  99. package/dist/components/index.js +277 -271
  100. package/dist/context/BearProvider.js +1 -1
  101. package/dist/hooks/index.cjs +1 -1
  102. package/dist/hooks/index.d.ts +3 -0
  103. package/dist/hooks/index.js +45 -41
  104. package/dist/hooks/useBreakpoint/index.d.ts +4 -0
  105. package/dist/hooks/useBreakpoint/useBreakpoint.cjs +1 -0
  106. package/dist/hooks/useBreakpoint/useBreakpoint.const.cjs +1 -0
  107. package/dist/hooks/useBreakpoint/useBreakpoint.const.d.ts +8 -0
  108. package/dist/hooks/useBreakpoint/useBreakpoint.const.js +10 -0
  109. package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +2 -0
  110. package/dist/hooks/useBreakpoint/useBreakpoint.js +26 -0
  111. package/dist/hooks/useBreakpoint/useBreakpoint.types.d.ts +12 -0
  112. package/dist/index.cjs +1 -1
  113. package/dist/index.js +452 -433
  114. package/dist/styles.css +0 -4
  115. package/dist/utils/generateBearId.const.cjs +1 -1
  116. package/dist/utils/generateBearId.const.d.ts +4 -2
  117. package/dist/utils/generateBearId.const.js +6 -4
  118. package/dist/utils/generateBearId.utils.cjs +1 -1
  119. package/dist/utils/generateBearId.utils.js +33 -21
  120. package/dist/utils/index.cjs +1 -1
  121. package/dist/utils/index.d.ts +4 -1
  122. package/dist/utils/index.js +27 -18
  123. package/dist/utils/liveRegion.const.cjs +1 -0
  124. package/dist/utils/liveRegion.const.d.ts +5 -0
  125. package/dist/utils/liveRegion.const.js +17 -0
  126. package/dist/utils/liveRegion.utils.cjs +1 -0
  127. package/dist/utils/liveRegion.utils.d.ts +7 -0
  128. package/dist/utils/liveRegion.utils.js +10 -0
  129. package/dist/utils/useBearId.cjs +1 -1
  130. package/dist/utils/useBearId.js +5 -4
  131. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),b=require("react"),a=require("./Select.const.cjs"),R=require("../Icon/index.cjs"),B=require("../Portal/Portal.cjs"),o=require("../../utils/cn.cjs"),U=require("../../utils/generateBearId.utils.cjs"),z=require("../../utils/useBearId.cjs"),F=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");require("../FormControl/FormControl.context.cjs");const X=I=>{const{options:v,value:t,onChange:l,placeholder:E=a.SELECT_DEFAULT_PLACEHOLDER,label:c,error:n,disabled:i=!1,size:w="md",fullWidth:y=!1,displayEmpty:m=!1,renderValue:L,native:u=!1,className:p,id:A,testId:T}=I,P=z.useBearId("Select"),_=U.resolveBearId(A,P),[s,x]=b.useState(!1),[S,q]=b.useState({top:0,left:0,width:0}),h=b.useRef(null),O=b.useRef(null),f=!!n,C=v.find(e=>e.value===t),g=t===void 0||t==="",j=g||m&&g,D=b.useCallback(()=>x(!1),[]);F.useClickOutsideMultiple([h,O],D,{enabled:s&&!u});const M=e=>{l==null||l(e),x(!1)};b.useEffect(()=>{if(!s||u)return;const e=()=>{var k;const d=(k=h.current)==null?void 0:k.getBoundingClientRect();d&&q({top:d.bottom+a.SELECT_MENU_OFFSET_PX,left:Math.max(a.SELECT_MENU_EDGE_PAD_PX,Math.min(d.left,window.innerWidth-d.width-a.SELECT_MENU_EDGE_PAD_PX)),width:d.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[s,u]);const $=L&&!g?L(t):j||!C?E:C.label,N={backgroundColor:"var(--bear-bg-primary)",borderColor:f?void 0:"var(--bear-border-default)",color:C&&!j?"var(--bear-text-primary)":"var(--bear-text-muted)"};return u?r.jsxs("div",{id:_,"data-testid":T,className:o.cn(a.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",y&&"bear-w-full"),children:[c&&r.jsx("label",{htmlFor:`${_}-native`,className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("select",{id:`${_}-native`,disabled:i,value:t??"",onChange:e=>l==null?void 0:l(e.target.value),className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__native`,"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",f?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500",i&&"bear-opacity-50 bear-cursor-not-allowed",a.SELECT_SIZE_CLASSES[w],p),style:N,"aria-invalid":f||void 0,children:[(m||E)&&r.jsx("option",{value:"",disabled:!m,children:E}),v.map(e=>r.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value))]}),n&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:n})]}):r.jsxs("div",{ref:h,id:_,"data-testid":T,className:o.cn(a.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",y&&"bear-w-full"),children:[c&&r.jsx("label",{className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:c}),r.jsxs("button",{type:"button",disabled:i,onClick:()=>!i&&x(!s),className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__trigger`,"bear-flex bear-items-center bear-justify-between bear-w-full","bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",f?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",i&&"bear-opacity-50 bear-cursor-not-allowed",a.SELECT_SIZE_CLASSES[w],p),style:N,"aria-haspopup":"listbox","aria-expanded":s,children:[r.jsx("span",{className:`${a.S_E_L_E_C_T_ROOT_CLASS}__value`,children:$}),r.jsx(R.ChevronDownIcon,{className:o.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",s&&"bear-rotate-180"),style:{color:"var(--bear-text-muted)"}})]}),s&&r.jsx(B.Portal,{children:r.jsx("div",{ref:O,className:`${a.S_E_L_E_C_T_ROOT_CLASS}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",top:S.top,left:S.left,width:S.width,zIndex:a.SELECT_MENU_Z_INDEX},role:"listbox",children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:v.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&M(e.value),role:"option","aria-selected":e.value===t,className:o.cn(`${a.S_E_L_E_C_T_ROOT_CLASS}__option`,"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2","bear-text-left bear-transition-colors",e.disabled&&"bear-cursor-not-allowed",e.value===t&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==t&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===t?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===t&&r.jsx(R.CheckIcon,{className:"bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})})}),n&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:n})]})};exports.Select=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),b=require("react"),t=require("./Select.const.cjs"),A=require("../Icon/index.cjs"),Z=require("../Portal/Portal.cjs"),n=require("../../utils/cn.cjs"),G=require("../../utils/generateBearId.utils.cjs"),V=require("../../utils/useBearId.cjs"),W=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const H=require("../../hooks/useFormControl/useFormControl.cjs"),J=P=>{const{options:E,value:s,onChange:i,placeholder:x=t.SELECT_DEFAULT_PLACEHOLDER,label:u,error:S,disabled:D=!1,required:M=!1,size:C="md",fullWidth:T=!1,displayEmpty:m=!1,renderValue:O,native:_=!1,className:j,id:B,testId:N}=P,$=V.useBearId("Select"),f=G.resolveBearId(B,$),a=H.useFormControl(),[l,h]=b.useState(!1),[g,F]=b.useState({top:0,left:0,width:0}),w=b.useRef(null),q=b.useRef(null),d=D||!!(a!=null&&a.disabled),y=M||!!(a!=null&&a.required),o=!!S||!!(a!=null&&a.error),v=typeof S=="string"?S:void 0,p=E.find(e=>e.value===s),L=s===void 0||s==="",I=L||m&&L,U=b.useCallback(()=>h(!1),[]);W.useClickOutsideMultiple([w,q],U,{enabled:l&&!_&&!d});const z=e=>{i==null||i(e),h(!1)};b.useEffect(()=>{if(!l||_)return;const e=()=>{var k;const c=(k=w.current)==null?void 0:k.getBoundingClientRect();c&&F({top:c.bottom+t.SELECT_MENU_OFFSET_PX,left:Math.max(t.SELECT_MENU_EDGE_PAD_PX,Math.min(c.left,window.innerWidth-c.width-t.SELECT_MENU_EDGE_PAD_PX)),width:c.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[l,_]);const X=O&&!L?O(s):I||!p?x:p.label,R={backgroundColor:"var(--bear-bg-primary)",borderColor:o?void 0:"var(--bear-border-default)",color:p&&!I?"var(--bear-text-primary)":"var(--bear-text-muted)"};return _?r.jsxs("div",{id:f,"data-testid":N,className:n.cn(t.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",T&&"bear-w-full"),children:[u&&r.jsx("label",{htmlFor:`${f}-native`,className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:u}),r.jsxs("select",{id:`${f}-native`,disabled:d,required:y,value:s??"",onChange:e=>i==null?void 0:i(e.target.value),className:n.cn(`${t.S_E_L_E_C_T_ROOT_CLASS}__native`,"bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",o?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500",d&&"bear-opacity-50 bear-cursor-not-allowed",t.SELECT_SIZE_CLASSES[C],j),style:R,"aria-invalid":o||void 0,"aria-required":y||void 0,"aria-describedby":a==null?void 0:a.helperId,children:[(m||x)&&r.jsx("option",{value:"",disabled:!m,children:x}),E.map(e=>r.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value))]}),v&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:v})]}):r.jsxs("div",{ref:w,id:f,"data-testid":N,className:n.cn(t.S_E_L_E_C_T_ROOT_CLASS,"bear-relative bear-flex bear-flex-col bear-gap-1.5",T&&"bear-w-full"),children:[u&&r.jsx("label",{className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:u}),r.jsxs("button",{type:"button",disabled:d,onClick:()=>!d&&h(!l),className:n.cn(`${t.S_E_L_E_C_T_ROOT_CLASS}__trigger`,"bear-flex bear-items-center bear-justify-between bear-w-full","bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",o?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",d&&"bear-opacity-50 bear-cursor-not-allowed",t.SELECT_SIZE_CLASSES[C],j),style:R,"aria-haspopup":"listbox","aria-expanded":l,"aria-invalid":o||void 0,"aria-required":y||void 0,"aria-describedby":a==null?void 0:a.helperId,children:[r.jsx("span",{className:`${t.S_E_L_E_C_T_ROOT_CLASS}__value`,children:X}),r.jsx(A.ChevronDownIcon,{className:n.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",l&&"bear-rotate-180"),style:{color:"var(--bear-text-muted)"}})]}),l&&r.jsx(Z.Portal,{children:r.jsx("div",{ref:q,className:`${t.S_E_L_E_C_T_ROOT_CLASS}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",top:g.top,left:g.left,width:g.width,zIndex:t.SELECT_MENU_Z_INDEX},role:"listbox",children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:E.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&z(e.value),role:"option","aria-selected":e.value===s,className:n.cn(`${t.S_E_L_E_C_T_ROOT_CLASS}__option`,"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2","bear-text-left bear-transition-colors",e.disabled&&"bear-cursor-not-allowed",e.value===s&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==s&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===s?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===s&&r.jsx(A.CheckIcon,{className:"bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})})}),v&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:v})]})};exports.Select=J;
@@ -1,151 +1,160 @@
1
- import { jsxs as n, jsx as r } from "react/jsx-runtime";
2
- import { useState as O, useRef as D, useCallback as X, useEffect as V } from "react";
3
- import { SELECT_DEFAULT_PLACEHOLDER as W, SELECT_SIZE_CLASSES as M, S_E_L_E_C_T_ROOT_CLASS as l, SELECT_MENU_Z_INDEX as Z, SELECT_MENU_EDGE_PAD_PX as $, SELECT_MENU_OFFSET_PX as G } from "./Select.const.js";
4
- import { ChevronDownIcon as H, CheckIcon as q } from "../Icon/index.js";
5
- import { Portal as J } from "../Portal/Portal.js";
1
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
2
+ import { useState as B, useRef as R, useCallback as G, useEffect as H } from "react";
3
+ import { SELECT_DEFAULT_PLACEHOLDER as J, SELECT_SIZE_CLASSES as $, S_E_L_E_C_T_ROOT_CLASS as s, SELECT_MENU_Z_INDEX as K, SELECT_MENU_EDGE_PAD_PX as q, SELECT_MENU_OFFSET_PX as Q } from "./Select.const.js";
4
+ import { ChevronDownIcon as Y, CheckIcon as ee } from "../Icon/index.js";
5
+ import { Portal as re } from "../Portal/Portal.js";
6
6
  import { cn as b } from "../../utils/cn.js";
7
- import { resolveBearId as K } from "../../utils/generateBearId.utils.js";
8
- import { useBearId as Q } from "../../utils/useBearId.js";
9
- import { useClickOutsideMultiple as Y } from "../../hooks/useClickOutside.js";
7
+ import { resolveBearId as ae } from "../../utils/generateBearId.utils.js";
8
+ import { useBearId as te } from "../../utils/useBearId.js";
9
+ import { useClickOutsideMultiple as le } from "../../hooks/useClickOutside.js";
10
10
  import "../../context/BearProvider.js";
11
11
  import "../../hooks/useBearComponent/useBearComponent.js";
12
- import "../FormControl/FormControl.context.js";
13
- const ue = (R) => {
12
+ import { useFormControl as se } from "../../hooks/useFormControl/useFormControl.js";
13
+ const xe = (A) => {
14
14
  const {
15
- options: v,
16
- value: a,
17
- onChange: o,
18
- placeholder: h = W,
19
- label: c,
20
- error: s,
21
- disabled: d = !1,
22
- size: y = "md",
23
- fullWidth: C = !1,
24
- displayEmpty: p = !1,
25
- renderValue: N,
26
- native: u = !1,
27
- className: S,
28
- id: A,
29
- testId: L
30
- } = R, j = Q("Select"), f = K(A, j), [t, x] = O(!1), [w, z] = O({
15
+ options: p,
16
+ value: t,
17
+ onChange: i,
18
+ placeholder: h = J,
19
+ label: u,
20
+ error: x,
21
+ disabled: F = !1,
22
+ required: j = !1,
23
+ size: L = "md",
24
+ fullWidth: k = !1,
25
+ displayEmpty: w = !1,
26
+ renderValue: I,
27
+ native: f = !1,
28
+ className: C,
29
+ id: z,
30
+ testId: P
31
+ } = A, U = te("Select"), m = ae(z, U), r = se(), [l, g] = B(!1), [y, X] = B({
31
32
  top: 0,
32
33
  left: 0,
33
34
  width: 0
34
- }), E = D(null), k = D(null), m = !!s, g = v.find((e) => e.value === a), _ = a === void 0 || a === "", I = _ || p && _, B = X(() => x(!1), []);
35
- Y([E, k], B, { enabled: t && !u });
36
- const F = (e) => {
37
- o == null || o(e), x(!1);
35
+ }), E = R(null), T = R(null), d = F || !!(r != null && r.disabled), _ = j || !!(r != null && r.required), o = !!x || !!(r != null && r.error), v = typeof x == "string" ? x : void 0, N = p.find((e) => e.value === t), S = t === void 0 || t === "", D = S || w && S, V = G(() => g(!1), []);
36
+ le([E, T], V, {
37
+ enabled: l && !f && !d
38
+ });
39
+ const W = (e) => {
40
+ i == null || i(e), g(!1);
38
41
  };
39
- V(() => {
40
- if (!t || u) return;
42
+ H(() => {
43
+ if (!l || f) return;
41
44
  const e = () => {
42
- var T;
43
- const i = (T = E.current) == null ? void 0 : T.getBoundingClientRect();
44
- i && z({
45
- top: i.bottom + G,
45
+ var O;
46
+ const n = (O = E.current) == null ? void 0 : O.getBoundingClientRect();
47
+ n && X({
48
+ top: n.bottom + Q,
46
49
  left: Math.max(
47
- $,
48
- Math.min(i.left, window.innerWidth - i.width - $)
50
+ q,
51
+ Math.min(n.left, window.innerWidth - n.width - q)
49
52
  ),
50
- width: i.width
53
+ width: n.width
51
54
  });
52
55
  };
53
56
  return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
54
57
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
55
58
  };
56
- }, [t, u]);
57
- const U = N && !_ ? N(a) : I || !g ? h : g.label, P = {
59
+ }, [l, f]);
60
+ const Z = I && !S ? I(t) : D || !N ? h : N.label, M = {
58
61
  backgroundColor: "var(--bear-bg-primary)",
59
- borderColor: m ? void 0 : "var(--bear-border-default)",
60
- color: g && !I ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
62
+ borderColor: o ? void 0 : "var(--bear-border-default)",
63
+ color: N && !D ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
61
64
  };
62
- return u ? /* @__PURE__ */ n(
65
+ return f ? /* @__PURE__ */ c(
63
66
  "div",
64
67
  {
65
- id: f,
66
- "data-testid": L,
68
+ id: m,
69
+ "data-testid": P,
67
70
  className: b(
68
- l,
71
+ s,
69
72
  "bear-relative bear-flex bear-flex-col bear-gap-1.5",
70
- C && "bear-w-full"
73
+ k && "bear-w-full"
71
74
  ),
72
75
  children: [
73
- c && /* @__PURE__ */ r(
76
+ u && /* @__PURE__ */ a(
74
77
  "label",
75
78
  {
76
- htmlFor: `${f}-native`,
79
+ htmlFor: `${m}-native`,
77
80
  className: "bear-text-sm bear-font-medium",
78
81
  style: { color: "var(--bear-text-secondary)" },
79
- children: c
82
+ children: u
80
83
  }
81
84
  ),
82
- /* @__PURE__ */ n(
85
+ /* @__PURE__ */ c(
83
86
  "select",
84
87
  {
85
- id: `${f}-native`,
88
+ id: `${m}-native`,
86
89
  disabled: d,
87
- value: a ?? "",
88
- onChange: (e) => o == null ? void 0 : o(e.target.value),
90
+ required: _,
91
+ value: t ?? "",
92
+ onChange: (e) => i == null ? void 0 : i(e.target.value),
89
93
  className: b(
90
- `${l}__native`,
94
+ `${s}__native`,
91
95
  "bear-w-full bear-rounded-lg bear-border bear-outline-none bear-transition-all bear-duration-200",
92
96
  "focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
93
- m ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500",
97
+ o ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500",
94
98
  d && "bear-opacity-50 bear-cursor-not-allowed",
95
- M[y],
96
- S
99
+ $[L],
100
+ C
97
101
  ),
98
- style: P,
99
- "aria-invalid": m || void 0,
102
+ style: M,
103
+ "aria-invalid": o || void 0,
104
+ "aria-required": _ || void 0,
105
+ "aria-describedby": r == null ? void 0 : r.helperId,
100
106
  children: [
101
- (p || h) && /* @__PURE__ */ r("option", { value: "", disabled: !p, children: h }),
102
- v.map((e) => /* @__PURE__ */ r("option", { value: e.value, disabled: e.disabled, children: e.label }, e.value))
107
+ (w || h) && /* @__PURE__ */ a("option", { value: "", disabled: !w, children: h }),
108
+ p.map((e) => /* @__PURE__ */ a("option", { value: e.value, disabled: e.disabled, children: e.label }, e.value))
103
109
  ]
104
110
  }
105
111
  ),
106
- s && /* @__PURE__ */ r("p", { className: "bear-text-sm bear-text-red-500", children: s })
112
+ v && /* @__PURE__ */ a("p", { className: "bear-text-sm bear-text-red-500", children: v })
107
113
  ]
108
114
  }
109
- ) : /* @__PURE__ */ n(
115
+ ) : /* @__PURE__ */ c(
110
116
  "div",
111
117
  {
112
118
  ref: E,
113
- id: f,
114
- "data-testid": L,
119
+ id: m,
120
+ "data-testid": P,
115
121
  className: b(
116
- l,
122
+ s,
117
123
  "bear-relative bear-flex bear-flex-col bear-gap-1.5",
118
- C && "bear-w-full"
124
+ k && "bear-w-full"
119
125
  ),
120
126
  children: [
121
- c && /* @__PURE__ */ r("label", { className: "bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)" }, children: c }),
122
- /* @__PURE__ */ n(
127
+ u && /* @__PURE__ */ a("label", { className: "bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)" }, children: u }),
128
+ /* @__PURE__ */ c(
123
129
  "button",
124
130
  {
125
131
  type: "button",
126
132
  disabled: d,
127
- onClick: () => !d && x(!t),
133
+ onClick: () => !d && g(!l),
128
134
  className: b(
129
- `${l}__trigger`,
135
+ `${s}__trigger`,
130
136
  "bear-flex bear-items-center bear-justify-between bear-w-full",
131
137
  "bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200",
132
138
  "focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
133
- m ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
139
+ o ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
134
140
  d && "bear-opacity-50 bear-cursor-not-allowed",
135
- M[y],
136
- S
141
+ $[L],
142
+ C
137
143
  ),
138
- style: P,
144
+ style: M,
139
145
  "aria-haspopup": "listbox",
140
- "aria-expanded": t,
146
+ "aria-expanded": l,
147
+ "aria-invalid": o || void 0,
148
+ "aria-required": _ || void 0,
149
+ "aria-describedby": r == null ? void 0 : r.helperId,
141
150
  children: [
142
- /* @__PURE__ */ r("span", { className: `${l}__value`, children: U }),
143
- /* @__PURE__ */ r(
144
- H,
151
+ /* @__PURE__ */ a("span", { className: `${s}__value`, children: Z }),
152
+ /* @__PURE__ */ a(
153
+ Y,
145
154
  {
146
155
  className: b(
147
156
  "bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",
148
- t && "bear-rotate-180"
157
+ l && "bear-rotate-180"
149
158
  ),
150
159
  style: { color: "var(--bear-text-muted)" }
151
160
  }
@@ -153,51 +162,51 @@ const ue = (R) => {
153
162
  ]
154
163
  }
155
164
  ),
156
- t && /* @__PURE__ */ r(J, { children: /* @__PURE__ */ r(
165
+ l && /* @__PURE__ */ a(re, { children: /* @__PURE__ */ a(
157
166
  "div",
158
167
  {
159
- ref: k,
160
- className: `${l}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,
168
+ ref: T,
169
+ className: `${s}__menu bear-fixed bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden`,
161
170
  style: {
162
171
  backgroundColor: "var(--bear-bg-primary)",
163
172
  borderColor: "var(--bear-border-default)",
164
- top: w.top,
165
- left: w.left,
166
- width: w.width,
167
- zIndex: Z
173
+ top: y.top,
174
+ left: y.left,
175
+ width: y.width,
176
+ zIndex: K
168
177
  },
169
178
  role: "listbox",
170
- children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: v.map((e) => /* @__PURE__ */ n(
179
+ children: /* @__PURE__ */ a("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: p.map((e) => /* @__PURE__ */ c(
171
180
  "button",
172
181
  {
173
182
  type: "button",
174
183
  disabled: e.disabled,
175
- onClick: () => !e.disabled && F(e.value),
184
+ onClick: () => !e.disabled && W(e.value),
176
185
  role: "option",
177
- "aria-selected": e.value === a,
186
+ "aria-selected": e.value === t,
178
187
  className: b(
179
- `${l}__option`,
188
+ `${s}__option`,
180
189
  "bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2",
181
190
  "bear-text-left bear-transition-colors",
182
191
  e.disabled && "bear-cursor-not-allowed",
183
- e.value === a && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",
184
- !e.disabled && e.value !== a && "hover:bear-bg-[var(--bear-bg-tertiary)]"
192
+ e.value === t && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",
193
+ !e.disabled && e.value !== t && "hover:bear-bg-[var(--bear-bg-tertiary)]"
185
194
  ),
186
- style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value === a ? void 0 : { color: "var(--bear-text-secondary)" },
195
+ style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value === t ? void 0 : { color: "var(--bear-text-secondary)" },
187
196
  children: [
188
197
  e.label,
189
- e.value === a && /* @__PURE__ */ r(q, { className: "bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400" })
198
+ e.value === t && /* @__PURE__ */ a(ee, { className: "bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400" })
190
199
  ]
191
200
  },
192
201
  e.value
193
202
  )) })
194
203
  }
195
204
  ) }),
196
- s && /* @__PURE__ */ r("p", { className: "bear-text-sm bear-text-red-500", children: s })
205
+ v && /* @__PURE__ */ a("p", { className: "bear-text-sm bear-text-red-500", children: v })
197
206
  ]
198
207
  }
199
208
  );
200
209
  };
201
210
  export {
202
- ue as Select
211
+ xe as Select
203
212
  };
@@ -18,9 +18,11 @@ export interface SelectProps {
18
18
  /** Select label */
19
19
  label?: string;
20
20
  /** Error message */
21
- error?: string;
21
+ error?: string | boolean;
22
22
  /** Whether select is disabled */
23
23
  disabled?: boolean;
24
+ /** Whether the field is required */
25
+ required?: boolean;
24
26
  /** Select size */
25
27
  size?: 'sm' | 'md' | 'lg';
26
28
  /** Whether select is full width */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),E=require("react-dom"),T=require("../../utils/cn.cjs");require("react");const K=require("../../utils/generateBearId.utils.cjs"),w=require("../../utils/useBearId.cjs"),z=require("../Paper/Paper.cjs"),d=require("../Flex/Flex.cjs"),p=require("../Typography/Typography.cjs"),L=require("../Progress/Progress.cjs"),U=require("../CloseButton/CloseButton.cjs"),s=require("./Snackbar.const.cjs"),X=require("./hooks/useSnackbar.cjs"),Z=(c,a,o,t)=>{const e={zIndex:s.SNACKBAR_Z_INDEX};return c==="top"?e.top=t:e.bottom=t,a==="left"?(e.left=o,e.right="auto"):a==="right"?(e.right=o,e.left="auto"):(e.left="50%",e.right="auto",e.transform="translateX(-50%)"),e},H=c=>{const{open:a,message:o,description:t,action:e,autoHideDuration:f=s.SNACKBAR_DEFAULT_AUTO_HIDE_MS,onClose:i,anchorOrigin:u={vertical:"bottom",horizontal:"center"},offsetX:h=s.SNACKBAR_DEFAULT_OFFSET_X,offsetY:A=s.SNACKBAR_DEFAULT_OFFSET_Y,size:B="md",progress:x=null,progressPosition:b="bottom",progressColor:C="default",countdownProgress:N=!1,showCloseButton:k,closeOnClickOutside:y,container:I,id:O,testId:q,className:D}=c,F=w.useBearId("Snackbar"),R=K.resolveBearId(O,F),_=I??(typeof document<"u"?document.body:null),n=!!i,j=k??n,S=y??n,{surfaceRef:v,progressValue:g}=X.useSnackbar({open:a,autoHideDuration:f,onClose:i,countdownProgress:N,staticProgress:x,closeOnClickOutside:S});if(!a||!_)return null;const l=typeof g=="number",m=l?r.jsx(L.Progress,{value:g,size:"sm",color:C,className:"Bear-Snackbar__progress"}):null,P=r.jsxs(r.Fragment,{children:[S&&n&&r.jsx("div",{className:"Bear-Snackbar__backdrop bear-fixed bear-inset-0",style:{zIndex:s.SNACKBAR_BACKDROP_Z_INDEX},"aria-hidden":!0}),r.jsxs(z.Paper,{ref:v,id:R,"data-testid":q,role:"status","aria-live":"polite",elevation:4,rounded:"lg",padding:"none",background:"transparent",className:T.cn(s.SNACKBAR_ROOT_CLASS,s.SNACKBAR_SURFACE_CLASSES,"bear-fixed bear-flex bear-flex-col bear-overflow-hidden","bear-border bear-border-[var(--bear-border-default)]",s.SNACKBAR_SIZE_PADDING[B],D),style:Z(u.vertical,u.horizontal,h,A),children:[l&&b==="top"&&m,r.jsxs(d.Flex,{className:"Bear-Snackbar__content bear-w-full",align:"center",gap:3,children:[r.jsxs(d.Flex,{direction:"column",className:"Bear-Snackbar__text bear-flex-1 bear-min-w-0",gap:1,children:[o&&r.jsx(p.Typography,{variant:"body2",className:"Bear-Snackbar__message",children:o}),t&&r.jsx(p.Typography,{variant:"caption",color:"muted",className:"Bear-Snackbar__description",children:t})]}),e&&r.jsx(d.Flex,{className:"Bear-Snackbar__action bear-shrink-0",align:"center",children:e}),j&&n&&r.jsx(U.CloseButton,{size:"sm",onClick:i,"aria-label":"Dismiss notification",className:"Bear-Snackbar__close bear-shrink-0"})]}),l&&b==="bottom"&&m]})]});return E.createPortal(P,_)};exports.Snackbar=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),K=require("react-dom"),w=require("../../utils/cn.cjs");require("react");const z=require("../../utils/generateBearId.utils.cjs"),L=require("../../utils/useBearId.cjs"),U=require("../../utils/liveRegion.utils.cjs"),X=require("../Paper/Paper.cjs"),d=require("../Flex/Flex.cjs"),B=require("../Typography/Typography.cjs"),Z=require("../Progress/Progress.cjs"),H=require("../CloseButton/CloseButton.cjs"),s=require("./Snackbar.const.cjs"),M=require("./hooks/useSnackbar.cjs"),G=(i,a,o,t)=>{const e={zIndex:s.SNACKBAR_Z_INDEX};return i==="top"?e.top=t:e.bottom=t,a==="left"?(e.left=o,e.right="auto"):a==="right"?(e.right=o,e.left="auto"):(e.left="50%",e.right="auto",e.transform="translateX(-50%)"),e},V=i=>{const{open:a,message:o,description:t,severity:e="default",action:u,autoHideDuration:h=s.SNACKBAR_DEFAULT_AUTO_HIDE_MS,onClose:c,anchorOrigin:b={vertical:"bottom",horizontal:"center"},offsetX:A=s.SNACKBAR_DEFAULT_OFFSET_X,offsetY:x=s.SNACKBAR_DEFAULT_OFFSET_Y,size:C="md",progress:N=null,progressPosition:_="bottom",progressColor:k="default",countdownProgress:v=!1,showCloseButton:y,closeOnClickOutside:R,container:q,id:I,testId:O,className:D}=i,F=L.useBearId("Snackbar"),P=z.resolveBearId(I,F),g=q??(typeof document<"u"?document.body:null),n=!!c,j=y??n,S=R??n,{surfaceRef:E,progressValue:m}=M.useSnackbar({open:a,autoHideDuration:h,onClose:c,countdownProgress:v,staticProgress:N,closeOnClickOutside:S});if(!a||!g)return null;const p=U.getBearLiveRegionProps(e),l=typeof m=="number",f=l?r.jsx(Z.Progress,{value:m,size:"sm",color:k,className:"Bear-Snackbar__progress"}):null,T=r.jsxs(r.Fragment,{children:[S&&n&&r.jsx("div",{className:"Bear-Snackbar__backdrop bear-fixed bear-inset-0",style:{zIndex:s.SNACKBAR_BACKDROP_Z_INDEX},"aria-hidden":!0}),r.jsxs(X.Paper,{ref:E,id:P,"data-testid":O,role:p.role,"aria-live":p["aria-live"],elevation:4,rounded:"lg",padding:"none",background:"transparent",className:w.cn(s.SNACKBAR_ROOT_CLASS,s.SNACKBAR_SURFACE_CLASSES,"bear-fixed bear-flex bear-flex-col bear-overflow-hidden","bear-border bear-border-[var(--bear-border-default)]",s.SNACKBAR_SIZE_PADDING[C],D),style:G(b.vertical,b.horizontal,A,x),children:[l&&_==="top"&&f,r.jsxs(d.Flex,{className:"Bear-Snackbar__content bear-w-full",align:"center",gap:3,children:[r.jsxs(d.Flex,{direction:"column",className:"Bear-Snackbar__text bear-flex-1 bear-min-w-0",gap:1,children:[o&&r.jsx(B.Typography,{variant:"body2",className:"Bear-Snackbar__message",children:o}),t&&r.jsx(B.Typography,{variant:"caption",color:"muted",className:"Bear-Snackbar__description",children:t})]}),u&&r.jsx(d.Flex,{className:"Bear-Snackbar__action bear-shrink-0",align:"center",children:u}),j&&n&&r.jsx(H.CloseButton,{size:"sm",onClick:c,"aria-label":"Dismiss notification",className:"Bear-Snackbar__close bear-shrink-0"})]}),l&&_==="bottom"&&f]})]});return K.createPortal(T,g)};exports.Snackbar=V;
@@ -1,99 +1,101 @@
1
- import { jsxs as n, Fragment as T, jsx as r } from "react/jsx-runtime";
2
- import { createPortal as w } from "react-dom";
3
- import { cn as z } from "../../utils/cn.js";
1
+ import { jsxs as n, Fragment as z, jsx as r } from "react/jsx-runtime";
2
+ import { createPortal as L } from "react-dom";
3
+ import { cn as U } from "../../utils/cn.js";
4
4
  import "react";
5
- import { resolveBearId as L } from "../../utils/generateBearId.utils.js";
6
- import { useBearId as U } from "../../utils/useBearId.js";
7
- import { Paper as X } from "../Paper/Paper.js";
5
+ import { resolveBearId as X } from "../../utils/generateBearId.utils.js";
6
+ import { useBearId as Z } from "../../utils/useBearId.js";
7
+ import { getBearLiveRegionProps as j } from "../../utils/liveRegion.utils.js";
8
+ import { Paper as H } from "../Paper/Paper.js";
8
9
  import { Flex as d } from "../Flex/Flex.js";
9
- import { Typography as S } from "../Typography/Typography.js";
10
- import { Progress as Z } from "../Progress/Progress.js";
11
- import { CloseButton as j } from "../CloseButton/CloseButton.js";
12
- import { SNACKBAR_DEFAULT_AUTO_HIDE_MS as H, SNACKBAR_DEFAULT_OFFSET_X as G, SNACKBAR_DEFAULT_OFFSET_Y as M, SNACKBAR_BACKDROP_Z_INDEX as V, SNACKBAR_SIZE_PADDING as Y, SNACKBAR_SURFACE_CLASSES as q, SNACKBAR_ROOT_CLASS as J, SNACKBAR_Z_INDEX as Q } from "./Snackbar.const.js";
13
- import { useSnackbar as W } from "./hooks/useSnackbar.js";
14
- const $ = (i, o, a, t) => {
15
- const e = { zIndex: Q };
10
+ import { Typography as A } from "../Typography/Typography.js";
11
+ import { Progress as G } from "../Progress/Progress.js";
12
+ import { CloseButton as M } from "../CloseButton/CloseButton.js";
13
+ import { SNACKBAR_DEFAULT_AUTO_HIDE_MS as V, SNACKBAR_DEFAULT_OFFSET_X as Y, SNACKBAR_DEFAULT_OFFSET_Y as q, SNACKBAR_BACKDROP_Z_INDEX as J, SNACKBAR_SIZE_PADDING as Q, SNACKBAR_SURFACE_CLASSES as W, SNACKBAR_ROOT_CLASS as $, SNACKBAR_Z_INDEX as ee } from "./Snackbar.const.js";
14
+ import { useSnackbar as re } from "./hooks/useSnackbar.js";
15
+ const oe = (i, o, a, t) => {
16
+ const e = { zIndex: ee };
16
17
  return i === "top" ? e.top = t : e.bottom = t, o === "left" ? (e.left = a, e.right = "auto") : o === "right" ? (e.right = a, e.left = "auto") : (e.left = "50%", e.right = "auto", e.transform = "translateX(-50%)"), e;
17
- }, be = (i) => {
18
+ }, ge = (i) => {
18
19
  const {
19
20
  open: o,
20
21
  message: a,
21
22
  description: t,
22
- action: e,
23
- autoHideDuration: g = H,
23
+ severity: e = "default",
24
+ action: m,
25
+ autoHideDuration: h = V,
24
26
  onClose: l,
25
- anchorOrigin: m = { vertical: "bottom", horizontal: "center" },
26
- offsetX: A = G,
27
- offsetY: h = M,
28
- size: B = "md",
29
- progress: N = null,
30
- progressPosition: u = "bottom",
31
- progressColor: C = "default",
32
- countdownProgress: k = !1,
27
+ anchorOrigin: f = { vertical: "bottom", horizontal: "center" },
28
+ offsetX: B = Y,
29
+ offsetY: N = q,
30
+ size: C = "md",
31
+ progress: k = null,
32
+ progressPosition: p = "bottom",
33
+ progressColor: v = "default",
34
+ countdownProgress: R = !1,
33
35
  showCloseButton: O,
34
36
  closeOnClickOutside: x,
35
37
  container: D,
36
38
  id: I,
37
- testId: R,
38
- className: v
39
- } = i, E = U("Snackbar"), y = L(I, E), b = D ?? (typeof document < "u" ? document.body : null), s = !!l, F = O ?? s, f = x ?? s, { surfaceRef: K, progressValue: p } = W({
39
+ testId: y,
40
+ className: E
41
+ } = i, F = Z("Snackbar"), P = X(I, F), u = D ?? (typeof document < "u" ? document.body : null), s = !!l, K = O ?? s, b = x ?? s, { surfaceRef: T, progressValue: _ } = re({
40
42
  open: o,
41
- autoHideDuration: g,
43
+ autoHideDuration: h,
42
44
  onClose: l,
43
- countdownProgress: k,
44
- staticProgress: N,
45
- closeOnClickOutside: f
45
+ countdownProgress: R,
46
+ staticProgress: k,
47
+ closeOnClickOutside: b
46
48
  });
47
- if (!o || !b)
49
+ if (!o || !u)
48
50
  return null;
49
- const c = typeof p == "number", _ = c ? /* @__PURE__ */ r(
50
- Z,
51
+ const g = j(e), c = typeof _ == "number", S = c ? /* @__PURE__ */ r(
52
+ G,
51
53
  {
52
- value: p,
54
+ value: _,
53
55
  size: "sm",
54
- color: C,
56
+ color: v,
55
57
  className: "Bear-Snackbar__progress"
56
58
  }
57
- ) : null, P = /* @__PURE__ */ n(T, { children: [
58
- f && s && /* @__PURE__ */ r(
59
+ ) : null, w = /* @__PURE__ */ n(z, { children: [
60
+ b && s && /* @__PURE__ */ r(
59
61
  "div",
60
62
  {
61
63
  className: "Bear-Snackbar__backdrop bear-fixed bear-inset-0",
62
- style: { zIndex: V },
64
+ style: { zIndex: J },
63
65
  "aria-hidden": !0
64
66
  }
65
67
  ),
66
68
  /* @__PURE__ */ n(
67
- X,
69
+ H,
68
70
  {
69
- ref: K,
70
- id: y,
71
- "data-testid": R,
72
- role: "status",
73
- "aria-live": "polite",
71
+ ref: T,
72
+ id: P,
73
+ "data-testid": y,
74
+ role: g.role,
75
+ "aria-live": g["aria-live"],
74
76
  elevation: 4,
75
77
  rounded: "lg",
76
78
  padding: "none",
77
79
  background: "transparent",
78
- className: z(
79
- J,
80
- q,
80
+ className: U(
81
+ $,
82
+ W,
81
83
  "bear-fixed bear-flex bear-flex-col bear-overflow-hidden",
82
84
  "bear-border bear-border-[var(--bear-border-default)]",
83
- Y[B],
84
- v
85
+ Q[C],
86
+ E
85
87
  ),
86
- style: $(m.vertical, m.horizontal, A, h),
88
+ style: oe(f.vertical, f.horizontal, B, N),
87
89
  children: [
88
- c && u === "top" && _,
90
+ c && p === "top" && S,
89
91
  /* @__PURE__ */ n(d, { className: "Bear-Snackbar__content bear-w-full", align: "center", gap: 3, children: [
90
92
  /* @__PURE__ */ n(d, { direction: "column", className: "Bear-Snackbar__text bear-flex-1 bear-min-w-0", gap: 1, children: [
91
- a && /* @__PURE__ */ r(S, { variant: "body2", className: "Bear-Snackbar__message", children: a }),
92
- t && /* @__PURE__ */ r(S, { variant: "caption", color: "muted", className: "Bear-Snackbar__description", children: t })
93
+ a && /* @__PURE__ */ r(A, { variant: "body2", className: "Bear-Snackbar__message", children: a }),
94
+ t && /* @__PURE__ */ r(A, { variant: "caption", color: "muted", className: "Bear-Snackbar__description", children: t })
93
95
  ] }),
94
- e && /* @__PURE__ */ r(d, { className: "Bear-Snackbar__action bear-shrink-0", align: "center", children: e }),
95
- F && s && /* @__PURE__ */ r(
96
- j,
96
+ m && /* @__PURE__ */ r(d, { className: "Bear-Snackbar__action bear-shrink-0", align: "center", children: m }),
97
+ K && s && /* @__PURE__ */ r(
98
+ M,
97
99
  {
98
100
  size: "sm",
99
101
  onClick: l,
@@ -102,13 +104,13 @@ const $ = (i, o, a, t) => {
102
104
  }
103
105
  )
104
106
  ] }),
105
- c && u === "bottom" && _
107
+ c && p === "bottom" && S
106
108
  ]
107
109
  }
108
110
  )
109
111
  ] });
110
- return w(P, b);
112
+ return L(w, u);
111
113
  };
112
114
  export {
113
- be as Snackbar
115
+ ge as Snackbar
114
116
  };
@@ -5,10 +5,12 @@ export type SnackbarAnchorOriginHorizontal = 'left' | 'center' | 'right';
5
5
  export type SnackbarProgressPosition = 'top' | 'bottom';
6
6
  export type SnackbarSize = Extract<BearSize, 'sm' | 'md' | 'lg'>;
7
7
  export type SnackbarProgressColor = 'default' | 'success' | 'warning' | 'danger' | 'info';
8
+ export type SnackbarSeverity = 'success' | 'info' | 'warning' | 'error' | 'default';
8
9
  export interface SnackbarProps {
9
10
  open: boolean;
10
11
  message?: ReactNode;
11
12
  description?: ReactNode;
13
+ severity?: SnackbarSeverity;
12
14
  action?: ReactNode;
13
15
  autoHideDuration?: number | null;
14
16
  onClose?: () => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),u=require("react"),b=require("../../utils/cn.cjs"),x=u.createContext(null),T=({children:o,value:n,defaultTab:e,variant:c="line",onChange:a,className:l,testId:d})=>{const[t,r]=u.useState(e),i=n!==void 0,v=i?n:t,m=p=>{i||r(p),a==null||a(p)};return s.jsx(x.Provider,{value:{activeTab:v,setActiveTab:m,variant:c},children:s.jsx("div",{className:b.cn("Bear-Tabs",l),"data-testid":d,children:o})})},y=({id:o,children:n,disabled:e=!1,icon:c})=>{const a=u.useContext(x);if(!a)throw new Error("Tab must be used within Tabs");const{activeTab:l,setActiveTab:d,variant:t}=a,r=l===o,i="bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors",v={line:b.cn("bear-border-b-2 bear--mb-px",r?"bear-border-primary-500 bear-text-primary-600 dark:bear-text-primary-400":"bear-border-transparent hover:bear-border-[var(--bear-border-default)]"),pills:b.cn("bear-rounded-md",r&&"bear-shadow-sm"),enclosed:b.cn("bear-rounded-t-lg bear-border bear-border-transparent",r&&"bear--mb-px")},m=e?void 0:r?t==="pills"?{backgroundColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:t==="enclosed"?{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",borderBottomColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:void 0:{color:"var(--bear-text-muted)"};return s.jsxs("button",{role:"tab","aria-selected":r,disabled:e,onClick:()=>!e&&d(o),className:b.cn("Bear-Tabs__tab",r&&"Bear-Tabs__tab--active",i,v[t],!r&&"hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]",e&&"Bear-Tabs__tab--disabled bear-opacity-50 bear-cursor-not-allowed"),style:m,children:[c&&s.jsx("span",{className:"Bear-Tabs__tab-icon",children:c}),s.jsx("span",{className:"Bear-Tabs__tab-label",children:n})]})};exports.Tab=y;exports.Tabs=T;exports.TabsContext=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("react"),t=require("../../utils/cn.cjs"),S=require("../../utils/generateBearId.utils.cjs"),g=require("../../utils/useBearId.cjs"),f=require("../../context/BearProvider.cjs"),B=require("./Tabs.const.cjs"),x=p.createContext(null),I=({children:b,value:n,defaultTab:r,variant:c="line",onChange:a,className:i,testId:l,id:s})=>{const d=g.useBearId("Tabs"),e=S.resolveBearId(s,d),{density:u}=f.useBearDensityOptional(),m=u==="compact",[v,T]=p.useState(r),_=n!==void 0,C=_?n:v,A=y=>{_||T(y),a==null||a(y)};return o.jsx(x.Provider,{value:{activeTab:C,setActiveTab:A,variant:c,compact:m},children:o.jsx("div",{id:e,"data-testid":l,className:t.cn("Bear-Tabs",i),children:b})})},j=({id:b,children:n,disabled:r=!1,icon:c})=>{const a=p.useContext(x);if(!a)throw new Error("Tab must be used within Tabs");const{activeTab:i,setActiveTab:l,variant:s,compact:d}=a,e=i===b,u=d?B.TABS_TAB_PADDING_COMPACT_CLASSES:B.TABS_TAB_PADDING_CLASSES,m=t.cn("bear-flex bear-items-center bear-gap-2 bear-text-sm bear-font-medium bear-transition-colors",u),v={line:t.cn("bear-border-b-2 bear--mb-px",e?"bear-border-primary-500 bear-text-primary-600 dark:bear-text-primary-400":"bear-border-transparent hover:bear-border-[var(--bear-border-default)]"),pills:t.cn("bear-rounded-md",e&&"bear-shadow-sm"),enclosed:t.cn("bear-rounded-t-lg bear-border bear-border-transparent",e&&"bear--mb-px")},T=r?void 0:e?s==="pills"?{backgroundColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:s==="enclosed"?{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",borderBottomColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:void 0:{color:"var(--bear-text-muted)"};return o.jsxs("button",{role:"tab","aria-selected":e,disabled:r,onClick:()=>!r&&l(b),className:t.cn("Bear-Tabs__tab",e&&"Bear-Tabs__tab--active",m,v[s],!e&&"hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]",r&&"Bear-Tabs__tab--disabled bear-opacity-50 bear-cursor-not-allowed"),style:T,children:[c&&o.jsx("span",{className:"Bear-Tabs__tab-icon",children:c}),o.jsx("span",{className:"Bear-Tabs__tab-label",children:n})]})};exports.Tab=j;exports.Tabs=I;exports.TabsContext=x;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A="bear-px-4 bear-py-2",S="bear-px-3 bear-py-1";exports.TABS_TAB_PADDING_CLASSES=A;exports.TABS_TAB_PADDING_COMPACT_CLASSES=S;
@@ -1 +1,3 @@
1
1
  export declare const T_A_B_S_ROOT_CLASS = "Bear-Tabs";
2
+ export declare const TABS_TAB_PADDING_CLASSES = "bear-px-4 bear-py-2";
3
+ export declare const TABS_TAB_PADDING_COMPACT_CLASSES = "bear-px-3 bear-py-1";
@@ -0,0 +1,5 @@
1
+ const A = "bear-px-4 bear-py-2", S = "bear-px-3 bear-py-1";
2
+ export {
3
+ A as TABS_TAB_PADDING_CLASSES,
4
+ S as TABS_TAB_PADDING_COMPACT_CLASSES
5
+ };