@hanwenbo/x-web-pro-components 0.0.2 → 0.0.3

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.
@@ -460,9 +460,12 @@ var renderSchemaColumns = function renderSchemaColumns(columns, form, currentVal
460
460
  var labelNode = titleNode !== null && titleNode !== void 0 ? titleNode : key;
461
461
  var searchSafeFormItemProps = _objectSpread({}, formItemProps);
462
462
  delete searchSafeFormItemProps.initialValue;
463
- var mergedFormItemProps = _objectSpread(_objectSpread({
463
+ var mergedFormItemProps = _objectSpread(_objectSpread(_objectSpread({
464
464
  name: fullName,
465
- label: labelNode,
465
+ label: labelNode
466
+ }, valueType === 'switch' ? {
467
+ valuePropName: 'checked'
468
+ } : {}), {}, {
466
469
  initialValue: getConvertedInitialValue(columnItem, fullName, getSchemaColumnInitialValue(columnItem, layoutType, searchInitialValueSnapshot, fullName)),
467
470
  tooltip: columnItem.tooltip
468
471
  }, isQueryForm ? searchSafeFormItemProps : formItemProps), {}, {
@@ -28,6 +28,8 @@ import { Checkbox } from '@hanwenbo/x-web-ui/checkbox';
28
28
  import { Dropdown } from '@hanwenbo/x-web-ui/dropdown';
29
29
  import { Form, useForm } from '@hanwenbo/x-web-ui/form';
30
30
  import { Pagination } from '@hanwenbo/x-web-ui/pagination';
31
+ import { Select } from '@hanwenbo/x-web-ui/select';
32
+ import { useLocale, zhCN } from '@hanwenbo/x-web-ui/i18n';
31
33
  import { Table } from '@hanwenbo/x-web-ui/table';
32
34
  import { Tooltip } from '@hanwenbo/x-web-ui/tooltip';
33
35
  import { cn } from '@hanwenbo/x-web-ui/utils/cn';
@@ -307,6 +309,9 @@ var BaseProTable = function BaseProTable(_ref3) {
307
309
  var _useForm = useForm(),
308
310
  _useForm2 = _slicedToArray(_useForm, 1),
309
311
  searchForm = _useForm2[0];
312
+ var _useLocale = useLocale(),
313
+ t = _useLocale.t;
314
+ var itemsPerPageLabel = t('common.itemsPerPage') !== 'common.itemsPerPage' ? t('common.itemsPerPage') : String(zhCN['common.itemsPerPage']);
310
315
  var _useState = useState(false),
311
316
  _useState2 = _slicedToArray(_useState, 2),
312
317
  requestLoading = _useState2[0],
@@ -691,7 +696,7 @@ var BaseProTable = function BaseProTable(_ref3) {
691
696
  setColumnVisibility(columnKey, checked);
692
697
  },
693
698
  children: /*#__PURE__*/_jsx("span", {
694
- className: "truncate text-sm text-foreground",
699
+ className: "text-foreground truncate text-sm",
695
700
  children: columnTitle
696
701
  })
697
702
  }), /*#__PURE__*/_jsx("div", {
@@ -1243,7 +1248,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1243
1248
  children: /*#__PURE__*/_jsxs("div", {
1244
1249
  className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
1245
1250
  children: [/*#__PURE__*/_jsxs("div", {
1246
- className: "flex items-center gap-2 text-sm text-foreground",
1251
+ className: "text-foreground flex items-center gap-2 text-sm",
1247
1252
  children: [/*#__PURE__*/_jsx("span", {
1248
1253
  className: "text-primary",
1249
1254
  children: /*#__PURE__*/_jsxs("svg", {
@@ -1296,7 +1301,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1296
1301
  }
1297
1302
  return /*#__PURE__*/_jsx(Card, {
1298
1303
  variant: "default",
1299
- className: "overflow-visible rounded-xl border-0 bg-card shadow-none",
1304
+ className: "bg-card overflow-visible rounded-xl border-0 shadow-none",
1300
1305
  bodyClassName: "px-4 py-4",
1301
1306
  children: searchNode
1302
1307
  });
@@ -1369,25 +1374,20 @@ var BaseProTable = function BaseProTable(_ref3) {
1369
1374
  return /*#__PURE__*/_jsxs("div", {
1370
1375
  className: cn(PRO_TABLE_STACK_CLASS, 'w-full sm:flex-row sm:items-center sm:justify-between'),
1371
1376
  children: [/*#__PURE__*/_jsxs("div", {
1372
- className: "flex flex-wrap items-center text-sm text-muted-foreground [gap:var(--x-space-4)]",
1373
- children: [normalizedPaginationConfig.showTotal ? normalizedPaginationConfig.showTotal(total, range) : null, normalizedPaginationConfig.showSizeChanger ? /*#__PURE__*/_jsxs("label", {
1374
- className: "flex items-center gap-2",
1375
- children: [/*#__PURE__*/_jsx("span", {
1376
- className: "text-xs uppercase tracking-wide text-muted-foreground",
1377
- children: "Page Size"
1378
- }), /*#__PURE__*/_jsx("select", {
1379
- className: "h-9 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition-colors focus:border-primary",
1380
- value: pageInfo.pageSize,
1381
- onChange: function onChange(event) {
1382
- void handleExternalPaginationChange(1, Number(event.target.value));
1383
- },
1384
- children: (normalizedPaginationConfig.pageSizeOptions || [10, 20, 50, 100]).map(function (option) {
1385
- return /*#__PURE__*/_jsxs("option", {
1386
- value: option,
1387
- children: [option, " / page"]
1388
- }, option);
1389
- })
1390
- })]
1377
+ className: "text-muted-foreground flex flex-wrap items-center [gap:var(--x-space-4)] text-sm",
1378
+ children: [normalizedPaginationConfig.showTotal ? normalizedPaginationConfig.showTotal(total, range) : null, normalizedPaginationConfig.showSizeChanger ? /*#__PURE__*/_jsx(Select, {
1379
+ "aria-label": itemsPerPageLabel,
1380
+ size: resolvedPaginationSize,
1381
+ value: pageInfo.pageSize,
1382
+ options: (normalizedPaginationConfig.pageSizeOptions || [10, 20, 50, 100]).map(function (option) {
1383
+ return {
1384
+ value: option,
1385
+ label: "".concat(option, " ").concat(itemsPerPageLabel)
1386
+ };
1387
+ }),
1388
+ onChange: function onChange(value) {
1389
+ void handleExternalPaginationChange(1, Number(value));
1390
+ }
1391
1391
  }) : null]
1392
1392
  }), shouldRenderPager ? /*#__PURE__*/_jsx(Pagination, {
1393
1393
  current: pageInfo.current,
@@ -1400,7 +1400,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1400
1400
  }
1401
1401
  }) : null]
1402
1402
  });
1403
- }, [dataSource.length, handleExternalPaginationChange, normalizedPaginationConfig, pageInfo.current, pageInfo.pageSize, pageInfo.total, resolvedPaginationSize, showExternalBottomPagination, tableSize]);
1403
+ }, [itemsPerPageLabel, dataSource.length, handleExternalPaginationChange, normalizedPaginationConfig, pageInfo.current, pageInfo.pageSize, pageInfo.total, resolvedPaginationSize, showExternalBottomPagination, tableSize]);
1404
1404
  var defaultTableNode = /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({}, tableProps), {}, {
1405
1405
  className: cn(tableClassName),
1406
1406
  style: tableStyle,
@@ -1526,7 +1526,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1526
1526
  cardStyle = _ref10.style,
1527
1527
  restCardProps = _objectWithoutProperties(_ref10, _excluded2);
1528
1528
  var tableCardNode = /*#__PURE__*/_jsxs(Card, _objectSpread(_objectSpread({}, restCardProps), {}, {
1529
- className: cn('overflow-visible rounded-xl border-0 bg-card shadow-none', fullscreen && 'fixed inset-4 z-40 overflow-auto bg-background p-2 shadow-2xl', className, cardClassName),
1529
+ className: cn('bg-card overflow-visible rounded-xl border-0 shadow-none', fullscreen && 'bg-background fixed inset-4 z-40 overflow-auto p-2 shadow-2xl', className, cardClassName),
1530
1530
  style: cardStyle,
1531
1531
  children: [searchFormConnectionNode, tableContent]
1532
1532
  }));
@@ -467,9 +467,12 @@ var renderSchemaColumns = function renderSchemaColumns(columns, form, currentVal
467
467
  var labelNode = titleNode !== null && titleNode !== void 0 ? titleNode : key;
468
468
  var searchSafeFormItemProps = _objectSpread({}, formItemProps);
469
469
  delete searchSafeFormItemProps.initialValue;
470
- var mergedFormItemProps = _objectSpread(_objectSpread({
470
+ var mergedFormItemProps = _objectSpread(_objectSpread(_objectSpread({
471
471
  name: fullName,
472
- label: labelNode,
472
+ label: labelNode
473
+ }, valueType === 'switch' ? {
474
+ valuePropName: 'checked'
475
+ } : {}), {}, {
473
476
  initialValue: getConvertedInitialValue(columnItem, fullName, getSchemaColumnInitialValue(columnItem, layoutType, searchInitialValueSnapshot, fullName)),
474
477
  tooltip: columnItem.tooltip
475
478
  }, isQueryForm ? searchSafeFormItemProps : formItemProps), {}, {
@@ -155,6 +155,8 @@ var _checkbox = require("@hanwenbo/x-web-ui/checkbox");
155
155
  var _dropdown = require("@hanwenbo/x-web-ui/dropdown");
156
156
  var _form = require("@hanwenbo/x-web-ui/form");
157
157
  var _pagination = require("@hanwenbo/x-web-ui/pagination");
158
+ var _select = require("@hanwenbo/x-web-ui/select");
159
+ var _i18n = require("@hanwenbo/x-web-ui/i18n");
158
160
  var _table = require("@hanwenbo/x-web-ui/table");
159
161
  var _tooltip = require("@hanwenbo/x-web-ui/tooltip");
160
162
  var _cn = require("@hanwenbo/x-web-ui/utils/cn");
@@ -452,6 +454,9 @@ var BaseProTable = function BaseProTable(_ref3) {
452
454
  var _useForm = (0, _form.useForm)(),
453
455
  _useForm2 = _slicedToArray(_useForm, 1),
454
456
  searchForm = _useForm2[0];
457
+ var _useLocale = (0, _i18n.useLocale)(),
458
+ t = _useLocale.t;
459
+ var itemsPerPageLabel = t('common.itemsPerPage') !== 'common.itemsPerPage' ? t('common.itemsPerPage') : String(_i18n.zhCN['common.itemsPerPage']);
455
460
  var _useState = (0, _react.useState)(false),
456
461
  _useState2 = _slicedToArray(_useState, 2),
457
462
  requestLoading = _useState2[0],
@@ -836,7 +841,7 @@ var BaseProTable = function BaseProTable(_ref3) {
836
841
  setColumnVisibility(columnKey, checked);
837
842
  },
838
843
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
839
- className: "truncate text-sm text-foreground",
844
+ className: "text-foreground truncate text-sm",
840
845
  children: columnTitle
841
846
  })
842
847
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -1388,7 +1393,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1388
1393
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1389
1394
  className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
1390
1395
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1391
- className: "flex items-center gap-2 text-sm text-foreground",
1396
+ className: "text-foreground flex items-center gap-2 text-sm",
1392
1397
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1393
1398
  className: "text-primary",
1394
1399
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
@@ -1441,7 +1446,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1441
1446
  }
1442
1447
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_card.Card, {
1443
1448
  variant: "default",
1444
- className: "overflow-visible rounded-xl border-0 bg-card shadow-none",
1449
+ className: "bg-card overflow-visible rounded-xl border-0 shadow-none",
1445
1450
  bodyClassName: "px-4 py-4",
1446
1451
  children: searchNode
1447
1452
  });
@@ -1514,25 +1519,20 @@ var BaseProTable = function BaseProTable(_ref3) {
1514
1519
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1515
1520
  className: (0, _cn.cn)(PRO_TABLE_STACK_CLASS, 'w-full sm:flex-row sm:items-center sm:justify-between'),
1516
1521
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1517
- className: "flex flex-wrap items-center text-sm text-muted-foreground [gap:var(--x-space-4)]",
1518
- children: [normalizedPaginationConfig.showTotal ? normalizedPaginationConfig.showTotal(total, range) : null, normalizedPaginationConfig.showSizeChanger ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
1519
- className: "flex items-center gap-2",
1520
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1521
- className: "text-xs uppercase tracking-wide text-muted-foreground",
1522
- children: "Page Size"
1523
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("select", {
1524
- className: "h-9 rounded-lg border border-border bg-background px-3 text-sm text-foreground outline-none transition-colors focus:border-primary",
1525
- value: pageInfo.pageSize,
1526
- onChange: function onChange(event) {
1527
- void handleExternalPaginationChange(1, Number(event.target.value));
1528
- },
1529
- children: (normalizedPaginationConfig.pageSizeOptions || [10, 20, 50, 100]).map(function (option) {
1530
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("option", {
1531
- value: option,
1532
- children: [option, " / page"]
1533
- }, option);
1534
- })
1535
- })]
1522
+ className: "text-muted-foreground flex flex-wrap items-center [gap:var(--x-space-4)] text-sm",
1523
+ children: [normalizedPaginationConfig.showTotal ? normalizedPaginationConfig.showTotal(total, range) : null, normalizedPaginationConfig.showSizeChanger ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_select.Select, {
1524
+ "aria-label": itemsPerPageLabel,
1525
+ size: resolvedPaginationSize,
1526
+ value: pageInfo.pageSize,
1527
+ options: (normalizedPaginationConfig.pageSizeOptions || [10, 20, 50, 100]).map(function (option) {
1528
+ return {
1529
+ value: option,
1530
+ label: "".concat(option, " ").concat(itemsPerPageLabel)
1531
+ };
1532
+ }),
1533
+ onChange: function onChange(value) {
1534
+ void handleExternalPaginationChange(1, Number(value));
1535
+ }
1536
1536
  }) : null]
1537
1537
  }), shouldRenderPager ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_pagination.Pagination, {
1538
1538
  current: pageInfo.current,
@@ -1545,7 +1545,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1545
1545
  }
1546
1546
  }) : null]
1547
1547
  });
1548
- }, [dataSource.length, handleExternalPaginationChange, normalizedPaginationConfig, pageInfo.current, pageInfo.pageSize, pageInfo.total, resolvedPaginationSize, showExternalBottomPagination, tableSize]);
1548
+ }, [itemsPerPageLabel, dataSource.length, handleExternalPaginationChange, normalizedPaginationConfig, pageInfo.current, pageInfo.pageSize, pageInfo.total, resolvedPaginationSize, showExternalBottomPagination, tableSize]);
1549
1549
  var defaultTableNode = /*#__PURE__*/(0, _jsxRuntime.jsx)(_table.Table, _objectSpread(_objectSpread({}, tableProps), {}, {
1550
1550
  className: (0, _cn.cn)(tableClassName),
1551
1551
  style: tableStyle,
@@ -1671,7 +1671,7 @@ var BaseProTable = function BaseProTable(_ref3) {
1671
1671
  cardStyle = _ref10.style,
1672
1672
  restCardProps = _objectWithoutProperties(_ref10, _excluded2);
1673
1673
  var tableCardNode = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_card.Card, _objectSpread(_objectSpread({}, restCardProps), {}, {
1674
- className: (0, _cn.cn)('overflow-visible rounded-xl border-0 bg-card shadow-none', fullscreen && 'fixed inset-4 z-40 overflow-auto bg-background p-2 shadow-2xl', className, cardClassName),
1674
+ className: (0, _cn.cn)('bg-card overflow-visible rounded-xl border-0 shadow-none', fullscreen && 'bg-background fixed inset-4 z-40 overflow-auto p-2 shadow-2xl', className, cardClassName),
1675
1675
  style: cardStyle,
1676
1676
  children: [searchFormConnectionNode, tableContent]
1677
1677
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanwenbo/x-web-pro-components",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Enterprise-ready pro components built on x-web-ui",
5
5
  "author": "9476400@qq.com",
6
6
  "license": "MIT",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "dayjs": "^1.11.3",
46
46
  "lucide-react": "^0.460.0",
47
- "@hanwenbo/x-web-ui": "0.0.2"
47
+ "@hanwenbo/x-web-ui": "0.0.3"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": ">=18.0.0",