@qq1948037137/adminsmart-ui 0.1.27 → 0.1.29

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/dist/index.d.cts CHANGED
@@ -288,8 +288,43 @@ interface SearchPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childre
288
288
  */
289
289
  declare const SearchPanel: react.ForwardRefExoticComponent<SearchPanelProps & react.RefAttributes<HTMLDivElement>>;
290
290
 
291
+ interface TableControlColumn {
292
+ /** 宿主表格的稳定列标识,在同一表格中必须唯一。 */
293
+ key: string;
294
+ /** 列选择面板中供用户识别的列标题。 */
295
+ label: ReactNode;
296
+ /** 为真时保留宿主原有显隐值,不允许用户切换。 */
297
+ disabled?: boolean;
298
+ }
299
+ interface TableControlsProps {
300
+ /** 筛选区当前可见。由宿主将该状态传给同页的 SearchPanel。 */
301
+ searchVisible?: boolean;
302
+ /** 请求宿主改变筛选区可见状态。省略时保持搜索按钮位置且禁用。 */
303
+ onSearchVisibleChange?: (visible: boolean) => void;
304
+ /** 重新加载当前页。省略时保持刷新按钮位置且禁用。 */
305
+ onRefresh?: () => void;
306
+ /** 当前正在重新加载。为真时刷新按钮显示进度并阻止重复操作。 */
307
+ refreshing?: boolean;
308
+ /** 可显示在列选择面板中的业务列。省略时列选择不可用。 */
309
+ columns?: readonly TableControlColumn[];
310
+ /** 当前可见的列标识。省略时将提供的所有列视为可见。 */
311
+ visibleColumns?: readonly string[];
312
+ /** 以 columns 原有顺序返回新的可见列标识,由宿主应用及按需持久化。 */
313
+ onVisibleColumnsChange?: (keys: string[]) => void;
314
+ /** 宿主用于定位工具组的可选类名。 */
315
+ className?: string;
316
+ /** 宿主可选的工具组样式覆写。 */
317
+ style?: CSSProperties;
318
+ }
319
+ /**
320
+ * 为列表右侧提供顺序固定的筛选显隐、刷新和显示列控件。
321
+ * @param props 搜索、刷新和列显隐由宿主管理,控件只管理面板的打开与键盘焦点。
322
+ * @returns 可放入 SearchPanel.trailingTools 的一组紧凑工具。
323
+ */
324
+ declare function TableControls({ searchVisible, onSearchVisibleChange, onRefresh, refreshing, columns, visibleColumns, onVisibleColumnsChange, className, style, }: TableControlsProps): react_jsx_runtime.JSX.Element;
325
+
291
326
  interface DataTableProps<RecordType extends object> extends TableProps<RecordType> {
292
- /** 设置表格整体容器的固定高度;省略时按屏幕剩余高度计算。 */
327
+ /** 设置表格整体容器高度;CrudWorkspace 内默认 100%,其它容器沿用视口剩余高度。 */
293
328
  containerHeight?: CSSProperties['height'];
294
329
  /** 仅作用于外层滚动边界,不覆盖 Ant Table 自身的 style。 */
295
330
  containerStyle?: CSSProperties;
@@ -380,6 +415,27 @@ interface CrudScaffoldProps extends Omit<HTMLAttributes<HTMLElement>, 'children'
380
415
  */
381
416
  declare function CrudScaffold({ label, description, filters, status, results, drawer, className, ...props }: CrudScaffoldProps): react_jsx_runtime.JSX.Element;
382
417
 
418
+ interface CrudWorkspaceProps extends HTMLAttributes<HTMLElement> {
419
+ /** 工作区的可访问名称。 */
420
+ label: string;
421
+ /** 第一排查询条件及相关表单操作。 */
422
+ filters?: ReactNode;
423
+ /** 业务操作及表格控制栏,独立于筛选区。 */
424
+ toolbar?: ReactNode;
425
+ /** 查询状态、警告或其它占用自然高度的结果反馈。 */
426
+ feedback?: ReactNode;
427
+ /** 可选的业务页脚,放在结果区域下方。 */
428
+ footer?: ReactNode;
429
+ /** 占满可用高度的表格、列表或其它页面结果。 */
430
+ children: ReactNode;
431
+ }
432
+ /**
433
+ * 在有明确高度的工作区内组织 CRUD 页面,结果独占剩余高度。
434
+ * @param props 宿主提供内容、状态及原生区块属性;业务请求和分页由宿主控制。
435
+ * @returns 可嵌入 WorkspaceLayout 表格模式的无状态页面骨架。
436
+ */
437
+ declare function CrudWorkspace({ label, filters, toolbar, feedback, footer, children, className, ...props }: CrudWorkspaceProps): react_jsx_runtime.JSX.Element;
438
+
383
439
  interface EllipsisTextProps extends ComponentProps<typeof Typography.Text> {
384
440
  /** 单行文本最多占用的宽度;业务表格可按列宽覆盖。 */
385
441
  maxWidth?: number | string;
@@ -508,4 +564,4 @@ declare function mapSchemaField(field: SchemaField): SchemaFieldMapping;
508
564
  /** 从字段默认值生成表单初值;调用方的 initialValues 可在渲染层覆盖。 */
509
565
  declare function schemaInitialValues(schema: SchemaFormSchema): SchemaFormValues;
510
566
 
511
- export { Affix, Alert, Anchor, App, AutoComplete, Avatar, BUSINESS_DRAWER_WIDTH, BackTop, Badge, BorderBeam, Breadcrumb, BusinessDrawer, type BusinessDrawerProps, type BusinessDrawerSize, Button, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker, ConfigProvider, CrudScaffold, type CrudScaffoldProps, DataTable, type DataTableProps, DatePicker, Descriptions, Divider, Drawer, Dropdown, EllipsisText, type EllipsisTextProps, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Listy, Masonry, Mentions, Menu, Modal, Pagination, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, RowActions, type RowActionsProps, type SchemaBooleanField, type SchemaChoiceField, type SchemaDateField, type SchemaDateRangeField, type SchemaField, type SchemaFieldMapping, type SchemaFieldName, SchemaForm, type SchemaFormProps, type SchemaFormSchema, type SchemaFormValues, type SchemaIssue, type SchemaNumberField, type SchemaNumberValidation, type SchemaOption, type SchemaTextField, type SchemaTextValidation, type SchemaValidationResult, SearchPanel, type SearchPanelProps, Segmented, Select, SessionReplay, type SessionReplayError, type SessionReplayEvent, type SessionReplayHandle, type SessionReplayMarker, type SessionReplayProps, type SessionReplayState, Skeleton, Slider, Space, Spin, Splitter, Statistic, Steps, Switch, Table, TableEmpty, type TableEmptyProps, Tabs, Tag, type ThemeMode, ThemeModeButton, type ThemeModeButtonProps, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark, WorkspaceLayout, type WorkspaceLayoutProps, mapSchemaField, schemaInitialValues, tableBodyHeight, validateSchemaForm };
567
+ export { Affix, Alert, Anchor, App, AutoComplete, Avatar, BUSINESS_DRAWER_WIDTH, BackTop, Badge, BorderBeam, Breadcrumb, BusinessDrawer, type BusinessDrawerProps, type BusinessDrawerSize, Button, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker, ConfigProvider, CrudScaffold, type CrudScaffoldProps, CrudWorkspace, type CrudWorkspaceProps, DataTable, type DataTableProps, DatePicker, Descriptions, Divider, Drawer, Dropdown, EllipsisText, type EllipsisTextProps, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Listy, Masonry, Mentions, Menu, Modal, Pagination, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, RowActions, type RowActionsProps, type SchemaBooleanField, type SchemaChoiceField, type SchemaDateField, type SchemaDateRangeField, type SchemaField, type SchemaFieldMapping, type SchemaFieldName, SchemaForm, type SchemaFormProps, type SchemaFormSchema, type SchemaFormValues, type SchemaIssue, type SchemaNumberField, type SchemaNumberValidation, type SchemaOption, type SchemaTextField, type SchemaTextValidation, type SchemaValidationResult, SearchPanel, type SearchPanelProps, Segmented, Select, SessionReplay, type SessionReplayError, type SessionReplayEvent, type SessionReplayHandle, type SessionReplayMarker, type SessionReplayProps, type SessionReplayState, Skeleton, Slider, Space, Spin, Splitter, Statistic, Steps, Switch, Table, type TableControlColumn, TableControls, type TableControlsProps, TableEmpty, type TableEmptyProps, Tabs, Tag, type ThemeMode, ThemeModeButton, type ThemeModeButtonProps, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark, WorkspaceLayout, type WorkspaceLayoutProps, mapSchemaField, schemaInitialValues, tableBodyHeight, validateSchemaForm };
package/dist/index.d.ts CHANGED
@@ -288,8 +288,43 @@ interface SearchPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childre
288
288
  */
289
289
  declare const SearchPanel: react.ForwardRefExoticComponent<SearchPanelProps & react.RefAttributes<HTMLDivElement>>;
290
290
 
291
+ interface TableControlColumn {
292
+ /** 宿主表格的稳定列标识,在同一表格中必须唯一。 */
293
+ key: string;
294
+ /** 列选择面板中供用户识别的列标题。 */
295
+ label: ReactNode;
296
+ /** 为真时保留宿主原有显隐值,不允许用户切换。 */
297
+ disabled?: boolean;
298
+ }
299
+ interface TableControlsProps {
300
+ /** 筛选区当前可见。由宿主将该状态传给同页的 SearchPanel。 */
301
+ searchVisible?: boolean;
302
+ /** 请求宿主改变筛选区可见状态。省略时保持搜索按钮位置且禁用。 */
303
+ onSearchVisibleChange?: (visible: boolean) => void;
304
+ /** 重新加载当前页。省略时保持刷新按钮位置且禁用。 */
305
+ onRefresh?: () => void;
306
+ /** 当前正在重新加载。为真时刷新按钮显示进度并阻止重复操作。 */
307
+ refreshing?: boolean;
308
+ /** 可显示在列选择面板中的业务列。省略时列选择不可用。 */
309
+ columns?: readonly TableControlColumn[];
310
+ /** 当前可见的列标识。省略时将提供的所有列视为可见。 */
311
+ visibleColumns?: readonly string[];
312
+ /** 以 columns 原有顺序返回新的可见列标识,由宿主应用及按需持久化。 */
313
+ onVisibleColumnsChange?: (keys: string[]) => void;
314
+ /** 宿主用于定位工具组的可选类名。 */
315
+ className?: string;
316
+ /** 宿主可选的工具组样式覆写。 */
317
+ style?: CSSProperties;
318
+ }
319
+ /**
320
+ * 为列表右侧提供顺序固定的筛选显隐、刷新和显示列控件。
321
+ * @param props 搜索、刷新和列显隐由宿主管理,控件只管理面板的打开与键盘焦点。
322
+ * @returns 可放入 SearchPanel.trailingTools 的一组紧凑工具。
323
+ */
324
+ declare function TableControls({ searchVisible, onSearchVisibleChange, onRefresh, refreshing, columns, visibleColumns, onVisibleColumnsChange, className, style, }: TableControlsProps): react_jsx_runtime.JSX.Element;
325
+
291
326
  interface DataTableProps<RecordType extends object> extends TableProps<RecordType> {
292
- /** 设置表格整体容器的固定高度;省略时按屏幕剩余高度计算。 */
327
+ /** 设置表格整体容器高度;CrudWorkspace 内默认 100%,其它容器沿用视口剩余高度。 */
293
328
  containerHeight?: CSSProperties['height'];
294
329
  /** 仅作用于外层滚动边界,不覆盖 Ant Table 自身的 style。 */
295
330
  containerStyle?: CSSProperties;
@@ -380,6 +415,27 @@ interface CrudScaffoldProps extends Omit<HTMLAttributes<HTMLElement>, 'children'
380
415
  */
381
416
  declare function CrudScaffold({ label, description, filters, status, results, drawer, className, ...props }: CrudScaffoldProps): react_jsx_runtime.JSX.Element;
382
417
 
418
+ interface CrudWorkspaceProps extends HTMLAttributes<HTMLElement> {
419
+ /** 工作区的可访问名称。 */
420
+ label: string;
421
+ /** 第一排查询条件及相关表单操作。 */
422
+ filters?: ReactNode;
423
+ /** 业务操作及表格控制栏,独立于筛选区。 */
424
+ toolbar?: ReactNode;
425
+ /** 查询状态、警告或其它占用自然高度的结果反馈。 */
426
+ feedback?: ReactNode;
427
+ /** 可选的业务页脚,放在结果区域下方。 */
428
+ footer?: ReactNode;
429
+ /** 占满可用高度的表格、列表或其它页面结果。 */
430
+ children: ReactNode;
431
+ }
432
+ /**
433
+ * 在有明确高度的工作区内组织 CRUD 页面,结果独占剩余高度。
434
+ * @param props 宿主提供内容、状态及原生区块属性;业务请求和分页由宿主控制。
435
+ * @returns 可嵌入 WorkspaceLayout 表格模式的无状态页面骨架。
436
+ */
437
+ declare function CrudWorkspace({ label, filters, toolbar, feedback, footer, children, className, ...props }: CrudWorkspaceProps): react_jsx_runtime.JSX.Element;
438
+
383
439
  interface EllipsisTextProps extends ComponentProps<typeof Typography.Text> {
384
440
  /** 单行文本最多占用的宽度;业务表格可按列宽覆盖。 */
385
441
  maxWidth?: number | string;
@@ -508,4 +564,4 @@ declare function mapSchemaField(field: SchemaField): SchemaFieldMapping;
508
564
  /** 从字段默认值生成表单初值;调用方的 initialValues 可在渲染层覆盖。 */
509
565
  declare function schemaInitialValues(schema: SchemaFormSchema): SchemaFormValues;
510
566
 
511
- export { Affix, Alert, Anchor, App, AutoComplete, Avatar, BUSINESS_DRAWER_WIDTH, BackTop, Badge, BorderBeam, Breadcrumb, BusinessDrawer, type BusinessDrawerProps, type BusinessDrawerSize, Button, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker, ConfigProvider, CrudScaffold, type CrudScaffoldProps, DataTable, type DataTableProps, DatePicker, Descriptions, Divider, Drawer, Dropdown, EllipsisText, type EllipsisTextProps, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Listy, Masonry, Mentions, Menu, Modal, Pagination, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, RowActions, type RowActionsProps, type SchemaBooleanField, type SchemaChoiceField, type SchemaDateField, type SchemaDateRangeField, type SchemaField, type SchemaFieldMapping, type SchemaFieldName, SchemaForm, type SchemaFormProps, type SchemaFormSchema, type SchemaFormValues, type SchemaIssue, type SchemaNumberField, type SchemaNumberValidation, type SchemaOption, type SchemaTextField, type SchemaTextValidation, type SchemaValidationResult, SearchPanel, type SearchPanelProps, Segmented, Select, SessionReplay, type SessionReplayError, type SessionReplayEvent, type SessionReplayHandle, type SessionReplayMarker, type SessionReplayProps, type SessionReplayState, Skeleton, Slider, Space, Spin, Splitter, Statistic, Steps, Switch, Table, TableEmpty, type TableEmptyProps, Tabs, Tag, type ThemeMode, ThemeModeButton, type ThemeModeButtonProps, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark, WorkspaceLayout, type WorkspaceLayoutProps, mapSchemaField, schemaInitialValues, tableBodyHeight, validateSchemaForm };
567
+ export { Affix, Alert, Anchor, App, AutoComplete, Avatar, BUSINESS_DRAWER_WIDTH, BackTop, Badge, BorderBeam, Breadcrumb, BusinessDrawer, type BusinessDrawerProps, type BusinessDrawerSize, Button, Calendar, Card, Carousel, Cascader, Checkbox, Col, Collapse, ColorPicker, ConfigProvider, CrudScaffold, type CrudScaffoldProps, CrudWorkspace, type CrudWorkspaceProps, DataTable, type DataTableProps, DatePicker, Descriptions, Divider, Drawer, Dropdown, EllipsisText, type EllipsisTextProps, Empty, Flex, FloatButton, Form, Grid, Image, Input, InputNumber, Layout, List, Listy, Masonry, Mentions, Menu, Modal, Pagination, Popconfirm, Popover, Progress, QRCode, Radio, Rate, Result, Row, RowActions, type RowActionsProps, type SchemaBooleanField, type SchemaChoiceField, type SchemaDateField, type SchemaDateRangeField, type SchemaField, type SchemaFieldMapping, type SchemaFieldName, SchemaForm, type SchemaFormProps, type SchemaFormSchema, type SchemaFormValues, type SchemaIssue, type SchemaNumberField, type SchemaNumberValidation, type SchemaOption, type SchemaTextField, type SchemaTextValidation, type SchemaValidationResult, SearchPanel, type SearchPanelProps, Segmented, Select, SessionReplay, type SessionReplayError, type SessionReplayEvent, type SessionReplayHandle, type SessionReplayMarker, type SessionReplayProps, type SessionReplayState, Skeleton, Slider, Space, Spin, Splitter, Statistic, Steps, Switch, Table, type TableControlColumn, TableControls, type TableControlsProps, TableEmpty, type TableEmptyProps, Tabs, Tag, type ThemeMode, ThemeModeButton, type ThemeModeButtonProps, TimePicker, Timeline, Tooltip, Tour, Transfer, Tree, TreeSelect, Typography, Upload, Watermark, WorkspaceLayout, type WorkspaceLayoutProps, mapSchemaField, schemaInitialValues, tableBodyHeight, validateSchemaForm };
package/dist/index.js CHANGED
@@ -1291,14 +1291,152 @@ var SearchPanel = forwardRef5(function SearchPanel2({ fields, actions, tools, tr
1291
1291
  ] });
1292
1292
  });
1293
1293
 
1294
+ // src/composites/TableControls.tsx
1295
+ import { ReloadOutlined, SearchOutlined, SettingOutlined } from "@ant-design/icons";
1296
+ import { useId, useRef as useRef5, useState as useState5 } from "react";
1297
+ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1298
+ function TableControls({
1299
+ searchVisible = true,
1300
+ onSearchVisibleChange,
1301
+ onRefresh,
1302
+ refreshing = false,
1303
+ columns = [],
1304
+ visibleColumns,
1305
+ onVisibleColumnsChange,
1306
+ className,
1307
+ style
1308
+ }) {
1309
+ const [open, setOpen] = useState5(false);
1310
+ const triggerRef = useRef5(null);
1311
+ const panelRef = useRef5(null);
1312
+ const panelId = useId();
1313
+ const editable = columns.filter((column) => !column.disabled);
1314
+ const visible = new Set(visibleColumns ?? columns.map((column) => column.key));
1315
+ const checkedCount = editable.filter((column) => visible.has(column.key)).length;
1316
+ const canSetColumns = editable.length > 0 && Boolean(onVisibleColumnsChange);
1317
+ const searchLabel = searchVisible ? "\u9690\u85CF\u641C\u7D22" : "\u663E\u793A\u641C\u7D22";
1318
+ const setVisible = (keys, checked) => {
1319
+ const next = new Set(visible);
1320
+ for (const key of keys) {
1321
+ if (checked) next.add(key);
1322
+ else next.delete(key);
1323
+ }
1324
+ onVisibleColumnsChange?.(columns.filter((column) => next.has(column.key)).map((column) => column.key));
1325
+ };
1326
+ const closeOnEscape = (event) => {
1327
+ if (event.key !== "Escape") return;
1328
+ event.stopPropagation();
1329
+ setOpen(false);
1330
+ triggerRef.current?.focus();
1331
+ };
1332
+ const panelStyle = {
1333
+ display: "grid",
1334
+ gap: 8,
1335
+ minWidth: 120,
1336
+ maxWidth: "min(320px, calc(100vw - 32px))",
1337
+ maxHeight: "min(380px, 60vh)",
1338
+ overflow: "auto"
1339
+ };
1340
+ return /* @__PURE__ */ jsxs3("div", { className, style: { display: "inline-flex", alignItems: "center", flexShrink: 0, gap: 8, ...style }, children: [
1341
+ /* @__PURE__ */ jsx6(Tooltip, { title: searchLabel, children: /* @__PURE__ */ jsx6(
1342
+ Button,
1343
+ {
1344
+ icon: /* @__PURE__ */ jsx6(SearchOutlined, { "aria-hidden": "true" }),
1345
+ "aria-label": searchLabel,
1346
+ "aria-pressed": searchVisible,
1347
+ "data-adminsmart-table-tool": "true",
1348
+ disabled: !onSearchVisibleChange,
1349
+ onClick: () => onSearchVisibleChange?.(!searchVisible)
1350
+ }
1351
+ ) }),
1352
+ /* @__PURE__ */ jsx6(Tooltip, { title: "\u5237\u65B0\u5217\u8868", children: /* @__PURE__ */ jsx6(
1353
+ Button,
1354
+ {
1355
+ icon: /* @__PURE__ */ jsx6(ReloadOutlined, { "aria-hidden": "true" }),
1356
+ "aria-label": "\u5237\u65B0\u5217\u8868",
1357
+ "data-adminsmart-table-tool": "true",
1358
+ loading: refreshing,
1359
+ disabled: !onRefresh || refreshing,
1360
+ onClick: onRefresh
1361
+ }
1362
+ ) }),
1363
+ /* @__PURE__ */ jsx6(
1364
+ Popover,
1365
+ {
1366
+ trigger: "click",
1367
+ placement: "bottomRight",
1368
+ title: "\u8BBE\u7F6E\u663E\u793A\u5217",
1369
+ open: canSetColumns && open,
1370
+ onOpenChange: (next) => setOpen(canSetColumns && next),
1371
+ afterOpenChange: (opened) => {
1372
+ if (opened) panelRef.current?.querySelector("input:not(:disabled)")?.focus();
1373
+ },
1374
+ content: /* @__PURE__ */ jsxs3("div", { ref: panelRef, id: panelId, role: "dialog", "aria-label": "\u8BBE\u7F6E\u663E\u793A\u5217", onKeyDown: closeOnEscape, style: panelStyle, children: [
1375
+ /* @__PURE__ */ jsx6(
1376
+ Checkbox,
1377
+ {
1378
+ checked: checkedCount === editable.length,
1379
+ indeterminate: checkedCount > 0 && checkedCount < editable.length,
1380
+ onChange: (event) => setVisible(editable.map((column) => column.key), event.target.checked),
1381
+ children: "\u663E\u793A\u5168\u90E8\u53EF\u9009\u5217"
1382
+ }
1383
+ ),
1384
+ columns.map((column) => /* @__PURE__ */ jsx6(
1385
+ Checkbox,
1386
+ {
1387
+ checked: visible.has(column.key),
1388
+ disabled: column.disabled,
1389
+ onChange: (event) => setVisible([column.key], event.target.checked),
1390
+ children: column.label
1391
+ },
1392
+ column.key
1393
+ ))
1394
+ ] }),
1395
+ children: /* @__PURE__ */ jsx6(
1396
+ Button,
1397
+ {
1398
+ ref: triggerRef,
1399
+ icon: /* @__PURE__ */ jsx6(SettingOutlined, { "aria-hidden": "true" }),
1400
+ "aria-label": "\u8BBE\u7F6E\u663E\u793A\u5217",
1401
+ "data-adminsmart-table-tool": "true",
1402
+ "aria-haspopup": "dialog",
1403
+ "aria-expanded": canSetColumns && open,
1404
+ "aria-controls": canSetColumns && open ? panelId : void 0,
1405
+ disabled: !canSetColumns,
1406
+ onKeyDown: open ? closeOnEscape : void 0
1407
+ }
1408
+ )
1409
+ }
1410
+ )
1411
+ ] });
1412
+ }
1413
+
1294
1414
  // src/composites/DataTable.tsx
1295
1415
  import {
1296
1416
  forwardRef as forwardRef6,
1417
+ useContext,
1297
1418
  useLayoutEffect,
1298
- useRef as useRef5,
1299
- useState as useState5
1419
+ useRef as useRef6,
1420
+ useState as useState6
1300
1421
  } from "react";
1301
- import { jsx as jsx6 } from "react/jsx-runtime";
1422
+
1423
+ // src/composites/CrudWorkspace.tsx
1424
+ import { createContext } from "react";
1425
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1426
+ var CrudTableHeightContext = createContext(false);
1427
+ function CrudWorkspace({ label, filters, toolbar, feedback, footer, children, className, ...props }) {
1428
+ const classes = ["adminsmart-crud-workspace", className].filter(Boolean).join(" ");
1429
+ return /* @__PURE__ */ jsxs4("section", { ...props, className: classes, "aria-label": label, children: [
1430
+ filters != null && /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud-workspace__filters", children: filters }),
1431
+ toolbar != null && /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud-workspace__toolbar", children: toolbar }),
1432
+ feedback != null && /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud-workspace__feedback", children: feedback }),
1433
+ /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud-workspace__results", children: /* @__PURE__ */ jsx7(CrudTableHeightContext.Provider, { value: true, children }) }),
1434
+ footer != null && /* @__PURE__ */ jsx7("div", { className: "adminsmart-crud-workspace__footer", children: footer })
1435
+ ] });
1436
+ }
1437
+
1438
+ // src/composites/DataTable.tsx
1439
+ import { jsx as jsx8 } from "react/jsx-runtime";
1302
1440
  function tableBodyHeight(availableHeight, chromeHeight) {
1303
1441
  return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
1304
1442
  }
@@ -1319,13 +1457,22 @@ function DataTableInner({
1319
1457
  scroll,
1320
1458
  ...tableProps
1321
1459
  }, ref) {
1322
- const containerRef = useRef5(null);
1323
- const [bodyHeight, setBodyHeight] = useState5(360);
1324
- const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
1460
+ const containerRef = useRef6(null);
1461
+ const [bodyHeight, setBodyHeight] = useState6(360);
1462
+ const inWorkspace = useContext(CrudTableHeightContext);
1463
+ const tableHeight = containerHeight ?? (inWorkspace && containerStyle?.height == null ? "100%" : void 0);
1464
+ const hasExplicitHeight = tableHeight != null || containerStyle?.height != null;
1325
1465
  useLayoutEffect(() => {
1326
1466
  const container = containerRef.current;
1327
1467
  if (!container || scroll?.y != null) return void 0;
1328
1468
  const update = () => {
1469
+ if (hasExplicitHeight) {
1470
+ const height = container.getBoundingClientRect().height;
1471
+ const chromeHeight = tableChromeHeight(container);
1472
+ const nextHeight2 = inWorkspace ? Math.max(0, Math.floor(height - chromeHeight)) : tableBodyHeight(height, chromeHeight);
1473
+ setBodyHeight((current) => current === nextHeight2 ? current : nextHeight2);
1474
+ return;
1475
+ }
1329
1476
  const top = container.getBoundingClientRect().top;
1330
1477
  let boundary = container.parentElement;
1331
1478
  while (boundary && ["", "visible", "clip"].includes(getComputedStyle(boundary).overflowY)) {
@@ -1334,13 +1481,16 @@ function DataTableInner({
1334
1481
  const boundaryStyle = boundary ? getComputedStyle(boundary) : null;
1335
1482
  const parentBottom = boundary ? boundary.getBoundingClientRect().bottom - Number.parseFloat(boundaryStyle?.paddingBottom || "0") : Number.POSITIVE_INFINITY;
1336
1483
  const viewportBottom = window.visualViewport?.height ?? window.innerHeight;
1337
- const availableHeight = !hasExplicitHeight ? Math.max(200, Math.min(viewportBottom - 16, parentBottom - 16) - top) : container.getBoundingClientRect().height;
1484
+ const availableHeight = Math.max(200, Math.min(viewportBottom - 16, parentBottom - 16) - top);
1338
1485
  const nextHeight = tableBodyHeight(availableHeight, tableChromeHeight(container));
1339
1486
  setBodyHeight((current) => current === nextHeight ? current : nextHeight);
1340
1487
  };
1341
1488
  const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
1342
1489
  observer?.observe(container);
1343
1490
  if (container.parentElement) observer?.observe(container.parentElement);
1491
+ if (inWorkspace) {
1492
+ for (const region of container.querySelectorAll(".ant-table-header, .ant-table-pagination, .ant-table-title, .ant-table-footer")) observer?.observe(region);
1493
+ }
1344
1494
  window.addEventListener("resize", update);
1345
1495
  window.visualViewport?.addEventListener("resize", update);
1346
1496
  update();
@@ -1349,21 +1499,22 @@ function DataTableInner({
1349
1499
  window.removeEventListener("resize", update);
1350
1500
  window.visualViewport?.removeEventListener("resize", update);
1351
1501
  };
1352
- }, [hasExplicitHeight, containerHeight, pagination, scroll?.y, tableProps.dataSource?.length]);
1502
+ }, [hasExplicitHeight, inWorkspace, tableHeight, pagination, scroll?.y, tableProps.dataSource?.length]);
1353
1503
  const tableScroll = {
1354
1504
  ...scroll,
1355
1505
  x: scroll?.x ?? "max-content",
1356
1506
  y: scroll?.y ?? bodyHeight
1357
1507
  };
1358
1508
  const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
1359
- return /* @__PURE__ */ jsx6(
1509
+ return /* @__PURE__ */ jsx8(
1360
1510
  "div",
1361
1511
  {
1362
1512
  ref: containerRef,
1363
1513
  className: containerClassName,
1364
1514
  "data-adminsmart-data-table": "true",
1365
- style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
1366
- children: /* @__PURE__ */ jsx6(
1515
+ "data-adminsmart-data-table-fill": inWorkspace || void 0,
1516
+ style: { width: "100%", minWidth: 0, overflowX: "hidden", ...tableHeight == null ? {} : { height: tableHeight, overflowY: "hidden" }, ...containerStyle },
1517
+ children: /* @__PURE__ */ jsx8(
1367
1518
  Table,
1368
1519
  {
1369
1520
  ...tableProps,
@@ -1379,7 +1530,7 @@ var DataTable = forwardRef6(DataTableInner);
1379
1530
 
1380
1531
  // src/composites/WorkspaceLayout.tsx
1381
1532
  import { theme as theme2 } from "antd";
1382
- import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
1533
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1383
1534
  var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
1384
1535
  function WorkspaceLayout({
1385
1536
  header,
@@ -1411,10 +1562,10 @@ function WorkspaceLayout({
1411
1562
  "--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
1412
1563
  // 夜间不复用日间固定底色。
1413
1564
  };
1414
- return /* @__PURE__ */ jsxs3(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
1415
- /* @__PURE__ */ jsx7("header", { className: "adminsmart-workspace__header", children: header }),
1416
- /* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__body", children: [
1417
- /* @__PURE__ */ jsx7(
1565
+ return /* @__PURE__ */ jsxs5(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
1566
+ /* @__PURE__ */ jsx9("header", { className: "adminsmart-workspace__header", children: header }),
1567
+ /* @__PURE__ */ jsxs5(Layout, { className: "adminsmart-workspace__body", children: [
1568
+ /* @__PURE__ */ jsx9(
1418
1569
  Layout.Sider,
1419
1570
  {
1420
1571
  theme: themeMode,
@@ -1426,9 +1577,9 @@ function WorkspaceLayout({
1426
1577
  children: sidebar
1427
1578
  }
1428
1579
  ),
1429
- /* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__main", children: [
1580
+ /* @__PURE__ */ jsxs5(Layout, { className: "adminsmart-workspace__main", children: [
1430
1581
  tabs,
1431
- /* @__PURE__ */ jsx7(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
1582
+ /* @__PURE__ */ jsx9(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
1432
1583
  footer
1433
1584
  ] })
1434
1585
  ] })
@@ -1436,7 +1587,7 @@ function WorkspaceLayout({
1436
1587
  }
1437
1588
 
1438
1589
  // src/composites/CrudScaffold.tsx
1439
- import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
1590
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1440
1591
  function CrudScaffold({
1441
1592
  label,
1442
1593
  description,
@@ -1448,16 +1599,16 @@ function CrudScaffold({
1448
1599
  ...props
1449
1600
  }) {
1450
1601
  const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
1451
- return /* @__PURE__ */ jsxs4("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
1452
- /* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__filters", children: filters }),
1453
- status ? /* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__status", children: status }) : null,
1454
- /* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__results", children: results }),
1602
+ return /* @__PURE__ */ jsxs6("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
1603
+ /* @__PURE__ */ jsx10("div", { className: "adminsmart-crud__filters", children: filters }),
1604
+ status ? /* @__PURE__ */ jsx10("div", { className: "adminsmart-crud__status", children: status }) : null,
1605
+ /* @__PURE__ */ jsx10("div", { className: "adminsmart-crud__results", children: results }),
1455
1606
  drawer
1456
1607
  ] });
1457
1608
  }
1458
1609
 
1459
1610
  // src/composites/EllipsisText.tsx
1460
- import { jsx as jsx9 } from "react/jsx-runtime";
1611
+ import { jsx as jsx11 } from "react/jsx-runtime";
1461
1612
  function EllipsisText({
1462
1613
  children,
1463
1614
  maxWidth = 240,
@@ -1469,7 +1620,7 @@ function EllipsisText({
1469
1620
  const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
1470
1621
  const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
1471
1622
  const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
1472
- return /* @__PURE__ */ jsx9(
1623
+ return /* @__PURE__ */ jsx11(
1473
1624
  Typography.Text,
1474
1625
  {
1475
1626
  ...props,
@@ -1484,7 +1635,7 @@ function EllipsisText({
1484
1635
  // src/composites/RowActions.tsx
1485
1636
  import { EllipsisOutlined } from "@ant-design/icons";
1486
1637
  import { Children as Children2, Fragment, isValidElement as isValidElement2 } from "react";
1487
- import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1638
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
1488
1639
  function collectButtons(children) {
1489
1640
  const actions = [];
1490
1641
  Children2.forEach(children, (child) => {
@@ -1515,9 +1666,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
1515
1666
  // 菜单仍按官方语义标识需要确认的动作。
1516
1667
  }));
1517
1668
  const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
1518
- return /* @__PURE__ */ jsxs5(Space, { ...props, className: classes, size, wrap, children: [
1669
+ return /* @__PURE__ */ jsxs7(Space, { ...props, className: classes, size, wrap, children: [
1519
1670
  direct,
1520
- overflow.length > 0 && /* @__PURE__ */ jsx10(
1671
+ overflow.length > 0 && /* @__PURE__ */ jsx12(
1521
1672
  Dropdown,
1522
1673
  {
1523
1674
  trigger: ["click"],
@@ -1529,12 +1680,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
1529
1680
  action.props.onClick?.(domEvent);
1530
1681
  }
1531
1682
  },
1532
- children: /* @__PURE__ */ jsx10(Tooltip, { title: moreLabel, children: /* @__PURE__ */ jsx10(
1683
+ children: /* @__PURE__ */ jsx12(Tooltip, { title: moreLabel, children: /* @__PURE__ */ jsx12(
1533
1684
  Button,
1534
1685
  {
1535
1686
  type: "text",
1536
1687
  size: "small",
1537
- icon: /* @__PURE__ */ jsx10(EllipsisOutlined, {}),
1688
+ icon: /* @__PURE__ */ jsx12(EllipsisOutlined, {}),
1538
1689
  "aria-label": moreLabel,
1539
1690
  "aria-haspopup": "menu",
1540
1691
  "data-adminsmart-row-more": "true",
@@ -1731,7 +1882,7 @@ function schemaInitialValues(schema) {
1731
1882
  }
1732
1883
 
1733
1884
  // src/schema/SchemaForm.tsx
1734
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1885
+ import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
1735
1886
  function fieldRules(field) {
1736
1887
  const rules = [];
1737
1888
  if (field.required) {
@@ -1776,32 +1927,32 @@ function dateItemProps(field) {
1776
1927
  function renderControl(field) {
1777
1928
  switch (field.type) {
1778
1929
  case "input":
1779
- return /* @__PURE__ */ jsx11(Input, { placeholder: field.placeholder });
1930
+ return /* @__PURE__ */ jsx13(Input, { placeholder: field.placeholder });
1780
1931
  case "password":
1781
- return /* @__PURE__ */ jsx11(Input.Password, { placeholder: field.placeholder });
1932
+ return /* @__PURE__ */ jsx13(Input.Password, { placeholder: field.placeholder });
1782
1933
  case "textarea":
1783
- return /* @__PURE__ */ jsx11(Input.TextArea, { placeholder: field.placeholder });
1934
+ return /* @__PURE__ */ jsx13(Input.TextArea, { placeholder: field.placeholder });
1784
1935
  case "number":
1785
- return /* @__PURE__ */ jsx11(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
1936
+ return /* @__PURE__ */ jsx13(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
1786
1937
  case "select":
1787
- return /* @__PURE__ */ jsx11(Select, { placeholder: field.placeholder, options: field.options });
1938
+ return /* @__PURE__ */ jsx13(Select, { placeholder: field.placeholder, options: field.options });
1788
1939
  case "radio":
1789
- return /* @__PURE__ */ jsx11(Radio.Group, { options: field.options });
1940
+ return /* @__PURE__ */ jsx13(Radio.Group, { options: field.options });
1790
1941
  case "checkbox":
1791
- return /* @__PURE__ */ jsx11(Checkbox, {});
1942
+ return /* @__PURE__ */ jsx13(Checkbox, {});
1792
1943
  case "switch":
1793
- return /* @__PURE__ */ jsx11(Switch, {});
1944
+ return /* @__PURE__ */ jsx13(Switch, {});
1794
1945
  case "date":
1795
- return /* @__PURE__ */ jsx11(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
1946
+ return /* @__PURE__ */ jsx13(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
1796
1947
  case "dateRange":
1797
- return /* @__PURE__ */ jsx11(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
1948
+ return /* @__PURE__ */ jsx13(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
1798
1949
  }
1799
1950
  }
1800
1951
  var SchemaForm = forwardRef7(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
1801
1952
  const result = validateSchemaForm(schema);
1802
1953
  if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
1803
1954
  const defaults = schemaInitialValues(schema);
1804
- return /* @__PURE__ */ jsxs6(
1955
+ return /* @__PURE__ */ jsxs8(
1805
1956
  Form,
1806
1957
  {
1807
1958
  ...formProps,
@@ -1819,7 +1970,7 @@ var SchemaForm = forwardRef7(function SchemaForm2({ schema, onSubmit, onChange,
1819
1970
  children: [
1820
1971
  schema.fields.map((field) => {
1821
1972
  const mapped = mapSchemaField(field);
1822
- return /* @__PURE__ */ jsx11(
1973
+ return /* @__PURE__ */ jsx13(
1823
1974
  Form.Item,
1824
1975
  {
1825
1976
  name: mapped.name,
@@ -1832,7 +1983,7 @@ var SchemaForm = forwardRef7(function SchemaForm2({ schema, onSubmit, onChange,
1832
1983
  mapped.name
1833
1984
  );
1834
1985
  }),
1835
- /* @__PURE__ */ jsx11(Form.Item, { children: /* @__PURE__ */ jsx11(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
1986
+ /* @__PURE__ */ jsx13(Form.Item, { children: /* @__PURE__ */ jsx13(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
1836
1987
  ]
1837
1988
  }
1838
1989
  );
@@ -1861,6 +2012,7 @@ export {
1861
2012
  ColorPicker,
1862
2013
  ConfigProvider,
1863
2014
  CrudScaffold,
2015
+ CrudWorkspace,
1864
2016
  DataTable,
1865
2017
  DatePicker,
1866
2018
  Descriptions,
@@ -1907,6 +2059,7 @@ export {
1907
2059
  Steps,
1908
2060
  Switch,
1909
2061
  Table,
2062
+ TableControls,
1910
2063
  TableEmpty,
1911
2064
  Tabs,
1912
2065
  Tag,