ele-admin-plus 1.2.1-beta.2 → 1.2.1-beta.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/es/ele-admin-layout/index.d.ts +26 -30
- package/es/ele-admin-layout/props.d.ts +11 -10
- package/es/ele-alert/index.d.ts +14 -14
- package/es/ele-alert/props.d.ts +9 -8
- package/es/ele-app/components/message-body.d.ts +5 -4
- package/es/ele-app/components/message-box-icon.d.ts +7 -6
- package/es/ele-app/style/overwrite/input/index.scss +2 -0
- package/es/ele-avatar-group/index.d.ts +15 -14
- package/es/ele-avatar-group/props.d.ts +10 -7
- package/es/ele-basic-select/index.d.ts +17 -14
- package/es/ele-basic-select/index.js +14 -7
- package/es/ele-basic-select/props.d.ts +11 -6
- package/es/ele-basic-select/props.js +3 -1
- package/es/ele-basic-select/util.d.ts +6 -0
- package/es/ele-basic-select/util.js +13 -0
- package/es/ele-bottom-bar/index.d.ts +4 -4
- package/es/ele-bottom-bar/props.d.ts +3 -2
- package/es/ele-breadcrumb/index.d.ts +3 -3
- package/es/ele-breadcrumb/props.d.ts +1 -1
- package/es/ele-card/index.d.ts +14 -14
- package/es/ele-card/props.d.ts +8 -6
- package/es/ele-check-card/components/card-item.d.ts +3 -2
- package/es/ele-check-card/index.d.ts +4 -4
- package/es/ele-check-card/index.js +8 -3
- package/es/ele-check-card/props.d.ts +3 -2
- package/es/ele-config-provider/index.d.ts +4 -4
- package/es/ele-config-provider/props.d.ts +3 -3
- package/es/ele-config-provider/types.d.ts +1 -0
- package/es/ele-copyable/index.d.ts +10 -10
- package/es/ele-copyable/props.d.ts +7 -5
- package/es/ele-count-up/index.d.ts +1 -1
- package/es/ele-cropper/components/cropper-tools.d.ts +4 -3
- package/es/ele-cropper/index.d.ts +3 -3
- package/es/ele-cropper/props.d.ts +2 -1
- package/es/ele-cropper-modal/index.d.ts +4 -4
- package/es/ele-cropper-modal/props.d.ts +1 -4
- package/es/ele-data-table/index.d.ts +22 -22
- package/es/ele-data-table/props.d.ts +16 -16
- package/es/ele-data-table/style/index.scss +1 -1
- package/es/ele-data-table/types.d.ts +2 -0
- package/es/ele-data-table/util.js +5 -1
- package/es/ele-drawer/index.d.ts +14 -14
- package/es/ele-drawer/props.d.ts +11 -10
- package/es/ele-dropdown/index.d.ts +22 -22
- package/es/ele-dropdown/index.js +45 -39
- package/es/ele-dropdown/props.d.ts +13 -12
- package/es/ele-dropdown/types.d.ts +2 -0
- package/es/ele-edit-tag/index.d.ts +21 -19
- package/es/ele-edit-tag/index.js +10 -2
- package/es/ele-edit-tag/props.d.ts +13 -8
- package/es/ele-edit-tag/props.js +3 -1
- package/es/ele-ellipsis/index.d.ts +5 -4
- package/es/ele-ellipsis/props.d.ts +1 -1
- package/es/ele-file-list/index.d.ts +4 -4
- package/es/ele-icon-select/components/icon-grid.d.ts +8 -6
- package/es/ele-icon-select/index.d.ts +37 -36
- package/es/ele-icon-select/index.js +6 -2
- package/es/ele-icon-select/props.d.ts +18 -14
- package/es/ele-icon-select/props.js +2 -0
- package/es/ele-loading/index.d.ts +4 -4
- package/es/ele-loading/props.d.ts +3 -2
- package/es/ele-map-picker/components/map-view.d.ts +26 -28
- package/es/ele-map-picker/components/map-view.js +1 -0
- package/es/ele-map-picker/index.d.ts +10 -10
- package/es/ele-map-picker/props.d.ts +6 -5
- package/es/ele-map-picker/style/index.scss +1 -1
- package/es/ele-menus/index.d.ts +2 -2
- package/es/ele-menus/props.d.ts +1 -1
- package/es/ele-menus/style/index.scss +4 -0
- package/es/ele-modal/index.d.ts +24 -23
- package/es/ele-modal/index.js +30 -64
- package/es/ele-modal/props.d.ts +14 -13
- package/es/ele-modal/util.d.ts +31 -24
- package/es/ele-modal/util.js +235 -132
- package/es/ele-pagination/index.d.ts +18 -6
- package/es/ele-pagination/index.js +3 -2
- package/es/ele-pagination/props.d.ts +8 -2
- package/es/ele-pagination/style/index.scss +70 -0
- package/es/ele-popconfirm/index.d.ts +32 -32
- package/es/ele-popconfirm/props.d.ts +19 -17
- package/es/ele-popover/index.d.ts +22 -22
- package/es/ele-popover/props.d.ts +11 -10
- package/es/ele-printer/index.d.ts +8 -8
- package/es/ele-printer/props.d.ts +6 -5
- package/es/ele-printer/util.d.ts +5 -5
- package/es/ele-printer/util.js +68 -43
- package/es/ele-pro-layout/index.d.ts +43 -47
- package/es/ele-pro-layout/props.d.ts +16 -14
- package/es/ele-pro-table/components/table-tools.d.ts +402 -32
- package/es/ele-pro-table/components/table-tools.js +223 -140
- package/es/ele-pro-table/components/tool-column-list.d.ts +12 -0
- package/es/ele-pro-table/components/tool-column-list.js +33 -6
- package/es/ele-pro-table/components/tool-column.d.ts +8 -7
- package/es/ele-pro-table/components/tool-column.js +11 -5
- package/es/ele-pro-table/components/tool-export.d.ts +33 -30
- package/es/ele-pro-table/components/tool-export.js +204 -184
- package/es/ele-pro-table/components/tool-print-body-cell.d.ts +5 -4
- package/es/ele-pro-table/components/tool-print-header-cell.d.ts +5 -4
- package/es/ele-pro-table/components/tool-print.d.ts +41 -40
- package/es/ele-pro-table/components/tool-print.js +357 -336
- package/es/ele-pro-table/index.d.ts +1006 -70
- package/es/ele-pro-table/index.js +63 -13
- package/es/ele-pro-table/props.d.ts +17 -18
- package/es/ele-pro-table/props.js +3 -1
- package/es/ele-pro-table/style/index.scss +43 -12
- package/es/ele-pro-table/types.d.ts +54 -0
- package/es/ele-pro-table/util.d.ts +51 -9
- package/es/ele-pro-table/util.js +89 -28
- package/es/ele-qr-code/components/canvas-render.d.ts +67 -0
- package/es/ele-qr-code/components/canvas-render.js +147 -0
- package/es/ele-qr-code/index.d.ts +5 -9
- package/es/ele-qr-code/index.js +33 -136
- package/es/ele-qr-code/props.d.ts +5 -2
- package/es/ele-qr-code/props.js +3 -1
- package/es/ele-qr-code/types.d.ts +5 -0
- package/es/ele-qr-code-svg/index.d.ts +6 -5
- package/es/ele-qr-code-svg/index.js +11 -14
- package/es/ele-segmented/index.js +3 -0
- package/es/ele-split-panel/index.d.ts +7 -7
- package/es/ele-split-panel/props.d.ts +4 -3
- package/es/ele-steps/index.d.ts +2 -2
- package/es/ele-steps/props.d.ts +2 -2
- package/es/ele-table/index.d.ts +2 -2
- package/es/ele-table/props.d.ts +2 -1
- package/es/ele-table-select/index.d.ts +22 -20
- package/es/ele-table-select/index.js +5 -2
- package/es/ele-table-select/props.d.ts +11 -7
- package/es/ele-table-select/props.js +2 -0
- package/es/ele-tabs/index.d.ts +19 -34
- package/es/ele-tabs/index.js +133 -86
- package/es/ele-tabs/props.d.ts +10 -24
- package/es/ele-tabs/props.js +3 -1
- package/es/ele-tabs/style/index.scss +42 -2
- package/es/ele-tabs/types.d.ts +2 -11
- package/es/ele-text/index.d.ts +2 -2
- package/es/ele-text/props.d.ts +2 -1
- package/es/ele-tool/index.d.ts +5 -2
- package/es/ele-tool/index.js +2 -5
- package/es/ele-tool/props.d.ts +4 -1
- package/es/ele-tool/props.js +3 -1
- package/es/ele-tool/style/index.scss +13 -0
- package/es/ele-toolbar/index.d.ts +17 -17
- package/es/ele-toolbar/props.d.ts +4 -3
- package/es/ele-tooltip/index.d.ts +13 -12
- package/es/ele-tooltip/props.d.ts +7 -6
- package/es/ele-tour/index.d.ts +1 -1
- package/es/ele-tree-select/index.d.ts +18 -18
- package/es/ele-tree-select/index.js +5 -2
- package/es/ele-tree-select/props.d.ts +12 -8
- package/es/ele-tree-select/props.js +3 -1
- package/es/ele-upload-list/index.d.ts +7 -9
- package/es/ele-upload-list/props.d.ts +4 -3
- package/es/ele-upload-list/style/index.scss +4 -0
- package/es/ele-virtual-table/components/body-cell.d.ts +11 -27
- package/es/ele-virtual-table/components/body-row.d.ts +13 -29
- package/es/ele-virtual-table/components/cell-checkbox.d.ts +3 -2
- package/es/ele-virtual-table/components/cell-filter.d.ts +6 -6
- package/es/ele-virtual-table/components/footer-row.d.ts +3 -3
- package/es/ele-virtual-table/components/header-cell.d.ts +7 -7
- package/es/ele-virtual-table/components/header-row.d.ts +7 -7
- package/es/ele-virtual-table/index.d.ts +20 -21
- package/es/ele-virtual-table/props.d.ts +11 -11
- package/es/ele-watermark/index.d.ts +5 -4
- package/es/ele-watermark/props.d.ts +2 -1
- package/es/ele-xg-player/index.d.ts +3 -3
- package/es/icons/SizeCompactOutlined.d.ts +2 -0
- package/es/icons/SizeCompactOutlined.js +34 -0
- package/es/icons/SizeSlackOutlined.d.ts +2 -0
- package/es/icons/SizeSlackOutlined.js +34 -0
- package/es/icons/index.d.ts +2 -0
- package/es/icons/index.js +46 -42
- package/es/lang/en_US.js +1 -0
- package/es/lang/zh_CN.js +1 -0
- package/es/lang/zh_TW.js +1 -0
- package/es/style/themes/default.scss +12 -5
- package/es/style/themes/rounded.scss +3 -2
- package/es/utils/hook.d.ts +75 -4
- package/es/utils/hook.js +155 -6
- package/lib/ele-admin-layout/index.d.ts +26 -30
- package/lib/ele-admin-layout/props.d.ts +11 -10
- package/lib/ele-alert/index.d.ts +14 -14
- package/lib/ele-alert/props.d.ts +9 -8
- package/lib/ele-app/components/message-body.d.ts +5 -4
- package/lib/ele-app/components/message-box-icon.d.ts +7 -6
- package/lib/ele-app/style/overwrite/input/index.scss +2 -0
- package/lib/ele-avatar-group/index.d.ts +15 -14
- package/lib/ele-avatar-group/props.d.ts +10 -7
- package/lib/ele-basic-select/index.cjs +14 -7
- package/lib/ele-basic-select/index.d.ts +17 -14
- package/lib/ele-basic-select/props.cjs +3 -1
- package/lib/ele-basic-select/props.d.ts +11 -6
- package/lib/ele-basic-select/util.cjs +13 -0
- package/lib/ele-basic-select/util.d.ts +6 -0
- package/lib/ele-bottom-bar/index.d.ts +4 -4
- package/lib/ele-bottom-bar/props.d.ts +3 -2
- package/lib/ele-breadcrumb/index.d.ts +3 -3
- package/lib/ele-breadcrumb/props.d.ts +1 -1
- package/lib/ele-card/index.d.ts +14 -14
- package/lib/ele-card/props.d.ts +8 -6
- package/lib/ele-check-card/components/card-item.d.ts +3 -2
- package/lib/ele-check-card/index.cjs +8 -3
- package/lib/ele-check-card/index.d.ts +4 -4
- package/lib/ele-check-card/props.d.ts +3 -2
- package/lib/ele-config-provider/index.d.ts +4 -4
- package/lib/ele-config-provider/props.d.ts +3 -3
- package/lib/ele-config-provider/types.d.ts +1 -0
- package/lib/ele-copyable/index.d.ts +10 -10
- package/lib/ele-copyable/props.d.ts +7 -5
- package/lib/ele-count-up/index.d.ts +1 -1
- package/lib/ele-cropper/components/cropper-tools.d.ts +4 -3
- package/lib/ele-cropper/index.d.ts +3 -3
- package/lib/ele-cropper/props.d.ts +2 -1
- package/lib/ele-cropper-modal/index.d.ts +4 -4
- package/lib/ele-cropper-modal/props.d.ts +1 -4
- package/lib/ele-data-table/index.d.ts +22 -22
- package/lib/ele-data-table/props.d.ts +16 -16
- package/lib/ele-data-table/style/index.scss +1 -1
- package/lib/ele-data-table/types.d.ts +2 -0
- package/lib/ele-data-table/util.cjs +5 -1
- package/lib/ele-drawer/index.d.ts +14 -14
- package/lib/ele-drawer/props.d.ts +11 -10
- package/lib/ele-dropdown/index.cjs +45 -39
- package/lib/ele-dropdown/index.d.ts +22 -22
- package/lib/ele-dropdown/props.d.ts +13 -12
- package/lib/ele-dropdown/types.d.ts +2 -0
- package/lib/ele-edit-tag/index.cjs +10 -2
- package/lib/ele-edit-tag/index.d.ts +21 -19
- package/lib/ele-edit-tag/props.cjs +3 -1
- package/lib/ele-edit-tag/props.d.ts +13 -8
- package/lib/ele-ellipsis/index.d.ts +5 -4
- package/lib/ele-ellipsis/props.d.ts +1 -1
- package/lib/ele-file-list/index.d.ts +4 -4
- package/lib/ele-icon-select/components/icon-grid.d.ts +8 -6
- package/lib/ele-icon-select/index.cjs +9 -5
- package/lib/ele-icon-select/index.d.ts +37 -36
- package/lib/ele-icon-select/props.cjs +2 -0
- package/lib/ele-icon-select/props.d.ts +18 -14
- package/lib/ele-loading/index.d.ts +4 -4
- package/lib/ele-loading/props.d.ts +3 -2
- package/lib/ele-map-picker/components/map-view.cjs +1 -0
- package/lib/ele-map-picker/components/map-view.d.ts +26 -28
- package/lib/ele-map-picker/index.d.ts +10 -10
- package/lib/ele-map-picker/props.d.ts +6 -5
- package/lib/ele-map-picker/style/index.scss +1 -1
- package/lib/ele-menus/index.d.ts +2 -2
- package/lib/ele-menus/props.d.ts +1 -1
- package/lib/ele-menus/style/index.scss +4 -0
- package/lib/ele-modal/index.cjs +28 -62
- package/lib/ele-modal/index.d.ts +24 -23
- package/lib/ele-modal/props.d.ts +14 -13
- package/lib/ele-modal/util.cjs +235 -132
- package/lib/ele-modal/util.d.ts +31 -24
- package/lib/ele-pagination/index.cjs +3 -2
- package/lib/ele-pagination/index.d.ts +18 -6
- package/lib/ele-pagination/props.d.ts +8 -2
- package/lib/ele-pagination/style/index.scss +70 -0
- package/lib/ele-popconfirm/index.d.ts +32 -32
- package/lib/ele-popconfirm/props.d.ts +19 -17
- package/lib/ele-popover/index.d.ts +22 -22
- package/lib/ele-popover/props.d.ts +11 -10
- package/lib/ele-printer/index.d.ts +8 -8
- package/lib/ele-printer/props.d.ts +6 -5
- package/lib/ele-printer/util.cjs +68 -43
- package/lib/ele-printer/util.d.ts +5 -5
- package/lib/ele-pro-layout/index.d.ts +43 -47
- package/lib/ele-pro-layout/props.d.ts +16 -14
- package/lib/ele-pro-table/components/table-tools.cjs +221 -138
- package/lib/ele-pro-table/components/table-tools.d.ts +402 -32
- package/lib/ele-pro-table/components/tool-column-list.cjs +32 -5
- package/lib/ele-pro-table/components/tool-column-list.d.ts +12 -0
- package/lib/ele-pro-table/components/tool-column.cjs +10 -4
- package/lib/ele-pro-table/components/tool-column.d.ts +8 -7
- package/lib/ele-pro-table/components/tool-export.cjs +201 -181
- package/lib/ele-pro-table/components/tool-export.d.ts +33 -30
- package/lib/ele-pro-table/components/tool-print-body-cell.d.ts +5 -4
- package/lib/ele-pro-table/components/tool-print-header-cell.d.ts +5 -4
- package/lib/ele-pro-table/components/tool-print.cjs +354 -333
- package/lib/ele-pro-table/components/tool-print.d.ts +41 -40
- package/lib/ele-pro-table/index.cjs +60 -10
- package/lib/ele-pro-table/index.d.ts +1006 -70
- package/lib/ele-pro-table/props.cjs +3 -1
- package/lib/ele-pro-table/props.d.ts +17 -18
- package/lib/ele-pro-table/style/index.scss +43 -12
- package/lib/ele-pro-table/types.d.ts +54 -0
- package/lib/ele-pro-table/util.cjs +89 -28
- package/lib/ele-pro-table/util.d.ts +51 -9
- package/lib/ele-qr-code/components/canvas-render.cjs +146 -0
- package/lib/ele-qr-code/components/canvas-render.d.ts +67 -0
- package/lib/ele-qr-code/index.cjs +32 -135
- package/lib/ele-qr-code/index.d.ts +5 -9
- package/lib/ele-qr-code/props.cjs +3 -1
- package/lib/ele-qr-code/props.d.ts +5 -2
- package/lib/ele-qr-code/types.d.ts +5 -0
- package/lib/ele-qr-code-svg/index.cjs +10 -13
- package/lib/ele-qr-code-svg/index.d.ts +6 -5
- package/lib/ele-segmented/index.cjs +3 -0
- package/lib/ele-split-panel/index.d.ts +7 -7
- package/lib/ele-split-panel/props.d.ts +4 -3
- package/lib/ele-steps/index.d.ts +2 -2
- package/lib/ele-steps/props.d.ts +2 -2
- package/lib/ele-table/index.d.ts +2 -2
- package/lib/ele-table/props.d.ts +2 -1
- package/lib/ele-table-select/index.cjs +20 -17
- package/lib/ele-table-select/index.d.ts +22 -20
- package/lib/ele-table-select/props.cjs +2 -0
- package/lib/ele-table-select/props.d.ts +11 -7
- package/lib/ele-tabs/index.cjs +132 -85
- package/lib/ele-tabs/index.d.ts +19 -34
- package/lib/ele-tabs/props.cjs +3 -1
- package/lib/ele-tabs/props.d.ts +10 -24
- package/lib/ele-tabs/style/index.scss +42 -2
- package/lib/ele-tabs/types.d.ts +2 -11
- package/lib/ele-text/index.d.ts +2 -2
- package/lib/ele-text/props.d.ts +2 -1
- package/lib/ele-tool/index.cjs +2 -5
- package/lib/ele-tool/index.d.ts +5 -2
- package/lib/ele-tool/props.cjs +3 -1
- package/lib/ele-tool/props.d.ts +4 -1
- package/lib/ele-tool/style/index.scss +13 -0
- package/lib/ele-toolbar/index.d.ts +17 -17
- package/lib/ele-toolbar/props.d.ts +4 -3
- package/lib/ele-tooltip/index.d.ts +13 -12
- package/lib/ele-tooltip/props.d.ts +7 -6
- package/lib/ele-tour/index.d.ts +1 -1
- package/lib/ele-tree-select/index.cjs +4 -1
- package/lib/ele-tree-select/index.d.ts +18 -18
- package/lib/ele-tree-select/props.cjs +3 -1
- package/lib/ele-tree-select/props.d.ts +12 -8
- package/lib/ele-upload-list/index.d.ts +7 -9
- package/lib/ele-upload-list/props.d.ts +4 -3
- package/lib/ele-upload-list/style/index.scss +4 -0
- package/lib/ele-virtual-table/components/body-cell.d.ts +11 -27
- package/lib/ele-virtual-table/components/body-row.d.ts +13 -29
- package/lib/ele-virtual-table/components/cell-checkbox.d.ts +3 -2
- package/lib/ele-virtual-table/components/cell-filter.d.ts +6 -6
- package/lib/ele-virtual-table/components/footer-row.d.ts +3 -3
- package/lib/ele-virtual-table/components/header-cell.d.ts +7 -7
- package/lib/ele-virtual-table/components/header-row.d.ts +7 -7
- package/lib/ele-virtual-table/index.d.ts +20 -21
- package/lib/ele-virtual-table/props.d.ts +11 -11
- package/lib/ele-watermark/index.d.ts +5 -4
- package/lib/ele-watermark/props.d.ts +2 -1
- package/lib/ele-xg-player/index.d.ts +3 -3
- package/lib/icons/SizeCompactOutlined.cjs +33 -0
- package/lib/icons/SizeCompactOutlined.d.ts +2 -0
- package/lib/icons/SizeSlackOutlined.cjs +33 -0
- package/lib/icons/SizeSlackOutlined.d.ts +2 -0
- package/lib/icons/index.cjs +4 -0
- package/lib/icons/index.d.ts +2 -0
- package/lib/lang/en_US.cjs +1 -0
- package/lib/lang/zh_CN.cjs +1 -0
- package/lib/lang/zh_TW.cjs +1 -0
- package/lib/style/themes/default.scss +12 -5
- package/lib/style/themes/rounded.scss +3 -2
- package/lib/utils/hook.cjs +154 -5
- package/lib/utils/hook.d.ts +75 -4
- package/package.json +14 -13
package/es/ele-pro-table/util.js
CHANGED
|
@@ -22,7 +22,7 @@ function getPaginationProps(size, pagination, globalPagination, pageProps) {
|
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
const defaultProps = {
|
|
25
|
-
|
|
25
|
+
size: size !== "large" ? "small" : "default",
|
|
26
26
|
pagerCount: 5,
|
|
27
27
|
layout: "total, prev, pager, next, sizes, jumper",
|
|
28
28
|
pageSizes: [10, 20, 30, 40, 50, 100],
|
|
@@ -223,36 +223,40 @@ function getColId(column) {
|
|
|
223
223
|
}
|
|
224
224
|
return column.columnKey;
|
|
225
225
|
}
|
|
226
|
-
function getInitColumns(columns) {
|
|
226
|
+
function getInitColumns(columns, cacheColsWidth) {
|
|
227
227
|
const data = [];
|
|
228
228
|
columns.forEach((d) => {
|
|
229
229
|
var _a;
|
|
230
230
|
if (!d.hideInTable) {
|
|
231
|
+
const width = getCacheColWidth(cacheColsWidth, d) ?? d.width;
|
|
231
232
|
if ((_a = d.children) == null ? void 0 : _a.length) {
|
|
232
233
|
const children = getInitColumns(d.children);
|
|
233
234
|
if (children.length) {
|
|
234
|
-
data.push({ ...d, children });
|
|
235
|
+
data.push({ ...d, width, children });
|
|
235
236
|
}
|
|
236
237
|
} else {
|
|
237
|
-
data.push({ ...d });
|
|
238
|
+
data.push({ ...d, width });
|
|
238
239
|
}
|
|
239
240
|
}
|
|
240
241
|
});
|
|
241
242
|
return data;
|
|
242
243
|
}
|
|
243
244
|
function getInitCacheColumns(columns, cacheKey, sortable) {
|
|
244
|
-
const cacheCols = getCacheCols(cacheKey);
|
|
245
|
+
const cacheCols = getCacheCols(getColsCacheKey(cacheKey));
|
|
245
246
|
if (!cacheCols) {
|
|
246
|
-
return getInitColumns(columns);
|
|
247
|
+
return getInitColumns(columns, getCacheColsWidth(cacheKey));
|
|
247
248
|
}
|
|
248
249
|
return getCheckedColumns(
|
|
249
250
|
columns,
|
|
250
251
|
cacheCols,
|
|
251
252
|
sortable,
|
|
252
|
-
(item) => item.hideInSetting
|
|
253
|
+
(item) => item.hideInSetting,
|
|
254
|
+
void 0,
|
|
255
|
+
false,
|
|
256
|
+
getCacheColsWidth(cacheKey)
|
|
253
257
|
);
|
|
254
258
|
}
|
|
255
|
-
function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserveUnchecked) {
|
|
259
|
+
function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserveUnchecked, cacheColsWidth) {
|
|
256
260
|
const data = [];
|
|
257
261
|
if (!columns || !columns.length) {
|
|
258
262
|
return data;
|
|
@@ -263,10 +267,11 @@ function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserve
|
|
|
263
267
|
return;
|
|
264
268
|
}
|
|
265
269
|
const temp = colId == null ? null : findTree(cols, (t) => t.uid === colId);
|
|
266
|
-
const
|
|
267
|
-
if (!reserveUnchecked &&
|
|
270
|
+
const hideInTable = temp ? !temp.checked : d.hideInTable;
|
|
271
|
+
if (!reserveUnchecked && hideInTable) {
|
|
268
272
|
return;
|
|
269
273
|
}
|
|
274
|
+
const width = getCacheColWidth(cacheColsWidth, d) ?? d.width;
|
|
270
275
|
const fixed = (temp == null ? void 0 : temp.fixed) ?? d.fixed;
|
|
271
276
|
const uid = uuid(8);
|
|
272
277
|
if (d.children && d.children.length) {
|
|
@@ -276,14 +281,15 @@ function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserve
|
|
|
276
281
|
sortable,
|
|
277
282
|
isHideInCol,
|
|
278
283
|
filter,
|
|
279
|
-
reserveUnchecked
|
|
284
|
+
reserveUnchecked,
|
|
285
|
+
cacheColsWidth
|
|
280
286
|
);
|
|
281
287
|
if (children.length) {
|
|
282
|
-
data.push({ ...d, fixed, hideInTable
|
|
288
|
+
data.push({ ...d, width, fixed, hideInTable, children, uid });
|
|
283
289
|
}
|
|
284
290
|
return;
|
|
285
291
|
}
|
|
286
|
-
data.push({ ...d, fixed, hideInTable
|
|
292
|
+
data.push({ ...d, width, fixed, hideInTable, uid });
|
|
287
293
|
});
|
|
288
294
|
if (!sortable || !data.length) {
|
|
289
295
|
return data;
|
|
@@ -303,7 +309,7 @@ function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserve
|
|
|
303
309
|
}
|
|
304
310
|
i++;
|
|
305
311
|
});
|
|
306
|
-
if (ai == null && isHideInCol(a) && a.fixed === "right") {
|
|
312
|
+
if (ai == null && (isHideInCol == null ? void 0 : isHideInCol(a)) && a.fixed === "right") {
|
|
307
313
|
ai = i;
|
|
308
314
|
}
|
|
309
315
|
if (ai == null) {
|
|
@@ -311,10 +317,10 @@ function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserve
|
|
|
311
317
|
}
|
|
312
318
|
if (a.fixed === true || a.fixed === "left") {
|
|
313
319
|
ai -= i;
|
|
314
|
-
} else if (a.fixed === "right" || isHideInCol(a) && !a.fixed) {
|
|
320
|
+
} else if (a.fixed === "right" || (isHideInCol == null ? void 0 : isHideInCol(a)) && !a.fixed) {
|
|
315
321
|
ai += i;
|
|
316
322
|
}
|
|
317
|
-
if (bi == null && isHideInCol(b) && b.fixed === "right") {
|
|
323
|
+
if (bi == null && (isHideInCol == null ? void 0 : isHideInCol(b)) && b.fixed === "right") {
|
|
318
324
|
bi = i;
|
|
319
325
|
}
|
|
320
326
|
if (bi == null) {
|
|
@@ -322,14 +328,14 @@ function getCheckedColumns(columns, cols, sortable, isHideInCol, filter, reserve
|
|
|
322
328
|
}
|
|
323
329
|
if (b.fixed === true || b.fixed === "left") {
|
|
324
330
|
bi -= i;
|
|
325
|
-
} else if (b.fixed === "right" || isHideInCol(b) && !b.fixed) {
|
|
331
|
+
} else if (b.fixed === "right" || (isHideInCol == null ? void 0 : isHideInCol(b)) && !b.fixed) {
|
|
326
332
|
bi += i;
|
|
327
333
|
}
|
|
328
334
|
return ai - bi;
|
|
329
335
|
});
|
|
330
336
|
return data;
|
|
331
337
|
}
|
|
332
|
-
function getColItems(columns, locale, filter, cacheCols, sortFixed, cancelFixed) {
|
|
338
|
+
function getColItems(columns, locale, filter, cacheCols, sortFixed, cancelFixed, cacheColsWidth) {
|
|
333
339
|
const temp = columns == null ? [] : [...columns];
|
|
334
340
|
if (sortFixed) {
|
|
335
341
|
temp.sort(
|
|
@@ -347,7 +353,8 @@ function getColItems(columns, locale, filter, cacheCols, sortFixed, cancelFixed)
|
|
|
347
353
|
type: d.type,
|
|
348
354
|
label: d.label || (d.type === "index" ? locale.columnIndex : d.type === "expand" ? locale.columnExpand : locale.columnUntitled),
|
|
349
355
|
checked: (old == null ? void 0 : old.checked) ?? !d.hideInTable,
|
|
350
|
-
fixed: cancelFixed || parent != null ? false : (old == null ? void 0 : old.fixed) ?? d.fixed
|
|
356
|
+
fixed: cancelFixed || parent != null ? false : (old == null ? void 0 : old.fixed) ?? d.fixed,
|
|
357
|
+
width: getCacheColWidth(cacheColsWidth, d) ?? d.width
|
|
351
358
|
};
|
|
352
359
|
return item;
|
|
353
360
|
});
|
|
@@ -394,9 +401,18 @@ function getColItems(columns, locale, filter, cacheCols, sortFixed, cancelFixed)
|
|
|
394
401
|
indeterminate: !checkAll && indeterminate
|
|
395
402
|
};
|
|
396
403
|
}
|
|
404
|
+
function getSizeCacheKey(cacheKey) {
|
|
405
|
+
return `${cacheKey}Size`;
|
|
406
|
+
}
|
|
407
|
+
function getColsCacheKey(cacheKey) {
|
|
408
|
+
return cacheKey ? `${cacheKey}Cols` : void 0;
|
|
409
|
+
}
|
|
410
|
+
function getColsWidthCacheKey(cacheKey) {
|
|
411
|
+
return `${cacheKey}ColsWidth`;
|
|
412
|
+
}
|
|
397
413
|
function getCacheCols(cacheKey) {
|
|
398
414
|
if (cacheKey) {
|
|
399
|
-
const oldJSON = localStorage.getItem(
|
|
415
|
+
const oldJSON = localStorage.getItem(cacheKey);
|
|
400
416
|
if (oldJSON) {
|
|
401
417
|
try {
|
|
402
418
|
const old = JSON.parse(oldJSON);
|
|
@@ -407,12 +423,6 @@ function getCacheCols(cacheKey) {
|
|
|
407
423
|
}
|
|
408
424
|
}
|
|
409
425
|
}
|
|
410
|
-
function getColsCacheKey(cacheKey) {
|
|
411
|
-
return `${cacheKey}Cols`;
|
|
412
|
-
}
|
|
413
|
-
function getSizeCacheKey(cacheKey) {
|
|
414
|
-
return `${cacheKey}Size`;
|
|
415
|
-
}
|
|
416
426
|
function getCacheSize(cacheKey) {
|
|
417
427
|
if (cacheKey) {
|
|
418
428
|
const size = localStorage.getItem(getSizeCacheKey(cacheKey));
|
|
@@ -421,6 +431,52 @@ function getCacheSize(cacheKey) {
|
|
|
421
431
|
}
|
|
422
432
|
}
|
|
423
433
|
}
|
|
434
|
+
function getCacheColsWidth(cacheKey) {
|
|
435
|
+
if (cacheKey) {
|
|
436
|
+
const oldJSON = localStorage.getItem(getColsWidthCacheKey(cacheKey));
|
|
437
|
+
if (oldJSON) {
|
|
438
|
+
try {
|
|
439
|
+
const old = JSON.parse(oldJSON);
|
|
440
|
+
return old && Array.isArray(old) ? old : void 0;
|
|
441
|
+
} catch (e) {
|
|
442
|
+
console.error(e);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
function getCacheColWidth(cacheColsWidth, column) {
|
|
448
|
+
if (cacheColsWidth == null || column == null) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const colId = getColId(column);
|
|
452
|
+
const c = findTree(cacheColsWidth, (d) => d.uid === colId);
|
|
453
|
+
if (!c || c.width == null) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (c.width === "" || typeof c.width === "string" && !c.width.trim()) {
|
|
457
|
+
return "";
|
|
458
|
+
}
|
|
459
|
+
const width = Number(c.width);
|
|
460
|
+
return isNaN(width) ? c.width : width;
|
|
461
|
+
}
|
|
462
|
+
function cacheColWidth(width, column, cacheKey) {
|
|
463
|
+
if (cacheKey && column) {
|
|
464
|
+
const colId = getColId(column);
|
|
465
|
+
if (colId) {
|
|
466
|
+
const colsWidth = getCacheColsWidth(cacheKey) || [];
|
|
467
|
+
const old = colsWidth.find((d) => d.uid === colId);
|
|
468
|
+
if (!old) {
|
|
469
|
+
colsWidth.push({ uid: colId, width });
|
|
470
|
+
} else {
|
|
471
|
+
old.width = width;
|
|
472
|
+
}
|
|
473
|
+
localStorage.setItem(
|
|
474
|
+
getColsWidthCacheKey(cacheKey),
|
|
475
|
+
JSON.stringify(colsWidth)
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
424
480
|
function getRowKey(rowKey) {
|
|
425
481
|
if (rowKey != null) {
|
|
426
482
|
return rowKey;
|
|
@@ -436,7 +492,7 @@ function getCellText(column, row, index, pageIndex) {
|
|
|
436
492
|
if (column.type === "index") {
|
|
437
493
|
return getIndexValue(index, column.index, pageIndex);
|
|
438
494
|
}
|
|
439
|
-
const propValue = getValue(row, column.prop);
|
|
495
|
+
const propValue = column.prop == null ? void 0 : getValue(row, column.prop);
|
|
440
496
|
if (typeof column.formatter === "function") {
|
|
441
497
|
return column.formatter(row, column, propValue, index);
|
|
442
498
|
}
|
|
@@ -625,7 +681,8 @@ function exportCSV(fileName, headerData, bodyData, footerData) {
|
|
|
625
681
|
const csvRows = [];
|
|
626
682
|
[...headerData, ...bodyData, ...footerData].forEach((item) => {
|
|
627
683
|
const cells = item.map((d) => {
|
|
628
|
-
const
|
|
684
|
+
const str = d.text ?? "";
|
|
685
|
+
const text = typeof str === "string" ? str.replace(/,/g, ",").replace(/\n/g, " ") : str;
|
|
629
686
|
if (!d.isTreeCell || !d.indent) {
|
|
630
687
|
return text;
|
|
631
688
|
}
|
|
@@ -662,17 +719,21 @@ function columnsSettingFilter(item) {
|
|
|
662
719
|
return !item.type || !["selection", "index", "expand"].includes(item.type);
|
|
663
720
|
}
|
|
664
721
|
export {
|
|
722
|
+
cacheColWidth,
|
|
665
723
|
columnsExportFilter,
|
|
666
724
|
columnsPrintFilter,
|
|
667
725
|
columnsSettingFilter,
|
|
668
726
|
exportCSV,
|
|
727
|
+
getCacheColWidth,
|
|
669
728
|
getCacheCols,
|
|
729
|
+
getCacheColsWidth,
|
|
670
730
|
getCacheSize,
|
|
671
731
|
getCellText,
|
|
672
732
|
getCheckedColumns,
|
|
673
733
|
getColId,
|
|
674
734
|
getColItems,
|
|
675
735
|
getColsCacheKey,
|
|
736
|
+
getColsWidthCacheKey,
|
|
676
737
|
getDefaultFilter,
|
|
677
738
|
getExportBodyNode,
|
|
678
739
|
getExportData,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{
|
|
2
|
+
value: StringConstructor;
|
|
3
|
+
size: {
|
|
4
|
+
type: NumberConstructor;
|
|
5
|
+
default: number;
|
|
6
|
+
};
|
|
7
|
+
level: {
|
|
8
|
+
type: import('vue').PropType<import('../types').Level>;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
bgColor: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
fgColor: {
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
19
|
+
margin: {
|
|
20
|
+
type: NumberConstructor;
|
|
21
|
+
default: number;
|
|
22
|
+
};
|
|
23
|
+
imageSettings: import('vue').PropType<import('../types').ImageSettings>;
|
|
24
|
+
customStyle: import('vue').PropType<import('../../ele-app/types').StyleValue>;
|
|
25
|
+
tag: import('vue').PropType<import('../types').QrCodeTag>;
|
|
26
|
+
}, {
|
|
27
|
+
imgData: import('vue').Ref<string>;
|
|
28
|
+
canvasRef: import('vue').Ref<HTMLCanvasElement | null>;
|
|
29
|
+
imageRef: import('vue').Ref<HTMLImageElement | null>;
|
|
30
|
+
render: () => void;
|
|
31
|
+
}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
32
|
+
done: () => boolean;
|
|
33
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
34
|
+
value: StringConstructor;
|
|
35
|
+
size: {
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
default: number;
|
|
38
|
+
};
|
|
39
|
+
level: {
|
|
40
|
+
type: import('vue').PropType<import('../types').Level>;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
bgColor: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
fgColor: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
margin: {
|
|
52
|
+
type: NumberConstructor;
|
|
53
|
+
default: number;
|
|
54
|
+
};
|
|
55
|
+
imageSettings: import('vue').PropType<import('../types').ImageSettings>;
|
|
56
|
+
customStyle: import('vue').PropType<import('../../ele-app/types').StyleValue>;
|
|
57
|
+
tag: import('vue').PropType<import('../types').QrCodeTag>;
|
|
58
|
+
}>> & {
|
|
59
|
+
onDone?: (() => any) | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
margin: number;
|
|
62
|
+
size: number;
|
|
63
|
+
level: import('../types').Level;
|
|
64
|
+
bgColor: string;
|
|
65
|
+
fgColor: string;
|
|
66
|
+
}, {}>;
|
|
67
|
+
export default _default;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { defineComponent, ref, watch, onMounted, openBlock, createElementBlock, normalizeStyle, createCommentVNode, createElementVNode } from "vue";
|
|
2
|
+
import qrcodegen from "../qrcodegen";
|
|
3
|
+
import { qrCodeProps, qrCodeEmits } from "../props";
|
|
4
|
+
import { ERROR_LEVEL_MAP, getImageSettings, excavateModules, SUPPORTS_PATH2D, generatePath } from "../util";
|
|
5
|
+
const _sfc_main = defineComponent({
|
|
6
|
+
name: "CanvasRender",
|
|
7
|
+
props: qrCodeProps,
|
|
8
|
+
emits: qrCodeEmits,
|
|
9
|
+
setup(props, { emit }) {
|
|
10
|
+
const imgData = ref("");
|
|
11
|
+
const canvasRef = ref(null);
|
|
12
|
+
const imageRef = ref(null);
|
|
13
|
+
const render = () => {
|
|
14
|
+
const { value, size, level, bgColor, fgColor, margin, imageSettings } = props;
|
|
15
|
+
const canvas = canvasRef.value;
|
|
16
|
+
if (!canvas) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const ctx = canvas.getContext("2d");
|
|
20
|
+
if (!ctx) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!value) {
|
|
24
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let cells = qrcodegen.QrCode.encodeText(
|
|
28
|
+
value,
|
|
29
|
+
ERROR_LEVEL_MAP[level]
|
|
30
|
+
).getModules();
|
|
31
|
+
const numCells = cells.length + margin * 2;
|
|
32
|
+
const calculatedImageSettings = getImageSettings(
|
|
33
|
+
imageSettings,
|
|
34
|
+
size,
|
|
35
|
+
margin,
|
|
36
|
+
cells
|
|
37
|
+
);
|
|
38
|
+
const image = imageRef.value;
|
|
39
|
+
const haveImageToRender = calculatedImageSettings != null && image != null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
40
|
+
if (haveImageToRender && calculatedImageSettings.excavation != null) {
|
|
41
|
+
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
42
|
+
}
|
|
43
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
44
|
+
canvas.height = canvas.width = size * pixelRatio;
|
|
45
|
+
const scale = size / numCells * pixelRatio;
|
|
46
|
+
ctx.scale(scale, scale);
|
|
47
|
+
ctx.fillStyle = bgColor;
|
|
48
|
+
ctx.fillRect(0, 0, numCells, numCells);
|
|
49
|
+
ctx.fillStyle = fgColor;
|
|
50
|
+
if (SUPPORTS_PATH2D) {
|
|
51
|
+
ctx.fill(new Path2D(generatePath(cells, margin)));
|
|
52
|
+
} else {
|
|
53
|
+
cells.forEach(function(row, rdx) {
|
|
54
|
+
row.forEach(function(cell, cdx) {
|
|
55
|
+
if (cell) {
|
|
56
|
+
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (haveImageToRender) {
|
|
62
|
+
ctx.drawImage(
|
|
63
|
+
image,
|
|
64
|
+
calculatedImageSettings.x + margin,
|
|
65
|
+
calculatedImageSettings.y + margin,
|
|
66
|
+
calculatedImageSettings.w,
|
|
67
|
+
calculatedImageSettings.h
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (props.tag === "img") {
|
|
71
|
+
imgData.value = canvas.toDataURL();
|
|
72
|
+
}
|
|
73
|
+
emit("done");
|
|
74
|
+
};
|
|
75
|
+
watch(
|
|
76
|
+
[
|
|
77
|
+
() => props.value,
|
|
78
|
+
() => props.size,
|
|
79
|
+
() => props.level,
|
|
80
|
+
() => props.margin,
|
|
81
|
+
() => props.bgColor,
|
|
82
|
+
() => props.fgColor,
|
|
83
|
+
() => props.tag
|
|
84
|
+
],
|
|
85
|
+
() => {
|
|
86
|
+
render();
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
watch(
|
|
90
|
+
() => props.imageSettings,
|
|
91
|
+
() => {
|
|
92
|
+
render();
|
|
93
|
+
},
|
|
94
|
+
{ deep: true }
|
|
95
|
+
);
|
|
96
|
+
onMounted(() => {
|
|
97
|
+
render();
|
|
98
|
+
});
|
|
99
|
+
return { imgData, canvasRef, imageRef, render };
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const _export_sfc = (sfc, props) => {
|
|
103
|
+
const target = sfc.__vccOpts || sfc;
|
|
104
|
+
for (const [key, val] of props) {
|
|
105
|
+
target[key] = val;
|
|
106
|
+
}
|
|
107
|
+
return target;
|
|
108
|
+
};
|
|
109
|
+
const _hoisted_1 = {
|
|
110
|
+
class: "ele-qr-code",
|
|
111
|
+
style: { display: "inline-flex" }
|
|
112
|
+
};
|
|
113
|
+
const _hoisted_2 = ["src"];
|
|
114
|
+
const _hoisted_3 = ["src"];
|
|
115
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
116
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
117
|
+
_ctx.tag === "img" ? (openBlock(), createElementBlock("img", {
|
|
118
|
+
key: 0,
|
|
119
|
+
src: _ctx.imgData,
|
|
120
|
+
style: normalizeStyle([{ width: _ctx.size + "px", height: _ctx.size + "px" }, _ctx.customStyle || {}])
|
|
121
|
+
}, null, 12, _hoisted_2)) : createCommentVNode("", true),
|
|
122
|
+
createElementVNode("canvas", {
|
|
123
|
+
ref: "canvasRef",
|
|
124
|
+
style: normalizeStyle([
|
|
125
|
+
{
|
|
126
|
+
width: _ctx.size + "px",
|
|
127
|
+
height: _ctx.size + "px",
|
|
128
|
+
display: _ctx.tag === "img" ? "none" : void 0
|
|
129
|
+
},
|
|
130
|
+
_ctx.customStyle || {}
|
|
131
|
+
])
|
|
132
|
+
}, null, 4),
|
|
133
|
+
_ctx.imageSettings && _ctx.imageSettings.src ? (openBlock(), createElementBlock("img", {
|
|
134
|
+
key: 1,
|
|
135
|
+
ref: "imageRef",
|
|
136
|
+
src: _ctx.imageSettings.src,
|
|
137
|
+
crossorigin: "anonymous",
|
|
138
|
+
referrerpolicy: "no-referrer",
|
|
139
|
+
style: { display: "none" },
|
|
140
|
+
onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.render && _ctx.render(...args))
|
|
141
|
+
}, null, 40, _hoisted_3)) : createCommentVNode("", true)
|
|
142
|
+
]);
|
|
143
|
+
}
|
|
144
|
+
const canvasRender = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
145
|
+
export {
|
|
146
|
+
canvasRender as default
|
|
147
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { StyleValues } from '../ele-app/types';
|
|
2
|
-
|
|
3
1
|
declare const _default: import('vue').DefineComponent<{
|
|
4
2
|
value: StringConstructor;
|
|
5
3
|
size: {
|
|
@@ -23,13 +21,10 @@ declare const _default: import('vue').DefineComponent<{
|
|
|
23
21
|
default: number;
|
|
24
22
|
};
|
|
25
23
|
imageSettings: import('vue').PropType<import('./types').ImageSettings>;
|
|
26
|
-
customStyle: import('vue').PropType<
|
|
24
|
+
customStyle: import('vue').PropType<import('../ele-app/types').StyleValue>;
|
|
25
|
+
tag: import('vue').PropType<import('./types').QrCodeTag>;
|
|
27
26
|
}, {
|
|
28
|
-
|
|
29
|
-
imageRef: import('vue').Ref<HTMLImageElement | null>;
|
|
30
|
-
imageSrc: import('vue').ComputedRef<string | undefined>;
|
|
31
|
-
canvasStyle: import('vue').ComputedRef<StyleValues>;
|
|
32
|
-
render: () => void;
|
|
27
|
+
handleDone: () => void;
|
|
33
28
|
}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
34
29
|
done: () => boolean;
|
|
35
30
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
@@ -55,7 +50,8 @@ declare const _default: import('vue').DefineComponent<{
|
|
|
55
50
|
default: number;
|
|
56
51
|
};
|
|
57
52
|
imageSettings: import('vue').PropType<import('./types').ImageSettings>;
|
|
58
|
-
customStyle: import('vue').PropType<
|
|
53
|
+
customStyle: import('vue').PropType<import('../ele-app/types').StyleValue>;
|
|
54
|
+
tag: import('vue').PropType<import('./types').QrCodeTag>;
|
|
59
55
|
}>> & {
|
|
60
56
|
onDone?: (() => any) | undefined;
|
|
61
57
|
}, {
|
package/es/ele-qr-code/index.js
CHANGED
|
@@ -1,128 +1,17 @@
|
|
|
1
|
-
import { defineComponent,
|
|
2
|
-
import
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createBlock } from "vue";
|
|
2
|
+
import EleQrCodeSvg from "../ele-qr-code-svg/index";
|
|
3
|
+
import CanvasRender from "./components/canvas-render";
|
|
3
4
|
import { qrCodeProps, qrCodeEmits } from "./props";
|
|
4
|
-
import { ERROR_LEVEL_MAP, getImageSettings, excavateModules, SUPPORTS_PATH2D, generatePath } from "./util";
|
|
5
5
|
const _sfc_main = defineComponent({
|
|
6
6
|
name: "EleQrCode",
|
|
7
|
+
components: { EleQrCodeSvg, CanvasRender },
|
|
7
8
|
props: qrCodeProps,
|
|
8
9
|
emits: qrCodeEmits,
|
|
9
|
-
setup(
|
|
10
|
-
const
|
|
11
|
-
const imageRef = ref(null);
|
|
12
|
-
const imageSrc = computed(
|
|
13
|
-
() => {
|
|
14
|
-
var _a;
|
|
15
|
-
return (_a = props.imageSettings) == null ? void 0 : _a.src;
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
const canvasStyle = computed(() => {
|
|
19
|
-
const styles = [
|
|
20
|
-
{
|
|
21
|
-
height: `${props.size}px`,
|
|
22
|
-
width: `${props.size}px`
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
if (props.customStyle != null) {
|
|
26
|
-
styles.push(props.customStyle);
|
|
27
|
-
}
|
|
28
|
-
return styles;
|
|
29
|
-
});
|
|
30
|
-
const render = () => {
|
|
31
|
-
const { value, size, level, bgColor, fgColor, margin, imageSettings } = props;
|
|
32
|
-
if (canvasRef.value == null) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const canvas = canvasRef.value;
|
|
36
|
-
const ctx = canvas.getContext("2d");
|
|
37
|
-
if (!ctx) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!value) {
|
|
41
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let cells = qrcodegen.QrCode.encodeText(
|
|
45
|
-
value,
|
|
46
|
-
ERROR_LEVEL_MAP[level]
|
|
47
|
-
).getModules();
|
|
48
|
-
const numCells = cells.length + margin * 2;
|
|
49
|
-
const calculatedImageSettings = getImageSettings(
|
|
50
|
-
imageSettings,
|
|
51
|
-
size,
|
|
52
|
-
margin,
|
|
53
|
-
cells
|
|
54
|
-
);
|
|
55
|
-
const image = imageRef.value;
|
|
56
|
-
const haveImageToRender = calculatedImageSettings != null && image != null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0;
|
|
57
|
-
if (haveImageToRender && calculatedImageSettings.excavation != null) {
|
|
58
|
-
cells = excavateModules(cells, calculatedImageSettings.excavation);
|
|
59
|
-
}
|
|
60
|
-
const pixelRatio = window.devicePixelRatio || 1;
|
|
61
|
-
canvas.height = canvas.width = size * pixelRatio;
|
|
62
|
-
const scale = size / numCells * pixelRatio;
|
|
63
|
-
ctx.scale(scale, scale);
|
|
64
|
-
ctx.fillStyle = bgColor;
|
|
65
|
-
ctx.fillRect(0, 0, numCells, numCells);
|
|
66
|
-
ctx.fillStyle = fgColor;
|
|
67
|
-
if (SUPPORTS_PATH2D) {
|
|
68
|
-
ctx.fill(new Path2D(generatePath(cells, margin)));
|
|
69
|
-
} else {
|
|
70
|
-
cells.forEach(function(row, rdx) {
|
|
71
|
-
row.forEach(function(cell, cdx) {
|
|
72
|
-
if (cell) {
|
|
73
|
-
ctx.fillRect(cdx + margin, rdx + margin, 1, 1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (haveImageToRender) {
|
|
79
|
-
ctx.drawImage(
|
|
80
|
-
image,
|
|
81
|
-
calculatedImageSettings.x + margin,
|
|
82
|
-
calculatedImageSettings.y + margin,
|
|
83
|
-
calculatedImageSettings.w,
|
|
84
|
-
calculatedImageSettings.h
|
|
85
|
-
);
|
|
86
|
-
}
|
|
10
|
+
setup(_props, { emit }) {
|
|
11
|
+
const handleDone = () => {
|
|
87
12
|
emit("done");
|
|
88
13
|
};
|
|
89
|
-
|
|
90
|
-
[
|
|
91
|
-
() => props.value,
|
|
92
|
-
() => props.level,
|
|
93
|
-
() => props.bgColor,
|
|
94
|
-
() => props.fgColor,
|
|
95
|
-
() => props.margin
|
|
96
|
-
],
|
|
97
|
-
() => {
|
|
98
|
-
render();
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
watch(
|
|
102
|
-
() => props.size,
|
|
103
|
-
() => {
|
|
104
|
-
nextTick(() => {
|
|
105
|
-
render();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
watch(
|
|
110
|
-
() => props.imageSettings,
|
|
111
|
-
() => {
|
|
112
|
-
render();
|
|
113
|
-
},
|
|
114
|
-
{ deep: true }
|
|
115
|
-
);
|
|
116
|
-
onMounted(() => {
|
|
117
|
-
render();
|
|
118
|
-
});
|
|
119
|
-
return {
|
|
120
|
-
canvasRef,
|
|
121
|
-
imageRef,
|
|
122
|
-
imageSrc,
|
|
123
|
-
canvasStyle,
|
|
124
|
-
render
|
|
125
|
-
};
|
|
14
|
+
return { handleDone };
|
|
126
15
|
}
|
|
127
16
|
});
|
|
128
17
|
const _export_sfc = (sfc, props) => {
|
|
@@ -132,25 +21,33 @@ const _export_sfc = (sfc, props) => {
|
|
|
132
21
|
}
|
|
133
22
|
return target;
|
|
134
23
|
};
|
|
135
|
-
const _hoisted_1 = { class: "ele-qr-code" };
|
|
136
|
-
const _hoisted_2 = ["height", "width"];
|
|
137
|
-
const _hoisted_3 = ["src"];
|
|
138
24
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
_ctx.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
25
|
+
const _component_EleQrCodeSvg = resolveComponent("EleQrCodeSvg");
|
|
26
|
+
const _component_CanvasRender = resolveComponent("CanvasRender");
|
|
27
|
+
return _ctx.tag === "svg" ? (openBlock(), createBlock(_component_EleQrCodeSvg, {
|
|
28
|
+
key: 0,
|
|
29
|
+
value: _ctx.value,
|
|
30
|
+
size: _ctx.size,
|
|
31
|
+
level: _ctx.level,
|
|
32
|
+
bgColor: _ctx.bgColor,
|
|
33
|
+
fgColor: _ctx.fgColor,
|
|
34
|
+
margin: _ctx.margin,
|
|
35
|
+
imageSettings: _ctx.imageSettings,
|
|
36
|
+
customStyle: _ctx.customStyle,
|
|
37
|
+
onDone: _ctx.handleDone
|
|
38
|
+
}, null, 8, ["value", "size", "level", "bgColor", "fgColor", "margin", "imageSettings", "customStyle", "onDone"])) : (openBlock(), createBlock(_component_CanvasRender, {
|
|
39
|
+
key: 1,
|
|
40
|
+
value: _ctx.value,
|
|
41
|
+
size: _ctx.size,
|
|
42
|
+
level: _ctx.level,
|
|
43
|
+
bgColor: _ctx.bgColor,
|
|
44
|
+
fgColor: _ctx.fgColor,
|
|
45
|
+
margin: _ctx.margin,
|
|
46
|
+
imageSettings: _ctx.imageSettings,
|
|
47
|
+
customStyle: _ctx.customStyle,
|
|
48
|
+
tag: _ctx.tag,
|
|
49
|
+
onDone: _ctx.handleDone
|
|
50
|
+
}, null, 8, ["value", "size", "level", "bgColor", "fgColor", "margin", "imageSettings", "customStyle", "tag", "onDone"]));
|
|
154
51
|
}
|
|
155
52
|
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
156
53
|
export {
|