stk-table-vue 1.2.4 → 1.2.6

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.
Files changed (68) hide show
  1. package/README.md +194 -194
  2. package/lib/{Dropdown-D_9cB0rD.js → Dropdown-BAANgg_5.js} +2 -2
  3. package/lib/{StkTable-CVcmlZi9.js → StkTable-CGcxwpdb.js} +22 -6
  4. package/lib/src/StkTable/StkTable.vue.d.ts +18 -4
  5. package/lib/src/StkTable/types/index.d.ts +4 -1
  6. package/lib/src/StkTable/useVirtualScroll.d.ts +6 -1
  7. package/lib/stk-table-vue.js +3 -3
  8. package/lib/style.css +1 -1
  9. package/package.json +93 -93
  10. package/src/StkTable/StkTable.vue +2362 -2338
  11. package/src/StkTable/components/DragHandle.vue +9 -9
  12. package/src/StkTable/components/SortIcon.vue +6 -6
  13. package/src/StkTable/components/TreeNodeCell.vue +19 -19
  14. package/src/StkTable/components/TriangleIcon.vue +3 -3
  15. package/src/StkTable/const.ts +50 -50
  16. package/src/StkTable/custom-cells/ChangeCell/ChangeCell.less +34 -34
  17. package/src/StkTable/custom-cells/ChangeCell/createChangeCell.ts +90 -90
  18. package/src/StkTable/custom-cells/ChangeCell/index.ts +4 -4
  19. package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.less +14 -14
  20. package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.vue +56 -56
  21. package/src/StkTable/custom-cells/CheckboxCell/createCheckboxCell.ts +146 -146
  22. package/src/StkTable/custom-cells/CheckboxCell/index.ts +5 -5
  23. package/src/StkTable/custom-cells/FilterCell/Dropdown/index.ts +16 -16
  24. package/src/StkTable/custom-cells/FilterCell/Dropdown/index.vue +186 -186
  25. package/src/StkTable/custom-cells/FilterCell/Filter.less +118 -118
  26. package/src/StkTable/custom-cells/FilterCell/Filter.vue +66 -66
  27. package/src/StkTable/custom-cells/FilterCell/createFilterCell.ts +120 -120
  28. package/src/StkTable/custom-cells/FilterCell/index.ts +6 -6
  29. package/src/StkTable/custom-cells/FilterCell/types.ts +43 -43
  30. package/src/StkTable/custom-cells/NumberCell/createNumberCell.ts +43 -43
  31. package/src/StkTable/custom-cells/NumberCell/index.ts +2 -2
  32. package/src/StkTable/custom-cells/utils/formatNumber.ts +137 -137
  33. package/src/StkTable/features/const.ts +1 -1
  34. package/src/StkTable/features/index.ts +1 -1
  35. package/src/StkTable/features/useAreaSelection.ts +1240 -1239
  36. package/src/StkTable/index.ts +20 -20
  37. package/src/StkTable/mergeCellsCache.ts +69 -69
  38. package/src/StkTable/registerFeature.ts +40 -40
  39. package/src/StkTable/style.less +791 -791
  40. package/src/StkTable/types/highlightDimOptions.ts +28 -28
  41. package/src/StkTable/types/index.ts +503 -500
  42. package/src/StkTable/useAutoResize.ts +87 -87
  43. package/src/StkTable/useColResize.ts +202 -202
  44. package/src/StkTable/useFixedCol.ts +168 -168
  45. package/src/StkTable/useFixedStyle.ts +75 -75
  46. package/src/StkTable/useGetFixedColPosition.ts +63 -63
  47. package/src/StkTable/useHighlight.ts +270 -270
  48. package/src/StkTable/useIndexResolver.ts +29 -29
  49. package/src/StkTable/useKeyboardArrowScroll.ts +114 -114
  50. package/src/StkTable/useMaxRowSpan.ts +60 -60
  51. package/src/StkTable/useMergeCells.ts +541 -541
  52. package/src/StkTable/useRowExpand.ts +81 -81
  53. package/src/StkTable/useScrollRowByRow.ts +96 -96
  54. package/src/StkTable/useScrollbar.ts +177 -177
  55. package/src/StkTable/useSorter.ts +267 -267
  56. package/src/StkTable/useTableColumns.ts +142 -142
  57. package/src/StkTable/useThDrag.ts +94 -94
  58. package/src/StkTable/useTrDrag.ts +100 -100
  59. package/src/StkTable/useTree.ts +253 -253
  60. package/src/StkTable/useVirtualScroll.ts +1032 -1025
  61. package/src/StkTable/useWheeling.ts +23 -23
  62. package/src/StkTable/utils/constRefUtils.ts +29 -29
  63. package/src/StkTable/utils/index.ts +331 -331
  64. package/src/StkTable/utils/rowHeightFenwickTree.ts +74 -74
  65. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  66. package/src/VirtualTree.vue +622 -622
  67. package/src/VirtualTreeSelect.vue +367 -367
  68. package/src/vite-env.d.ts +10 -10
@@ -1,9 +1,9 @@
1
- <template>
2
- <span class="drag-row-handle" draggable="true">
3
- <svg viewBox="0 0 1024 1024" width="20" height="20" fill="currentColor">
4
- <path
5
- d="M640 853.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3zM384 341.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z"
6
- ></path>
7
- </svg>
8
- </span>
9
- </template>
1
+ <template>
2
+ <span class="drag-row-handle" draggable="true">
3
+ <svg viewBox="0 0 1024 1024" width="20" height="20" fill="currentColor">
4
+ <path
5
+ d="M640 853.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m-256 0a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z m256-256a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3zM384 341.3a85.3 85.3 0 1 1 85.3-85.3 85.3 85.3 0 0 1-85.3 85.3z"
6
+ ></path>
7
+ </svg>
8
+ </span>
9
+ </template>
@@ -1,6 +1,6 @@
1
- <template>
2
- <svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 16 16">
3
- <polygon class="arrow-up" fill="#757699" points="8 2 4.8 6 11.2 6"></polygon>
4
- <polygon class="arrow-down" transform="translate(8, 12) rotate(-180) translate(-8, -12) " points="8 10 4.8 14 11.2 14"></polygon>
5
- </svg>
6
- </template>
1
+ <template>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" viewBox="0 0 16 16">
3
+ <polygon class="arrow-up" fill="#757699" points="8 2 4.8 6 11.2 6"></polygon>
4
+ <polygon class="arrow-down" transform="translate(8, 12) rotate(-180) translate(-8, -12) " points="8 10 4.8 14 11.2 14"></polygon>
5
+ </svg>
6
+ </template>
@@ -1,19 +1,19 @@
1
- <template>
2
- <div :title="row[col.dataIndex] || ''" :style="row.__T_LV__ ? `padding-left:${row.__T_LV__ * 16}px` : ''">
3
- <TriangleIcon v-if="row.children !== void 0" @click="emit('click')" />
4
- <span :style="!row.children ? 'padding-left: 16px;' : null">
5
- {{ row[col.dataIndex] ?? '' }}
6
- </span>
7
- </div>
8
- </template>
9
-
10
- <script setup lang="ts">
11
- import { PrivateStkTableColumn } from '../types';
12
- import TriangleIcon from './TriangleIcon.vue';
13
-
14
- defineProps<{
15
- col: PrivateStkTableColumn<any>;
16
- row: any;
17
- }>();
18
- const emit = defineEmits(['click']);
19
- </script>
1
+ <template>
2
+ <div :title="row[col.dataIndex] || ''" :style="row.__T_LV__ ? `padding-left:${row.__T_LV__ * 16}px` : ''">
3
+ <TriangleIcon v-if="row.children !== void 0" @click="emit('click')" />
4
+ <span :style="!row.children ? 'padding-left: 16px;' : null">
5
+ {{ row[col.dataIndex] ?? '' }}
6
+ </span>
7
+ </div>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { PrivateStkTableColumn } from '../types';
12
+ import TriangleIcon from './TriangleIcon.vue';
13
+
14
+ defineProps<{
15
+ col: PrivateStkTableColumn<any>;
16
+ row: any;
17
+ }>();
18
+ const emit = defineEmits(['click']);
19
+ </script>
@@ -1,3 +1,3 @@
1
- <template>
2
- <div class="stk-fold-icon"></div>
3
- </template>
1
+ <template>
2
+ <div class="stk-fold-icon"></div>
3
+ </template>
@@ -1,50 +1,50 @@
1
- import { RowActiveOption, SortConfig } from './types';
2
- import { getBrowsersVersion } from './utils';
3
-
4
- export const DEFAULT_COL_WIDTH = 100;
5
-
6
- export const DEFAULT_TABLE_HEIGHT = 100;
7
- export const DEFAULT_TABLE_WIDTH = 200;
8
- export const DEFAULT_ROW_HEIGHT = 28;
9
-
10
- /** highlight background */
11
- export const HIGHLIGHT_COLOR = {
12
- light: { from: '#71a2fd', to: '#fff' },
13
- dark: { from: '#1e4c99', to: '#181c21' },
14
- };
15
- export const HIGHLIGHT_DURATION = 2000;
16
-
17
- /** highlight change frequency 1000/30 -> 30FPS */
18
- // export const HIGHLIGHT_FREQ = 1000 / 30;
19
-
20
- export const HIGHLIGHT_ROW_CLASS = 'highlight-row';
21
- export const HIGHLIGHT_CELL_CLASS = 'highlight-cell';
22
-
23
- const _chromeVersion = getBrowsersVersion('chrome');
24
- const _firefoxVersion = getBrowsersVersion('firefox');
25
-
26
- /** legacy sticky compatible mode */
27
- export const IS_LEGACY_MODE = _chromeVersion < 56 || _firefoxVersion < 59;
28
-
29
- /** default props.smoothDefault */
30
- export const DEFAULT_SMOOTH_SCROLL = _chromeVersion < 85;
31
-
32
- export const STK_ID_PREFIX = 'stk';
33
-
34
- /** expanded row key prefix */
35
- export const EXPANDED_ROW_KEY_PREFIX = 'expanded-';
36
-
37
- /** cell key split str */
38
- export const CELL_KEY_SEPARATE = '--';
39
-
40
- export const DEFAULT_SORT_CONFIG = {
41
- emptyToBottom: false,
42
- stringLocaleCompare: false,
43
- sortChildren: false,
44
- } satisfies SortConfig<any>;
45
-
46
- export const DEFAULT_ROW_ACTIVE_CONFIG: Required<RowActiveOption<any>> = {
47
- enabled: true,
48
- disabled: () => false,
49
- revokable: true,
50
- };
1
+ import { RowActiveOption, SortConfig } from './types';
2
+ import { getBrowsersVersion } from './utils';
3
+
4
+ export const DEFAULT_COL_WIDTH = 100;
5
+
6
+ export const DEFAULT_TABLE_HEIGHT = 100;
7
+ export const DEFAULT_TABLE_WIDTH = 200;
8
+ export const DEFAULT_ROW_HEIGHT = 28;
9
+
10
+ /** highlight background */
11
+ export const HIGHLIGHT_COLOR = {
12
+ light: { from: '#71a2fd', to: '#fff' },
13
+ dark: { from: '#1e4c99', to: '#181c21' },
14
+ };
15
+ export const HIGHLIGHT_DURATION = 2000;
16
+
17
+ /** highlight change frequency 1000/30 -> 30FPS */
18
+ // export const HIGHLIGHT_FREQ = 1000 / 30;
19
+
20
+ export const HIGHLIGHT_ROW_CLASS = 'highlight-row';
21
+ export const HIGHLIGHT_CELL_CLASS = 'highlight-cell';
22
+
23
+ const _chromeVersion = getBrowsersVersion('chrome');
24
+ const _firefoxVersion = getBrowsersVersion('firefox');
25
+
26
+ /** legacy sticky compatible mode */
27
+ export const IS_LEGACY_MODE = _chromeVersion < 56 || _firefoxVersion < 59;
28
+
29
+ /** default props.smoothDefault */
30
+ export const DEFAULT_SMOOTH_SCROLL = _chromeVersion < 85;
31
+
32
+ export const STK_ID_PREFIX = 'stk';
33
+
34
+ /** expanded row key prefix */
35
+ export const EXPANDED_ROW_KEY_PREFIX = 'expanded-';
36
+
37
+ /** cell key split str */
38
+ export const CELL_KEY_SEPARATE = '--';
39
+
40
+ export const DEFAULT_SORT_CONFIG = {
41
+ emptyToBottom: false,
42
+ stringLocaleCompare: false,
43
+ sortChildren: false,
44
+ } satisfies SortConfig<any>;
45
+
46
+ export const DEFAULT_ROW_ACTIVE_CONFIG: Required<RowActiveOption<any>> = {
47
+ enabled: true,
48
+ disabled: () => false,
49
+ revokable: true,
50
+ };
@@ -1,34 +1,34 @@
1
- .stk-change-cell {
2
- // 默认(浅色)配色:涨红跌绿为 A 股习惯,颜色方向由组件按 colorReverse 决定
3
- --stk-change-red: #e02020;
4
- --stk-change-green: #00a870;
5
- --stk-change-flat: #666;
6
-
7
- display: inline-flex;
8
- align-items: center;
9
- gap: 2px;
10
-
11
- &--red {
12
- color: var(--stk-change-red);
13
- }
14
-
15
- &--green {
16
- color: var(--stk-change-green);
17
- }
18
-
19
- &--flat {
20
- color: var(--stk-change-flat);
21
- }
22
-
23
- &__arrow {
24
- font-size: 0.85em;
25
- line-height: 1;
26
- }
27
- }
28
-
29
- // 暗色主题下适当提亮,跟随表格根节点 .stk-table.dark
30
- .stk-table.dark .stk-change-cell {
31
- --stk-change-red: #ff5c5c;
32
- --stk-change-green: #26c281;
33
- --stk-change-flat: #aaa;
34
- }
1
+ .stk-change-cell {
2
+ // 默认(浅色)配色:涨红跌绿为 A 股习惯,颜色方向由组件按 colorReverse 决定
3
+ --stk-change-red: #e02020;
4
+ --stk-change-green: #00a870;
5
+ --stk-change-flat: #666;
6
+
7
+ display: inline-flex;
8
+ align-items: center;
9
+ gap: 2px;
10
+
11
+ &--red {
12
+ color: var(--stk-change-red);
13
+ }
14
+
15
+ &--green {
16
+ color: var(--stk-change-green);
17
+ }
18
+
19
+ &--flat {
20
+ color: var(--stk-change-flat);
21
+ }
22
+
23
+ &__arrow {
24
+ font-size: 0.85em;
25
+ line-height: 1;
26
+ }
27
+ }
28
+
29
+ // 暗色主题下适当提亮,跟随表格根节点 .stk-table.dark
30
+ .stk-table.dark .stk-change-cell {
31
+ --stk-change-red: #ff5c5c;
32
+ --stk-change-green: #26c281;
33
+ --stk-change-flat: #aaa;
34
+ }
@@ -1,90 +1,90 @@
1
- import type { CustomCellProps } from '../../types';
2
- import { defineComponent, h, markRaw } from 'vue';
3
- import { formatNumber, type FormatNumberOptions } from '../utils/formatNumber';
4
-
5
- /** createChangeCell 配置选项 */
6
- export interface CreateChangeCellOptions extends FormatNumberOptions {
7
- /** 涨跌颜色是否反转:false=A股(涨红跌绿,默认),true=国际(涨绿跌红) */
8
- colorReverse?: boolean;
9
- /** 是否显示涨跌箭头 ▲/▼,默认 false */
10
- arrow?: boolean;
11
- /** 自定义上涨颜色(覆盖默认配色,传入后不受 colorReverse 影响) */
12
- riseColor?: string;
13
- /** 自定义下跌颜色 */
14
- fallColor?: string;
15
- /** 自定义平盘颜色 */
16
- flatColor?: string;
17
- }
18
-
19
- /** 涨跌方向:涨 / 跌 / 平(含空值) */
20
- type ChangeDir = 'rise' | 'fall' | 'flat';
21
-
22
- /** 根据原始值判断涨跌方向 */
23
- function resolveDir(rawValue: any): ChangeDir {
24
- const num = rawValue === '' || rawValue == null ? NaN : Number(rawValue);
25
- if (Number.isNaN(num) || num === 0) return 'flat';
26
- return num > 0 ? 'rise' : 'fall';
27
- }
28
-
29
- /**
30
- * 涨跌单元格工厂函数
31
- *
32
- * 在 {@link formatNumber} 的基础上叠加涨跌染色与箭头。染色按 `cellValue` 正负判断,
33
- * 颜色方向可通过 `colorReverse` 切换(A股 / 国际),也可用 `riseColor` 等自定义。
34
- * 数字对齐请在列配置上设置 `align: 'right'`。
35
- *
36
- * @param options 格式化 + 染色/箭头选项
37
- * @returns `ChangeCell` 组件构造函数,使用时需调用一次:`customCell: ChangeCell()`
38
- *
39
- * @example
40
- * ```ts
41
- * const { ChangeCell } = createChangeCell({ decimals: 2, showSign: true, arrow: true });
42
- * const ChangeCellComp = ChangeCell();
43
- * const columns = [
44
- * { title: '涨跌额', dataIndex: 'change', align: 'right', customCell: ChangeCellComp },
45
- * ];
46
- * ```
47
- */
48
- export function createChangeCell(options: CreateChangeCellOptions = {}) {
49
- const { colorReverse = false, arrow = false, riseColor, fallColor, flatColor } = options;
50
-
51
- /** 单元格组件 - 用于 customCell */
52
- function ChangeCell() {
53
- return markRaw(
54
- defineComponent({
55
- // eslint-disable-next-line vue/require-prop-types
56
- props: ['row', 'col', 'cellValue', 'rowIndex', 'colIndex', 'expanded', 'treeExpanded'],
57
- setup(props: CustomCellProps<any>) {
58
- return () => {
59
- const raw = props.cellValue;
60
- const dir = resolveDir(raw);
61
-
62
- // 颜色 class:涨=红/跌=绿(colorReverse 时互换),平=中性
63
- let colorClass = 'stk-change-cell--flat';
64
- if (dir === 'rise') colorClass = colorReverse ? 'stk-change-cell--green' : 'stk-change-cell--red';
65
- else if (dir === 'fall') colorClass = colorReverse ? 'stk-change-cell--red' : 'stk-change-cell--green';
66
-
67
- // 自定义颜色(若传)直接内联覆盖
68
- const customColor = dir === 'rise' ? riseColor : dir === 'fall' ? fallColor : flatColor;
69
-
70
- // 箭头:涨 ▲ / 跌 ▼,平及空值不显示
71
- const arrowChar = arrow && dir !== 'flat' ? (dir === 'rise' ? '▲' : '▼') : ''; // TODO: 支持自定义箭头
72
-
73
- return h(
74
- 'span',
75
- {
76
- class: ['stk-change-cell', colorClass],
77
- style: customColor ? { color: customColor } : undefined,
78
- },
79
- [arrowChar ? h('span', { class: 'stk-change-cell__arrow' }, arrowChar) : null, formatNumber(raw, options)],
80
- );
81
- };
82
- },
83
- }),
84
- );
85
- }
86
-
87
- return {
88
- ChangeCell,
89
- };
90
- }
1
+ import type { CustomCellProps } from '../../types';
2
+ import { defineComponent, h, markRaw } from 'vue';
3
+ import { formatNumber, type FormatNumberOptions } from '../utils/formatNumber';
4
+
5
+ /** createChangeCell 配置选项 */
6
+ export interface CreateChangeCellOptions extends FormatNumberOptions {
7
+ /** 涨跌颜色是否反转:false=A股(涨红跌绿,默认),true=国际(涨绿跌红) */
8
+ colorReverse?: boolean;
9
+ /** 是否显示涨跌箭头 ▲/▼,默认 false */
10
+ arrow?: boolean;
11
+ /** 自定义上涨颜色(覆盖默认配色,传入后不受 colorReverse 影响) */
12
+ riseColor?: string;
13
+ /** 自定义下跌颜色 */
14
+ fallColor?: string;
15
+ /** 自定义平盘颜色 */
16
+ flatColor?: string;
17
+ }
18
+
19
+ /** 涨跌方向:涨 / 跌 / 平(含空值) */
20
+ type ChangeDir = 'rise' | 'fall' | 'flat';
21
+
22
+ /** 根据原始值判断涨跌方向 */
23
+ function resolveDir(rawValue: any): ChangeDir {
24
+ const num = rawValue === '' || rawValue == null ? NaN : Number(rawValue);
25
+ if (Number.isNaN(num) || num === 0) return 'flat';
26
+ return num > 0 ? 'rise' : 'fall';
27
+ }
28
+
29
+ /**
30
+ * 涨跌单元格工厂函数
31
+ *
32
+ * 在 {@link formatNumber} 的基础上叠加涨跌染色与箭头。染色按 `cellValue` 正负判断,
33
+ * 颜色方向可通过 `colorReverse` 切换(A股 / 国际),也可用 `riseColor` 等自定义。
34
+ * 数字对齐请在列配置上设置 `align: 'right'`。
35
+ *
36
+ * @param options 格式化 + 染色/箭头选项
37
+ * @returns `ChangeCell` 组件构造函数,使用时需调用一次:`customCell: ChangeCell()`
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const { ChangeCell } = createChangeCell({ decimals: 2, showSign: true, arrow: true });
42
+ * const ChangeCellComp = ChangeCell();
43
+ * const columns = [
44
+ * { title: '涨跌额', dataIndex: 'change', align: 'right', customCell: ChangeCellComp },
45
+ * ];
46
+ * ```
47
+ */
48
+ export function createChangeCell(options: CreateChangeCellOptions = {}) {
49
+ const { colorReverse = false, arrow = false, riseColor, fallColor, flatColor } = options;
50
+
51
+ /** 单元格组件 - 用于 customCell */
52
+ function ChangeCell() {
53
+ return markRaw(
54
+ defineComponent({
55
+ // eslint-disable-next-line vue/require-prop-types
56
+ props: ['row', 'col', 'cellValue', 'rowIndex', 'colIndex', 'expanded', 'treeExpanded'],
57
+ setup(props: CustomCellProps<any>) {
58
+ return () => {
59
+ const raw = props.cellValue;
60
+ const dir = resolveDir(raw);
61
+
62
+ // 颜色 class:涨=红/跌=绿(colorReverse 时互换),平=中性
63
+ let colorClass = 'stk-change-cell--flat';
64
+ if (dir === 'rise') colorClass = colorReverse ? 'stk-change-cell--green' : 'stk-change-cell--red';
65
+ else if (dir === 'fall') colorClass = colorReverse ? 'stk-change-cell--red' : 'stk-change-cell--green';
66
+
67
+ // 自定义颜色(若传)直接内联覆盖
68
+ const customColor = dir === 'rise' ? riseColor : dir === 'fall' ? fallColor : flatColor;
69
+
70
+ // 箭头:涨 ▲ / 跌 ▼,平及空值不显示
71
+ const arrowChar = arrow && dir !== 'flat' ? (dir === 'rise' ? '▲' : '▼') : ''; // TODO: 支持自定义箭头
72
+
73
+ return h(
74
+ 'span',
75
+ {
76
+ class: ['stk-change-cell', colorClass],
77
+ style: customColor ? { color: customColor } : undefined,
78
+ },
79
+ [arrowChar ? h('span', { class: 'stk-change-cell__arrow' }, arrowChar) : null, formatNumber(raw, options)],
80
+ );
81
+ };
82
+ },
83
+ }),
84
+ );
85
+ }
86
+
87
+ return {
88
+ ChangeCell,
89
+ };
90
+ }
@@ -1,4 +1,4 @@
1
- export { createChangeCell } from './createChangeCell';
2
- export type { CreateChangeCellOptions } from './createChangeCell';
3
-
4
- import './ChangeCell.less';
1
+ export { createChangeCell } from './createChangeCell';
2
+ export type { CreateChangeCellOptions } from './createChangeCell';
3
+
4
+ import './ChangeCell.less';
@@ -1,14 +1,14 @@
1
- .stk-checkbox-cell {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- width: 100%;
6
- height: 100%;
7
-
8
- .stk-checkbox-native {
9
- width: 16px;
10
- height: 16px;
11
- cursor: pointer;
12
- vertical-align: middle;
13
- }
14
- }
1
+ .stk-checkbox-cell {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ width: 100%;
6
+ height: 100%;
7
+
8
+ .stk-checkbox-native {
9
+ width: 16px;
10
+ height: 16px;
11
+ cursor: pointer;
12
+ vertical-align: middle;
13
+ }
14
+ }
@@ -1,56 +1,56 @@
1
- <template>
2
- <div class="stk-checkbox-cell">
3
- <component
4
- :is="customComponent"
5
- v-if="customComponent"
6
- :model-value="checked"
7
- :checked="checked"
8
- :indeterminate="indeterminate"
9
- @update:model-value="handleChange"
10
- @update:checked="handleChange"
11
- @change="handleChange"
12
- @click.stop
13
- />
14
- <input
15
- v-else
16
- type="checkbox"
17
- :checked="checked"
18
- :indeterminate.prop="indeterminate"
19
- class="stk-checkbox-native"
20
- @change="handleChange"
21
- @click.stop
22
- />
23
- </div>
24
- </template>
25
-
26
- <script lang="ts" setup>
27
- const props = defineProps<{
28
- /** 当前是否选中 */
29
- checked?: boolean;
30
- /** 是否半选状态 */
31
- indeterminate?: boolean;
32
- /** 自定义 checkbox 组件(如 Element Plus / Ant Design Vue 的 Checkbox) */
33
- customComponent?: any;
34
- }>();
35
-
36
- const emit = defineEmits<{
37
- (e: 'change', checked: boolean): void;
38
- }>();
39
-
40
- /** 防重保护:部分 UI 库(Element Plus / Arco Design)会同时触发多个事件 */
41
- let _lastValue: boolean | undefined;
42
-
43
- function handleChange(e: any) {
44
- let checked: boolean;
45
- if (typeof e === 'boolean') {
46
- checked = e;
47
- } else if (e?.target?.checked !== undefined) {
48
- checked = e.target.checked;
49
- } else {
50
- checked = !!e;
51
- }
52
- if (checked === _lastValue) return;
53
- _lastValue = checked;
54
- emit('change', checked);
55
- }
56
- </script>
1
+ <template>
2
+ <div class="stk-checkbox-cell">
3
+ <component
4
+ :is="customComponent"
5
+ v-if="customComponent"
6
+ :model-value="checked"
7
+ :checked="checked"
8
+ :indeterminate="indeterminate"
9
+ @update:model-value="handleChange"
10
+ @update:checked="handleChange"
11
+ @change="handleChange"
12
+ @click.stop
13
+ />
14
+ <input
15
+ v-else
16
+ type="checkbox"
17
+ :checked="checked"
18
+ :indeterminate.prop="indeterminate"
19
+ class="stk-checkbox-native"
20
+ @change="handleChange"
21
+ @click.stop
22
+ />
23
+ </div>
24
+ </template>
25
+
26
+ <script lang="ts" setup>
27
+ const props = defineProps<{
28
+ /** 当前是否选中 */
29
+ checked?: boolean;
30
+ /** 是否半选状态 */
31
+ indeterminate?: boolean;
32
+ /** 自定义 checkbox 组件(如 Element Plus / Ant Design Vue 的 Checkbox) */
33
+ customComponent?: any;
34
+ }>();
35
+
36
+ const emit = defineEmits<{
37
+ (e: 'change', checked: boolean): void;
38
+ }>();
39
+
40
+ /** 防重保护:部分 UI 库(Element Plus / Arco Design)会同时触发多个事件 */
41
+ let _lastValue: boolean | undefined;
42
+
43
+ function handleChange(e: any) {
44
+ let checked: boolean;
45
+ if (typeof e === 'boolean') {
46
+ checked = e;
47
+ } else if (e?.target?.checked !== undefined) {
48
+ checked = e.target.checked;
49
+ } else {
50
+ checked = !!e;
51
+ }
52
+ if (checked === _lastValue) return;
53
+ _lastValue = checked;
54
+ emit('change', checked);
55
+ }
56
+ </script>