@acronis-platform/ui-react 0.62.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/components/ui/alert/alert.js +115 -57
  2. package/dist/components/ui/alert/alert.js.map +1 -1
  3. package/dist/components/ui/button-group/button-group.js +57 -0
  4. package/dist/components/ui/button-group/button-group.js.map +1 -0
  5. package/dist/components/ui/button-icon-menu/button-icon-menu.js +26 -0
  6. package/dist/components/ui/button-icon-menu/button-icon-menu.js.map +1 -0
  7. package/dist/components/ui/calendar-panel/calendar-panel.js.map +1 -1
  8. package/dist/components/ui/chip/chip.js +33 -33
  9. package/dist/components/ui/chip/chip.js.map +1 -1
  10. package/dist/components/ui/date-range-picker/date-range-picker-utils.js +11 -23
  11. package/dist/components/ui/date-range-picker/date-range-picker-utils.js.map +1 -1
  12. package/dist/components/ui/date-range-picker/date-range-picker.js +94 -134
  13. package/dist/components/ui/date-range-picker/date-range-picker.js.map +1 -1
  14. package/dist/components/ui/dropdown-menu/dropdown-menu.js +129 -72
  15. package/dist/components/ui/dropdown-menu/dropdown-menu.js.map +1 -1
  16. package/dist/components/ui/filter-chips/filter-chips.js +44 -0
  17. package/dist/components/ui/filter-chips/filter-chips.js.map +1 -0
  18. package/dist/components/ui/filter-search/filter-search.js +184 -138
  19. package/dist/components/ui/filter-search/filter-search.js.map +1 -1
  20. package/dist/components/ui/fitted-actions/fitted-actions.js +139 -0
  21. package/dist/components/ui/fitted-actions/fitted-actions.js.map +1 -0
  22. package/dist/components/ui/input-date-picker/input-date-picker.js +103 -93
  23. package/dist/components/ui/input-date-picker/input-date-picker.js.map +1 -1
  24. package/dist/components/ui/input-password/input-password.js +76 -66
  25. package/dist/components/ui/input-password/input-password.js.map +1 -1
  26. package/dist/components/ui/input-search/input-search.js +9 -9
  27. package/dist/components/ui/input-search/input-search.js.map +1 -1
  28. package/dist/components/ui/input-select/input-select.js +8 -8
  29. package/dist/components/ui/input-select/input-select.js.map +1 -1
  30. package/dist/components/ui/input-text/input-text.js +77 -66
  31. package/dist/components/ui/input-text/input-text.js.map +1 -1
  32. package/dist/components/ui/input-text-area/input-text-area.js +76 -66
  33. package/dist/components/ui/input-text-area/input-text-area.js.map +1 -1
  34. package/dist/components/ui/link/link.js +50 -35
  35. package/dist/components/ui/link/link.js.map +1 -1
  36. package/dist/components/ui/number-field/number-field.js +1 -1
  37. package/dist/components/ui/number-field/number-field.js.map +1 -1
  38. package/dist/components/ui/popover/popover.js +75 -56
  39. package/dist/components/ui/popover/popover.js.map +1 -1
  40. package/dist/components/ui/scroll-area/scroll-area.js +46 -30
  41. package/dist/components/ui/scroll-area/scroll-area.js.map +1 -1
  42. package/dist/components/ui/timer/timer.js +47 -0
  43. package/dist/components/ui/timer/timer.js.map +1 -0
  44. package/dist/components/ui/toast/toast.js +168 -61
  45. package/dist/components/ui/toast/toast.js.map +1 -1
  46. package/dist/components/ui/truncate-text/middle-truncate.js +20 -0
  47. package/dist/components/ui/truncate-text/middle-truncate.js.map +1 -0
  48. package/dist/components/ui/truncate-text/text-width.js +12 -0
  49. package/dist/components/ui/truncate-text/text-width.js.map +1 -0
  50. package/dist/components/ui/truncate-text/truncate-text.js +152 -0
  51. package/dist/components/ui/truncate-text/truncate-text.js.map +1 -0
  52. package/dist/index.js +505 -473
  53. package/dist/index.js.map +1 -1
  54. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/addDays.js +5 -5
  55. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/addDays.js.map +1 -1
  56. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/constants.js +3 -6
  57. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/constants.js.map +1 -1
  58. package/dist/react.js +505 -473
  59. package/dist/react.js.map +1 -1
  60. package/dist/src/components/ui/alert/alert.d.ts +34 -3
  61. package/dist/src/components/ui/alert/index.d.ts +2 -2
  62. package/dist/src/components/ui/button/button.d.ts +1 -1
  63. package/dist/src/components/ui/button-group/button-group.d.ts +38 -0
  64. package/dist/src/components/ui/button-group/index.d.ts +1 -0
  65. package/dist/src/components/ui/button-icon/button-icon.d.ts +1 -1
  66. package/dist/src/components/ui/button-icon-menu/button-icon-menu.d.ts +28 -0
  67. package/dist/src/components/ui/button-icon-menu/index.d.ts +1 -0
  68. package/dist/src/components/ui/button-menu/button-menu.d.ts +1 -1
  69. package/dist/src/components/ui/calendar-panel/calendar-panel.d.ts +2 -2
  70. package/dist/src/components/ui/chip/chip.d.ts +1 -1
  71. package/dist/src/components/ui/date-range-picker/date-range-picker-utils.d.ts +10 -16
  72. package/dist/src/components/ui/date-range-picker/date-range-picker.d.ts +46 -2
  73. package/dist/src/components/ui/dropdown-menu/dropdown-menu.d.ts +8 -1
  74. package/dist/src/components/ui/dropdown-menu/index.d.ts +1 -1
  75. package/dist/src/components/ui/filter-chips/filter-chips.d.ts +25 -0
  76. package/dist/src/components/ui/filter-chips/index.d.ts +1 -0
  77. package/dist/src/components/ui/filter-search/filter-search.d.ts +39 -1
  78. package/dist/src/components/ui/fitted-actions/fitted-actions.d.ts +50 -0
  79. package/dist/src/components/ui/fitted-actions/fitted-actions.docs.d.ts +45 -0
  80. package/dist/src/components/ui/fitted-actions/index.d.ts +1 -0
  81. package/dist/src/components/ui/link/index.d.ts +1 -1
  82. package/dist/src/components/ui/link/link.d.ts +22 -4
  83. package/dist/src/components/ui/metric/metric.d.ts +1 -1
  84. package/dist/src/components/ui/popover/popover.d.ts +30 -1
  85. package/dist/src/components/ui/popover/popover.docs.d.ts +27 -2
  86. package/dist/src/components/ui/scroll-area/scroll-area.d.ts +24 -0
  87. package/dist/src/components/ui/tag/tag.d.ts +1 -1
  88. package/dist/src/components/ui/timer/index.d.ts +1 -0
  89. package/dist/src/components/ui/timer/timer.d.ts +28 -0
  90. package/dist/src/components/ui/toast/index.d.ts +1 -1
  91. package/dist/src/components/ui/toast/toast.d.ts +51 -18
  92. package/dist/src/components/ui/toast/toast.docs.d.ts +4 -0
  93. package/dist/src/components/ui/trend-indicator/trend-indicator.d.ts +1 -1
  94. package/dist/src/components/ui/truncate-text/__tests__/middle-truncate.test.d.ts +1 -0
  95. package/dist/src/components/ui/truncate-text/index.d.ts +3 -0
  96. package/dist/src/components/ui/truncate-text/middle-truncate.d.ts +13 -0
  97. package/dist/src/components/ui/truncate-text/text-width.d.ts +11 -0
  98. package/dist/src/components/ui/truncate-text/truncate-text.d.ts +45 -0
  99. package/dist/src/components/ui/truncate-text/truncate-text.docs.d.ts +35 -0
  100. package/dist/src/index.d.ts +6 -0
  101. package/dist/ui-react.css +1 -1
  102. package/package.json +3 -3
  103. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/getDefaultOptions.js +0 -8
  104. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/getDefaultOptions.js.map +0 -1
  105. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/getISODay.js +0 -9
  106. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/getISODay.js.map +0 -1
  107. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/Parser.js +0 -23
  108. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/Parser.js.map +0 -1
  109. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/Setter.js +0 -42
  110. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/Setter.js.map +0 -1
  111. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/constants.js +0 -50
  112. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/constants.js.map +0 -1
  113. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/AMPMMidnightParser.js +0 -50
  114. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/AMPMMidnightParser.js.map +0 -1
  115. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/AMPMParser.js +0 -50
  116. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/AMPMParser.js.map +0 -1
  117. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DateParser.js +0 -62
  118. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DateParser.js.map +0 -1
  119. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayOfYearParser.js +0 -52
  120. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayOfYearParser.js.map +0 -1
  121. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayParser.js +0 -50
  122. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayParser.js.map +0 -1
  123. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.js +0 -50
  124. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/DayPeriodParser.js.map +0 -1
  125. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/EraParser.js +0 -34
  126. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/EraParser.js.map +0 -1
  127. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ExtendedYearParser.js +0 -22
  128. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ExtendedYearParser.js.map +0 -1
  129. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.js +0 -23
  130. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/FractionOfSecondParser.js.map +0 -1
  131. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js +0 -33
  132. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour0To11Parser.js.map +0 -1
  133. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour0to23Parser.js +0 -33
  134. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour0to23Parser.js.map +0 -1
  135. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.js +0 -34
  136. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour1To24Parser.js.map +0 -1
  137. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour1to12Parser.js +0 -34
  138. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/Hour1to12Parser.js.map +0 -1
  139. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISODayParser.js +0 -106
  140. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISODayParser.js.map +0 -1
  141. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.js +0 -49
  142. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneParser.js.map +0 -1
  143. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.js +0 -49
  144. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOTimezoneWithZParser.js.map +0 -1
  145. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOWeekParser.js +0 -50
  146. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOWeekParser.js.map +0 -1
  147. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOWeekYearParser.js +0 -41
  148. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/ISOWeekYearParser.js.map +0 -1
  149. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalDayParser.js +0 -81
  150. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalDayParser.js.map +0 -1
  151. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalWeekParser.js +0 -49
  152. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalWeekParser.js.map +0 -1
  153. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.js +0 -70
  154. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/LocalWeekYearParser.js.map +0 -1
  155. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/MinuteParser.js +0 -33
  156. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/MinuteParser.js.map +0 -1
  157. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/MonthParser.js +0 -78
  158. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/MonthParser.js.map +0 -1
  159. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/QuarterParser.js +0 -76
  160. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/QuarterParser.js.map +0 -1
  161. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/SecondParser.js +0 -33
  162. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/SecondParser.js.map +0 -1
  163. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.js +0 -81
  164. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.js.map +0 -1
  165. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneMonthParser.js +0 -78
  166. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneMonthParser.js.map +0 -1
  167. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneQuarterParser.js +0 -76
  168. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/StandAloneQuarterParser.js.map +0 -1
  169. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.js +0 -23
  170. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/TimestampMillisecondsParser.js.map +0 -1
  171. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/TimestampSecondsParser.js +0 -23
  172. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/TimestampSecondsParser.js.map +0 -1
  173. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/YearParser.js +0 -50
  174. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers/YearParser.js.map +0 -1
  175. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers.js +0 -68
  176. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/parsers.js.map +0 -1
  177. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/utils.js +0 -104
  178. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse/_lib/utils.js.map +0 -1
  179. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse.js +0 -86
  180. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/parse.js.map +0 -1
  181. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setDay.js +0 -12
  182. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setDay.js.map +0 -1
  183. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setISODay.js +0 -11
  184. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setISODay.js.map +0 -1
  185. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setISOWeek.js +0 -10
  186. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setISOWeek.js.map +0 -1
  187. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setWeek.js +0 -10
  188. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/setWeek.js.map +0 -1
  189. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/transpose.js +0 -18
  190. package/dist/node_modules/.pnpm/date-fns@4.3.0/node_modules/date-fns/transpose.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
+ import * as m from "react";
3
+ import { cn as i } from "../../../lib/utils.js";
4
+ import { ButtonGroup as c } from "../button-group/button-group.js";
5
+ const u = m.forwardRef(
6
+ ({ className: t, value: o, children: r, actionsLabel: n = "Timer actions", ...a }, l) => /* @__PURE__ */ d(
7
+ "div",
8
+ {
9
+ ref: l,
10
+ className: i(
11
+ // `overflow-hidden` clips the trailing action's hover fill and inset
12
+ // focus ring to the container's radius — the same reason ButtonGroup
13
+ // needs it, one level up.
14
+ "inline-flex h-[var(--ui-timer-container-height)] w-fit items-center overflow-hidden",
15
+ "rounded-[var(--ui-timer-container-radius)] bg-[var(--ui-timer-container-color)]",
16
+ "border-[length:var(--ui-timer-container-border-width)] border-[color:var(--ui-timer-container-border-color)] [border-style:var(--ui-timer-container-border-style)]",
17
+ t
18
+ ),
19
+ ...a,
20
+ children: [
21
+ /* @__PURE__ */ e(
22
+ "div",
23
+ {
24
+ role: "timer",
25
+ className: i(
26
+ "ui-timer-value-text-style flex h-full shrink-0 items-center whitespace-nowrap",
27
+ "px-[var(--ui-timer-content-box-padding-x)] text-[var(--ui-timer-value-color)]",
28
+ "[font-variant-numeric:var(--ui-timer-value-font-variant-numeric)]",
29
+ // The divider is the readout's own inline-end border, as in Figma,
30
+ // and is derived from the DOM rather than a prop: with no actions the
31
+ // readout is the last child and the border is dropped. `border-e-*`
32
+ // (not `border-r-*`) so it flips under `dir="rtl"`.
33
+ "border-e-[length:var(--ui-timer-content-box-divider-width)] border-[color:var(--ui-timer-content-box-divider-color)] [border-inline-end-style:var(--ui-timer-content-box-divider-style)] last:border-e-0"
34
+ ),
35
+ children: o
36
+ }
37
+ ),
38
+ r ? /* @__PURE__ */ e(c, { variant: "inlined", "aria-label": n, children: r }) : null
39
+ ]
40
+ }
41
+ )
42
+ );
43
+ u.displayName = "Timer";
44
+ export {
45
+ u as Timer
46
+ };
47
+ //# sourceMappingURL=timer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timer.js","sources":["../../../../src/components/ui/timer/timer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { ButtonGroup } from '@/components/ui/button-group';\nimport { cn } from '@/lib/utils';\n\n// Mirrors the Figma \"Timer\" component (node 7987:25477): a bordered 32px pill\n// holding an elapsed-time readout, hairline-separated from a cluster of\n// icon-only actions.\n//\n// Figma models exactly two properties on it — `value` (TEXT) and the nested\n// ButtonGroup's `ListItem` slot — so that is the whole API: a required `value`\n// and variadic `children`. There is no variant axis and no design-defined\n// state, so no `cva` here.\n//\n// The action cluster is a real `ButtonGroup` with `variant=\"inlined\"` (the\n// design instantiates it exactly that way) because the Timer container already\n// draws the border and radius an `outlined` group would duplicate. Composing it\n// rather than re-implementing the item box keeps the separators, the roving\n// tabindex, and the hover/active/focus fills in one place — which is also why\n// the actions are plain `ButtonGroupItem` children rather than a Timer-specific\n// alias of it.\n//\n// The Timer does NOT tick: it renders whatever it is given. Formatting and the\n// interval belong to the consumer, who owns the clock the actions operate on.\n\nexport interface TimerProps\n extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {\n /**\n * The formatted time to display, e.g. `\"12:01:45\"`. Rendered with tabular\n * figures so the readout doesn't jitter as the digits change. The component\n * neither ticks nor formats — pass an already-formatted value.\n */\n value: React.ReactNode;\n /**\n * The actions, as `ButtonGroupItem` elements in visual order. Omit them for a\n * read-only readout — with no actions the divider is dropped too.\n */\n children?: React.ReactNode;\n /**\n * Accessible name for the action cluster's toolbar. Localize it; the default\n * is English.\n */\n actionsLabel?: string;\n}\n\n/**\n * An elapsed-time readout paired with a cluster of icon-only actions.\n *\n * The readout is a `role=\"timer\"` live region — implicitly `aria-live=\"off\"`,\n * so it is not announced on every tick. Each action needs its own accessible\n * name; the cluster as a whole is named by `actionsLabel`.\n */\nconst Timer = React.forwardRef<HTMLDivElement, TimerProps>(\n (\n { className, value, children, actionsLabel = 'Timer actions', ...props },\n ref\n ) => (\n <div\n ref={ref}\n className={cn(\n // `overflow-hidden` clips the trailing action's hover fill and inset\n // focus ring to the container's radius — the same reason ButtonGroup\n // needs it, one level up.\n 'inline-flex h-[var(--ui-timer-container-height)] w-fit items-center overflow-hidden',\n 'rounded-[var(--ui-timer-container-radius)] bg-[var(--ui-timer-container-color)]',\n 'border-[length:var(--ui-timer-container-border-width)] border-[color:var(--ui-timer-container-border-color)] [border-style:var(--ui-timer-container-border-style)]',\n className\n )}\n {...props}\n >\n <div\n role=\"timer\"\n className={cn(\n 'ui-timer-value-text-style flex h-full shrink-0 items-center whitespace-nowrap',\n 'px-[var(--ui-timer-content-box-padding-x)] text-[var(--ui-timer-value-color)]',\n '[font-variant-numeric:var(--ui-timer-value-font-variant-numeric)]',\n // The divider is the readout's own inline-end border, as in Figma,\n // and is derived from the DOM rather than a prop: with no actions the\n // readout is the last child and the border is dropped. `border-e-*`\n // (not `border-r-*`) so it flips under `dir=\"rtl\"`.\n 'border-e-[length:var(--ui-timer-content-box-divider-width)] border-[color:var(--ui-timer-content-box-divider-color)] [border-inline-end-style:var(--ui-timer-content-box-divider-style)] last:border-e-0'\n )}\n >\n {value}\n </div>\n {children ? (\n <ButtonGroup variant=\"inlined\" aria-label={actionsLabel}>\n {children}\n </ButtonGroup>\n ) : null}\n </div>\n )\n);\nTimer.displayName = 'Timer';\n\nexport { Timer };\n"],"names":["Timer","React","className","value","children","actionsLabel","props","ref","jsxs","cn","jsx","ButtonGroup"],"mappings":";;;;AAoDA,MAAMA,IAAQC,EAAM;AAAA,EAClB,CACE,EAAE,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,cAAAC,IAAe,iBAAiB,GAAGC,KACjEC,MAEA,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAD;AAAA,MACA,WAAWE;AAAA;AAAA;AAAA;AAAA,QAIT;AAAA,QACA;AAAA,QACA;AAAA,QACAP;AAAA,MAAA;AAAA,MAED,GAAGI;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAI;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAWD;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA;AAAA;AAAA;AAAA;AAAA,cAKA;AAAA,YAAA;AAAA,YAGD,UAAAN;AAAA,UAAA;AAAA,QAAA;AAAA,QAEFC,sBACEO,GAAA,EAAY,SAAQ,WAAU,cAAYN,GACxC,UAAAD,GACH,IACE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;AACAJ,EAAM,cAAc;"}
@@ -1,85 +1,192 @@
1
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
2
- import { Toast as o } from "@base-ui/react/toast";
3
- import { TimesIcon as d, CircleTimesIcon as m, TriangleWarningIcon as u, CircleInfoIcon as f, CircleCheckIcon as x } from "@acronis-platform/icons-react/stroke-mono";
4
- import { cn as g } from "../../../lib/utils.js";
5
- import { usePortalContainer as p } from "../../../lib/portal-container.js";
6
- import { Spinner as v } from "../spinner/spinner.js";
7
- const i = o.createToastManager();
8
- function a(t, e, n = {}) {
9
- const { action: r, ...l } = n;
10
- return i.add({
1
+ import { jsx as o, jsxs as u } from "react/jsx-runtime";
2
+ import { Toast as r } from "@base-ui/react/toast";
3
+ import { cva as v } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
4
+ import { TimesIcon as m } from "@acronis-platform/icons-react/stroke-mono";
5
+ import { DiamondWarningRedIcon as x, CircleWarningOrangeIcon as w, TriangleWarningYellowIcon as h, CircleCheckGreenIcon as y, CircleInfoBlueIcon as C } from "@acronis-platform/icons-react/stroke-multi";
6
+ import { cn as N } from "../../../lib/utils.js";
7
+ import { usePortalContainer as T } from "../../../lib/portal-container.js";
8
+ import { Spinner as I } from "../spinner/spinner.js";
9
+ import { Button as k } from "../button/button.js";
10
+ import { ButtonIcon as z } from "../button-icon/button-icon.js";
11
+ const _ = v(
12
+ "relative flex w-full items-start overflow-clip [overflow-clip-margin:border-box] border-solid gap-[var(--ui-toast-global-container-gap)] px-[var(--ui-toast-global-container-padding-x)] py-[var(--ui-toast-global-container-padding-y)] rounded-[var(--ui-toast-global-container-border-radius)] border-[length:var(--ui-toast-global-container-border-width)] bg-[var(--ui-toast-global-container-background)] shadow-[var(--ui-toast-global-container-shadow)] before:absolute before:content-[''] before:-inset-y-px before:start-[-1px] before:w-[var(--ui-toast-global-container-status-width)]",
13
+ {
14
+ variants: {
15
+ variant: {
16
+ info: "border-[color:var(--ui-toast-info-border-color)] before:bg-[var(--ui-toast-info-left-line)]",
17
+ success: "border-[color:var(--ui-toast-success-border-color)] before:bg-[var(--ui-toast-success-left-line)]",
18
+ warning: "border-[color:var(--ui-toast-warning-border-color)] before:bg-[var(--ui-toast-warning-left-line)]",
19
+ critical: "border-[color:var(--ui-toast-critical-border-color)] before:bg-[var(--ui-toast-critical-left-line)]",
20
+ danger: "border-[color:var(--ui-toast-danger-border-color)] before:bg-[var(--ui-toast-danger-left-line)]"
21
+ }
22
+ },
23
+ defaultVariants: {
24
+ variant: "info"
25
+ }
26
+ }
27
+ ), B = {
28
+ info: C,
29
+ success: y,
30
+ warning: h,
31
+ critical: w,
32
+ danger: x
33
+ }, P = {
34
+ info: "info",
35
+ success: "success",
36
+ warning: "warning",
37
+ critical: "critical",
38
+ danger: "danger",
39
+ error: "danger",
40
+ loading: "info"
41
+ }, d = r.createToastManager();
42
+ function s(t, a, n = {}) {
43
+ const { actions: e, dismissable: l, ...i } = n;
44
+ return d.add({
11
45
  title: t,
12
- type: e,
13
- actionProps: r ? { children: r.label, onClick: r.onClick } : void 0,
14
- ...l
46
+ type: a,
47
+ data: { actions: e, dismissable: l },
48
+ ...i
15
49
  });
16
50
  }
17
- const I = Object.assign(
18
- (t, e) => a(t, void 0, e),
51
+ const G = Object.assign(
52
+ (t, a) => s(t, void 0, a),
19
53
  {
20
- success: (t, e) => a(t, "success", e),
21
- info: (t, e) => a(t, "info", e),
22
- warning: (t, e) => a(t, "warning", e),
23
- error: (t, e) => a(t, "error", e),
24
- loading: (t, e) => a(t, "loading", { timeout: 0, ...e }),
25
- dismiss: (t) => i.close(t),
26
- promise: i.promise
54
+ info: (t, a) => s(t, "info", a),
55
+ success: (t, a) => s(t, "success", a),
56
+ warning: (t, a) => s(t, "warning", a),
57
+ critical: (t, a) => s(t, "critical", a),
58
+ danger: (t, a) => s(t, "danger", a),
59
+ loading: (t, a) => s(t, "loading", { timeout: 0, ...a }),
60
+ dismiss: (t) => d.close(t),
61
+ promise: d.promise
27
62
  }
28
- ), N = {
29
- success: /* @__PURE__ */ s(x, { className: "size-4 text-[var(--ui-text-on-status-success)]" }),
30
- info: /* @__PURE__ */ s(f, { className: "size-4 text-[var(--ui-text-on-status-info)]" }),
31
- warning: /* @__PURE__ */ s(u, { className: "size-4 text-[var(--ui-text-on-status-warning)]" }),
32
- error: /* @__PURE__ */ s(m, { className: "size-4 text-[var(--ui-text-on-status-danger)]" }),
33
- loading: /* @__PURE__ */ s(v, { size: "sm", className: "size-4" })
34
- };
35
- function b() {
36
- const { toasts: t } = o.useToastManager();
37
- return t.map((e) => {
38
- const n = N[e.type];
39
- return /* @__PURE__ */ c(
40
- o.Root,
63
+ );
64
+ function S({ closeAriaLabel: t }) {
65
+ const { toasts: a } = r.useToastManager();
66
+ return a.map((n) => {
67
+ var b, p;
68
+ const e = P[n.type ?? ""] ?? "info", l = B[e], i = (b = n.data) == null ? void 0 : b.actions, c = ((p = n.data) == null ? void 0 : p.dismissable) ?? !0;
69
+ return /* @__PURE__ */ u(
70
+ r.Root,
41
71
  {
42
- toast: e,
43
- className: g(
44
- "relative flex w-full items-start gap-3 rounded border border-border bg-background p-4 shadow-md",
72
+ toast: n,
73
+ "data-slot": "toast",
74
+ "data-variant": e,
75
+ swipeDirection: c ? void 0 : [],
76
+ className: N(
77
+ _({ variant: e }),
45
78
  "transition-all data-[ending-style]:opacity-0 data-[starting-style]:opacity-0",
46
- "data-[starting-style]:translate-x-4 data-[ending-style]:translate-x-4"
79
+ // The stack sits on the inline-end edge, so a toast slides in from the
80
+ // right in LTR and from the left in RTL.
81
+ "data-[ending-style]:translate-x-4 data-[starting-style]:translate-x-4",
82
+ "rtl:data-[ending-style]:-translate-x-4 rtl:data-[starting-style]:-translate-x-4"
47
83
  ),
48
84
  children: [
49
- n ? /* @__PURE__ */ s("span", { className: "mt-0.5 shrink-0", children: n }) : null,
50
- /* @__PURE__ */ c("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
51
- /* @__PURE__ */ s(o.Title, { className: "text-sm font-semibold leading-5 text-foreground" }),
52
- /* @__PURE__ */ s(o.Description, { className: "text-sm leading-5 text-muted-foreground" }),
53
- e.actionProps ? /* @__PURE__ */ s(o.Action, { className: "mt-1 self-start text-sm font-semibold text-secondary hover:underline" }) : null
54
- ] }),
55
- /* @__PURE__ */ s(
56
- o.Close,
85
+ /* @__PURE__ */ o(
86
+ "div",
87
+ {
88
+ "data-slot": "toast-icon",
89
+ className: "flex shrink-0 items-start px-[var(--ui-toast-global-icon-padding-x)] py-[var(--ui-toast-global-icon-padding-y)] [&_svg]:size-[var(--ui-toast-global-icon-size)] [&_svg]:shrink-0",
90
+ children: n.type === "loading" ? /* @__PURE__ */ o(
91
+ I,
92
+ {
93
+ size: "sm",
94
+ className: "size-[var(--ui-toast-global-icon-size)]"
95
+ }
96
+ ) : /* @__PURE__ */ o(l, { size: 16 })
97
+ }
98
+ ),
99
+ /* @__PURE__ */ u(
100
+ "div",
101
+ {
102
+ "data-slot": "toast-content",
103
+ className: "flex min-w-0 flex-1 flex-col items-start gap-[var(--ui-toast-global-content-gap)] px-[var(--ui-toast-global-content-padding-x)] py-[var(--ui-toast-global-content-padding-y)]",
104
+ children: [
105
+ /* @__PURE__ */ u(
106
+ "div",
107
+ {
108
+ "data-slot": "toast-text",
109
+ className: "flex w-full shrink-0 flex-col items-start gap-[var(--ui-toast-global-content-text-container-gap)] px-[var(--ui-toast-global-content-text-container-padding-x)] py-[var(--ui-toast-global-content-text-container-padding-y)] [word-break:break-word]",
110
+ children: [
111
+ /* @__PURE__ */ o(
112
+ r.Title,
113
+ {
114
+ "data-slot": "toast-title",
115
+ render: /* @__PURE__ */ o("h5", {}),
116
+ className: "ui-typography-headings-lead mb-0 w-full text-[var(--ui-toast-global-content-text-container-title-color)]"
117
+ }
118
+ ),
119
+ n.description ? /* @__PURE__ */ o(
120
+ r.Description,
121
+ {
122
+ "data-slot": "toast-description",
123
+ className: "ui-toast-global-content-text-container-description-text-style line-clamp-3 w-full text-[var(--ui-toast-global-content-text-container-description-color)]"
124
+ }
125
+ ) : null
126
+ ]
127
+ }
128
+ ),
129
+ i != null && i.length ? /* @__PURE__ */ o(
130
+ "div",
131
+ {
132
+ "data-slot": "toast-actions",
133
+ className: "flex w-full shrink-0 flex-wrap content-start items-start gap-x-[var(--ui-toast-global-content-actions-container-gap-x)] gap-y-[var(--ui-toast-global-content-actions-container-gap-y)] px-[var(--ui-toast-global-content-actions-container-padding-x)] py-[var(--ui-toast-global-content-actions-container-padding-y)]",
134
+ children: i.map((g, f) => /* @__PURE__ */ o(
135
+ k,
136
+ {
137
+ variant: g.variant ?? (f === 0 ? "secondary" : "ghost"),
138
+ onClick: g.onClick,
139
+ children: g.label
140
+ },
141
+ f
142
+ ))
143
+ }
144
+ ) : null
145
+ ]
146
+ }
147
+ ),
148
+ c ? /* @__PURE__ */ o(
149
+ r.Close,
57
150
  {
58
- "aria-label": "Close",
59
- className: "shrink-0 rounded text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ui-focus-primary)]",
60
- children: /* @__PURE__ */ s(d, { className: "size-4" })
151
+ "aria-label": t,
152
+ "data-slot": "toast-close",
153
+ render: /* @__PURE__ */ o(z, { variant: "ghost", children: /* @__PURE__ */ o(m, {}) })
61
154
  }
62
- )
155
+ ) : null
63
156
  ]
64
157
  },
65
- e.id
158
+ n.id
66
159
  );
67
160
  });
68
161
  }
69
- function k({ timeout: t, limit: e, portalContainer: n }) {
70
- const r = p(), l = n ?? r;
71
- return /* @__PURE__ */ s(
72
- o.Provider,
162
+ function L({
163
+ timeout: t,
164
+ limit: a,
165
+ label: n = "Notifications",
166
+ closeAriaLabel: e = "Close",
167
+ portalContainer: l
168
+ }) {
169
+ const i = T(), c = l ?? i;
170
+ return /* @__PURE__ */ o(
171
+ r.Provider,
73
172
  {
74
- toastManager: i,
173
+ toastManager: d,
75
174
  timeout: t,
76
- limit: e,
77
- children: /* @__PURE__ */ s(o.Portal, { container: l, children: /* @__PURE__ */ s(o.Viewport, { className: "fixed bottom-4 end-4 z-[100] flex w-[384px] max-w-[calc(100vw-2rem)] flex-col gap-3 outline-none", children: /* @__PURE__ */ s(b, {}) }) })
175
+ limit: a,
176
+ children: /* @__PURE__ */ o(r.Portal, { container: c, children: /* @__PURE__ */ o(
177
+ r.Viewport,
178
+ {
179
+ "aria-label": n,
180
+ className: "fixed bottom-4 end-4 z-[100] flex w-[var(--ui-toast-global-container-width-min)] max-w-[calc(100vw-2rem)] flex-col gap-3 outline-none",
181
+ children: /* @__PURE__ */ o(S, { closeAriaLabel: e })
182
+ }
183
+ ) })
78
184
  }
79
185
  );
80
186
  }
81
187
  export {
82
- k as Toaster,
83
- I as toast
188
+ L as Toaster,
189
+ G as toast,
190
+ _ as toastVariants
84
191
  };
85
192
  //# sourceMappingURL=toast.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toast.js","sources":["../../../../src/components/ui/toast/toast.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Toast as ToastPrimitive } from '@base-ui/react/toast';\nimport {\n CircleCheckIcon,\n CircleInfoIcon,\n CircleTimesIcon,\n TimesIcon,\n TriangleWarningIcon,\n} from '@acronis-platform/icons-react/stroke-mono';\n\nimport { cn } from '@/lib/utils';\nimport { usePortalContainer } from '@/lib/portal-container';\nimport { Spinner } from '../spinner';\n\n// Ported from `@acronis-platform/shadcn-uikit`'s `sonner`\n// (packages/ui-legacy/src/components/ui/sonner.tsx), which wrapped the Sonner\n// library. Rebuilt on the Base UI toast primitive (the ui-react convention), so\n// no Sonner dependency. The contract is preserved: drop a single `<Toaster />`\n// at the app root and call the imperative `toast(...)` / `toast.success(...)`\n// API from anywhere. No `--ui-toast-*` tier yet, so this design-pending v1 is a\n// neutral surface (bg-background + border-border + shadow) with the status\n// conveyed by a colored leading icon (`--ui-text-on-status-*`); per-status\n// surface tinting is design-pending. Auto-dismiss after `timeout` (default\n// 5000ms); `loading` toasts persist until updated or dismissed.\n\n// A module-level manager so `toast(...)` works outside React (like Sonner's\n// `toast`). `<Toaster />` subscribes this manager to its provider.\nconst toastManager = ToastPrimitive.createToastManager();\n\nexport type ToastType = 'success' | 'info' | 'warning' | 'error' | 'loading';\n\nexport interface ToastOptions {\n /** Secondary line under the title. */\n description?: React.ReactNode;\n /** Auto-dismiss delay in ms; `0` keeps the toast until dismissed. */\n timeout?: number;\n /** A single inline action button (e.g. Undo). */\n action?: { label: React.ReactNode; onClick?: () => void };\n /** Stable id — re-adding with the same id updates the toast in place. */\n id?: string;\n}\n\nfunction add(title: React.ReactNode, type?: ToastType, options: ToastOptions = {}) {\n const { action, ...rest } = options;\n return toastManager.add({\n title,\n type,\n actionProps: action\n ? { children: action.label, onClick: action.onClick }\n : undefined,\n ...rest,\n });\n}\n\n/**\n * Imperative toast API. `toast(title, options)` shows a neutral toast;\n * `toast.success` / `info` / `warning` / `error` / `loading` set the variant.\n * `toast.dismiss(id?)` closes one (or all) and `toast.promise` ties a toast to a\n * promise's lifecycle.\n */\nconst toast = Object.assign(\n (title: React.ReactNode, options?: ToastOptions) => add(title, undefined, options),\n {\n success: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'success', options),\n info: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'info', options),\n warning: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'warning', options),\n error: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'error', options),\n loading: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'loading', { timeout: 0, ...options }),\n dismiss: (id?: string) => toastManager.close(id),\n promise: toastManager.promise,\n }\n);\n\nconst ICON_BY_TYPE: Record<ToastType, React.ReactNode> = {\n success: (\n <CircleCheckIcon className=\"size-4 text-[var(--ui-text-on-status-success)]\" />\n ),\n info: (\n <CircleInfoIcon className=\"size-4 text-[var(--ui-text-on-status-info)]\" />\n ),\n warning: (\n <TriangleWarningIcon className=\"size-4 text-[var(--ui-text-on-status-warning)]\" />\n ),\n error: (\n <CircleTimesIcon className=\"size-4 text-[var(--ui-text-on-status-danger)]\" />\n ),\n loading: <Spinner size=\"sm\" className=\"size-4\" />,\n};\n\nfunction ToastList() {\n const { toasts } = ToastPrimitive.useToastManager();\n return toasts.map((item) => {\n const icon = ICON_BY_TYPE[item.type as ToastType];\n return (\n <ToastPrimitive.Root\n key={item.id}\n toast={item}\n className={cn(\n 'relative flex w-full items-start gap-3 rounded border border-border bg-background p-4 shadow-md',\n 'transition-all data-[ending-style]:opacity-0 data-[starting-style]:opacity-0',\n 'data-[starting-style]:translate-x-4 data-[ending-style]:translate-x-4'\n )}\n >\n {icon ? <span className=\"mt-0.5 shrink-0\">{icon}</span> : null}\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <ToastPrimitive.Title className=\"text-sm font-semibold leading-5 text-foreground\" />\n <ToastPrimitive.Description className=\"text-sm leading-5 text-muted-foreground\" />\n {item.actionProps ? (\n <ToastPrimitive.Action className=\"mt-1 self-start text-sm font-semibold text-secondary hover:underline\" />\n ) : null}\n </div>\n <ToastPrimitive.Close\n aria-label=\"Close\"\n className=\"shrink-0 rounded text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ui-focus-primary)]\"\n >\n <TimesIcon className=\"size-4\" />\n </ToastPrimitive.Close>\n </ToastPrimitive.Root>\n );\n });\n}\n\nexport interface ToasterProps {\n /** Default auto-dismiss delay in ms for toasts that don't set one. */\n timeout?: number;\n /** Max toasts shown at once; the oldest is dropped past the limit. */\n limit?: number;\n /**\n * Portal container for the toast stack. Pass a shadow-root mount for\n * isolated-style previews (the docs demos do this via `useShadowMount`).\n */\n portalContainer?: ToastPrimitive.Portal.Props['container'];\n}\n\n/**\n * The toast region. Render once near the app root; it portals a bottom-right\n * stack and renders every queued toast. Trigger toasts with the `toast` API.\n */\nfunction Toaster({ timeout, limit, portalContainer }: ToasterProps) {\n const ctxContainer = usePortalContainer();\n const resolvedContainer = portalContainer ?? ctxContainer;\n\n return (\n <ToastPrimitive.Provider\n toastManager={toastManager}\n timeout={timeout}\n limit={limit}\n >\n <ToastPrimitive.Portal container={resolvedContainer}>\n <ToastPrimitive.Viewport className=\"fixed bottom-4 end-4 z-[100] flex w-[384px] max-w-[calc(100vw-2rem)] flex-col gap-3 outline-none\">\n <ToastList />\n </ToastPrimitive.Viewport>\n </ToastPrimitive.Portal>\n </ToastPrimitive.Provider>\n );\n}\n\nexport { toast, Toaster };\n"],"names":["toastManager","ToastPrimitive","add","title","type","options","action","rest","toast","id","ICON_BY_TYPE","jsx","CircleCheckIcon","CircleInfoIcon","TriangleWarningIcon","CircleTimesIcon","Spinner","ToastList","toasts","item","icon","jsxs","cn","TimesIcon","Toaster","timeout","limit","portalContainer","ctxContainer","usePortalContainer","resolvedContainer"],"mappings":"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"}
1
+ {"version":3,"file":"toast.js","sources":["../../../../src/components/ui/toast/toast.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Toast as ToastPrimitive } from '@base-ui/react/toast';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { TimesIcon } from '@acronis-platform/icons-react/stroke-mono';\nimport {\n CircleCheckGreenIcon,\n CircleInfoBlueIcon,\n CircleWarningOrangeIcon,\n DiamondWarningRedIcon,\n TriangleWarningYellowIcon,\n type IconProps,\n} from '@acronis-platform/icons-react/stroke-multi';\n\nimport { cn } from '@/lib/utils';\nimport { usePortalContainer } from '@/lib/portal-container';\nimport { Button } from '../button';\nimport { ButtonIcon } from '../button-icon';\nimport { Spinner } from '../spinner';\n\n// Mirrors the Figma \"Toast\" component set (node 7421:126262), which is the Alert\n// banner plus a drop shadow: a *neutral* surface — not a status tint — with the\n// severity carried by a 1px border in the status color and a 6px status line down\n// the leading edge. Geometry, colors, and spacing all come from the dedicated\n// `--ui-toast-*` tier (imported in `src/styles/index.css`).\n//\n// The delivery mechanism is unchanged from the Sonner-compatible port: a single\n// `<Toaster />` at the app root plus the imperative `toast(...)` API, built on the\n// Base UI toast manager (no Sonner dependency). Only the rendered surface and the\n// variant vocabulary changed.\n//\n// The Figma's `hasDescription` / `hasActions` / `dismissable` booleans map onto\n// per-toast options rather than props, since there is no per-toast component to\n// take them: omitting `description` or `actions` drops those parts, and\n// `dismissable: false` drops the close control. `dismissable` also has to switch\n// off Base UI's swipe-to-dismiss, which is on by default — see the `Root` below.\n//\n// The status line is a `::before` pseudo-element rather than a DOM node: it is\n// never optional and never a slot, so a real element would only add markup for\n// consumers to get wrong. It is bled 1px outwards on three sides so it paints\n// *over* the border it sits on (matching the Figma, where the line covers the\n// leading border), and the root's clip rounds its square corners to the\n// container radius. `start-` keeps it on the leading edge under `dir=\"rtl\"`.\n//\n// `overflow-clip-margin: border-box` is load-bearing, not decoration. `overflow:\n// clip` alone clips at the *padding* box, which is exactly where the bleed has to\n// reach — and an absolutely positioned pseudo-element's containing block is that\n// same padding box — so the outward 1px gets shaved off and the line renders 5px\n// wide starting *inside* the border. Since the border and the line are different\n// tokens, that reads as two adjacent stripes rather than one 6px line. Moving the\n// clip edge out to the border box lets the bleed survive while still rounding the\n// corners.\n//\n// Typography comes from the generated classes rather than hand-written utilities:\n// `ui-typography-headings-lead` is the title's Figma text style (Inter Regular\n// 18 / 24 — the same treatment Alert's title uses) and the Toast tier emits its\n// own class for the description (Inter Regular 14 / 24). Only the *colors* are\n// separate token references.\n//\n// One deliberate deviation from the Figma: `container/widthMin` (384px) is applied\n// to the viewport, not to the card. A fixed-position stack with a 384px\n// `min-width` overflows a narrow phone viewport (min-width always beats\n// max-width), so the viewport owns the width and clamps it with `max-w`, and the\n// card just fills it.\nconst toastVariants = cva(\n 'relative flex w-full items-start overflow-clip [overflow-clip-margin:border-box] border-solid ' +\n 'gap-[var(--ui-toast-global-container-gap)] ' +\n 'px-[var(--ui-toast-global-container-padding-x)] py-[var(--ui-toast-global-container-padding-y)] ' +\n 'rounded-[var(--ui-toast-global-container-border-radius)] ' +\n 'border-[length:var(--ui-toast-global-container-border-width)] ' +\n 'bg-[var(--ui-toast-global-container-background)] ' +\n 'shadow-[var(--ui-toast-global-container-shadow)] ' +\n \"before:absolute before:content-[''] before:-inset-y-px before:start-[-1px] \" +\n 'before:w-[var(--ui-toast-global-container-status-width)]',\n {\n variants: {\n variant: {\n info: 'border-[color:var(--ui-toast-info-border-color)] before:bg-[var(--ui-toast-info-left-line)]',\n success:\n 'border-[color:var(--ui-toast-success-border-color)] before:bg-[var(--ui-toast-success-left-line)]',\n warning:\n 'border-[color:var(--ui-toast-warning-border-color)] before:bg-[var(--ui-toast-warning-left-line)]',\n critical:\n 'border-[color:var(--ui-toast-critical-border-color)] before:bg-[var(--ui-toast-critical-left-line)]',\n danger:\n 'border-[color:var(--ui-toast-danger-border-color)] before:bg-[var(--ui-toast-danger-left-line)]',\n },\n },\n defaultVariants: {\n variant: 'info',\n },\n }\n);\n\nexport type ToastVariant = NonNullable<\n VariantProps<typeof toastVariants>['variant']\n>;\n\n/**\n * A toast's kind. The five severities match the Figma variants; `loading` has no\n * Figma variant — it is the spinner state `toast.promise` needs.\n */\nexport type ToastType = ToastVariant | 'loading';\n\n// The Figma binds exactly one icon to each variant, and they are multicolor\n// (`stroke-multi`) glyphs that carry their own fills — so nothing here tints them.\nconst STATUS_ICON: Record<ToastVariant, React.ComponentType<IconProps>> = {\n info: CircleInfoBlueIcon,\n success: CircleCheckGreenIcon,\n warning: TriangleWarningYellowIcon,\n critical: CircleWarningOrangeIcon,\n danger: DiamondWarningRedIcon,\n};\n\n// Base UI's `promise` helper hardcodes `type: 'loading' | 'success' | 'error'`\n// *after* spreading the caller's options, so `'error'` reaches us even though the\n// public API only offers `toast.danger` — it has to resolve to the danger chrome.\n// `loading` has no Figma variant, so its spinner borrows info's border and status\n// line. Anything else (including a bare `toast(...)`) falls back to info, the\n// Figma's default variant.\nconst VARIANT_BY_TYPE: Record<string, ToastVariant> = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n critical: 'critical',\n danger: 'danger',\n error: 'danger',\n loading: 'info',\n};\n\nexport interface ToastAction {\n /** The button's label. */\n label: React.ReactNode;\n /** Invoked on click. The toast is not dismissed automatically. */\n onClick?: () => void;\n /**\n * Button style. Defaults to `secondary` for the first action and `ghost` for\n * the rest, matching the Figma's button pairing.\n */\n variant?: 'secondary' | 'ghost';\n}\n\n/** Custom per-toast payload carried through the Base UI manager. */\ninterface ToastData {\n actions?: ToastAction[];\n dismissable?: boolean;\n}\n\n// A module-level manager so `toast(...)` works outside React (like Sonner's\n// `toast`). `<Toaster />` subscribes this manager to its provider.\n//\n// Module-level means it is a *per-package-instance* singleton, which matters in a\n// micro-frontend host. Two copies of this package — an MFE bundling its own, or\n// module federation without `singleton: true` — get two independent managers, and\n// then `toast(...)` called through one copy is invisible to the `<Toaster />`\n// rendered by the other: the toast is queued and simply never appears. Two\n// `<Toaster />`s also both pin to `bottom-4 end-4`, so they overlap in the same\n// corner, and `timeout` / `limit` are per-region props that drift independently.\n//\n// So: share one ui-react instance across MFEs and mount exactly one `<Toaster />`\n// for the page (typically in the shell). See apps/docs `shadow-dom.mdx` for the\n// MFE integration contract, and use `PortalContainerProvider` when the single\n// region has to render inside a shadow root.\nconst toastManager = ToastPrimitive.createToastManager<ToastData>();\n\nexport interface ToastOptions {\n /** Secondary line under the title; clamped to three lines. */\n description?: React.ReactNode;\n /** Auto-dismiss delay in ms; `0` keeps the toast until dismissed. */\n timeout?: number;\n /** Action buttons rendered in a wrapping row under the text. */\n actions?: ToastAction[];\n /**\n * Whether the toast shows its dismiss control and can be swiped away.\n * Defaults to `true`. A non-dismissable toast with `timeout: 0` can only be\n * removed with `toast.dismiss(id)`.\n */\n dismissable?: boolean;\n /** Stable id — re-adding with the same id updates the toast in place. */\n id?: string;\n}\n\nfunction add(title: React.ReactNode, type?: ToastType, options: ToastOptions = {}) {\n const { actions, dismissable, ...rest } = options;\n return toastManager.add({\n title,\n type,\n data: { actions, dismissable },\n ...rest,\n });\n}\n\n/**\n * Imperative toast API. `toast(title, options)` shows an info toast;\n * `toast.info` / `success` / `warning` / `critical` / `danger` set the severity\n * and `toast.loading` shows a persistent spinner. `toast.dismiss(id?)` closes one\n * (or all) and `toast.promise` ties a toast to a promise's lifecycle.\n */\nconst toast = Object.assign(\n (title: React.ReactNode, options?: ToastOptions) => add(title, undefined, options),\n {\n info: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'info', options),\n success: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'success', options),\n warning: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'warning', options),\n critical: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'critical', options),\n danger: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'danger', options),\n loading: (title: React.ReactNode, options?: ToastOptions) =>\n add(title, 'loading', { timeout: 0, ...options }),\n dismiss: (id?: string) => toastManager.close(id),\n promise: toastManager.promise,\n }\n);\n\nfunction ToastList({ closeAriaLabel }: { closeAriaLabel: string }) {\n const { toasts } = ToastPrimitive.useToastManager<ToastData>();\n return toasts.map((item) => {\n const variant = VARIANT_BY_TYPE[item.type ?? ''] ?? 'info';\n const StatusIcon = STATUS_ICON[variant];\n const actions = item.data?.actions;\n const dismissable = item.data?.dismissable ?? true;\n return (\n <ToastPrimitive.Root\n key={item.id}\n toast={item}\n data-slot=\"toast\"\n data-variant={variant}\n // Base UI enables swipe-to-dismiss by default (`['down', 'right']`), so\n // a non-dismissable toast has to opt out of it too — otherwise hiding\n // the close button would only hide the *control*, not the capability.\n swipeDirection={dismissable ? undefined : []}\n className={cn(\n toastVariants({ variant }),\n 'transition-all data-[ending-style]:opacity-0 data-[starting-style]:opacity-0',\n // The stack sits on the inline-end edge, so a toast slides in from the\n // right in LTR and from the left in RTL.\n 'data-[ending-style]:translate-x-4 data-[starting-style]:translate-x-4',\n 'rtl:data-[ending-style]:-translate-x-4 rtl:data-[starting-style]:-translate-x-4'\n )}\n >\n {/* The icon box's padding (4/8) is what optically aligns the 16px glyph\n with the first line of the title: glyph centre 8 + 8 = 16, title\n centre (the text block's 4px padding) 4 + 12 = 16. */}\n <div\n data-slot=\"toast-icon\"\n className=\"flex shrink-0 items-start px-[var(--ui-toast-global-icon-padding-x)] py-[var(--ui-toast-global-icon-padding-y)] [&_svg]:size-[var(--ui-toast-global-icon-size)] [&_svg]:shrink-0\"\n >\n {item.type === 'loading' ? (\n <Spinner\n size=\"sm\"\n className=\"size-[var(--ui-toast-global-icon-size)]\"\n />\n ) : (\n <StatusIcon size={16} />\n )}\n </div>\n <div\n data-slot=\"toast-content\"\n className=\"flex min-w-0 flex-1 flex-col items-start gap-[var(--ui-toast-global-content-gap)] px-[var(--ui-toast-global-content-padding-x)] py-[var(--ui-toast-global-content-padding-y)]\"\n >\n <div\n data-slot=\"toast-text\"\n className=\"flex w-full shrink-0 flex-col items-start gap-[var(--ui-toast-global-content-text-container-gap)] px-[var(--ui-toast-global-content-text-container-padding-x)] py-[var(--ui-toast-global-content-text-container-padding-y)] [word-break:break-word]\"\n >\n <ToastPrimitive.Title\n data-slot=\"toast-title\"\n // `h5` overrides Base UI's `h2` default to match Alert — a toast\n // is not a page-level heading.\n render={<h5 />}\n className=\"ui-typography-headings-lead mb-0 w-full text-[var(--ui-toast-global-content-text-container-title-color)]\"\n />\n {item.description ? (\n <ToastPrimitive.Description\n data-slot=\"toast-description\"\n className=\"ui-toast-global-content-text-container-description-text-style line-clamp-3 w-full text-[var(--ui-toast-global-content-text-container-description-color)]\"\n />\n ) : null}\n </div>\n {actions?.length ? (\n <div\n data-slot=\"toast-actions\"\n className=\"flex w-full shrink-0 flex-wrap content-start items-start gap-x-[var(--ui-toast-global-content-actions-container-gap-x)] gap-y-[var(--ui-toast-global-content-actions-container-gap-y)] px-[var(--ui-toast-global-content-actions-container-padding-x)] py-[var(--ui-toast-global-content-actions-container-padding-y)]\"\n >\n {actions.map((action, index) => (\n <Button\n key={index}\n variant={action.variant ?? (index === 0 ? 'secondary' : 'ghost')}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n ))}\n </div>\n ) : null}\n </div>\n {dismissable ? (\n <ToastPrimitive.Close\n aria-label={closeAriaLabel}\n data-slot=\"toast-close\"\n render={\n <ButtonIcon variant=\"ghost\">\n <TimesIcon />\n </ButtonIcon>\n }\n />\n ) : null}\n </ToastPrimitive.Root>\n );\n });\n}\n\nexport interface ToasterProps {\n /** Default auto-dismiss delay in ms for toasts that don't set one. */\n timeout?: number;\n /** Max toasts shown at once; the oldest is dropped past the limit. */\n limit?: number;\n /** Accessible name for the toast region. */\n label?: string;\n /** Accessible name for each toast's dismiss control. */\n closeAriaLabel?: string;\n /**\n * Portal container for the toast stack. Pass a shadow-root mount for\n * isolated-style previews (the docs demos do this via `useShadowMount`).\n */\n portalContainer?: ToastPrimitive.Portal.Props['container'];\n}\n\n/**\n * The toast region. Render once near the app root; it portals a bottom-end stack\n * and renders every queued toast. Trigger toasts with the `toast` API.\n */\nfunction Toaster({\n timeout,\n limit,\n label = 'Notifications',\n closeAriaLabel = 'Close',\n portalContainer,\n}: ToasterProps) {\n const ctxContainer = usePortalContainer();\n const resolvedContainer = portalContainer ?? ctxContainer;\n\n return (\n <ToastPrimitive.Provider\n toastManager={toastManager}\n timeout={timeout}\n limit={limit}\n >\n <ToastPrimitive.Portal container={resolvedContainer}>\n <ToastPrimitive.Viewport\n aria-label={label}\n className=\"fixed bottom-4 end-4 z-[100] flex w-[var(--ui-toast-global-container-width-min)] max-w-[calc(100vw-2rem)] flex-col gap-3 outline-none\"\n >\n <ToastList closeAriaLabel={closeAriaLabel} />\n </ToastPrimitive.Viewport>\n </ToastPrimitive.Portal>\n </ToastPrimitive.Provider>\n );\n}\n\nexport { toast, Toaster, toastVariants };\n"],"names":["toastVariants","cva","STATUS_ICON","CircleInfoBlueIcon","CircleCheckGreenIcon","TriangleWarningYellowIcon","CircleWarningOrangeIcon","DiamondWarningRedIcon","VARIANT_BY_TYPE","toastManager","ToastPrimitive","add","title","type","options","actions","dismissable","rest","toast","id","ToastList","closeAriaLabel","toasts","item","variant","StatusIcon","_a","_b","jsxs","cn","jsx","Spinner","action","index","Button","ButtonIcon","TimesIcon","Toaster","timeout","limit","label","portalContainer","ctxContainer","usePortalContainer","resolvedContainer"],"mappings":"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"}
@@ -0,0 +1,20 @@
1
+ function u(n, c, { measure: l, ellipsis: i = "…" }) {
2
+ if (c <= 0) return "";
3
+ if (l(n) <= c) return n;
4
+ if (l(i) > c) return "";
5
+ const f = (r) => {
6
+ if (r <= 0) return i;
7
+ const t = Math.ceil(r / 2), h = r - t;
8
+ return h > 0 ? `${n.slice(0, t)}${i}${n.slice(n.length - h)}` : `${n.slice(0, t)}${i}`;
9
+ };
10
+ let e = 0, o = n.length;
11
+ for (; o - e > 1; ) {
12
+ const r = Math.floor((e + o) / 2);
13
+ l(f(r)) <= c ? e = r : o = r;
14
+ }
15
+ return f(e);
16
+ }
17
+ export {
18
+ u as middleTruncate
19
+ };
20
+ //# sourceMappingURL=middle-truncate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middle-truncate.js","sources":["../../../../src/components/ui/truncate-text/middle-truncate.ts"],"sourcesContent":["// The pure search behind `<TruncateText mode=\"middle\">`: given a string, a pixel budget, and a\n// way to measure a candidate's rendered width, find the longest start+end slice\n// (joined by an ellipsis) that still fits — preserving both ends of the string\n// rather than just the start, which is what a plain CSS end-ellipsis already does\n// and is useless for a URL, hash or path whose distinguishing part is at the tail.\n//\n// Binary search over \"how many non-ellipsis characters to keep\", not over the split\n// point between start/end — the split is always the same proportion (kept chars\n// divided evenly, the extra one going to the start on an odd count), so there is\n// exactly one candidate per kept-count and `measure` is called O(log n) times\n// rather than O(n). `measure` is injected rather than hard-coded to\n// `canvas.measureText` specifically so this file has no DOM dependency: the real\n// component supplies a canvas-backed measurer (see `truncate-text.tsx`), and\n// these tests supply a deterministic fake — jsdom has no layout engine, so a test\n// asserting real pixel widths would need the browser project for no benefit here,\n// the search logic does not care what \"width\" means.\n\nexport interface MiddleTruncateOptions {\n /** Returns the rendered width of `candidate`, in the same unit as `maxWidth`. */\n readonly measure: (candidate: string) => number;\n /** Inserted between the kept start and end slices. Defaults to `'…'`. */\n readonly ellipsis?: string;\n}\n\n/**\n * Returns `text` unchanged if it already fits `maxWidth`, otherwise the widest\n * start+ellipsis+end slice that does. Never returns something wider than\n * `maxWidth`, even when nothing meaningful fits — the degenerate result is the\n * bare ellipsis, or `''` if `maxWidth` cannot fit that either.\n */\nexport function middleTruncate(\n text: string,\n maxWidth: number,\n { measure, ellipsis = '…' }: MiddleTruncateOptions\n): string {\n if (maxWidth <= 0) return '';\n if (measure(text) <= maxWidth) return text;\n\n const ellipsisWidth = measure(ellipsis);\n if (ellipsisWidth > maxWidth) return '';\n\n const candidateFor = (kept: number): string => {\n if (kept <= 0) return ellipsis;\n const startLen = Math.ceil(kept / 2);\n const endLen = kept - startLen;\n return endLen > 0\n ? `${text.slice(0, startLen)}${ellipsis}${text.slice(text.length - endLen)}`\n : `${text.slice(0, startLen)}${ellipsis}`;\n };\n\n // Invariant: `low` is always a kept-count that fits (0 does, by the ellipsis\n // check above); `high` is always one that does not (`text.length` does not, by\n // the \"already fits\" check above). The loop halves the gap until they meet,\n // so `low` ends on the largest fitting count.\n let low = 0;\n let high = text.length;\n while (high - low > 1) {\n const mid = Math.floor((low + high) / 2);\n if (measure(candidateFor(mid)) <= maxWidth) {\n low = mid;\n } else {\n high = mid;\n }\n }\n return candidateFor(low);\n}\n"],"names":["middleTruncate","text","maxWidth","measure","ellipsis","candidateFor","kept","startLen","endLen","low","high","mid"],"mappings":"AA8BO,SAASA,EACdC,GACAC,GACA,EAAE,SAAAC,GAAS,UAAAC,IAAW,OACd;AACR,MAAIF,KAAY,EAAG,QAAO;AAC1B,MAAIC,EAAQF,CAAI,KAAKC,EAAU,QAAOD;AAGtC,MADsBE,EAAQC,CAAQ,IAClBF,EAAU,QAAO;AAErC,QAAMG,IAAe,CAACC,MAAyB;AAC7C,QAAIA,KAAQ,EAAG,QAAOF;AACtB,UAAMG,IAAW,KAAK,KAAKD,IAAO,CAAC,GAC7BE,IAASF,IAAOC;AACtB,WAAOC,IAAS,IACZ,GAAGP,EAAK,MAAM,GAAGM,CAAQ,CAAC,GAAGH,CAAQ,GAAGH,EAAK,MAAMA,EAAK,SAASO,CAAM,CAAC,KACxE,GAAGP,EAAK,MAAM,GAAGM,CAAQ,CAAC,GAAGH,CAAQ;AAAA,EAC3C;AAMA,MAAIK,IAAM,GACNC,IAAOT,EAAK;AAChB,SAAOS,IAAOD,IAAM,KAAG;AACrB,UAAME,IAAM,KAAK,OAAOF,IAAMC,KAAQ,CAAC;AACvC,IAAIP,EAAQE,EAAaM,CAAG,CAAC,KAAKT,IAChCO,IAAME,IAEND,IAAOC;AAAA,EAEX;AACA,SAAON,EAAaI,CAAG;AACzB;"}
@@ -0,0 +1,12 @@
1
+ let e;
2
+ function o() {
3
+ return e === void 0 && (e = document.createElement("canvas").getContext("2d")), e;
4
+ }
5
+ function u(n, r) {
6
+ const t = o();
7
+ return t === null ? n.length * 8 : (t.font = r, t.measureText(n).width);
8
+ }
9
+ export {
10
+ u as measureTextWidth
11
+ };
12
+ //# sourceMappingURL=text-width.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-width.js","sources":["../../../../src/components/ui/truncate-text/text-width.ts"],"sourcesContent":["// A single offscreen canvas, reused across every `<TruncateText mode=\"middle\">` instance and\n// every candidate it measures. `canvas.measureText` is O(1) per call — no layout,\n// no reflow — which is why `middleTruncate`'s binary search calls `measure` a\n// handful of times per resize without it being a performance concern the way a\n// DOM-clone measurement (render, read `offsetWidth`, repeat per candidate) would\n// be for a search space the size of a whole string.\nlet sharedContext: CanvasRenderingContext2D | null | undefined;\n\nfunction getSharedContext(): CanvasRenderingContext2D | null {\n if (sharedContext === undefined) {\n sharedContext = document.createElement('canvas').getContext('2d');\n }\n return sharedContext;\n}\n\n/**\n * The rendered width of `text` in `font` (a CSS `font` shorthand string, e.g. from\n * `getComputedStyle(el).font`), in CSS pixels.\n *\n * Falls back to a fixed per-character estimate when `canvas` 2D contexts are\n * unavailable (jsdom's default; the real component is exercised by the browser\n * test project instead) — a rough width is enough to keep the search from\n * throwing, and nothing in the unit project renders far enough to compare it\n * against a pixel budget.\n */\nexport function measureTextWidth(text: string, font: string): number {\n const context = getSharedContext();\n if (context === null) return text.length * 8;\n context.font = font;\n return context.measureText(text).width;\n}\n"],"names":["sharedContext","getSharedContext","measureTextWidth","text","font","context"],"mappings":"AAMA,IAAIA;AAEJ,SAASC,IAAoD;AAC3D,SAAID,MAAkB,WACpBA,IAAgB,SAAS,cAAc,QAAQ,EAAE,WAAW,IAAI,IAE3DA;AACT;AAYO,SAASE,EAAiBC,GAAcC,GAAsB;AACnE,QAAMC,IAAUJ,EAAA;AAChB,SAAII,MAAY,OAAaF,EAAK,SAAS,KAC3CE,EAAQ,OAAOD,GACRC,EAAQ,YAAYF,CAAI,EAAE;AACnC;"}
@@ -0,0 +1,152 @@
1
+ import { jsx as l, jsxs as k } from "react/jsx-runtime";
2
+ import * as n from "react";
3
+ import { cn as x } from "../../../lib/utils.js";
4
+ import { middleTruncate as C } from "./middle-truncate.js";
5
+ import { measureTextWidth as E } from "./text-width.js";
6
+ import { Tooltip as W, TooltipTrigger as g, TooltipContent as S } from "../tooltip/tooltip.js";
7
+ const R = n.forwardRef(
8
+ function({ children: e, mode: f = "end", className: s, side: a = "top", lines: o = 1, defaultOpen: c, portalContainer: r }, u) {
9
+ return f === "middle" ? /* @__PURE__ */ l(
10
+ z,
11
+ {
12
+ ref: u,
13
+ text: e,
14
+ side: a,
15
+ portalContainer: r,
16
+ className: s
17
+ }
18
+ ) : /* @__PURE__ */ l(
19
+ O,
20
+ {
21
+ ref: u,
22
+ text: e,
23
+ side: a,
24
+ lines: o,
25
+ defaultOpen: c,
26
+ portalContainer: r,
27
+ className: s
28
+ }
29
+ );
30
+ }
31
+ ), O = n.forwardRef(
32
+ function({ text: e, side: f, lines: s, defaultOpen: a, portalContainer: o, className: c }, r) {
33
+ const u = n.useRef(null), [d, v] = n.useState(!1), m = n.useCallback(
34
+ (t) => {
35
+ u.current = t, typeof r == "function" ? r(t) : r && (r.current = t);
36
+ },
37
+ [r]
38
+ );
39
+ n.useLayoutEffect(() => {
40
+ const t = u.current;
41
+ if (!t) return;
42
+ const p = () => v(
43
+ s > 1 ? t.scrollHeight > t.clientHeight + 1 : t.scrollWidth > t.clientWidth + 1
44
+ );
45
+ p();
46
+ const b = new ResizeObserver(p);
47
+ return b.observe(t), () => b.disconnect();
48
+ }, [e, s, d]);
49
+ const T = s > 1, h = T ? {
50
+ display: "-webkit-box",
51
+ WebkitLineClamp: s,
52
+ WebkitBoxOrient: "vertical",
53
+ overflow: "hidden"
54
+ } : void 0, i = /* @__PURE__ */ l(
55
+ "span",
56
+ {
57
+ ref: m,
58
+ className: x("block", T ? "overflow-hidden" : "truncate", c),
59
+ style: h,
60
+ children: e
61
+ }
62
+ );
63
+ return d ? /* @__PURE__ */ k(W, { defaultOpen: a, children: [
64
+ /* @__PURE__ */ l(g, { render: i }),
65
+ /* @__PURE__ */ l(S, { side: f, portalContainer: o, children: e })
66
+ ] }) : i;
67
+ }
68
+ ), z = n.forwardRef(
69
+ function({ text: e, side: f, portalContainer: s, className: a }, o) {
70
+ const [c, r] = n.useState(null), [u, d] = n.useState(e), [v, m] = n.useState(!1), T = n.useCallback(
71
+ (i) => {
72
+ r(i), typeof o == "function" ? o(i) : o && (o.current = i);
73
+ },
74
+ [o]
75
+ );
76
+ n.useLayoutEffect(() => {
77
+ if (m(!1), c === null || typeof ResizeObserver > "u") {
78
+ d(e);
79
+ return;
80
+ }
81
+ const i = () => {
82
+ const p = c.clientWidth;
83
+ if (p === 0) return;
84
+ const b = getComputedStyle(c).font;
85
+ d(
86
+ C(e, p, {
87
+ measure: (w) => E(w, b)
88
+ })
89
+ ), m(!0);
90
+ };
91
+ i();
92
+ const t = new ResizeObserver(i);
93
+ return t.observe(c), () => t.disconnect();
94
+ }, [c, e]);
95
+ const h = /* @__PURE__ */ l(
96
+ "span",
97
+ {
98
+ ref: T,
99
+ className: x(
100
+ // `flex-1` (`flex: 1 1 0%`) only takes effect when the parent this
101
+ // renders into happens to itself be a flex container — inert
102
+ // otherwise, so it's safe alongside `block`. It's not decorative:
103
+ // without it, a `display: block` element with no explicit width
104
+ // only *auto-fills a plain block parent* — the browser's default
105
+ // "fill available width" rule for `width: auto` is specific to
106
+ // block layout. Nested inside a flex parent (a caller's own cell
107
+ // wrapping this next to an icon button, say), the same element
108
+ // becomes a flex item instead, where `flex-basis: auto` means
109
+ // "size to your own content" — and this component's own content
110
+ // is whatever it truncated itself to *last* time. Once shrunk, it
111
+ // would then measure its own shrunken self forever, growing back
112
+ // only if some ancestor's width changed enough to force a reflow
113
+ // for an unrelated reason — not when the column actually had more
114
+ // room to give it all along.
115
+ "block min-w-0 flex-1",
116
+ // Nowrap + clip only once `measured` — *before* that, this is the
117
+ // string's first-ever render, and if it already clips and refuses to
118
+ // wrap, it dictates its own column's width to `table-layout: auto`
119
+ // before `ResizeObserver` ever gets a turn: nowrap makes an unbroken
120
+ // string's min-content the string's *entire* rendered width, so the
121
+ // browser hands the column exactly that much room — measuring
122
+ // `clientWidth` after the fact just reads back the width this same
123
+ // element inflated the column to, not the width some other column
124
+ // needed and this one gave up.
125
+ //
126
+ // Left at the browser's own default on the unmeasured pass rather than
127
+ // forced to `overflow-wrap: anywhere` — tried that first, and it
128
+ // overcorrects: telling `auto`-layout this column's min-content is a
129
+ // single character makes it treat the column as free to take almost
130
+ // nothing, starving it in favor of siblings with a normal (space- and
131
+ // punctuation-driven) min-content. The browser's own line-breaking
132
+ // already finds break opportunities in a URL — after `/`, around `?`,
133
+ // `=`, `_` — without being told everything is breakable, which is
134
+ // exactly the multi-line wrap this component exists to replace: worse
135
+ // than what `nowrap` would give it, but a real, usable column width to
136
+ // hand to the first `ResizeObserver` measurement, not a starved one.
137
+ v && "overflow-hidden whitespace-nowrap",
138
+ a
139
+ ),
140
+ children: u
141
+ }
142
+ );
143
+ return u === e ? h : /* @__PURE__ */ k(W, { children: [
144
+ /* @__PURE__ */ l(g, { render: h }),
145
+ /* @__PURE__ */ l(S, { side: f, portalContainer: s, children: e })
146
+ ] });
147
+ }
148
+ );
149
+ export {
150
+ R as TruncateText
151
+ };
152
+ //# sourceMappingURL=truncate-text.js.map