@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,36 +1,54 @@
1
- import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
- import { cn as t } from "../../utils/cn.js";
1
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
+ import { EMPTY_STATE_SIZE_CLASSES as p, EMPTY_STATE_ICON_CLASSES as h, EMPTY_STATE_TITLE_CLASSES as C, EMPTY_STATE_DESCRIPTION_CLASSES as f, EMPTY_STATE_ROOT_CLASS as d, EMPTY_STATE_CARD_CLASSES as I, EMPTY_STATE_BASE_CLASSES as L } from "./EmptyState.const.js";
3
+ import { cn as r } from "../../utils/cn.js";
3
4
  import "react";
4
- const m = ({ className: b }) => /* @__PURE__ */ e("svg", { className: b, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" }) }), f = ({
5
- icon: b,
6
- title: i,
7
- description: l,
8
- action: d,
9
- secondaryAction: n,
10
- className: s,
11
- size: a = "md",
12
- variant: o = "default"
5
+ import { resolveBearId as u } from "../../utils/generateBearId.utils.js";
6
+ import { useBearId as v } from "../../utils/useBearId.js";
7
+ const M = ({ className: t }) => /* @__PURE__ */ e("svg", { className: t, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e(
8
+ "path",
9
+ {
10
+ strokeLinecap: "round",
11
+ strokeLinejoin: "round",
12
+ strokeWidth: 1.5,
13
+ d: "M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"
14
+ }
15
+ ) }), k = ({
16
+ icon: t,
17
+ title: E,
18
+ description: s,
19
+ action: S,
20
+ secondaryAction: o,
21
+ className: i,
22
+ size: T = "md",
23
+ variant: m = "default",
24
+ id: n,
25
+ testId: _
13
26
  }) => {
14
- const r = {
15
- sm: { icon: "bear-w-12 bear-h-12", title: "bear-text-lg", desc: "bear-text-sm", padding: "bear-py-6 bear-px-4" },
16
- md: { icon: "bear-w-16 bear-h-16", title: "bear-text-xl", desc: "bear-text-base", padding: "bear-py-10 bear-px-6" },
17
- lg: { icon: "bear-w-20 bear-h-20", title: "bear-text-2xl", desc: "bear-text-lg", padding: "bear-py-14 bear-px-8" }
18
- };
19
- return /* @__PURE__ */ c("div", { className: t(
20
- "bear-flex bear-flex-col bear-items-center bear-text-center",
21
- r[a].padding,
22
- o === "card" && "bear-bg-zinc-800/50 bear-rounded-xl bear-border bear-border-zinc-700",
23
- s
24
- ), children: [
25
- /* @__PURE__ */ e("div", { className: t("bear-text-zinc-600 bear-mb-4", r[a].icon), children: b || /* @__PURE__ */ e(m, { className: "bear-w-full bear-h-full" }) }),
26
- /* @__PURE__ */ e("h3", { className: t("bear-font-semibold bear-text-white bear-mb-2", r[a].title), children: i }),
27
- l && /* @__PURE__ */ e("p", { className: t("bear-text-zinc-400 bear-max-w-md bear-mb-6", r[a].desc), children: l }),
28
- (d || n) && /* @__PURE__ */ c("div", { className: "bear-flex bear-items-center bear-gap-3", children: [
29
- d,
30
- n
31
- ] })
32
- ] });
27
+ const c = v("EmptyState"), A = u(n, c), a = p[T];
28
+ return /* @__PURE__ */ l(
29
+ "div",
30
+ {
31
+ id: A,
32
+ "data-testid": _,
33
+ className: r(
34
+ d,
35
+ L,
36
+ a.padding,
37
+ m === "card" && I,
38
+ i
39
+ ),
40
+ children: [
41
+ /* @__PURE__ */ e("div", { className: r(h, a.icon), children: t || /* @__PURE__ */ e(M, { className: "bear-w-full bear-h-full" }) }),
42
+ /* @__PURE__ */ e("h3", { className: r(C, a.title), children: E }),
43
+ s && /* @__PURE__ */ e("p", { className: r(f, a.desc), children: s }),
44
+ (S || o) && /* @__PURE__ */ l("div", { className: `${d}__actions bear-flex bear-items-center bear-gap-3`, children: [
45
+ S,
46
+ o
47
+ ] })
48
+ ]
49
+ }
50
+ );
33
51
  };
34
52
  export {
35
- f as EmptyState
53
+ k as EmptyState
36
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),b=require("../../utils/cn.cjs"),me=require("../../utils/generateBearId.utils.cjs"),we=require("../../utils/useBearId.cjs"),K=require("../../context/BearProvider.cjs"),Be=require("./components/ClearIcon/ClearIcon.cjs"),Ne=require("./Input.utils.cjs"),je=require("../Form/Form.utils.cjs"),d=require("./Input.const.cjs"),Q=o.forwardRef(({label:C,helperText:V,error:v,success:k,size:T="md",variant:Ce,radius:ke,InputProps:l,leftAddon:Y,rightAddon:Z,prefix:Te,suffix:Ee,fullWidth:P=!1,clearable:ee=!1,onClear:re,showCharCount:E=!1,charCountMax:ae,autoFormat:m,validation:t,validateOnBlur:te,validateOnChange:S=!1,loading:Se,copyable:qe,onCopy:Le,floatingLabel:Ae,multiline:c=!1,rows:se,minRows:ne=d.INPUT_MULTILINE_MIN_ROWS,maxRows:Ue,readOnly:q,inputRef:s,inputProps:L,id:oe,testId:ie,className:le,disabled:u,value:f,defaultValue:x,maxLength:w,onChange:_,onBlur:h,...A},n)=>{var J;const ce=we.useBearId("Input"),B=me.resolveBearId(oe,ce),N=o.useContext(K.BearContext),r=(J=N==null?void 0:N.components)==null?void 0:J.Input,be=r==null?void 0:r.root,de=r==null?void 0:r.input,ue=r==null?void 0:r.label,fe=r==null?void 0:r.helper,xe=r==null?void 0:r.prefix,_e=r==null?void 0:r.suffix,[he,U]=o.useState(null),M=o.useRef(!1),pe=d.INPUT_TEXT_CLASSES,ge=d.INPUT_WRAPPER_HEIGHT_CLASSES,O=t?te??!0:!1,R=v||he,i=!!R,p=!!k&&!i,g=ae??w,j=typeof f=="string"?f.length:typeof x=="string"?x.length:0,H=g!=null&&j>g,Ie=ee&&!u&&j>0,{direction:ye}=K.useBearDirectionOptional(),W=(l==null?void 0:l.startAdornment)??Y,D=(l==null?void 0:l.endAdornment)??Z,F=R||k||V,I=o.useCallback(async e=>{if(!t)return;M.current=!0;const y=await je.validateFieldValue(e,t);M.current=!1,U(y)},[t]);o.useEffect(()=>{v&&U(null)},[v]);const $=o.useCallback(e=>{if(m&&!c){const y=Ne.applyAutoFormat(e.target.value,m);y!==e.target.value&&(e.target.value=y)}_==null||_(e),S&&t&&I(e.target.value)},[m,c,_,S,t,I]),G=o.useCallback(e=>{h==null||h(e),O&&t&&I(e.target.value)},[h,O,t,I]),X=b.cn("Bear-Input__field","bear-flex-1 bear-min-w-0 bear-border-0 bear-outline-none bear-bg-transparent","placeholder:opacity-100 placeholder:[color:var(--bear-text-muted)]",pe[T],c&&"bear-resize-y bear-py-2 bear-min-h-0 bear-h-auto",le),z={color:"var(--bear-text-primary)",...de},ve=se??ne??d.INPUT_MULTILINE_DEFAULT_ROWS;return a.jsxs("div",{id:B,"data-testid":ie,className:b.cn(d.INPUT_ROOT_CLASS,"bear-flex bear-flex-col bear-gap-1.5",P&&"bear-w-full"),style:be,children:[C&&a.jsx("label",{className:"Bear-Input__label bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)",...ue},children:C}),a.jsxs("div",{className:b.cn("Bear-Input__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-overflow-hidden bear-transition-all bear-duration-200","focus-within:bear-ring-2 focus-within:bear-ring-offset-2","focus-within:bear-ring-offset-[var(--bear-bg-primary)]",i?"Bear-Input__wrapper--error bear-border-red-500 focus-within:bear-ring-red-500":p?"Bear-Input__wrapper--success bear-border-green-500 focus-within:bear-ring-green-500":"focus-within:bear-border-bear-500 focus-within:bear-ring-bear-500 dark:focus-within:bear-border-bear-500 dark:focus-within:bear-ring-bear-500",u&&"bear-opacity-50 bear-cursor-not-allowed",!c&&ge[T]),dir:ye,style:{backgroundColor:"var(--bear-bg-primary)",borderColor:i||p?void 0:"var(--bear-border-default)"},children:[W&&a.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--left bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-text-sm bear-font-medium bear-select-none bear-pointer-events-none",style:{backgroundColor:"var(--bear-bg-tertiary)",borderInlineEnd:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",...xe},children:W}),c?a.jsx("textarea",{ref:e=>{typeof n=="function"?n(e):n&&(n.current=e),typeof s=="function"?s(e):s&&(s.current=e)},id:`${B}-field`,disabled:u,readOnly:q,value:f,defaultValue:x,maxLength:w,rows:ve,"aria-invalid":i||void 0,className:X,style:z,...L,...A,onChange:e=>$(e),onBlur:e=>G(e)}):a.jsx("input",{ref:e=>{typeof n=="function"?n(e):n&&(n.current=e),typeof s=="function"?s(e):s&&(s.current=e)},id:`${B}-field`,disabled:u,readOnly:q,value:f,defaultValue:x,maxLength:w,"aria-invalid":i||void 0,onChange:$,onBlur:G,className:X,style:z,...L,...A}),Ie&&a.jsx("div",{className:"Bear-Input__clear bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-2 bear-cursor-pointer",style:{color:"var(--bear-text-muted)"},children:a.jsx(Be.ClearIcon,{onClick:re})}),D&&a.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--right bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-gap-1.5",style:{backgroundColor:"var(--bear-bg-tertiary)",borderInlineStart:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",..._e},children:D})]}),a.jsxs("div",{className:"Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2",children:[F?a.jsx("p",{className:b.cn("Bear-Input__helper bear-text-sm bear-flex-1",i&&"Bear-Input__helper--error bear-text-red-500",p&&"Bear-Input__helper--success bear-text-green-500"),style:{...i||p?{}:{color:"var(--bear-text-muted)"},...fe},children:F}):E?a.jsx("span",{}):null,E&&g!=null&&a.jsxs("span",{className:b.cn("Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",H&&"bear-text-red-500"),style:H?void 0:{color:"var(--bear-text-muted)"},children:[j,"/",g]})]})]})});Q.displayName="Input";exports.Input=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),o=require("react"),d=require("../../utils/cn.cjs"),we=require("../../utils/generateBearId.utils.cjs"),Ce=require("../../utils/useBearId.cjs"),T=require("../../context/BearProvider.cjs"),Ne=require("./components/ClearIcon/ClearIcon.cjs"),Te=require("./Input.utils.cjs"),Se=require("../Form/Form.utils.cjs"),c=require("./Input.const.cjs"),Q=o.forwardRef(({label:S,helperText:V,error:v,success:E,size:j="md",variant:Ee,radius:je,InputProps:l,leftAddon:Y,rightAddon:Z,prefix:ke,suffix:Ae,fullWidth:ee=!1,clearable:re=!1,onClear:ae,showCharCount:k=!1,charCountMax:te,autoFormat:m,validation:t,validateOnBlur:se,validateOnChange:A=!1,loading:Le,copyable:qe,onCopy:Ue,floatingLabel:Oe,multiline:b=!1,rows:ne,minRows:oe=c.INPUT_MULTILINE_MIN_ROWS,maxRows:Me,readOnly:L,inputRef:s,inputProps:q,id:ie,testId:ce,className:le,disabled:u,value:f,defaultValue:_,maxLength:B,onChange:x,onBlur:p,...U},n)=>{var K;const be=Ce.useBearId("Input"),w=we.resolveBearId(ie,be),{density:de}=T.useBearDensityOptional(),O=de==="compact",C=o.useContext(T.BearContext),r=(K=C==null?void 0:C.components)==null?void 0:K.Input,ue=r==null?void 0:r.root,fe=r==null?void 0:r.input,_e=r==null?void 0:r.label,xe=r==null?void 0:r.helper,pe=r==null?void 0:r.prefix,he=r==null?void 0:r.suffix,[ge,M]=o.useState(null),R=o.useRef(!1),Ie=O?c.INPUT_TEXT_COMPACT_CLASSES:c.INPUT_TEXT_CLASSES,ye=O?c.INPUT_WRAPPER_HEIGHT_COMPACT_CLASSES:c.INPUT_WRAPPER_HEIGHT_CLASSES,H=t?se??!0:!1,P=v||ge,i=!!P,h=!!E&&!i,g=te??B,N=typeof f=="string"?f.length:typeof _=="string"?_.length:0,W=g!=null&&N>g,ve=re&&!u&&N>0,{direction:me}=T.useBearDirectionOptional(),D=(l==null?void 0:l.startAdornment)??Y,F=(l==null?void 0:l.endAdornment)??Z,G=P||E||V,I=o.useCallback(async e=>{if(!t)return;R.current=!0;const y=await Se.validateFieldValue(e,t);R.current=!1,M(y)},[t]);o.useEffect(()=>{v&&M(null)},[v]);const X=o.useCallback(e=>{if(m&&!b){const y=Te.applyAutoFormat(e.target.value,m);y!==e.target.value&&(e.target.value=y)}x==null||x(e),A&&t&&I(e.target.value)},[m,b,x,A,t,I]),$=o.useCallback(e=>{p==null||p(e),H&&t&&I(e.target.value)},[p,H,t,I]),z=d.cn("Bear-Input__field","bear-flex-1 bear-min-w-0 bear-border-0 bear-outline-none bear-bg-transparent","placeholder:opacity-100 placeholder:[color:var(--bear-text-muted)]",Ie[j],b&&"bear-resize-y bear-py-2 bear-min-h-0 bear-h-auto",le),J={color:"var(--bear-text-primary)",...fe},Be=ne??oe??c.INPUT_MULTILINE_DEFAULT_ROWS;return a.jsxs("div",{id:w,"data-testid":ce,className:d.cn(c.INPUT_ROOT_CLASS,"bear-flex bear-flex-col bear-gap-1.5",ee&&"bear-w-full"),style:ue,children:[S&&a.jsx("label",{className:"Bear-Input__label bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)",..._e},children:S}),a.jsxs("div",{className:d.cn("Bear-Input__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-overflow-hidden bear-transition-all bear-duration-200","focus-within:bear-ring-2 focus-within:bear-ring-offset-2","focus-within:bear-ring-offset-[var(--bear-bg-primary)]",i?"Bear-Input__wrapper--error bear-border-red-500 focus-within:bear-ring-red-500":h?"Bear-Input__wrapper--success bear-border-green-500 focus-within:bear-ring-green-500":"focus-within:bear-border-bear-500 focus-within:bear-ring-bear-500 dark:focus-within:bear-border-bear-500 dark:focus-within:bear-ring-bear-500",u&&"bear-opacity-50 bear-cursor-not-allowed",!b&&ye[j]),dir:me,style:{backgroundColor:"var(--bear-bg-primary)",borderColor:i||h?void 0:"var(--bear-border-default)"},children:[D&&a.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--left bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-text-sm bear-font-medium bear-select-none bear-pointer-events-none",style:{backgroundColor:"var(--bear-bg-tertiary)",borderInlineEnd:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",...pe},children:D}),b?a.jsx("textarea",{ref:e=>{typeof n=="function"?n(e):n&&(n.current=e),typeof s=="function"?s(e):s&&(s.current=e)},id:`${w}-field`,disabled:u,readOnly:L,value:f,defaultValue:_,maxLength:B,rows:Be,"aria-invalid":i||void 0,className:z,style:J,...q,...U,onChange:e=>X(e),onBlur:e=>$(e)}):a.jsx("input",{ref:e=>{typeof n=="function"?n(e):n&&(n.current=e),typeof s=="function"?s(e):s&&(s.current=e)},id:`${w}-field`,disabled:u,readOnly:L,value:f,defaultValue:_,maxLength:B,"aria-invalid":i||void 0,onChange:X,onBlur:$,className:z,style:J,...q,...U}),ve&&a.jsx("div",{className:"Bear-Input__clear bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-2 bear-cursor-pointer",style:{color:"var(--bear-text-muted)"},children:a.jsx(Ne.ClearIcon,{onClick:ae})}),F&&a.jsx("div",{className:"Bear-Input__addon Bear-Input__addon--right bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-gap-1.5",style:{backgroundColor:"var(--bear-bg-tertiary)",borderInlineStart:"1px solid var(--bear-border-default)",color:"var(--bear-text-secondary)",...he},children:F})]}),a.jsxs("div",{className:"Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2",children:[G?a.jsx("p",{className:d.cn("Bear-Input__helper bear-text-sm bear-flex-1",i&&"Bear-Input__helper--error bear-text-red-500",h&&"Bear-Input__helper--success bear-text-green-500"),style:{...i||h?{}:{color:"var(--bear-text-muted)"},...xe},children:G}):k?a.jsx("span",{}):null,k&&g!=null&&a.jsxs("span",{className:d.cn("Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",W&&"bear-text-red-500"),style:W?void 0:{color:"var(--bear-text-muted)"},children:[N,"/",g]})]})]})});Q.displayName="Input";exports.Input=Q;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="Bear-Input",T={sm:"bear-h-8",md:"bear-h-10",lg:"bear-h-12"},I={sm:"bear-text-sm bear-px-3",md:"bear-text-base bear-px-4",lg:"bear-text-lg bear-px-5"},S=3,e=4;exports.INPUT_MULTILINE_DEFAULT_ROWS=e;exports.INPUT_MULTILINE_MIN_ROWS=S;exports.INPUT_ROOT_CLASS=_;exports.INPUT_TEXT_CLASSES=I;exports.INPUT_WRAPPER_HEIGHT_CLASSES=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="Bear-Input",T={sm:"bear-h-8",md:"bear-h-10",lg:"bear-h-12"},e={sm:"bear-h-7",md:"bear-h-8",lg:"bear-h-10"},S={sm:"bear-text-sm bear-px-3",md:"bear-text-base bear-px-4",lg:"bear-text-lg bear-px-5"},I={sm:"bear-text-xs bear-px-2.5",md:"bear-text-sm bear-px-3",lg:"bear-text-base bear-px-4"},P=3,t=4;exports.INPUT_MULTILINE_DEFAULT_ROWS=t;exports.INPUT_MULTILINE_MIN_ROWS=P;exports.INPUT_ROOT_CLASS=_;exports.INPUT_TEXT_CLASSES=S;exports.INPUT_TEXT_COMPACT_CLASSES=I;exports.INPUT_WRAPPER_HEIGHT_CLASSES=T;exports.INPUT_WRAPPER_HEIGHT_COMPACT_CLASSES=e;
@@ -4,10 +4,20 @@ export declare const INPUT_WRAPPER_HEIGHT_CLASSES: {
4
4
  readonly md: "bear-h-10";
5
5
  readonly lg: "bear-h-12";
6
6
  };
7
+ export declare const INPUT_WRAPPER_HEIGHT_COMPACT_CLASSES: {
8
+ readonly sm: "bear-h-7";
9
+ readonly md: "bear-h-8";
10
+ readonly lg: "bear-h-10";
11
+ };
7
12
  export declare const INPUT_TEXT_CLASSES: {
8
13
  readonly sm: "bear-text-sm bear-px-3";
9
14
  readonly md: "bear-text-base bear-px-4";
10
15
  readonly lg: "bear-text-lg bear-px-5";
11
16
  };
17
+ export declare const INPUT_TEXT_COMPACT_CLASSES: {
18
+ readonly sm: "bear-text-xs bear-px-2.5";
19
+ readonly md: "bear-text-sm bear-px-3";
20
+ readonly lg: "bear-text-base bear-px-4";
21
+ };
12
22
  export declare const INPUT_MULTILINE_MIN_ROWS = 3;
13
23
  export declare const INPUT_MULTILINE_DEFAULT_ROWS = 4;
@@ -1,16 +1,26 @@
1
- const e = "Bear-Input", t = {
1
+ const e = "Bear-Input", a = {
2
2
  sm: "bear-h-8",
3
3
  md: "bear-h-10",
4
4
  lg: "bear-h-12"
5
- }, _ = {
5
+ }, t = {
6
+ sm: "bear-h-7",
7
+ md: "bear-h-8",
8
+ lg: "bear-h-10"
9
+ }, b = {
6
10
  sm: "bear-text-sm bear-px-3",
7
11
  md: "bear-text-base bear-px-4",
8
12
  lg: "bear-text-lg bear-px-5"
9
- }, I = 3, T = 4;
13
+ }, r = {
14
+ sm: "bear-text-xs bear-px-2.5",
15
+ md: "bear-text-sm bear-px-3",
16
+ lg: "bear-text-base bear-px-4"
17
+ }, _ = 3, T = 4;
10
18
  export {
11
19
  T as INPUT_MULTILINE_DEFAULT_ROWS,
12
- I as INPUT_MULTILINE_MIN_ROWS,
20
+ _ as INPUT_MULTILINE_MIN_ROWS,
13
21
  e as INPUT_ROOT_CLASS,
14
- _ as INPUT_TEXT_CLASSES,
15
- t as INPUT_WRAPPER_HEIGHT_CLASSES
22
+ b as INPUT_TEXT_CLASSES,
23
+ r as INPUT_TEXT_COMPACT_CLASSES,
24
+ a as INPUT_WRAPPER_HEIGHT_CLASSES,
25
+ t as INPUT_WRAPPER_HEIGHT_COMPACT_CLASSES
16
26
  };
@@ -1,120 +1,120 @@
1
1
  import { jsxs as g, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as ye, useContext as ve, useState as Ie, useRef as we, useCallback as C, useEffect as Be } from "react";
3
- import { cn as b } from "../../utils/cn.js";
4
- import { resolveBearId as Ne } from "../../utils/generateBearId.utils.js";
5
- import { useBearId as Ce } from "../../utils/useBearId.js";
6
- import { BearContext as Ee, useBearDirectionOptional as Te } from "../../context/BearProvider.js";
7
- import { ClearIcon as ke } from "./components/ClearIcon/ClearIcon.js";
8
- import { applyAutoFormat as Se } from "./Input.utils.js";
9
- import { validateFieldValue as Le } from "../Form/Form.utils.js";
10
- import { INPUT_TEXT_CLASSES as Ae, INPUT_MULTILINE_MIN_ROWS as Ue, INPUT_MULTILINE_DEFAULT_ROWS as Me, INPUT_WRAPPER_HEIGHT_CLASSES as Oe, INPUT_ROOT_CLASS as je } from "./Input.const.js";
11
- const He = ye(
2
+ import { forwardRef as ve, useContext as we, useState as Ne, useRef as Be, useCallback as C, useEffect as Ce } from "react";
3
+ import { cn as c } from "../../utils/cn.js";
4
+ import { resolveBearId as Te } from "../../utils/generateBearId.utils.js";
5
+ import { useBearId as Ee } from "../../utils/useBearId.js";
6
+ import { useBearDensityOptional as Se, BearContext as Ae, useBearDirectionOptional as ke } from "../../context/BearProvider.js";
7
+ import { ClearIcon as Le } from "./components/ClearIcon/ClearIcon.js";
8
+ import { applyAutoFormat as Ue } from "./Input.utils.js";
9
+ import { validateFieldValue as Oe } from "../Form/Form.utils.js";
10
+ import { INPUT_TEXT_COMPACT_CLASSES as Me, INPUT_TEXT_CLASSES as He, INPUT_MULTILINE_MIN_ROWS as Re, INPUT_MULTILINE_DEFAULT_ROWS as We, INPUT_WRAPPER_HEIGHT_COMPACT_CLASSES as je, INPUT_WRAPPER_HEIGHT_CLASSES as De, INPUT_ROOT_CLASS as Ge } from "./Input.const.js";
11
+ const Pe = ve(
12
12
  ({
13
- label: E,
13
+ label: T,
14
14
  helperText: K,
15
15
  error: y,
16
- success: T,
17
- size: k = "md",
18
- variant: We,
19
- radius: De,
16
+ success: E,
17
+ size: S = "md",
18
+ variant: Xe,
19
+ radius: $e,
20
20
  InputProps: i,
21
21
  leftAddon: Q,
22
22
  rightAddon: V,
23
- prefix: Re,
24
- suffix: $e,
23
+ prefix: Fe,
24
+ suffix: qe,
25
25
  fullWidth: Y = !1,
26
26
  clearable: Z = !1,
27
- onClear: P,
28
- showCharCount: S = !1,
29
- charCountMax: ee,
30
- autoFormat: v,
27
+ onClear: ee,
28
+ showCharCount: A = !1,
29
+ charCountMax: re,
30
+ autoFormat: I,
31
31
  validation: t,
32
- validateOnBlur: re,
33
- validateOnChange: L = !1,
34
- loading: Fe,
35
- copyable: Ge,
36
- onCopy: Xe,
37
- floatingLabel: qe,
32
+ validateOnBlur: ae,
33
+ validateOnChange: k = !1,
34
+ loading: ze,
35
+ copyable: Je,
36
+ onCopy: Ke,
37
+ floatingLabel: Qe,
38
38
  multiline: l = !1,
39
- rows: ae,
40
- minRows: te = Ue,
41
- maxRows: ze,
42
- readOnly: A,
39
+ rows: te,
40
+ minRows: se = Re,
41
+ maxRows: Ve,
42
+ readOnly: L,
43
43
  inputRef: s,
44
44
  inputProps: U,
45
- id: se,
46
- testId: oe,
47
- className: ne,
48
- disabled: c,
45
+ id: oe,
46
+ testId: ne,
47
+ className: ie,
48
+ disabled: b,
49
49
  value: d,
50
50
  defaultValue: f,
51
- maxLength: I,
51
+ maxLength: v,
52
52
  onChange: u,
53
53
  onBlur: _,
54
- ...M
54
+ ...O
55
55
  }, o) => {
56
56
  var J;
57
- const ie = Ce("Input"), w = Ne(se, ie), B = ve(Ee), r = (J = B == null ? void 0 : B.components) == null ? void 0 : J.Input, le = r == null ? void 0 : r.root, be = r == null ? void 0 : r.input, ce = r == null ? void 0 : r.label, de = r == null ? void 0 : r.helper, fe = r == null ? void 0 : r.prefix, ue = r == null ? void 0 : r.suffix, [_e, O] = Ie(null), j = we(!1), pe = Ae, xe = Oe, H = t ? re ?? !0 : !1, W = y || _e, n = !!W, p = !!T && !n, x = ee ?? I, N = typeof d == "string" ? d.length : typeof f == "string" ? f.length : 0, D = x != null && N > x, me = Z && !c && N > 0, { direction: he } = Te(), R = (i == null ? void 0 : i.startAdornment) ?? Q, $ = (i == null ? void 0 : i.endAdornment) ?? V, F = W || T || K, m = C(async (e) => {
57
+ const le = Ee("Input"), w = Te(oe, le), { density: ce } = Se(), M = ce === "compact", N = we(Ae), r = (J = N == null ? void 0 : N.components) == null ? void 0 : J.Input, be = r == null ? void 0 : r.root, de = r == null ? void 0 : r.input, fe = r == null ? void 0 : r.label, ue = r == null ? void 0 : r.helper, _e = r == null ? void 0 : r.prefix, pe = r == null ? void 0 : r.suffix, [me, H] = Ne(null), R = Be(!1), xe = M ? Me : He, he = M ? je : De, W = t ? ae ?? !0 : !1, j = y || me, n = !!j, p = !!E && !n, m = re ?? v, B = typeof d == "string" ? d.length : typeof f == "string" ? f.length : 0, D = m != null && B > m, ge = Z && !b && B > 0, { direction: ye } = ke(), G = (i == null ? void 0 : i.startAdornment) ?? Q, P = (i == null ? void 0 : i.endAdornment) ?? V, X = j || E || K, x = C(async (e) => {
58
58
  if (!t) return;
59
- j.current = !0;
60
- const h = await Le(e, t);
61
- j.current = !1, O(h);
59
+ R.current = !0;
60
+ const h = await Oe(e, t);
61
+ R.current = !1, H(h);
62
62
  }, [t]);
63
- Be(() => {
64
- y && O(null);
63
+ Ce(() => {
64
+ y && H(null);
65
65
  }, [y]);
66
- const G = C(
66
+ const $ = C(
67
67
  (e) => {
68
- if (v && !l) {
69
- const h = Se(e.target.value, v);
68
+ if (I && !l) {
69
+ const h = Ue(e.target.value, I);
70
70
  h !== e.target.value && (e.target.value = h);
71
71
  }
72
- u == null || u(e), L && t && m(e.target.value);
72
+ u == null || u(e), k && t && x(e.target.value);
73
73
  },
74
- [v, l, u, L, t, m]
75
- ), X = C(
74
+ [I, l, u, k, t, x]
75
+ ), F = C(
76
76
  (e) => {
77
- _ == null || _(e), H && t && m(e.target.value);
77
+ _ == null || _(e), W && t && x(e.target.value);
78
78
  },
79
- [_, H, t, m]
80
- ), q = b(
79
+ [_, W, t, x]
80
+ ), q = c(
81
81
  "Bear-Input__field",
82
82
  "bear-flex-1 bear-min-w-0 bear-border-0 bear-outline-none bear-bg-transparent",
83
83
  "placeholder:opacity-100 placeholder:[color:var(--bear-text-muted)]",
84
- pe[k],
84
+ xe[S],
85
85
  l && "bear-resize-y bear-py-2 bear-min-h-0 bear-h-auto",
86
- ne
86
+ ie
87
87
  ), z = {
88
88
  color: "var(--bear-text-primary)",
89
- ...be
90
- }, ge = ae ?? te ?? Me;
89
+ ...de
90
+ }, Ie = te ?? se ?? We;
91
91
  return /* @__PURE__ */ g(
92
92
  "div",
93
93
  {
94
94
  id: w,
95
- "data-testid": oe,
96
- className: b(je, "bear-flex bear-flex-col bear-gap-1.5", Y && "bear-w-full"),
97
- style: le,
95
+ "data-testid": ne,
96
+ className: c(Ge, "bear-flex bear-flex-col bear-gap-1.5", Y && "bear-w-full"),
97
+ style: be,
98
98
  children: [
99
- E && /* @__PURE__ */ a("label", { className: "Bear-Input__label bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)", ...ce }, children: E }),
99
+ T && /* @__PURE__ */ a("label", { className: "Bear-Input__label bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)", ...fe }, children: T }),
100
100
  /* @__PURE__ */ g(
101
101
  "div",
102
102
  {
103
- className: b(
103
+ className: c(
104
104
  "Bear-Input__wrapper bear-flex bear-items-center bear-rounded-lg bear-border bear-overflow-hidden bear-transition-all bear-duration-200",
105
105
  "focus-within:bear-ring-2 focus-within:bear-ring-offset-2",
106
106
  "focus-within:bear-ring-offset-[var(--bear-bg-primary)]",
107
107
  n ? "Bear-Input__wrapper--error bear-border-red-500 focus-within:bear-ring-red-500" : p ? "Bear-Input__wrapper--success bear-border-green-500 focus-within:bear-ring-green-500" : "focus-within:bear-border-bear-500 focus-within:bear-ring-bear-500 dark:focus-within:bear-border-bear-500 dark:focus-within:bear-ring-bear-500",
108
- c && "bear-opacity-50 bear-cursor-not-allowed",
109
- !l && xe[k]
108
+ b && "bear-opacity-50 bear-cursor-not-allowed",
109
+ !l && he[S]
110
110
  ),
111
- dir: he,
111
+ dir: ye,
112
112
  style: {
113
113
  backgroundColor: "var(--bear-bg-primary)",
114
114
  borderColor: n || p ? void 0 : "var(--bear-border-default)"
115
115
  },
116
116
  children: [
117
- R && /* @__PURE__ */ a(
117
+ G && /* @__PURE__ */ a(
118
118
  "div",
119
119
  {
120
120
  className: "Bear-Input__addon Bear-Input__addon--left bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-text-sm bear-font-medium bear-select-none bear-pointer-events-none",
@@ -122,9 +122,9 @@ const He = ye(
122
122
  backgroundColor: "var(--bear-bg-tertiary)",
123
123
  borderInlineEnd: "1px solid var(--bear-border-default)",
124
124
  color: "var(--bear-text-secondary)",
125
- ...fe
125
+ ..._e
126
126
  },
127
- children: R
127
+ children: G
128
128
  }
129
129
  ),
130
130
  l ? /* @__PURE__ */ a(
@@ -134,19 +134,19 @@ const He = ye(
134
134
  typeof o == "function" ? o(e) : o && (o.current = e), typeof s == "function" ? s(e) : s && (s.current = e);
135
135
  },
136
136
  id: `${w}-field`,
137
- disabled: c,
138
- readOnly: A,
137
+ disabled: b,
138
+ readOnly: L,
139
139
  value: d,
140
140
  defaultValue: f,
141
- maxLength: I,
142
- rows: ge,
141
+ maxLength: v,
142
+ rows: Ie,
143
143
  "aria-invalid": n || void 0,
144
144
  className: q,
145
145
  style: z,
146
146
  ...U,
147
- ...M,
148
- onChange: (e) => G(e),
149
- onBlur: (e) => X(e)
147
+ ...O,
148
+ onChange: (e) => $(e),
149
+ onBlur: (e) => F(e)
150
150
  }
151
151
  ) : /* @__PURE__ */ a(
152
152
  "input",
@@ -155,29 +155,29 @@ const He = ye(
155
155
  typeof o == "function" ? o(e) : o && (o.current = e), typeof s == "function" ? s(e) : s && (s.current = e);
156
156
  },
157
157
  id: `${w}-field`,
158
- disabled: c,
159
- readOnly: A,
158
+ disabled: b,
159
+ readOnly: L,
160
160
  value: d,
161
161
  defaultValue: f,
162
- maxLength: I,
162
+ maxLength: v,
163
163
  "aria-invalid": n || void 0,
164
- onChange: G,
165
- onBlur: X,
164
+ onChange: $,
165
+ onBlur: F,
166
166
  className: q,
167
167
  style: z,
168
168
  ...U,
169
- ...M
169
+ ...O
170
170
  }
171
171
  ),
172
- me && /* @__PURE__ */ a(
172
+ ge && /* @__PURE__ */ a(
173
173
  "div",
174
174
  {
175
175
  className: "Bear-Input__clear bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-2 bear-cursor-pointer",
176
176
  style: { color: "var(--bear-text-muted)" },
177
- children: /* @__PURE__ */ a(ke, { onClick: P })
177
+ children: /* @__PURE__ */ a(Le, { onClick: ee })
178
178
  }
179
179
  ),
180
- $ && /* @__PURE__ */ a(
180
+ P && /* @__PURE__ */ a(
181
181
  "div",
182
182
  {
183
183
  className: "Bear-Input__addon Bear-Input__addon--right bear-flex bear-items-center bear-self-stretch bear-shrink-0 bear-px-3 bear-gap-1.5",
@@ -185,42 +185,42 @@ const He = ye(
185
185
  backgroundColor: "var(--bear-bg-tertiary)",
186
186
  borderInlineStart: "1px solid var(--bear-border-default)",
187
187
  color: "var(--bear-text-secondary)",
188
- ...ue
188
+ ...pe
189
189
  },
190
- children: $
190
+ children: P
191
191
  }
192
192
  )
193
193
  ]
194
194
  }
195
195
  ),
196
196
  /* @__PURE__ */ g("div", { className: "Bear-Input__footer bear-flex bear-items-center bear-justify-between bear-gap-2", children: [
197
- F ? /* @__PURE__ */ a(
197
+ X ? /* @__PURE__ */ a(
198
198
  "p",
199
199
  {
200
- className: b(
200
+ className: c(
201
201
  "Bear-Input__helper bear-text-sm bear-flex-1",
202
202
  n && "Bear-Input__helper--error bear-text-red-500",
203
203
  p && "Bear-Input__helper--success bear-text-green-500"
204
204
  ),
205
205
  style: {
206
206
  ...n || p ? {} : { color: "var(--bear-text-muted)" },
207
- ...de
207
+ ...ue
208
208
  },
209
- children: F
209
+ children: X
210
210
  }
211
- ) : S ? /* @__PURE__ */ a("span", {}) : null,
212
- S && x != null && /* @__PURE__ */ g(
211
+ ) : A ? /* @__PURE__ */ a("span", {}) : null,
212
+ A && m != null && /* @__PURE__ */ g(
213
213
  "span",
214
214
  {
215
- className: b(
215
+ className: c(
216
216
  "Bear-Input__char-count bear-text-xs bear-tabular-nums bear-shrink-0",
217
217
  D && "bear-text-red-500"
218
218
  ),
219
219
  style: D ? void 0 : { color: "var(--bear-text-muted)" },
220
220
  children: [
221
- N,
221
+ B,
222
222
  "/",
223
- x
223
+ m
224
224
  ]
225
225
  }
226
226
  )
@@ -230,7 +230,7 @@ const He = ye(
230
230
  );
231
231
  }
232
232
  );
233
- He.displayName = "Input";
233
+ Pe.displayName = "Input";
234
234
  export {
235
- He as Input
235
+ Pe as Input
236
236
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),n=require("react"),Z=require("../Avatar/Avatar.cjs"),o=require("../Typography/Typography.cjs"),e=require("./MessageList.const.cjs"),A=require("./MessageList.utils.cjs"),t=require("../../utils/cn.cjs"),J=require("../../utils/generateBearId.utils.cjs"),K=require("../../utils/useBearId.cjs"),Q=({id:x,testId:f,messages:c,currentUserId:j,groupWindowMs:B=e.MESSAGE_LIST_GROUP_WINDOW_MS,showDaySeparators:b=!0,showAvatars:H=!0,showTimestamps:G=!0,autoScroll:R=!0,virtualized:$,height:E=e.MESSAGE_LIST_DEFAULT_HEIGHT,renderMessage:L,emptyState:g,formatDayLabel:T,formatTimestamp:I,translations:w,onNewMessagesClick:d,className:U})=>{const D=K.useBearId("MessageList"),P=J.resolveBearId(x,D),a=n.useRef(null),h=n.useRef(!0),O=n.useRef(null),[q,u]=n.useState(!1),[Y,W]=n.useState(0),[F,p]=n.useState(typeof E=="number"?E:e.MESSAGE_LIST_DEFAULT_HEIGHT),M={...e.MESSAGE_LIST_DEFAULT_TRANSLATIONS,...w},r=A.buildMessageListItems(c,j,B,b),V=S=>(T==null?void 0:T(S))??A.getDefaultDayLabel(S,M),m=S=>(I==null?void 0:I(S))??A.getDefaultTimestamp(S),C=$??c.length>=e.MESSAGE_LIST_VIRTUALIZE_THRESHOLD,y=S=>{const _=a.current;_&&_.scrollTo({top:_.scrollHeight,behavior:S?"smooth":"auto"})},k=()=>{const S=a.current;if(!S)return;W(S.scrollTop),p(S.clientHeight);const i=S.scrollHeight-S.scrollTop-S.clientHeight<=e.MESSAGE_LIST_BOTTOM_THRESHOLD_PX;h.current=i,i&&u(!1)};n.useEffect(()=>{const S=a.current;S&&p(S.clientHeight)},[E]),n.useEffect(()=>{const S=c.length>0?c[c.length-1].id:null,_=O.current===null,i=S!==null&&S!==O.current;if(O.current=S,!!i){if(_||R&&h.current){y(!_);return}u(!0)}},[c,R]);const z=()=>{y(!0),u(!1),d==null||d()},X=S=>s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group`,e.MESSAGE_LIST_GROUP_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_OWN_CLASSES),children:[H&&!S.isOwn&&s.jsx(Z.Avatar,{src:S.author.avatar,initials:S.author.name[0],size:"sm",className:"bear-flex-shrink-0"}),s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group-body`,e.MESSAGE_LIST_GROUP_BODY_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_BODY_OWN_CLASSES),children:[!S.isOwn&&s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__meta`,e.MESSAGE_LIST_META_CLASSES),children:[s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__author`,e.MESSAGE_LIST_AUTHOR_CLASSES),children:S.author.name}),G&&s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:m(S.messages[0].timestamp)})]}),S.messages.map(_=>s.jsx("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__bubble`,e.MESSAGE_LIST_BUBBLE_CLASSES,S.isOwn&&`${e.MESSAGE_LIST_ROOT_CLASS}__bubble--own`,S.isOwn&&e.MESSAGE_LIST_BUBBLE_OWN_CLASSES),children:(L==null?void 0:L(_))??_.content},_.id)),S.isOwn&&G&&s.jsx(o.Typography,{variant:"caption",component:"span",className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:m(S.messages[S.messages.length-1].timestamp)})]})]},S.key),N=S=>S.kind==="day"?s.jsxs("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-separator`,e.MESSAGE_LIST_DAY_SEPARATOR_CLASSES),children:[s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)}),s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-label`,e.MESSAGE_LIST_DAY_LABEL_CLASSES),children:V(S.date)}),s.jsx("span",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)})]},S.key):X(S),l=C?A.getMessageListWindow(r,Y,F,e.MESSAGE_LIST_OVERSCAN):null,v=l===null?r:r.slice(l.startIndex,l.endIndex+1);return s.jsxs("div",{id:P,"data-testid":f,className:t.cn(e.MESSAGE_LIST_ROOT_CLASS,e.MESSAGE_LIST_BASE_CLASSES,U),style:{height:typeof E=="number"?`${E}px`:E},children:[s.jsxs("div",{ref:a,onScroll:k,className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__scroller`,e.MESSAGE_LIST_SCROLLER_CLASSES),role:"log","aria-live":"polite",children:[r.length===0&&s.jsx("div",{className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__empty`,e.MESSAGE_LIST_EMPTY_CLASSES),children:g??s.jsx(o.Typography,{variant:"body2",component:"span",children:M.emptyLabel})}),C&&l?s.jsx("div",{className:`${e.MESSAGE_LIST_ROOT_CLASS}__virtual`,style:{height:l.totalHeight,position:"relative"},children:s.jsx("div",{style:{transform:`translateY(${l.offsetTop}px)`},children:v.map(S=>N(S))})}):v.map(S=>N(S))]}),q&&s.jsx("button",{type:"button",onClick:z,className:t.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__new-messages`,e.MESSAGE_LIST_NEW_MESSAGES_CLASSES),children:M.newMessages})]})};exports.MessageList=Q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),_=require("react"),eS=require("../Avatar/Avatar.cjs"),a=require("../Typography/Typography.cjs"),e=require("./MessageList.const.cjs"),A=require("./MessageList.utils.cjs"),n=require("../../utils/cn.cjs"),tS=require("../../utils/generateBearId.utils.cjs"),sS=require("../../utils/useBearId.cjs"),nS=({id:H,testId:B,messages:c,currentUserId:b,groupWindowMs:$=e.MESSAGE_LIST_GROUP_WINDOW_MS,showDaySeparators:g=!0,showAvatars:w=!0,showTimestamps:h=!0,autoScroll:p=!0,virtualized:P,overscan:U=e.MESSAGE_LIST_OVERSCAN,height:E=e.MESSAGE_LIST_DEFAULT_HEIGHT,renderMessage:L,emptyState:D,formatDayLabel:T,formatTimestamp:u,translations:q,onNewMessagesClick:d,className:Y})=>{const W=sS.useBearId("MessageList"),F=tS.resolveBearId(H,W),l=_.useRef(null),C=_.useRef(!0),I=_.useRef(null),O=_.useRef(null),M=_.useRef(null),[V,G]=_.useState(!1),[k,m]=_.useState(0),[z,f]=_.useState(typeof E=="number"?E:e.MESSAGE_LIST_DEFAULT_HEIGHT),R={...e.MESSAGE_LIST_DEFAULT_TRANSLATIONS,...q},o=A.buildMessageListItems(c,b,$,g),X=S=>(T==null?void 0:T(S))??A.getDefaultDayLabel(S,R),y=S=>(u==null?void 0:u(S))??A.getDefaultTimestamp(S),v=P??c.length>=e.MESSAGE_LIST_VIRTUALIZE_THRESHOLD,N=S=>{const s=l.current;s&&s.scrollTo({top:s.scrollHeight,behavior:S?"smooth":"auto"})},Z=()=>{const S=l.current;if(!S)return;m(S.scrollTop),f(S.clientHeight);const r=S.scrollHeight-S.scrollTop-S.clientHeight<=e.MESSAGE_LIST_BOTTOM_THRESHOLD_PX;C.current=r,r&&G(!1)};_.useEffect(()=>{const S=l.current;S&&f(S.clientHeight)},[E]),_.useEffect(()=>{const S=c.length>0?c[0].id:null,s=c.length>0?c[c.length-1].id:null,r=I.current===null,Q=S!==null&&O.current!==null&&S!==O.current,SS=s!==null&&s!==I.current;if(Q&&l.current&&(M.current=l.current.scrollHeight),O.current=S,I.current=s,!!SS){if(r||p&&C.current){N(!r);return}G(!0)}},[c,p]),_.useLayoutEffect(()=>{const S=l.current,s=M.current;if(!S||s===null)return;const r=S.scrollHeight-s;r>0&&(S.scrollTop+=r,m(S.scrollTop)),M.current=null},[c]);const J=()=>{N(!0),G(!1),d==null||d()},K=S=>t.jsxs("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group`,e.MESSAGE_LIST_GROUP_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_OWN_CLASSES),children:[w&&!S.isOwn&&t.jsx(eS.Avatar,{src:S.author.avatar,initials:S.author.name[0],size:"sm",className:"bear-flex-shrink-0"}),t.jsxs("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__group-body`,e.MESSAGE_LIST_GROUP_BODY_CLASSES,S.isOwn&&e.MESSAGE_LIST_GROUP_BODY_OWN_CLASSES),children:[!S.isOwn&&t.jsxs("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__meta`,e.MESSAGE_LIST_META_CLASSES),children:[t.jsx(a.Typography,{variant:"caption",component:"span",className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__author`,e.MESSAGE_LIST_AUTHOR_CLASSES),children:S.author.name}),h&&t.jsx(a.Typography,{variant:"caption",component:"span",className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:y(S.messages[0].timestamp)})]}),S.messages.map(s=>t.jsx("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__bubble`,e.MESSAGE_LIST_BUBBLE_CLASSES,S.isOwn&&`${e.MESSAGE_LIST_ROOT_CLASS}__bubble--own`,S.isOwn&&e.MESSAGE_LIST_BUBBLE_OWN_CLASSES),children:(L==null?void 0:L(s))??s.content},s.id)),S.isOwn&&h&&t.jsx(a.Typography,{variant:"caption",component:"span",className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__timestamp`,e.MESSAGE_LIST_TIMESTAMP_CLASSES),children:y(S.messages[S.messages.length-1].timestamp)})]})]},S.key),x=S=>S.kind==="day"?t.jsxs("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-separator`,e.MESSAGE_LIST_DAY_SEPARATOR_CLASSES),children:[t.jsx("span",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)}),t.jsx("span",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-label`,e.MESSAGE_LIST_DAY_LABEL_CLASSES),children:X(S.date)}),t.jsx("span",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__day-line`,e.MESSAGE_LIST_DAY_LINE_CLASSES)})]},S.key):K(S),i=v?A.getMessageListWindow(o,k,z,U):null,j=i===null?o:o.slice(i.startIndex,i.endIndex+1);return t.jsxs("div",{id:F,"data-testid":B,className:n.cn(e.MESSAGE_LIST_ROOT_CLASS,e.MESSAGE_LIST_BASE_CLASSES,Y),style:{height:typeof E=="number"?`${E}px`:E},children:[t.jsxs("div",{ref:l,onScroll:Z,className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__scroller`,e.MESSAGE_LIST_SCROLLER_CLASSES),role:"log","aria-live":"polite",children:[o.length===0&&t.jsx("div",{className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__empty`,e.MESSAGE_LIST_EMPTY_CLASSES),children:D??t.jsx(a.Typography,{variant:"body2",component:"span",children:R.emptyLabel})}),v&&i?t.jsx("div",{className:`${e.MESSAGE_LIST_ROOT_CLASS}__virtual`,style:{height:i.totalHeight,position:"relative"},children:t.jsx("div",{style:{transform:`translateY(${i.offsetTop}px)`},children:j.map(S=>x(S))})}):j.map(S=>x(S))]}),V&&t.jsx("button",{type:"button",onClick:J,className:n.cn(`${e.MESSAGE_LIST_ROOT_CLASS}__new-messages`,e.MESSAGE_LIST_NEW_MESSAGES_CLASSES),children:R.newMessages})]})};exports.MessageList=nS;