@bioturing/components 0.14.1 → 0.15.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 (82) hide show
  1. package/dist/Badge.css +6 -0
  2. package/dist/Breadcrumb.css +83 -0
  3. package/dist/Checkbox.css +13 -0
  4. package/dist/CodeBlock.css +213 -0
  5. package/dist/CodeBlock.js +11 -8
  6. package/dist/Collapse.css +21 -0
  7. package/dist/DSRoot.css +667 -0
  8. package/dist/DSRoot.js +264 -17
  9. package/dist/DropdownMenu.css +95 -0
  10. package/dist/Empty.css +19 -0
  11. package/dist/Field.css +14 -0
  12. package/dist/Form.css +64 -0
  13. package/dist/IconButton.css +52 -0
  14. package/dist/Modal.css +317 -0
  15. package/dist/Modal.js +256 -9
  16. package/dist/PopupPanel.css +156 -102
  17. package/dist/Radio.css +14 -0
  18. package/dist/ScrollArea.css +64 -0
  19. package/dist/ScrollArea.js +4 -4
  20. package/dist/Segmented.css +16 -0
  21. package/dist/Select.css +24 -0
  22. package/dist/Spin.css +36 -0
  23. package/dist/Splitter.css +6 -0
  24. package/dist/Switch.css +7 -0
  25. package/dist/Table.css +116 -0
  26. package/dist/Tag.css +17 -0
  27. package/dist/ThemeProvider.css +39 -0
  28. package/dist/Toast.css +622 -0
  29. package/dist/Toast.js +264 -17
  30. package/dist/Tooltip.css +6 -0
  31. package/dist/Tour.css +73 -0
  32. package/dist/Tour.js +1 -1
  33. package/dist/Truncate.css +31 -0
  34. package/dist/Truncate.js +75 -19
  35. package/dist/Upload.css +144 -0
  36. package/dist/Upload.js +75 -19
  37. package/dist/VerticalCollapsiblePanel.css +193 -0
  38. package/dist/VerticalCollapsiblePanel.js +75 -19
  39. package/dist/components/Badge/component.d.ts +1 -0
  40. package/dist/components/Breadcrumb/component.d.ts +1 -0
  41. package/dist/components/Button/component.d.ts +1 -0
  42. package/dist/components/Checkbox/component.d.ts +1 -0
  43. package/dist/components/CodeBlock/component.d.ts +2 -1
  44. package/dist/components/CodeBlock/types.d.ts +12 -0
  45. package/dist/components/Collapse/component.d.ts +1 -0
  46. package/dist/components/DSRoot/component.d.ts +1 -0
  47. package/dist/components/DropdownMenu/component.d.ts +1 -0
  48. package/dist/components/Empty/component.d.ts +1 -0
  49. package/dist/components/Field/component.d.ts +1 -0
  50. package/dist/components/Form/component.d.ts +1 -0
  51. package/dist/components/IconButton/component.d.ts +1 -0
  52. package/dist/components/Modal/index.d.ts +1 -0
  53. package/dist/components/Radio/component.d.ts +1 -0
  54. package/dist/components/ScrollArea/component.d.ts +26 -4
  55. package/dist/components/Segmented/component.d.ts +1 -0
  56. package/dist/components/Select/component.d.ts +1 -0
  57. package/dist/components/Spin/component.d.ts +1 -0
  58. package/dist/components/Splitter/component.d.ts +1 -0
  59. package/dist/components/Stack/Stack.d.ts +39 -0
  60. package/dist/components/Stack/StackChild.d.ts +30 -0
  61. package/dist/components/Stack/index.d.ts +8 -0
  62. package/dist/components/Switch/component.d.ts +1 -0
  63. package/dist/components/Table/component.d.ts +1 -0
  64. package/dist/components/Tag/component.d.ts +1 -0
  65. package/dist/components/ThemeProvider/component.d.ts +1 -0
  66. package/dist/components/Toast/component.d.ts +1 -0
  67. package/dist/components/Tooltip/component.d.ts +1 -0
  68. package/dist/components/Tour/component.d.ts +1 -0
  69. package/dist/components/Truncate/component.d.ts +3 -0
  70. package/dist/components/Upload/index.d.ts +1 -0
  71. package/dist/components/VerticalCollapsiblePanel/component.d.ts +1 -0
  72. package/dist/components/index.d.ts +1 -0
  73. package/dist/hooks.js +1 -1
  74. package/dist/index.css +1469 -114
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.js +784 -156
  77. package/dist/metadata.d.ts +363 -0
  78. package/dist/tailwind.css +118 -1
  79. package/package.json +2 -2
  80. package/dist/style.css +0 -1392
  81. package/dist/style.js +0 -0
  82. package/dist/tailwind.js +0 -0
package/dist/Toast.js CHANGED
@@ -3,7 +3,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
3
3
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_config_provider_6a57beb3__ from "antd/es/config-provider";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_theme_useToken_e8911485__ from "antd/es/theme/useToken";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
6
- import "tailwind-merge";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__ from "tailwind-merge";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE__bioturing_assets_dd0c210d__ from "@bioturing/assets";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__ from "@base-ui-components/react";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
@@ -15,6 +15,8 @@ import * as __WEBPACK_EXTERNAL_MODULE_antd_es_modal_components_NormalCancelBtn_5
15
15
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_modal_components_NormalOkBtn_897b50c4__ from "antd/es/modal/components/NormalOkBtn";
16
16
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_modal_locale_f16c0933__ from "antd/es/modal/locale";
17
17
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_locale_31079002__ from "antd/es/locale";
18
+ import * as __WEBPACK_EXTERNAL_MODULE__base_ui_components_react_use_render_2fb9dc6d__ from "@base-ui-components/react/use-render";
19
+ import * as __WEBPACK_EXTERNAL_MODULE__base_ui_components_react_merge_props_04b69945__ from "@base-ui-components/react/merge-props";
18
20
  import * as __WEBPACK_EXTERNAL_MODULE_antd_es_segmented_6dbdbe23__ from "antd/es/segmented";
19
21
  import * as __WEBPACK_EXTERNAL_MODULE__ant_design_cssinjs_c619260f__ from "@ant-design/cssinjs";
20
22
  import * as __WEBPACK_EXTERNAL_MODULE_prism_react_renderer_be33806e__ from "prism-react-renderer";
@@ -32,6 +34,9 @@ function cx(...args) {
32
34
  function clsx(...args) {
33
35
  return cx(...args).join(" ");
34
36
  }
37
+ function cn(...args) {
38
+ return (0, __WEBPACK_EXTERNAL_MODULE_tailwind_merge_e05e3e95__.twMerge)(cx(...args));
39
+ }
35
40
  "use client";
36
41
  const useAntdCssVarClassname = ()=>{
37
42
  var _token_;
@@ -147,9 +152,244 @@ var constants_ModalSize = /*#__PURE__*/ function(ModalSize) {
147
152
  ModalSize["fullscreen"] = "100%";
148
153
  return ModalSize;
149
154
  }({});
155
+ const measureText = (container)=>{
156
+ const span = document.createElement("span");
157
+ span.style.opacity = "0";
158
+ span.style.position = "absolute";
159
+ span.style.top = "-1000px";
160
+ span.style.left = "-1000px";
161
+ span.style.whiteSpace = "nowrap";
162
+ span.style.pointerEvents = "none";
163
+ container.appendChild(span);
164
+ return {
165
+ measure: (text)=>{
166
+ span.innerText = text;
167
+ return span.clientWidth;
168
+ },
169
+ destroy: ()=>{
170
+ container.removeChild(span);
171
+ }
172
+ };
173
+ };
174
+ const getMiddleTruncatedString = (text, ellipsis, container)=>{
175
+ var _Object_values_reverse_find;
176
+ if (!text) return text;
177
+ const { measure: getTextWidth, destroy: destroyMeasure } = measureText(container);
178
+ const textWidth = getTextWidth(text);
179
+ const containerWidth = container.clientWidth;
180
+ const initialOffset = Math.floor(containerWidth / textWidth * text.length);
181
+ if (textWidth <= containerWidth) {
182
+ destroyMeasure();
183
+ return text;
184
+ }
185
+ let offset = initialOffset;
186
+ const attempts = {};
187
+ const maxAttempts = 20;
188
+ const buffer = 10;
189
+ while(Object.values(attempts).length <= maxAttempts){
190
+ if (attempts[offset]) break;
191
+ if (offset <= 1) {
192
+ attempts[0] = [
193
+ 0,
194
+ ellipsis
195
+ ];
196
+ break;
197
+ }
198
+ const start = text.slice(0, Math.ceil((offset - ellipsis.length) / 2 - 1)).trimEnd();
199
+ const end = text.slice(Math.floor((offset - ellipsis.length) / 2) - offset).trimStart();
200
+ const truncatedStr = start + ellipsis + end;
201
+ const width = getTextWidth(truncatedStr);
202
+ attempts[offset] = [
203
+ width,
204
+ truncatedStr
205
+ ];
206
+ if (width >= containerWidth) offset -= 2;
207
+ else {
208
+ if (containerWidth - width < buffer) break;
209
+ offset += 2;
210
+ }
211
+ }
212
+ destroyMeasure();
213
+ return (null == (_Object_values_reverse_find = Object.values(attempts).reverse().find(([width])=>width < containerWidth)) ? void 0 : _Object_values_reverse_find[1]) ?? Object.values(attempts)[0][1];
214
+ };
215
+ "use client";
216
+ const Truncate = ({ children, position = "end", lines = 1, className, style, ...rest })=>{
217
+ const cls = useCls();
218
+ const containerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
219
+ const [isTruncated, setIsTruncated] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
220
+ const [truncatedText, setTruncatedText] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(children);
221
+ const text = children;
222
+ const getContainerStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
223
+ if ("auto" !== lines) return {
224
+ ...style,
225
+ ...lines > 1 ? {
226
+ "--ds-line-clamp": lines
227
+ } : {}
228
+ };
229
+ return {
230
+ ...style,
231
+ "--ds-line-clamp": 999
232
+ };
233
+ }, [
234
+ lines,
235
+ style
236
+ ]);
237
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
238
+ const container = containerRef.current;
239
+ if (!container) return;
240
+ if ("auto" === lines) {
241
+ var _window_document_fonts_ready, _window_document_fonts;
242
+ setTruncatedText(text);
243
+ const calculateLines = ()=>{
244
+ const parent = container.parentElement;
245
+ if (!parent) return;
246
+ const styles = window.getComputedStyle(container);
247
+ const fontSize = parseFloat(styles.fontSize);
248
+ const lineHeight = "normal" === styles.lineHeight ? 1.2 * fontSize : parseFloat(styles.lineHeight);
249
+ const parentStyles = window.getComputedStyle(parent);
250
+ const paddingTop = parseFloat(parentStyles.paddingTop) || 0;
251
+ const paddingBottom = parseFloat(parentStyles.paddingBottom) || 0;
252
+ const borderTopWidth = parseFloat(parentStyles.borderTopWidth) || 0;
253
+ const borderBottomWidth = parseFloat(parentStyles.borderBottomWidth) || 0;
254
+ const parentHeight = parent.clientHeight;
255
+ const availableHeight = parentHeight - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth;
256
+ const maxLines = Math.max(1, Math.floor(availableHeight / lineHeight));
257
+ if (container) container.style.setProperty("--ds-line-clamp", String(maxLines));
258
+ const clone = document.createElement("span");
259
+ clone.style.visibility = "hidden";
260
+ clone.style.position = "absolute";
261
+ clone.style.width = `${container.clientWidth}px`;
262
+ clone.style.fontSize = styles.fontSize;
263
+ clone.style.fontFamily = styles.fontFamily;
264
+ clone.style.lineHeight = styles.lineHeight;
265
+ clone.textContent = text;
266
+ document.body.appendChild(clone);
267
+ const isTruncated = clone.scrollHeight > availableHeight;
268
+ document.body.removeChild(clone);
269
+ setIsTruncated(isTruncated);
270
+ };
271
+ null == (_window_document_fonts = window.document.fonts) || null == (_window_document_fonts_ready = _window_document_fonts.ready) || _window_document_fonts_ready.then(calculateLines);
272
+ const observer = new ResizeObserver(()=>{
273
+ window.requestAnimationFrame(calculateLines);
274
+ });
275
+ observer.observe(container);
276
+ if (container.parentElement) observer.observe(container.parentElement);
277
+ return ()=>observer.disconnect();
278
+ }
279
+ if ("number" == typeof lines && lines > 1) {
280
+ var _window_document_fonts_ready1, _window_document_fonts1;
281
+ setTruncatedText(text);
282
+ const checkIfTruncated = ()=>{
283
+ const clone = document.createElement("span");
284
+ clone.style.visibility = "hidden";
285
+ clone.style.position = "absolute";
286
+ clone.style.width = `${container.clientWidth}px`;
287
+ clone.textContent = text;
288
+ document.body.appendChild(clone);
289
+ const isTruncated = clone.scrollHeight > (container.clientHeight || container.offsetHeight);
290
+ document.body.removeChild(clone);
291
+ setIsTruncated(isTruncated);
292
+ };
293
+ null == (_window_document_fonts1 = window.document.fonts) || null == (_window_document_fonts_ready1 = _window_document_fonts1.ready) || _window_document_fonts_ready1.then(checkIfTruncated);
294
+ const observer = new ResizeObserver(()=>{
295
+ window.requestAnimationFrame(checkIfTruncated);
296
+ });
297
+ observer.observe(container);
298
+ return ()=>observer.disconnect();
299
+ }
300
+ let cancellationToken = {
301
+ cancelled: false
302
+ };
303
+ const calculateTruncatedString = ()=>{
304
+ if (cancellationToken) cancellationToken.cancelled = true;
305
+ const requestCancellationToken = {
306
+ cancelled: false
307
+ };
308
+ cancellationToken = requestCancellationToken;
309
+ const truncated = getMiddleTruncatedString(text, "\u2026", container);
310
+ if (requestCancellationToken.cancelled) return;
311
+ setTruncatedText(truncated);
312
+ };
313
+ if ("middle" == position) {
314
+ var _window_document_fonts_ready2, _window_document_fonts2;
315
+ null == (_window_document_fonts2 = window.document.fonts) || null == (_window_document_fonts_ready2 = _window_document_fonts2.ready) || _window_document_fonts_ready2.then(calculateTruncatedString);
316
+ }
317
+ if ("end" == position) setTruncatedText(text);
318
+ const observer = new ResizeObserver(()=>{
319
+ if ("middle" == position) window.requestAnimationFrame(calculateTruncatedString);
320
+ if ("end" == position) {
321
+ const isOverflowing = container.scrollWidth > container.clientWidth;
322
+ if (isOverflowing) setIsTruncated(true);
323
+ }
324
+ });
325
+ observer.observe(container);
326
+ return ()=>{
327
+ cancellationToken.cancelled = true;
328
+ observer.disconnect();
329
+ };
330
+ }, [
331
+ text,
332
+ position,
333
+ lines
334
+ ]);
335
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
336
+ ref: containerRef,
337
+ style: getContainerStyles(),
338
+ className: clsx(1 === lines ? cls("truncate") : cls("truncate-multiline"), "middle" === position ? cls("truncate-middle") : cls("truncate-end"), className),
339
+ title: isTruncated ? text : void 0,
340
+ ...rest,
341
+ children: text === truncatedText ? text : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
342
+ children: truncatedText
343
+ })
344
+ });
345
+ };
346
+ const Stack = ({ hug = false, align = "flex-start", justify = "flex-start", vertical = false, gap = 0, wrap = false, className, children, ...rest })=>{
347
+ const cls = useCls();
348
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
349
+ className: cn(cls("stack"), hug ? cls("stack-hug") : cls("stack-fill"), cls(`stack-gap-${gap}`), vertical ? cls("stack-vertical") : cls("stack-horizontal"), wrap && cls("stack-wrap"), cls(`stack-align-${align}`), cls(`stack-justify-${justify}`), className),
350
+ ...rest,
351
+ children: children
352
+ });
353
+ };
354
+ const StackChild = ({ flex, grow = false, shrink = false, children, style, stack = false, hug = false, align = "flex-start", justify = "flex-start", vertical = false, gap = 0, wrap = false, className, ...rest })=>{
355
+ const cls = useCls();
356
+ const stackProps = {
357
+ hug,
358
+ align,
359
+ justify,
360
+ vertical,
361
+ gap,
362
+ wrap
363
+ };
364
+ let flexClass = "";
365
+ if ("boolean" == typeof flex) flexClass = flex ? cls("stack-child-flex-1") : cls("stack-child-flex-0");
366
+ const combinedClassName = cn(cls("stack-child"), grow && cls("stack-child-grow"), shrink && cls("stack-child-shrink"), flexClass, className);
367
+ const flexValue = "string" == typeof flex || "number" == typeof flex ? flex : void 0;
368
+ const { renderElement } = (0, __WEBPACK_EXTERNAL_MODULE__base_ui_components_react_use_render_2fb9dc6d__.useRender)({
369
+ render: ()=>/*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].isValidElement(children) ? children : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
370
+ children: children
371
+ }),
372
+ props: (0, __WEBPACK_EXTERNAL_MODULE__base_ui_components_react_merge_props_04b69945__.mergeProps)({
373
+ className: combinedClassName,
374
+ style: {
375
+ ...style,
376
+ flex: flexValue
377
+ },
378
+ ...rest
379
+ })
380
+ });
381
+ return stack ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Stack, {
382
+ ...stackProps,
383
+ className: combinedClassName,
384
+ children: children
385
+ }) : renderElement();
386
+ };
387
+ const Stack_Stack = Object.assign(Stack, {
388
+ Child: StackChild
389
+ });
150
390
  "use client";
151
391
  const Modal = ({ open: externalOpen, closeIcon, children, size: sizeProp, footer, width, style, styles, classNames, okButtonProps, cancelButtonProps, loading, onOk, onCancel, okText, okType = "primary", confirmLoading, cancelText = "Close", hideOkButton = false, hideCancelButton = false, contentPadding, title, afterTitle, beforeCloseButton, afterCloseButton, defaultFixedHeaderFooter = false, centered = true, type = "default", defaultOpen = true, background: backgroundProp, bodyScrollable = true, ...rest })=>{
152
- const defaultCloseIcon = void 0 === closeIcon ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__bioturing_assets_dd0c210d__.X, {
392
+ const defaultCloseIcon = void 0 === closeIcon ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__bioturing_assets_dd0c210d__.XIcon, {
153
393
  size: 16,
154
394
  weight: "bold"
155
395
  }) : closeIcon;
@@ -232,17 +472,21 @@ const Modal = ({ open: externalOpen, closeIcon, children, size: sizeProp, footer
232
472
  });
233
473
  const renderTitle = ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
234
474
  children: [
235
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Flex, {
475
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(Stack_Stack, {
236
476
  align: "center",
237
477
  gap: 8,
238
478
  className: cls("modal-title-wrapper"),
239
479
  children: [
240
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
241
- className: cls("grow", "truncate"),
242
- children: title
480
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Stack_Stack.Child, {
481
+ grow: true,
482
+ children: "string" == typeof title ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Truncate, {
483
+ children: title
484
+ }) : title
243
485
  }),
244
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
245
- className: "flex items-center gap-2",
486
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(Stack_Stack.Child, {
487
+ stack: true,
488
+ hug: true,
489
+ align: "center",
246
490
  children: [
247
491
  beforeCloseButton,
248
492
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(IconButton, {
@@ -265,7 +509,7 @@ const Modal = ({ open: externalOpen, closeIcon, children, size: sizeProp, footer
265
509
  title: renderTitle(),
266
510
  classNames: {
267
511
  ...classNames,
268
- wrapper: cls("modal-wrap", "fullscreen" == size && "modal-fullscreen", isContentOverflow && "modal-content-overflow", false === bodyScrollable && "modal-no-body-scroll", (defaultFixedHeaderFooter || isContentOverflow || "fullscreen" == size) && "modal-fixed")
512
+ wrapper: cls("modal-wrap", "fullscreen" == size && "modal-fullscreen", isContentOverflow && "modal-content-overflow", false === bodyScrollable && "modal-no-body-scroll", defaultFixedHeaderFooter || isContentOverflow || "fullscreen" == size ? "modal-fixed" : "")
269
513
  },
270
514
  styles: modalStyles,
271
515
  modalRender: (modal)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
@@ -478,24 +722,24 @@ const Modal_Modal = Object.assign(Modal, {
478
722
  useModal
479
723
  });
480
724
  "use client";
481
- const ScrollArea = ({ children, className, viewportClassName, thumbClassName, scrollbarClassName, orientation = "vertical" })=>{
725
+ const ScrollArea = ({ children, className, classNames = {}, orientation = "vertical" })=>{
482
726
  const cls = useCls();
483
727
  return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__.ScrollArea.Root, {
484
728
  className: clsx(cls("scroll-area"), className),
485
729
  children: [
486
730
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__.ScrollArea.Viewport, {
487
- className: clsx(cls("scroll-area-viewport"), viewportClassName),
731
+ className: clsx(cls("scroll-area-viewport"), null == classNames ? void 0 : classNames.viewport),
488
732
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__.ScrollArea.Content, {
489
733
  className: clsx(cls("scroll-area-content")),
490
734
  children: children
491
735
  })
492
736
  }),
493
737
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__.ScrollArea.Scrollbar, {
494
- className: clsx(cls("scroll-area-scrollbar"), scrollbarClassName),
738
+ className: clsx(cls("scroll-area-scrollbar"), null == classNames ? void 0 : classNames.scrollbar),
495
739
  orientation: orientation,
496
740
  "data-orientation": orientation,
497
741
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__base_ui_components_react_5aaa6934__.ScrollArea.Thumb, {
498
- className: clsx(cls("scroll-area-thumb", thumbClassName))
742
+ className: clsx(cls("scroll-area-thumb"), null == classNames ? void 0 : classNames.thumb)
499
743
  })
500
744
  })
501
745
  ]
@@ -931,7 +1175,7 @@ function reactNodeToString(node) {
931
1175
  return "";
932
1176
  }
933
1177
  "use client";
934
- const CodeBlock = ({ code, children, lang: defaultLang = "tsx", className, options, activeOption: controlledActiveOption, defaultActiveOption = 0, onActiveOptionChange, copyText = "Copy", copySuccessText = "Copied", ...rest })=>{
1178
+ const CodeBlock = ({ code, children, lang: defaultLang = "tsx", className, options, activeOption: controlledActiveOption, defaultActiveOption = 0, onActiveOptionChange, copyText = "Copy", copySuccessText = "Copied", classNames, maxHeight, ...rest })=>{
935
1179
  const [activeOption, setActiveOption] = useControlledState(controlledActiveOption, onActiveOptionChange, defaultActiveOption);
936
1180
  const [currentCode, setCurrentCode] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(code || "");
937
1181
  const [lang, setLang] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(defaultLang);
@@ -974,11 +1218,11 @@ const CodeBlock = ({ code, children, lang: defaultLang = "tsx", className, optio
974
1218
  return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(ThemeProvider, {
975
1219
  theme: "dark",
976
1220
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(WithAntdTokens, {
977
- className: clsx(cls("code-block"), className),
1221
+ className: clsx(cls("code-block"), className, null == classNames ? void 0 : classNames.root),
978
1222
  ...rest,
979
1223
  children: [
980
1224
  hasOptions && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
981
- className: cls("code-block-header"),
1225
+ className: cls("code-block-header", null == classNames ? void 0 : classNames.header),
982
1226
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Segmented, {
983
1227
  value: activeOption,
984
1228
  onChange: setActiveOption,
@@ -998,7 +1242,10 @@ const CodeBlock = ({ code, children, lang: defaultLang = "tsx", className, optio
998
1242
  })
999
1243
  }),
1000
1244
  /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
1001
- className: cls("code-block-content"),
1245
+ className: cls("code-block-content", null == classNames ? void 0 : classNames.content),
1246
+ style: {
1247
+ maxHeight: maxHeight && ("number" == typeof maxHeight ? `${maxHeight}px` : maxHeight)
1248
+ },
1002
1249
  children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(ScrollArea, {
1003
1250
  children: currentCode ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_prism_react_renderer_be33806e__.Highlight, {
1004
1251
  language: lang,
@@ -0,0 +1,6 @@
1
+ @layer components {
2
+ .ds-tooltip .ds-tooltip-inner {
3
+ min-height: auto;
4
+ }
5
+ }
6
+
package/dist/Tour.css ADDED
@@ -0,0 +1,73 @@
1
+ @layer components {
2
+ .ds-tour .ds-tour-header {
3
+ padding-top: 1rem;
4
+ padding-bottom: .75rem;
5
+ }
6
+
7
+ .ds-tour .ds-tour-title {
8
+ font-size: var(--text-ds-h5);
9
+ font-weight: var(--text-ds-h5--font-weight);
10
+ line-height: var(--text-ds-h5--line-height);
11
+ }
12
+
13
+ .ds-tour .ds-tour-description {
14
+ font-size: var(--text-ds-md);
15
+ font-weight: var(--text-ds-md--font-weight);
16
+ line-height: var(--text-ds-md--line-height);
17
+ }
18
+
19
+ :is(:is(.ds-tour .ds-tour-description) p, :is(.ds-tour .ds-tour-description) ul, :is(.ds-tour .ds-tour-description) ol):not(:first-child) {
20
+ margin-top: .875rem;
21
+ }
22
+
23
+ :is(.ds-tour .ds-tour-description) strong {
24
+ font-weight: 600;
25
+ }
26
+
27
+ :is(.ds-tour .ds-tour-description) ul {
28
+ padding-left: 1rem;
29
+ list-style: outside;
30
+ }
31
+
32
+ :is(.ds-tour .ds-tour-description) ol {
33
+ padding-left: 1rem;
34
+ list-style: decimal;
35
+ }
36
+
37
+ :is(.ds-tour .ds-tour-description) li {
38
+ padding-left: .5rem;
39
+ }
40
+
41
+ :is(.ds-tour .ds-tour-description) li:not(:first-child) {
42
+ margin-top: .5rem;
43
+ }
44
+
45
+ :is(.ds-tour .ds-tour-description) li svg {
46
+ margin-bottom: -.25rem;
47
+ font-size: 1.25rem;
48
+ display: inline-block;
49
+ }
50
+
51
+ .ds-tour .ds-tour-footer {
52
+ padding-top: 1rem;
53
+ }
54
+
55
+ .ds-tour .ds-tour-indicator-wrapper {
56
+ align-items: center;
57
+ gap: .5rem;
58
+ width: 100%;
59
+ height: 100%;
60
+ display: inline-flex;
61
+ }
62
+
63
+ .ds-tour .ds-tour-indicator-summary-text {
64
+ font-size: var(--text-ds-sm);
65
+ font-weight: var(--text-ds-sm--font-weight);
66
+ line-height: var(--text-ds-sm--line-height);
67
+ color: var(--ds-color-text-tertiary);
68
+ align-items: center;
69
+ padding-top: .25rem;
70
+ display: inline-flex;
71
+ }
72
+ }
73
+
package/dist/Tour.js CHANGED
@@ -33,7 +33,7 @@ const Tour = ({ indicatorsRender, ...rest })=>{
33
33
  className: cls("tour-indicator-summary-text"),
34
34
  children: [
35
35
  current + 1,
36
- " / ",
36
+ "/",
37
37
  total
38
38
  ]
39
39
  }),
@@ -0,0 +1,31 @@
1
+ @layer components {
2
+ .ds-truncate {
3
+ white-space: nowrap;
4
+ flex-grow: 1;
5
+ width: 100%;
6
+ min-width: 0;
7
+ max-width: 100%;
8
+ display: block;
9
+ overflow: hidden;
10
+ }
11
+
12
+ .ds-truncate-end {
13
+ text-overflow: ellipsis;
14
+ }
15
+
16
+ .ds-truncate-middle {
17
+ text-overflow: clip;
18
+ }
19
+
20
+ .ds-truncate-multiline {
21
+ -webkit-line-clamp: var(--ds-line-clamp, 2);
22
+ line-clamp: var(--ds-line-clamp, 2);
23
+ white-space: normal;
24
+ text-overflow: ellipsis;
25
+ word-break: break-word;
26
+ -webkit-box-orient: vertical;
27
+ display: -webkit-box;
28
+ overflow: hidden;
29
+ }
30
+ }
31
+
package/dist/Truncate.js CHANGED
@@ -83,35 +83,90 @@ const getMiddleTruncatedString = (text, ellipsis, container)=>{
83
83
  return (null == (_Object_values_reverse_find = Object.values(attempts).reverse().find(([width])=>width < containerWidth)) ? void 0 : _Object_values_reverse_find[1]) ?? Object.values(attempts)[0][1];
84
84
  };
85
85
  "use client";
86
- const Truncate = ({ children, position = "end", className, style, ...rest })=>{
86
+ const Truncate = ({ children, position = "end", lines = 1, className, style, ...rest })=>{
87
87
  const cls = useCls();
88
88
  const containerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
89
89
  const [isTruncated, setIsTruncated] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
90
90
  const [truncatedText, setTruncatedText] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(children);
91
91
  const text = children;
92
92
  const getContainerStyles = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
93
- const baseStyles = {
94
- overflow: "hidden",
95
- whiteSpace: "nowrap",
96
- textOverflow: "clip",
97
- flexGrow: 1,
98
- minWidth: 0,
99
- maxWidth: "100%",
100
- display: "block",
101
- ...style
93
+ if ("auto" !== lines) return {
94
+ ...style,
95
+ ...lines > 1 ? {
96
+ "--ds-line-clamp": lines
97
+ } : {}
102
98
  };
103
- if ("end" === position) return {
104
- ...baseStyles,
105
- textOverflow: "ellipsis"
99
+ return {
100
+ ...style,
101
+ "--ds-line-clamp": 999
106
102
  };
107
- return baseStyles;
108
103
  }, [
109
- position,
104
+ lines,
110
105
  style
111
106
  ]);
112
107
  (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
113
108
  const container = containerRef.current;
114
109
  if (!container) return;
110
+ if ("auto" === lines) {
111
+ var _window_document_fonts_ready, _window_document_fonts;
112
+ setTruncatedText(text);
113
+ const calculateLines = ()=>{
114
+ const parent = container.parentElement;
115
+ if (!parent) return;
116
+ const styles = window.getComputedStyle(container);
117
+ const fontSize = parseFloat(styles.fontSize);
118
+ const lineHeight = "normal" === styles.lineHeight ? 1.2 * fontSize : parseFloat(styles.lineHeight);
119
+ const parentStyles = window.getComputedStyle(parent);
120
+ const paddingTop = parseFloat(parentStyles.paddingTop) || 0;
121
+ const paddingBottom = parseFloat(parentStyles.paddingBottom) || 0;
122
+ const borderTopWidth = parseFloat(parentStyles.borderTopWidth) || 0;
123
+ const borderBottomWidth = parseFloat(parentStyles.borderBottomWidth) || 0;
124
+ const parentHeight = parent.clientHeight;
125
+ const availableHeight = parentHeight - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth;
126
+ const maxLines = Math.max(1, Math.floor(availableHeight / lineHeight));
127
+ if (container) container.style.setProperty("--ds-line-clamp", String(maxLines));
128
+ const clone = document.createElement("span");
129
+ clone.style.visibility = "hidden";
130
+ clone.style.position = "absolute";
131
+ clone.style.width = `${container.clientWidth}px`;
132
+ clone.style.fontSize = styles.fontSize;
133
+ clone.style.fontFamily = styles.fontFamily;
134
+ clone.style.lineHeight = styles.lineHeight;
135
+ clone.textContent = text;
136
+ document.body.appendChild(clone);
137
+ const isTruncated = clone.scrollHeight > availableHeight;
138
+ document.body.removeChild(clone);
139
+ setIsTruncated(isTruncated);
140
+ };
141
+ null == (_window_document_fonts = window.document.fonts) || null == (_window_document_fonts_ready = _window_document_fonts.ready) || _window_document_fonts_ready.then(calculateLines);
142
+ const observer = new ResizeObserver(()=>{
143
+ window.requestAnimationFrame(calculateLines);
144
+ });
145
+ observer.observe(container);
146
+ if (container.parentElement) observer.observe(container.parentElement);
147
+ return ()=>observer.disconnect();
148
+ }
149
+ if ("number" == typeof lines && lines > 1) {
150
+ var _window_document_fonts_ready1, _window_document_fonts1;
151
+ setTruncatedText(text);
152
+ const checkIfTruncated = ()=>{
153
+ const clone = document.createElement("span");
154
+ clone.style.visibility = "hidden";
155
+ clone.style.position = "absolute";
156
+ clone.style.width = `${container.clientWidth}px`;
157
+ clone.textContent = text;
158
+ document.body.appendChild(clone);
159
+ const isTruncated = clone.scrollHeight > (container.clientHeight || container.offsetHeight);
160
+ document.body.removeChild(clone);
161
+ setIsTruncated(isTruncated);
162
+ };
163
+ null == (_window_document_fonts1 = window.document.fonts) || null == (_window_document_fonts_ready1 = _window_document_fonts1.ready) || _window_document_fonts_ready1.then(checkIfTruncated);
164
+ const observer = new ResizeObserver(()=>{
165
+ window.requestAnimationFrame(checkIfTruncated);
166
+ });
167
+ observer.observe(container);
168
+ return ()=>observer.disconnect();
169
+ }
115
170
  let cancellationToken = {
116
171
  cancelled: false
117
172
  };
@@ -126,8 +181,8 @@ const Truncate = ({ children, position = "end", className, style, ...rest })=>{
126
181
  setTruncatedText(truncated);
127
182
  };
128
183
  if ("middle" == position) {
129
- var _window_document_fonts_ready, _window_document_fonts;
130
- null == (_window_document_fonts = window.document.fonts) || null == (_window_document_fonts_ready = _window_document_fonts.ready) || _window_document_fonts_ready.then(calculateTruncatedString);
184
+ var _window_document_fonts_ready2, _window_document_fonts2;
185
+ null == (_window_document_fonts2 = window.document.fonts) || null == (_window_document_fonts_ready2 = _window_document_fonts2.ready) || _window_document_fonts_ready2.then(calculateTruncatedString);
131
186
  }
132
187
  if ("end" == position) setTruncatedText(text);
133
188
  const observer = new ResizeObserver(()=>{
@@ -144,12 +199,13 @@ const Truncate = ({ children, position = "end", className, style, ...rest })=>{
144
199
  };
145
200
  }, [
146
201
  text,
147
- position
202
+ position,
203
+ lines
148
204
  ]);
149
205
  return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
150
206
  ref: containerRef,
151
207
  style: getContainerStyles(),
152
- className: clsx(cls("truncate"), className),
208
+ className: clsx(1 === lines ? cls("truncate") : cls("truncate-multiline"), "middle" === position ? cls("truncate-middle") : cls("truncate-end"), className),
153
209
  title: isTruncated ? text : void 0,
154
210
  ...rest,
155
211
  children: text === truncatedText ? text : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {