@aloudata/aloudata-design 3.0.0-beta.16 → 3.0.0-beta.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloudata/aloudata-design",
3
- "version": "3.0.0-beta.16",
3
+ "version": "3.0.0-beta.18",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -79,6 +79,7 @@
79
79
  "immer": "^10.0.3",
80
80
  "memoize-one": "^6.0.0",
81
81
  "rc-field-form": "^2.7.1",
82
+ "rc-overflow": "^1.3.2",
82
83
  "rc-picker": "^4.11.3",
83
84
  "rc-tree": "^5.13.1",
84
85
  "rc-upload": "^4.8.1",
@@ -1,14 +0,0 @@
1
- import { default as React } from 'react';
2
- interface SimpleOverflowProps<T> {
3
- data: T[];
4
- renderItem: (item: T, index: number) => React.ReactNode;
5
- renderRest?: (omittedItems: T[]) => React.ReactNode;
6
- suffix?: React.ReactNode;
7
- itemKey?: string | ((item: T) => string);
8
- maxCount?: 'responsive' | number;
9
- className?: string;
10
- prefixCls?: string;
11
- onVisibleChange?: (visibleCount: number) => void;
12
- }
13
- export default function SimpleOverflow<T>(props: SimpleOverflowProps<T>): import("react/jsx-runtime").JSX.Element;
14
- export {};
@@ -1,61 +0,0 @@
1
- import { cn } from "../lib/utils.js";
2
- import { useEffect, useRef, useState } from "react";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/_utils/SimpleOverflow.tsx
5
- function SimpleOverflow(props) {
6
- const { data, renderItem, renderRest, suffix, itemKey, className, prefixCls, onVisibleChange } = props;
7
- const containerRef = useRef(null);
8
- const [visibleCount, setVisibleCount] = useState(data.length);
9
- useEffect(() => {
10
- const container = containerRef.current;
11
- if (!container) return;
12
- const measure = () => {
13
- const overflowItems = [];
14
- for (const child of Array.from(container.children)) if (child.dataset.overflowItem === "true") overflowItems.push(child);
15
- if (overflowItems.length === 0) return;
16
- const savedDisplays = overflowItems.map((el) => el.style.display);
17
- overflowItems.forEach((el) => {
18
- el.style.display = "";
19
- });
20
- container.offsetHeight;
21
- const containerRect = container.getBoundingClientRect();
22
- let count = 0;
23
- for (const el of overflowItems) if (el.getBoundingClientRect().right <= containerRect.right - 40) count++;
24
- else break;
25
- overflowItems.forEach((el, i) => {
26
- el.style.display = savedDisplays[i];
27
- });
28
- const newCount = Math.max(1, Math.min(count, data.length));
29
- setVisibleCount(newCount);
30
- onVisibleChange?.(newCount);
31
- };
32
- measure();
33
- const ro = new window.ResizeObserver(measure);
34
- ro.observe(container);
35
- return () => ro.disconnect();
36
- }, [data.length, onVisibleChange]);
37
- const getKey = (item, index) => {
38
- if (typeof itemKey === "function") return itemKey(item);
39
- if (typeof itemKey === "string") return item[itemKey];
40
- return String(index);
41
- };
42
- const omittedItems = data.slice(visibleCount);
43
- return /* @__PURE__ */ jsxs("div", {
44
- ref: containerRef,
45
- className: cn(prefixCls, "tw-flex tw-flex-nowrap tw-items-center tw-overflow-hidden", className),
46
- children: [
47
- data.map((item, index) => /* @__PURE__ */ jsx("div", {
48
- "data-overflow-item": "true",
49
- className: prefixCls ? `${prefixCls}-item` : void 0,
50
- style: { display: index < visibleCount ? void 0 : "none" },
51
- children: renderItem(item, index)
52
- }, getKey(item, index))),
53
- omittedItems.length > 0 && renderRest?.(omittedItems),
54
- suffix
55
- ]
56
- });
57
- }
58
- //#endregion
59
- export { SimpleOverflow as default };
60
-
61
- //# sourceMappingURL=SimpleOverflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleOverflow.js","names":[],"sources":["../../src/_utils/SimpleOverflow.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { cn } from '../lib/utils';\n\ninterface SimpleOverflowProps<T> {\n data: T[];\n renderItem: (item: T, index: number) => React.ReactNode;\n renderRest?: (omittedItems: T[]) => React.ReactNode;\n suffix?: React.ReactNode;\n itemKey?: string | ((item: T) => string);\n maxCount?: 'responsive' | number;\n className?: string;\n prefixCls?: string;\n onVisibleChange?: (visibleCount: number) => void;\n}\n\nexport default function SimpleOverflow<T>(props: SimpleOverflowProps<T>) {\n const {\n data,\n renderItem,\n renderRest,\n suffix,\n itemKey,\n className,\n prefixCls,\n onVisibleChange,\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [visibleCount, setVisibleCount] = useState(data.length);\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n\n const measure = () => {\n const overflowItems: HTMLElement[] = [];\n for (const child of Array.from(container.children)) {\n if ((child as HTMLElement).dataset.overflowItem === 'true') {\n overflowItems.push(child as HTMLElement);\n }\n }\n if (overflowItems.length === 0) return;\n\n // Temporarily show all items so we can measure their natural positions\n const savedDisplays = overflowItems.map((el) => el.style.display);\n overflowItems.forEach((el) => {\n el.style.display = '';\n });\n // Force synchronous reflow\n void container.offsetHeight;\n\n const containerRect = container.getBoundingClientRect();\n let count = 0;\n for (const el of overflowItems) {\n const rect = el.getBoundingClientRect();\n if (rect.right <= containerRect.right - 40) {\n count++;\n } else {\n break;\n }\n }\n\n // Restore display values before React re-renders\n overflowItems.forEach((el, i) => {\n el.style.display = savedDisplays[i];\n });\n\n const newCount = Math.max(1, Math.min(count, data.length));\n setVisibleCount(newCount);\n onVisibleChange?.(newCount);\n };\n\n measure();\n const ro = new window.ResizeObserver(measure);\n ro.observe(container);\n return () => ro.disconnect();\n }, [data.length, onVisibleChange]);\n\n const getKey = (item: T, index: number) => {\n if (typeof itemKey === 'function') return itemKey(item);\n if (typeof itemKey === 'string')\n return (item as Record<string, string>)[itemKey];\n return String(index);\n };\n\n const omittedItems = data.slice(visibleCount);\n\n return (\n <div\n ref={containerRef}\n className={cn(\n prefixCls,\n 'tw-flex tw-flex-nowrap tw-items-center tw-overflow-hidden',\n className,\n )}\n >\n {data.map((item, index) => (\n <div\n key={getKey(item, index)}\n data-overflow-item=\"true\"\n className={prefixCls ? `${prefixCls}-item` : undefined}\n style={{\n display: index < visibleCount ? undefined : 'none',\n }}\n >\n {renderItem(item, index)}\n </div>\n ))}\n {omittedItems.length > 0 && renderRest?.(omittedItems)}\n {suffix}\n </div>\n );\n}\n"],"mappings":";;;;AAeA,SAAwB,eAAkB,OAA+B;CACvE,MAAM,EACJ,MACA,YACA,YACA,QACA,SACA,WACA,WACA,oBACE;CAEJ,MAAM,eAAe,OAAuB,KAAK;CACjD,MAAM,CAAC,cAAc,mBAAmB,SAAS,KAAK,OAAO;AAE7D,iBAAgB;EACd,MAAM,YAAY,aAAa;AAC/B,MAAI,CAAC,UAAW;EAEhB,MAAM,gBAAgB;GACpB,MAAM,gBAA+B,EAAE;AACvC,QAAK,MAAM,SAAS,MAAM,KAAK,UAAU,SAAS,CAChD,KAAK,MAAsB,QAAQ,iBAAiB,OAClD,eAAc,KAAK,MAAqB;AAG5C,OAAI,cAAc,WAAW,EAAG;GAGhC,MAAM,gBAAgB,cAAc,KAAK,OAAO,GAAG,MAAM,QAAQ;AACjE,iBAAc,SAAS,OAAO;AAC5B,OAAG,MAAM,UAAU;KACnB;AAEF,GAAK,UAAU;GAEf,MAAM,gBAAgB,UAAU,uBAAuB;GACvD,IAAI,QAAQ;AACZ,QAAK,MAAM,MAAM,cAEf,KADa,GAAG,uBAAuB,CAC9B,SAAS,cAAc,QAAQ,GACtC;OAEA;AAKJ,iBAAc,SAAS,IAAI,MAAM;AAC/B,OAAG,MAAM,UAAU,cAAc;KACjC;GAEF,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,KAAK,OAAO,CAAC;AAC1D,mBAAgB,SAAS;AACzB,qBAAkB,SAAS;;AAG7B,WAAS;EACT,MAAM,KAAK,IAAI,OAAO,eAAe,QAAQ;AAC7C,KAAG,QAAQ,UAAU;AACrB,eAAa,GAAG,YAAY;IAC3B,CAAC,KAAK,QAAQ,gBAAgB,CAAC;CAElC,MAAM,UAAU,MAAS,UAAkB;AACzC,MAAI,OAAO,YAAY,WAAY,QAAO,QAAQ,KAAK;AACvD,MAAI,OAAO,YAAY,SACrB,QAAQ,KAAgC;AAC1C,SAAO,OAAO,MAAM;;CAGtB,MAAM,eAAe,KAAK,MAAM,aAAa;AAE7C,QACE,qBAAC,OAAD;EACE,KAAK;EACL,WAAW,GACT,WACA,6DACA,UACD;YANH;GAQG,KAAK,KAAK,MAAM,UACf,oBAAC,OAAD;IAEE,sBAAmB;IACnB,WAAW,YAAY,GAAG,UAAU,SAAS;IAC7C,OAAO,EACL,SAAS,QAAQ,eAAe,SAAY,QAC7C;cAEA,WAAW,MAAM,MAAM;IACpB,EARC,OAAO,MAAM,MAAM,CAQpB,CACN;GACD,aAAa,SAAS,KAAK,aAAa,aAAa;GACrD;GACG"}