@pnkx-lib/ui 1.9.491 → 1.9.493

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { Modal, Spin } from 'antd';
2
+ import { Modal, Spin, Upload as Upload$2 } from 'antd';
3
3
  import * as React from 'react';
4
4
  import React__default, { isValidElement, version as version$1, useRef, useLayoutEffect, useEffect, forwardRef, useImperativeHandle, Component, useContext, useMemo as useMemo$1, useState, Children } from 'react';
5
5
  import { b as useMemo, i as isFragment$1, L as LocaleContext, l as localeValues, c as useLayoutUpdateEffect, d as Context, e as useLayoutEffect$1, _ as _toConsumableArray, t as toArray$2, u as unit, f as clearFix, h as textEllipsis, g as genStyleHooks, m as merge, r as resetComponent, j as defaultPrefixCls, k as genComponentStyleHook, w as warning$1, C as ConfigContext, n as useToken, S as SizeContext, p as devUseWarning, q as getAlphaColor, s as getLineHeight, v as genFocusStyle, x as resetIcon, y as genSubStyleComponent, a as useComponentConfig, D as DisabledContext, o as omit } from './toArray-2LkvUaha.js';
@@ -13,7 +13,6 @@ import { R as RefIcon$7 } from './LoadingOutlined-DCtDXz9K.js';
13
13
  import { R as RefIcon$8, a as RefIcon$a } from './CloseCircleFilled-Bo29sDEQ.js';
14
14
  import { R as RefIcon$9 } from './CloseOutlined-CZUJ_3tW.js';
15
15
  import { C as Controller } from './index.esm-Dr5ZHcf7.js';
16
- import { toast } from '@pnkx-lib/core';
17
16
  import { R as RefIcon$b } from './InboxOutlined-BBuIJe6u.js';
18
17
 
19
18
  // This icon file is generated automatically.
@@ -11478,39 +11477,32 @@ function GenericUploadModal({
11478
11477
  open,
11479
11478
  onCancel,
11480
11479
  control,
11481
- setFileList,
11482
11480
  record,
11483
- // allowedExtensions,
11484
- maxSize = 5,
11485
- texts
11481
+ texts,
11482
+ setFileList,
11483
+ fileList,
11484
+ trans
11486
11485
  }) {
11487
- const [displayFileList, setDisplayFileList] = useState([]);
11486
+ const [displayFileList, setDisplayFileList] = useState(fileList);
11487
+ const [listFileId, setListFileId] = useState([]);
11488
11488
  useEffect(() => {
11489
- if (open) {
11489
+ if (open && displayFileList.length === 0) {
11490
11490
  const recordFiles = record?.map((item) => ({
11491
- uid: item.uid,
11491
+ uid: item?.uid,
11492
11492
  name: item.fileName,
11493
11493
  url: item.filePath,
11494
- listFileId: item.fileManagerId,
11494
+ listFileId: item.fileMangerId,
11495
11495
  status: "done"
11496
11496
  })) ?? [];
11497
11497
  setDisplayFileList(recordFiles);
11498
- setFileList(recordFiles);
11499
11498
  }
11500
- }, [open, record, setFileList]);
11499
+ }, [open, record]);
11501
11500
  const createUploadProps = (onChange) => ({
11502
11501
  multiple: true,
11503
11502
  listType: "text",
11504
11503
  showUploadList: true,
11505
11504
  fileList: displayFileList,
11506
- beforeUpload: async (file) => {
11507
- const isLtMax = file.size / 1024 / 1024 <= maxSize;
11508
- if (!isLtMax) {
11509
- toast.warning(
11510
- texts?.fileSizeError ?? `File must be smaller than ${maxSize}MB`
11511
- );
11512
- return;
11513
- }
11505
+ beforeUpload: (file) => {
11514
11506
  const newFile = {
11515
11507
  uid: file.uid,
11516
11508
  name: file.name,
@@ -11520,13 +11512,12 @@ function GenericUploadModal({
11520
11512
  const newList = [...displayFileList, newFile];
11521
11513
  setDisplayFileList((prev) => {
11522
11514
  const newList2 = [...prev, newFile];
11523
- setFileList(newList2);
11524
11515
  onChange(newList2);
11516
+ setFileList(newList2);
11525
11517
  return newList2;
11526
11518
  });
11527
- setFileList(newList);
11528
11519
  onChange(newList);
11529
- return false;
11520
+ return Upload$2.LIST_IGNORE;
11530
11521
  },
11531
11522
  onPreview: (file) => {
11532
11523
  const fileUrl = file.url || (file.originFileObj ? URL.createObjectURL(file.originFileObj) : "");
@@ -11538,23 +11529,31 @@ function GenericUploadModal({
11538
11529
  link.click();
11539
11530
  document.body.removeChild(link);
11540
11531
  },
11541
- onRemove: (file) => {
11532
+ onRemove: async (file) => {
11533
+ const id = file.listFileId || file.uid;
11534
+ setListFileId((prev) => {
11535
+ const newList2 = [...prev, id];
11536
+ return Array.from(new Set(newList2));
11537
+ });
11542
11538
  const newList = displayFileList.filter((item) => item.uid !== file.uid);
11543
11539
  setDisplayFileList(newList);
11544
- setFileList(newList);
11545
11540
  onChange(newList);
11541
+ setFileList(newList);
11546
11542
  return true;
11547
11543
  }
11548
11544
  });
11545
+ const handleSubmitDeleteFile = async () => {
11546
+ onCancel();
11547
+ };
11549
11548
  return /* @__PURE__ */ jsx(
11550
11549
  Modal,
11551
11550
  {
11552
11551
  open,
11553
- title: texts?.title ?? "Upload Files",
11554
- okText: texts?.okText ?? "Confirm",
11555
- cancelText: texts?.cancelText ?? "Close",
11552
+ title: texts?.title,
11553
+ okText: texts?.okText,
11554
+ cancelText: texts?.cancelText,
11556
11555
  onCancel,
11557
- onOk: onCancel,
11556
+ onOk: handleSubmitDeleteFile,
11558
11557
  width: 800,
11559
11558
  centered: true,
11560
11559
  className: "pnkx-default-upload-modal",
@@ -11566,10 +11565,10 @@ function GenericUploadModal({
11566
11565
  render: ({ field }) => {
11567
11566
  const { onChange } = field;
11568
11567
  const props = createUploadProps(onChange);
11569
- return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading ?? "Uploading...", children: /* @__PURE__ */ jsxs(Dragger, { ...props, accept: ".pdf,.docx,image/*", children: [
11568
+ return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading, children: /* @__PURE__ */ jsxs(Dragger, { ...props, accept: ".pdf,.doc,.docx,.jpg,.jpeg,.png", children: [
11570
11569
  /* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon$b, {}) }),
11571
- /* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText ?? "Click or drag files to this area to upload" }),
11572
- /* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 ?? "Max size 5MB" }),
11570
+ /* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText }),
11571
+ /* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 }),
11573
11572
  /* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint2 })
11574
11573
  ] }) });
11575
11574
  }
package/es/index.js CHANGED
@@ -65,7 +65,7 @@ export { ViewPdf } from './ui/ViewPdf.js';
65
65
  export { Sidebar } from './ui/Sidebar/index.js';
66
66
  export { SelectTable } from './ui/SelectTable.js';
67
67
  export { SelectSingleTable } from './ui/SelectSingleTable.js';
68
- export { G as GenericUploadModal } from './chunks/GenericUploadModal-ncG7n1M5.js';
68
+ export { G as GenericUploadModal } from './chunks/GenericUploadModal-DlXxiQ6N.js';
69
69
  export { Input } from './fields/Input.js';
70
70
  export { PnkxField } from './fields/PnkxField.js';
71
71
  export { Select } from './fields/Select.js';
@@ -1,7 +1,6 @@
1
1
  import 'react/jsx-runtime';
2
2
  import 'antd';
3
- export { G as GenericUploadModal } from '../chunks/GenericUploadModal-ncG7n1M5.js';
3
+ export { G as GenericUploadModal } from '../chunks/GenericUploadModal-DlXxiQ6N.js';
4
4
  import '../chunks/index.esm-Dr5ZHcf7.js';
5
5
  import 'react';
6
- import '@pnkx-lib/core';
7
6
  import '../chunks/InboxOutlined-BBuIJe6u.js';
package/es/ui/index.js CHANGED
@@ -63,8 +63,8 @@ import { r as requireClassnames, c as classNames } from '../chunks/index-BLRvgOF
63
63
  import { F as FastColor, m as blue, n as blueDark, o as cyan, q as cyanDark, s as geekblue, t as geekblueDark, i as generate, v as gold, x as goldDark, y as gray, z as green, A as greenDark, B as grey, C as greyDark, D as lime, E as limeDark, G as magenta, H as magentaDark, J as orange, K as orangeDark, L as presetDarkPalettes, j as presetPalettes, p as presetPrimaryColors, M as purple, N as purpleDark, O as red, P as redDark, Q as volcano, R as volcanoDark, S as yellow, T as yellowDark, c as _slicedToArray, b as _objectSpread2, w as warningOnce, a as _objectWithoutProperties, _ as _extends$1 } from '../chunks/AntdIcon-Bve8mGNz.js';
64
64
  import { b as _defineProperty, _ as _typeof$1 } from '../chunks/defineProperty-CTLrw71t.js';
65
65
  import { z as lintWarning, A as toStyleStr, B as ATTR_CACHE_MAP, E as serialize, F as extract, G as CSS_VAR_PREFIX, H as STYLE_PREFIX, I as extract$1, T as TOKEN_PREFIX, J as extract$2, K as unitlessKeys, M as supportWhere, N as supportLogicProps, O as StyleContext, P as StyleProvider, Q as Theme, R as createCache, U as createTheme, V as getComputedToken, W as token2CSSVar, u as unit$1, X as useCSSVarRegister, Y as useCacheToken, Z as useStyleRegister, $ as genCalc$1, a0 as genStyleUtils$1, m as merge, a1 as statistic, a2 as statisticToken, a3 as MotionProvider, _ as _toConsumableArray, a4 as merge$1, a5 as get$1, a6 as set$1, a7 as isEqual$1, t as toArray$3 } from '../chunks/toArray-2LkvUaha.js';
66
- import { K as Keyframe, C as CSSMotion, a as CSSMotionList, T as Tooltip, P as Popup, _ as _asyncToGenerator, b as _regeneratorRuntime, c as Color, u as useEvent$2, d as useMergedState$1, r as requireReactIs, p as pickAttrs } from '../chunks/GenericUploadModal-ncG7n1M5.js';
67
- export { G as GenericUploadModal } from '../chunks/GenericUploadModal-ncG7n1M5.js';
66
+ import { K as Keyframe, C as CSSMotion, a as CSSMotionList, T as Tooltip, P as Popup, _ as _asyncToGenerator, b as _regeneratorRuntime, c as Color, u as useEvent$2, d as useMergedState$1, r as requireReactIs, p as pickAttrs } from '../chunks/GenericUploadModal-DlXxiQ6N.js';
67
+ export { G as GenericUploadModal } from '../chunks/GenericUploadModal-DlXxiQ6N.js';
68
68
  import { _ as _createClass, a as _classCallCheck, b as _inherits, c as _createSuper, d as _assertThisInitialized, e as _isNativeReflectConstruct, f as _setPrototypeOf, g as _getPrototypeOf } from '../chunks/createSuper-C9_dQ5Zr.js';
69
69
  import ReactDOM__default, { unstable_batchedUpdates, createPortal } from 'react-dom';
70
70
  import { isEmpty, isBoolean } from 'lodash';
@@ -336,6 +336,7 @@ const Table = ({
336
336
  onDoubleClickRow,
337
337
  handleSubmit,
338
338
  customPagination,
339
+ noPagination,
339
340
  ...rest
340
341
  }) => {
341
342
  const status = filters?.status;
@@ -450,7 +451,7 @@ const Table = ({
450
451
  className: "table-scroll-bar"
451
452
  }
452
453
  ),
453
- customPagination || /* @__PURE__ */ jsx(
454
+ customPagination || !noPagination && /* @__PURE__ */ jsx(
454
455
  CustomPagination,
455
456
  {
456
457
  current: filters?.page,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pnkx-lib/ui",
3
3
  "private": false,
4
- "version": "1.9.491",
4
+ "version": "1.9.493",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",
@@ -1,22 +1,19 @@
1
- import { UploadFile } from 'antd';
2
1
  import { Control } from 'react-hook-form';
3
2
  export interface GenericUploadModalProps {
4
3
  open: boolean;
5
4
  onCancel: () => void;
6
5
  control: Control<any>;
7
- setFileList(fileList: UploadFile[]): void;
8
- /** danh sách file từ API để hiển thị */
6
+ fileList: any[];
9
7
  record?: Array<{
10
8
  filePath: string;
9
+ fileMangerId: string;
11
10
  uid: string;
12
11
  fileName: string;
13
- fileManagerId: string;
14
12
  }>;
15
- /** các extension cho phép, vd: ["pdf","docx","png"] */
13
+ setFileList: (value: any) => void;
16
14
  allowedExtensions: string[];
17
- /** dung lượng tối đa (MB) */
18
15
  maxSize?: number;
19
- /** i18n text */
16
+ trans: any;
20
17
  texts?: {
21
18
  title?: string;
22
19
  okText?: string;
@@ -29,4 +26,4 @@ export interface GenericUploadModalProps {
29
26
  uploading?: string;
30
27
  };
31
28
  }
32
- export declare function GenericUploadModal({ open, onCancel, control, setFileList, record, maxSize, texts, }: GenericUploadModalProps): import("react/jsx-runtime").JSX.Element;
29
+ export declare function GenericUploadModal({ open, onCancel, control, record, texts, setFileList, fileList, trans, }: GenericUploadModalProps): import("react/jsx-runtime").JSX.Element;
@@ -31,7 +31,8 @@ export interface TableCommonProps<T> extends Omit<TableProps<T>, "columns"> {
31
31
  size?: SizeType;
32
32
  defaultEllipsis?: boolean;
33
33
  handleSubmit?: FormEventHandler<any>;
34
+ noPagination: boolean;
34
35
  customPagination?: React.ReactNode;
35
36
  }
36
- export declare const Table: <T>({ dataSource, columns, loading, totalItems, filters, onChangePage, onChangePageSize, onSort, rowsSelected, onSelect, onRowClick, rowKey, showIndexColumn, size, defaultEllipsis, onDoubleClickRow, handleSubmit, customPagination, ...rest }: TableCommonProps<T>) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const Table: <T>({ dataSource, columns, loading, totalItems, filters, onChangePage, onChangePageSize, onSort, rowsSelected, onSelect, onRowClick, rowKey, showIndexColumn, size, defaultEllipsis, onDoubleClickRow, handleSubmit, customPagination, noPagination, ...rest }: TableCommonProps<T>) => import("react/jsx-runtime").JSX.Element;
37
38
  export {};