@creekjs/web-components 1.0.1 → 1.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.
- package/.fatherrc.ts +1 -5
- package/.turbo/turbo-father$colon$build.log +5 -0
- package/.turbo/turbo-father$colon$dev.log +33 -0
- package/dist/creek-config-provider/CreekConfigContext.js +31 -2
- package/dist/creek-config-provider/CreekConfigContext.js.map +7 -0
- package/dist/creek-config-provider/index.js +35 -13
- package/dist/creek-config-provider/index.js.map +7 -0
- package/dist/creek-hooks/index.d.ts +1 -0
- package/dist/creek-hooks/index.js +26 -1
- package/dist/creek-hooks/index.js.map +7 -0
- package/dist/creek-hooks/useApp/DrawerHelper.d.ts +9 -0
- package/dist/creek-hooks/useApp/DrawerHelper.js +62 -0
- package/dist/creek-hooks/useApp/DrawerHelper.js.map +7 -0
- package/dist/creek-hooks/useApp/ModalHelper.d.ts +9 -0
- package/dist/creek-hooks/useApp/ModalHelper.js +62 -0
- package/dist/creek-hooks/useApp/ModalHelper.js.map +7 -0
- package/dist/creek-hooks/useApp/index.d.ts +25 -0
- package/dist/creek-hooks/useApp/index.js +118 -0
- package/dist/creek-hooks/useApp/index.js.map +7 -0
- package/dist/creek-hooks/useApp/types.d.ts +26 -0
- package/dist/creek-hooks/useApp/types.js +18 -0
- package/dist/creek-hooks/useApp/types.js.map +7 -0
- package/dist/creek-hooks/useViewportHeight.js +99 -96
- package/dist/creek-hooks/useViewportHeight.js.map +7 -0
- package/dist/creek-icon/index.js +53 -31
- package/dist/creek-icon/index.js.map +7 -0
- package/dist/creek-keep-alive/index.js +36 -18
- package/dist/creek-keep-alive/index.js.map +7 -0
- package/dist/creek-layout/CollapseButton.js +69 -47
- package/dist/creek-layout/CollapseButton.js.map +7 -0
- package/dist/creek-layout/Exception/NotFound.js +42 -13
- package/dist/creek-layout/Exception/NotFound.js.map +7 -0
- package/dist/creek-layout/Exception/NotFoundPage.js +30 -5
- package/dist/creek-layout/Exception/NotFoundPage.js.map +7 -0
- package/dist/creek-layout/Exception/index.js +37 -8
- package/dist/creek-layout/Exception/index.js.map +7 -0
- package/dist/creek-layout/HeaderContent/FullScreen.js +45 -39
- package/dist/creek-layout/HeaderContent/FullScreen.js.map +7 -0
- package/dist/creek-layout/HeaderContent/UserInfo.js +75 -53
- package/dist/creek-layout/HeaderContent/UserInfo.js.map +7 -0
- package/dist/creek-layout/HeaderContent/index.js +48 -32
- package/dist/creek-layout/HeaderContent/index.js.map +7 -0
- package/dist/creek-layout/index.js +117 -80
- package/dist/creek-layout/index.js.map +7 -0
- package/dist/creek-loading/index.js +55 -48
- package/dist/creek-loading/index.js.map +7 -0
- package/dist/creek-table/SearchTable.js +107 -116
- package/dist/creek-table/SearchTable.js.map +7 -0
- package/dist/creek-table/TableOptionRender.js +69 -60
- package/dist/creek-table/TableOptionRender.js.map +7 -0
- package/dist/creek-table/TableViewContent.js +60 -39
- package/dist/creek-table/TableViewContent.js.map +7 -0
- package/dist/creek-table/hooks/index.d.ts +1 -1
- package/dist/creek-table/hooks/index.js +28 -3
- package/dist/creek-table/hooks/index.js.map +7 -0
- package/dist/creek-table/hooks/useAdaptiveToolBar.js +48 -36
- package/dist/creek-table/hooks/useAdaptiveToolBar.js.map +7 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.d.ts +6 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.js +187 -0
- package/dist/creek-table/hooks/useAutoWidthColumns.js.map +7 -0
- package/dist/creek-table/hooks/useElementDistance.js +51 -39
- package/dist/creek-table/hooks/useElementDistance.js.map +7 -0
- package/dist/creek-table/index.js +35 -25
- package/dist/creek-table/index.js.map +7 -0
- package/dist/creek-table/toolBarRender.js +55 -33
- package/dist/creek-table/toolBarRender.js.map +7 -0
- package/dist/creek-table/type.d.ts +1 -1
- package/dist/creek-table/type.js +18 -1
- package/dist/creek-table/type.js.map +7 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +34 -7
- package/dist/index.js.map +7 -0
- package/package.json +2 -2
- package/src/creek-hooks/index.ts +2 -0
- package/src/creek-hooks/useApp/DrawerHelper.tsx +43 -0
- package/src/creek-hooks/useApp/ModalHelper.tsx +43 -0
- package/src/creek-hooks/useApp/index.tsx +119 -0
- package/src/creek-hooks/useApp/types.ts +25 -0
- package/src/creek-hooks/useViewportHeight.tsx +34 -3
- package/src/creek-layout/HeaderContent/index.tsx +1 -4
- package/src/creek-layout/index.tsx +7 -6
- package/src/creek-table/SearchTable.tsx +16 -37
- package/src/creek-table/TableViewContent.tsx +21 -12
- package/src/creek-table/hooks/index.ts +1 -1
- package/src/creek-table/hooks/useAutoWidthColumns.tsx +212 -0
- package/src/creek-table/index.tsx +1 -5
- package/src/creek-table/type.ts +1 -1
- package/src/index.tsx +2 -2
- package/dist/bg-center/index.d.ts +0 -5
- package/dist/bg-center/index.js +0 -28
- package/dist/creek-search/CreekSearch.d.ts +0 -7
- package/dist/creek-search/CreekSearch.js +0 -51
- package/dist/creek-search/CreekSearchContext.d.ts +0 -54
- package/dist/creek-search/CreekSearchContext.js +0 -546
- package/dist/creek-search/CreekSearchFilterDisplay.d.ts +0 -5
- package/dist/creek-search/CreekSearchFilterDisplay.js +0 -97
- package/dist/creek-search/CreekSearchInput.d.ts +0 -4
- package/dist/creek-search/CreekSearchInput.js +0 -96
- package/dist/creek-search/CreekSearchValueSelector.d.ts +0 -5
- package/dist/creek-search/CreekSearchValueSelector.js +0 -422
- package/dist/creek-search/index.d.ts +0 -5
- package/dist/creek-search/index.js +0 -5
- package/dist/creek-search/type.d.ts +0 -8
- package/dist/creek-search/type.js +0 -1
- package/dist/creek-table/hooks/useAutoAddFilterToColumns.d.ts +0 -12
- package/dist/creek-table/hooks/useAutoAddFilterToColumns.js +0 -93
- package/src/bg-center/index.tsx +0 -26
- package/src/creek-search/CreekSearch.tsx +0 -59
- package/src/creek-search/CreekSearchContext.tsx +0 -593
- package/src/creek-search/CreekSearchFilterDisplay.tsx +0 -84
- package/src/creek-search/CreekSearchInput.tsx +0 -75
- package/src/creek-search/CreekSearchValueSelector.tsx +0 -324
- package/src/creek-search/index.tsx +0 -5
- package/src/creek-search/type.ts +0 -9
- package/src/creek-table/hooks/useAutoAddFilterToColumns.tsx +0 -90
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useAutoWidthColumns.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ProColumns } from '@ant-design/pro-components';\nimport { useMemoizedFn } from 'ahooks';\nimport { Space } from 'antd';\nimport { RefObject, useEffect, useMemo, useRef, useState } from 'react';\n\nconst DEFAULT_PADDING_WIDTH = 16;\n\n/**\n * 估算字符串宽度(简单估算:汉字 14px,非汉字 8px,左右 padding 16px)\n */\nconst estimateWidth = (text: string) => {\n let width = 0;\n for (const char of text) {\n if (/[\\u4e00-\\u9fa5]/.test(char)) {\n width += 14;\n } else {\n width += 8;\n }\n }\n return width + DEFAULT_PADDING_WIDTH; // padding\n};\n\n/**\n * 根据 valueType 获取默认宽度\n */\nconst getValueTypeWidth = (valueType: string | undefined): number => {\n switch (valueType) {\n case 'date':\n case 'dateRange':\n return 120;\n case 'dateTime':\n case 'dateTimeRange':\n return 180;\n case 'time':\n case 'timeRange':\n return 100;\n case 'index':\n case 'indexBorder':\n return 60;\n case 'money':\n return 100;\n case 'digit':\n return 100;\n case 'select':\n return 120;\n default:\n return 80; // 默认给 80\n }\n};\n\n/**\n * 一个用于测量的包裹组件\n */\nconst MeasureWrapper = ({ children, onResize }: { children: React.ReactNode; onResize: (width: number) => void }) => {\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!ref.current) return;\n\n // 初次测量\n onResize(ref.current.offsetWidth);\n\n // 监听变化\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n onResize((entry.target as HTMLElement).offsetWidth);\n }\n });\n\n observer.observe(ref.current);\n\n return () => {\n observer.disconnect();\n };\n }, []); // 依赖为空,只在挂载时设置监听\n\n return <Space ref={ref}>{children}</Space>;\n};\n\nexport const useAutoWidthColumns = <T, ValueType>(\n columns: ProColumns<T, ValueType>[] | undefined,\n tableRef: RefObject<HTMLDivElement>,\n): { columns: ProColumns<T, ValueType>[] | undefined; totalWidth: number | undefined } => {\n // 存储每个列的最大宽度:key 是 dataIndex 或 title,value 是最大宽度\n const [columnWidths, setColumnWidths] = useState<Record<string, number>>({});\n const [tableWidth, setTableWidth] = useState<number>(0);\n\n // 监听 table 容器宽度变化\n useEffect(() => {\n if (!tableRef.current) return;\n\n // 立即获取一次宽度\n setTableWidth(tableRef.current.offsetWidth);\n\n // 使用 requestAnimationFrame + setTimeout 防抖\n let rafId: number;\n let timerId: NodeJS.Timeout;\n\n const updateWidth = (width: number) => {\n cancelAnimationFrame(rafId);\n clearTimeout(timerId);\n\n rafId = requestAnimationFrame(() => {\n timerId = setTimeout(() => {\n setTableWidth(width);\n }, 500);\n });\n };\n\n const observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n updateWidth(entry.contentRect.width);\n }\n });\n\n observer.observe(tableRef.current);\n\n // 监听 window resize 作为后备\n const handleWindowResize = () => {\n if (tableRef.current) {\n updateWidth(tableRef.current.offsetWidth);\n }\n };\n window.addEventListener('resize', handleWindowResize);\n\n return () => {\n observer.disconnect();\n window.removeEventListener('resize', handleWindowResize);\n cancelAnimationFrame(rafId);\n clearTimeout(timerId);\n };\n }, [tableRef]);\n\n const handleResize = useMemoizedFn((key: string, width: number) => {\n setColumnWidths((prev) => {\n const currentMax = prev[key] || 0;\n if (width > currentMax) {\n return { ...prev, [key]: width };\n }\n return prev;\n });\n });\n\n const { columns: finalColumns, totalWidth } = useMemo(() => {\n if (!columns) return { columns: undefined, totalWidth: undefined };\n\n // 1. 先计算所有列的理想宽度(不考虑 table 宽度)\n const calculatedColumns = columns.map((col, index) => {\n const colKey = (col.dataIndex as string) || (col.key as string) || `col-${index}`;\n const measuredWidth = columnWidths[colKey];\n let width: number;\n if (col.width) {\n width = typeof col.width === 'number' ? col.width : 100; // 暂时给个默认值如果手动设了 string width\n } else if (col.valueType === 'option' && measuredWidth) {\n width = measuredWidth + DEFAULT_PADDING_WIDTH;\n } else {\n width = Math.max(estimateWidth(col.title as string), getValueTypeWidth(col.valueType as string));\n }\n\n return {\n ...col,\n _calculatedWidth: width,\n _colKey: colKey,\n };\n });\n\n // 2. 计算所有列的总宽度\n const totalCalculatedWidth = calculatedColumns.reduce((acc, col) => acc + col._calculatedWidth, 0);\n\n // 3. 判断是否需要自适应\n // 如果总宽度小于 table 宽度,说明空间足够,除了 option 列,其他列可以不设宽度让 table 自动撑开\n const isOverflow = totalCalculatedWidth > tableWidth;\n\n const processedColumns = calculatedColumns.map((col) => {\n // 提取内部使用的字段\n const { _calculatedWidth, _colKey, ...originalCol } = col;\n\n // 针对 valueType === 'option' (操作列),始终需要特殊处理(包裹测量组件)\n if (col.valueType === 'option') {\n const originalRender = col.render;\n return {\n ...originalCol,\n // 始终设置 option 列宽度\n width: _calculatedWidth,\n fixed: col.fixed ?? 'right',\n render: (dom: any, entity: any, index: any, action: any, schema: any) => {\n const originalRenderResult = originalRender ? (originalRender(dom, entity, index, action, schema) as React.ReactNode) : dom;\n return <MeasureWrapper onResize={(width) => handleResize(_colKey, width)}>{originalRenderResult}</MeasureWrapper>;\n },\n } as ProColumns<T, ValueType>;\n }\n\n // 非 option 列\n return {\n ...originalCol,\n // 只有当内容溢出(需要滚动)或者手动设置了宽度时,才应用计算出的宽度\n // 否则不设置 width,让 Antd Table 自动布局占满剩余空间\n width: isOverflow || col.width ? _calculatedWidth : undefined,\n };\n });\n\n return {\n columns: processedColumns,\n totalWidth: isOverflow ? totalCalculatedWidth : undefined,\n };\n }, [columns, columnWidths, tableWidth]);\n\n return {\n columns: finalColumns,\n totalWidth,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,kBAAsB;AACtB,mBAA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|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,58 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/creek-table/hooks/useElementDistance.tsx
|
|
20
|
+
var useElementDistance_exports = {};
|
|
21
|
+
__export(useElementDistance_exports, {
|
|
22
|
+
useElementDistance: () => useElementDistance
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useElementDistance_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var getElementCenter = (element) => {
|
|
28
|
+
const rect = element.getBoundingClientRect();
|
|
11
29
|
return {
|
|
12
30
|
left: rect.left,
|
|
13
31
|
width: rect.width
|
|
14
32
|
};
|
|
15
33
|
};
|
|
16
|
-
var calculateDistance =
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
x: x
|
|
20
|
-
};
|
|
34
|
+
var calculateDistance = (pos1, pos2) => {
|
|
35
|
+
const x = Math.abs(pos2.left - pos1.left - pos1.width);
|
|
36
|
+
return { x };
|
|
21
37
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var distanceRef = useLatest(distance);
|
|
28
|
-
var _useDebounceFn = useDebounceFn(function () {
|
|
38
|
+
var useElementDistance = (element1Ref, element2Ref) => {
|
|
39
|
+
const [distance, setDistance] = (0, import_react.useState)(null);
|
|
40
|
+
const distanceRef = (0, import_ahooks.useLatest)(distance);
|
|
41
|
+
const { run: calculateAndUpdateDistance } = (0, import_ahooks.useDebounceFn)(
|
|
42
|
+
() => {
|
|
29
43
|
if (!element1Ref.current || !element2Ref.current) {
|
|
30
44
|
if (distanceRef.current !== null) {
|
|
31
45
|
setDistance(null);
|
|
32
46
|
}
|
|
33
47
|
return;
|
|
34
48
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// 只有当距离发生变化时才更新,避免不必要的重渲染
|
|
49
|
+
const pos1 = getElementCenter(element1Ref.current);
|
|
50
|
+
const pos2 = getElementCenter(element2Ref.current);
|
|
51
|
+
const newDistance = calculateDistance(pos1, pos2);
|
|
40
52
|
if (!distanceRef.current || distanceRef.current.x !== newDistance.x) {
|
|
41
53
|
setDistance(newDistance);
|
|
42
54
|
}
|
|
43
|
-
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
44
57
|
wait: 100
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// 初始计算
|
|
49
|
-
useEffect(function () {
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
(0, import_react.useEffect)(() => {
|
|
50
61
|
calculateAndUpdateDistance();
|
|
51
62
|
}, [element1Ref, element2Ref]);
|
|
52
|
-
|
|
53
|
-
// 监听 window 的 resize 和 scroll 事件
|
|
54
|
-
useEventListener('resize', calculateAndUpdateDistance, {
|
|
55
|
-
target: window
|
|
56
|
-
});
|
|
63
|
+
(0, import_ahooks.useEventListener)("resize", calculateAndUpdateDistance, { target: window });
|
|
57
64
|
return distance;
|
|
58
|
-
};
|
|
65
|
+
};
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
useElementDistance
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=useElementDistance.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/creek-table/hooks/useElementDistance.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useDebounceFn, useEventListener, useLatest } from 'ahooks';\nimport { useEffect, useState } from 'react';\n\ntype ElementRef = React.RefObject<HTMLElement>;\n\ninterface Position {\n left: number;\n width: number;\n}\n\ninterface Distance {\n x: number;\n}\n\nconst getElementCenter = (element: HTMLElement): Position => {\n const rect = element.getBoundingClientRect();\n return {\n left: rect.left,\n width: rect.width,\n };\n};\n\nconst calculateDistance = (pos1: Position, pos2: Position): Distance => {\n const x = Math.abs(pos2.left - pos1.left - pos1.width);\n return { x };\n};\n\nexport const useElementDistance = (element1Ref: ElementRef, element2Ref: ElementRef): Distance | null => {\n const [distance, setDistance] = useState<Distance | null>(null);\n const distanceRef = useLatest(distance);\n\n const { run: calculateAndUpdateDistance } = useDebounceFn(\n () => {\n if (!element1Ref.current || !element2Ref.current) {\n if (distanceRef.current !== null) {\n setDistance(null);\n }\n return;\n }\n\n const pos1 = getElementCenter(element1Ref.current);\n const pos2 = getElementCenter(element2Ref.current);\n const newDistance = calculateDistance(pos1, pos2);\n\n // 只有当距离发生变化时才更新,避免不必要的重渲染\n if (!distanceRef.current || distanceRef.current.x !== newDistance.x) {\n setDistance(newDistance);\n }\n },\n {\n wait: 100,\n },\n );\n\n // 初始计算\n useEffect(() => {\n calculateAndUpdateDistance();\n }, [element1Ref, element2Ref]);\n\n // 监听 window 的 resize 和 scroll 事件\n useEventListener('resize', calculateAndUpdateDistance, { target: window });\n\n return distance;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2D;AAC3D,mBAAoC;AAapC,IAAM,mBAAmB,CAAC,YAAmC;AAC3D,QAAM,OAAO,QAAQ,sBAAsB;AAC3C,SAAO;AAAA,IACL,MAAM,KAAK;AAAA,IACX,OAAO,KAAK;AAAA,EACd;AACF;AAEA,IAAM,oBAAoB,CAAC,MAAgB,SAA6B;AACtE,QAAM,IAAI,KAAK,IAAI,KAAK,OAAO,KAAK,OAAO,KAAK,KAAK;AACrD,SAAO,EAAE,EAAE;AACb;AAEO,IAAM,qBAAqB,CAAC,aAAyB,gBAA6C;AACvG,QAAM,CAAC,UAAU,WAAW,QAAI,uBAA0B,IAAI;AAC9D,QAAM,kBAAc,yBAAU,QAAQ;AAEtC,QAAM,EAAE,KAAK,2BAA2B,QAAI;AAAA,IAC1C,MAAM;AACJ,UAAI,CAAC,YAAY,WAAW,CAAC,YAAY,SAAS;AAChD,YAAI,YAAY,YAAY,MAAM;AAChC,sBAAY,IAAI;AAAA,QAClB;AACA;AAAA,MACF;AAEA,YAAM,OAAO,iBAAiB,YAAY,OAAO;AACjD,YAAM,OAAO,iBAAiB,YAAY,OAAO;AACjD,YAAM,cAAc,kBAAkB,MAAM,IAAI;AAGhD,UAAI,CAAC,YAAY,WAAW,YAAY,QAAQ,MAAM,YAAY,GAAG;AACnE,oBAAY,WAAW;AAAA,MACzB;AAAA,IACF;AAAA,IACA;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EACF;AAGA,8BAAU,MAAM;AACd,+BAA2B;AAAA,EAC7B,GAAG,CAAC,aAAa,WAAW,CAAC;AAG7B,sCAAiB,UAAU,4BAA4B,EAAE,QAAQ,OAAO,CAAC;AAEzE,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/creek-table/index.tsx
|
|
20
|
+
var creek_table_exports = {};
|
|
21
|
+
__export(creek_table_exports, {
|
|
22
|
+
CreekTable: () => CreekTable
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(creek_table_exports);
|
|
25
|
+
var import_SearchTable = require("./SearchTable");
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var CreekTable = (props) => {
|
|
28
|
+
const { columns = [], onSubmit, ...restProps } = props;
|
|
29
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SearchTable.SearchProTable, { columns, ...restProps });
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
CreekTable
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import { ParamsType } from '@ant-design/pro-components';\n\nimport { SearchProTable } from './SearchTable';\nimport { CreekTableProps } from './type';\n\nexport const CreekTable = <T extends ParamsType, U extends ParamsType, ValueType = 'text'>(props: CreekTableProps<T, U, ValueType>) => {\n const { columns = [], onSubmit, ...restProps } = props;\n\n return (\n <SearchProTable columns={columns} {...restProps} />\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA+B;AAO1B;AAJE,IAAM,aAAa,CAAiE,UAA4C;AACrI,QAAM,EAAE,UAAU,CAAC,GAAI,UAAU,GAAG,UAAU,IAAI;AAElD,SACG,4CAAC,qCAAe,SAAmB,GAAG,WAAW;AAEtD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/creek-table/toolBarRender.tsx
|
|
20
|
+
var toolBarRender_exports = {};
|
|
21
|
+
__export(toolBarRender_exports, {
|
|
22
|
+
toolBarRender: () => toolBarRender
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(toolBarRender_exports);
|
|
25
|
+
var import_icons = require("@ant-design/icons");
|
|
26
|
+
var import_antd = require("antd");
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var toolBarRender = (options) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const { shouldCollapse, restProps } = options;
|
|
31
|
+
const baseActions = ((_a = restProps.toolBarRender) == null ? void 0 : _a.call(restProps)) || [];
|
|
16
32
|
if (!shouldCollapse || baseActions.length <= 1) {
|
|
17
33
|
return baseActions;
|
|
18
34
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
key: index,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const [first, ...rest] = baseActions;
|
|
36
|
+
return [
|
|
37
|
+
first,
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
import_antd.Dropdown,
|
|
40
|
+
{
|
|
41
|
+
menu: {
|
|
42
|
+
items: rest.map((item, index) => ({ key: index, label: item }))
|
|
43
|
+
},
|
|
44
|
+
trigger: ["click"],
|
|
45
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd.Button, { children: [
|
|
46
|
+
"更多 ",
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DownOutlined, {})
|
|
48
|
+
] })
|
|
49
|
+
},
|
|
50
|
+
"more"
|
|
51
|
+
)
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
toolBarRender
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=toolBarRender.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/toolBarRender.tsx"],
|
|
4
|
+
"sourcesContent": ["import { DownOutlined } from '@ant-design/icons';\nimport { Button, Dropdown } from 'antd';\n\nexport const toolBarRender = (options: { shouldCollapse: boolean; restProps: any }) => {\n const { shouldCollapse, restProps } = options;\n\n const baseActions = restProps.toolBarRender?.() || [];\n if (!shouldCollapse || baseActions.length <= 1) {\n return baseActions;\n }\n\n const [first, ...rest] = baseActions;\n\n return [\n first,\n <Dropdown\n key=\"more\"\n menu={{\n items: rest.map((item: React.ReactDOM, index: number) => ({ key: index, label: item })),\n }}\n trigger={['click']}\n >\n <Button>\n 更多 <DownOutlined />\n </Button>\n </Dropdown>,\n ];\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6B;AAC7B,kBAAiC;AAqB3B;AAnBC,IAAM,gBAAgB,CAAC,YAAyD;AAHvF;AAIE,QAAM,EAAE,gBAAgB,UAAU,IAAI;AAEtC,QAAM,gBAAc,eAAU,kBAAV,uCAA+B,CAAC;AACpD,MAAI,CAAC,kBAAkB,YAAY,UAAU,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QAEC,MAAM;AAAA,UACJ,OAAO,KAAK,IAAI,CAAC,MAAsB,WAAmB,EAAE,KAAK,OAAO,OAAO,KAAK,EAAE;AAAA,QACxF;AAAA,QACA,SAAS,CAAC,OAAO;AAAA,QAEjB,uDAAC,sBAAO;AAAA;AAAA,UACH,4CAAC,6BAAa;AAAA,WACnB;AAAA;AAAA,MARI;AAAA,IASN;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ export type OptionRenderCustom = {
|
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
onClick?: () => void;
|
|
7
7
|
};
|
|
8
|
-
export type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, '
|
|
8
|
+
export type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, 'options'> & {
|
|
9
9
|
pageFixedBottom?: boolean;
|
|
10
10
|
pageFixedBottomConfig?: {
|
|
11
11
|
/** 底部保留空间(如固定在底部的元素高度),默认 0 */
|
package/dist/creek-table/type.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/creek-table/type.ts
|
|
16
|
+
var type_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(type_exports);
|
|
18
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/creek-table/type.ts"],
|
|
4
|
+
"sourcesContent": ["import { ParamsType, ProTableProps } from '@ant-design/pro-components';\n\nexport type OptionRenderCustom = {\n text?: string;\n icon?: React.ReactNode;\n onClick?: () => void;\n};\n\nexport type CreekTableProps<T extends ParamsType, U extends ParamsType, ValueType = 'text'> = Omit<ProTableProps<T, U, ValueType>, 'options'> & {\n pageFixedBottom?: boolean; // 是否固定分页在底部\n pageFixedBottomConfig?: {\n /** 底部保留空间(如固定在底部的元素高度),默认 0 */\n bottomFix?: number;\n };\n options?: ProTableProps<T, U, ValueType>['options'] & {\n importConfig?: OptionRenderCustom;\n exportConfig?: OptionRenderCustom;\n };\n // 是否自动为列添加筛选功能,默认 true\n autoAddFilterForColumn?: boolean;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './bg-center';
|
|
2
1
|
export * from './creek-config-provider';
|
|
2
|
+
export * from './creek-hooks';
|
|
3
3
|
export * from './creek-icon';
|
|
4
4
|
export * from './creek-layout';
|
|
5
5
|
export * from './creek-loading';
|
|
6
|
-
export * from './creek-search';
|
|
7
6
|
export * from './creek-table';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.tsx
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./creek-config-provider"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./creek-hooks"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./creek-icon"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./creek-layout"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./creek-loading"), module.exports);
|
|
24
|
+
__reExport(src_exports, require("./creek-table"), module.exports);
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
...require("./creek-config-provider"),
|
|
28
|
+
...require("./creek-hooks"),
|
|
29
|
+
...require("./creek-icon"),
|
|
30
|
+
...require("./creek-layout"),
|
|
31
|
+
...require("./creek-loading"),
|
|
32
|
+
...require("./creek-table")
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["\nexport * from './creek-config-provider';\nexport * from './creek-hooks';\nexport * from './creek-icon';\nexport * from './creek-layout';\nexport * from './creek-loading';\nexport * from './creek-table';\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AACA,wBAAc,oCADd;AAEA,wBAAc,0BAFd;AAGA,wBAAc,yBAHd;AAIA,wBAAc,2BAJd;AAKA,wBAAc,4BALd;AAMA,wBAAc,0BANd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creekjs/web-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"father:build": "father build",
|
|
8
|
-
"father:dev": "father dev"
|
|
8
|
+
"father:dev": "father dev --no-clean"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [],
|
|
11
11
|
"author": "",
|
package/src/creek-hooks/index.ts
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DrawerForm } from '@ant-design/pro-components';
|
|
2
|
+
import { Drawer } from 'antd';
|
|
3
|
+
import { omit } from 'lodash';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { DrawerConfig, FormDrawerConfig, NormalDrawerConfig } from './types';
|
|
6
|
+
|
|
7
|
+
interface DrawerHelperProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
config: DrawerConfig;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DrawerHelper: React.FC<DrawerHelperProps> = ({ open, config, onClose }) => {
|
|
14
|
+
const { content, type, ...restConfig } = config;
|
|
15
|
+
|
|
16
|
+
if (type === 'form') {
|
|
17
|
+
return (
|
|
18
|
+
<DrawerForm
|
|
19
|
+
open={open}
|
|
20
|
+
onOpenChange={(visible) => !visible && onClose()}
|
|
21
|
+
drawerProps={{
|
|
22
|
+
destroyOnClose: true,
|
|
23
|
+
onClose,
|
|
24
|
+
...((config as FormDrawerConfig).drawerProps || {}),
|
|
25
|
+
}}
|
|
26
|
+
{...(omit(restConfig, 'drawerProps') as any)}
|
|
27
|
+
>
|
|
28
|
+
{content}
|
|
29
|
+
</DrawerForm>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Drawer
|
|
35
|
+
open={open}
|
|
36
|
+
onClose={onClose}
|
|
37
|
+
destroyOnClose
|
|
38
|
+
{...(restConfig as NormalDrawerConfig)}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</Drawer>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ModalForm } from '@ant-design/pro-components';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { omit } from 'lodash';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { FormModalConfig, ModalConfig, NormalModalConfig } from './types';
|
|
6
|
+
|
|
7
|
+
interface ModalHelperProps {
|
|
8
|
+
open: boolean;
|
|
9
|
+
config: ModalConfig;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ModalHelper: React.FC<ModalHelperProps> = ({ open, config, onClose }) => {
|
|
14
|
+
const { content, type, ...restConfig } = config;
|
|
15
|
+
|
|
16
|
+
if (type === 'form') {
|
|
17
|
+
return (
|
|
18
|
+
<ModalForm
|
|
19
|
+
open={open}
|
|
20
|
+
onOpenChange={(visible) => !visible && onClose()}
|
|
21
|
+
modalProps={{
|
|
22
|
+
destroyOnClose: true,
|
|
23
|
+
onCancel: onClose,
|
|
24
|
+
...((config as FormModalConfig).modalProps || {}),
|
|
25
|
+
}}
|
|
26
|
+
{...(omit(restConfig, 'modalProps') as any)}
|
|
27
|
+
>
|
|
28
|
+
{content}
|
|
29
|
+
</ModalForm>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Modal
|
|
35
|
+
open={open}
|
|
36
|
+
onCancel={onClose}
|
|
37
|
+
destroyOnClose
|
|
38
|
+
{...(restConfig as NormalModalConfig)}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</Modal>
|
|
42
|
+
);
|
|
43
|
+
};
|