xt-element-ui 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="ex-grid-box" :style="styleAttrs">
2
+ <div class="xt-grid-box" :style="styleAttrs">
3
3
  <slot></slot>
4
4
  </div>
5
5
  </template>
@@ -8,35 +8,128 @@
8
8
  export default {
9
9
  name: "XtGridBox",
10
10
  props: {
11
+ // 列配置
11
12
  columns: {
12
- type: [String, Array], // ["1fr","2fr", "20%"]
13
+ type: [String, Array, Number],
13
14
  default: "1fr"
14
15
  },
15
- rows: { // 1
16
- type: [String, Array], // ["1fr","2fr", "20%"]
17
- default: "1fr"
16
+ // 行配置
17
+ rows: {
18
+ type: [String, Array],
19
+ default: "auto"
20
+ },
21
+ // 间距(同时控制行列间距)
22
+ gap: { type: String, default: "" },
23
+ // 行间距
24
+ rowGap: { type: String, default: "" },
25
+ // 列间距
26
+ colGap: { type: String, default: "" },
27
+ // 排列方向
28
+ flow: {
29
+ type: String,
30
+ default: "row",
31
+ validator: (val) => ['row', 'column', 'row dense', 'column dense'].includes(val)
32
+ },
33
+ // 命名区域
34
+ areas: { type: [String, Array], default: "" },
35
+ // 子项对齐(place-items)
36
+ align: {
37
+ type: String,
38
+ default: "stretch",
39
+ validator: (val) => ['start', 'end', 'center', 'stretch', 'baseline'].includes(val)
18
40
  },
19
- gap: { type: String, default: "" }
41
+ // 内容对齐(place-content)
42
+ justify: {
43
+ type: String,
44
+ default: "start",
45
+ validator: (val) => ['start', 'end', 'center', 'space-between', 'space-around', 'space-evenly', 'stretch'].includes(val)
46
+ },
47
+ // 响应式配置 { sm: 2, md: 3, lg: 4 }
48
+ responsive: { type: Object, default: () => ({}) },
49
+ // 是否自动填充
50
+ autoFlow: { type: String, default: "" }
20
51
  },
21
52
  computed: {
22
53
  styleAttrs() {
23
- const gridTemplateRows = (typeof this.rows !== "string") ? this.rows.join(" ") : this.rows;
24
- const gridTemplateColumns = (typeof this.columns !== "string") ? this.columns.join(" ") : this.columns;
25
- return this.gap ? {
26
- gridTemplateColumns,
27
- gridTemplateRows,
28
- gap: this.gap.toString().split(" ").map(_getGap).join(" ")
29
- } : {
30
- gridTemplateColumns,
31
- gridTemplateRows
54
+ const styles = {
55
+ display: "grid"
56
+ };
57
+
58
+ // 处理列配置
59
+ if (typeof this.columns === 'number') {
60
+ styles.gridTemplateColumns = `repeat(${this.columns}, 1fr)`;
61
+ } else if (Array.isArray(this.columns)) {
62
+ styles.gridTemplateColumns = this.columns.join(" ");
63
+ } else {
64
+ styles.gridTemplateColumns = this.columns;
65
+ }
66
+
67
+ // 处理行配置
68
+ if (Array.isArray(this.rows)) {
69
+ styles.gridTemplateRows = this.rows.join(" ");
70
+ } else {
71
+ styles.gridTemplateRows = this.rows;
72
+ }
73
+
74
+ // 处理间距
75
+ if (this.gap) {
76
+ styles.gap = this.gap;
77
+ } else {
78
+ if (this.rowGap) styles.rowGap = this.rowGap;
79
+ if (this.colGap) styles.columnGap = this.colGap;
80
+ }
81
+
82
+ // 处理排列方向
83
+ if (this.flow) {
84
+ styles.gridAutoFlow = this.flow;
85
+ }
86
+
87
+ // 处理命名区域
88
+ if (this.areas) {
89
+ if (Array.isArray(this.areas)) {
90
+ styles.gridTemplateAreas = this.areas.map(row => `"${row}"`).join(" ");
91
+ } else {
92
+ styles.gridTemplateAreas = this.areas;
93
+ }
94
+ }
95
+
96
+ // 处理子项对齐
97
+ if (this.align) {
98
+ styles.placeItems = this.align;
99
+ }
100
+
101
+ // 处理内容对齐
102
+ if (this.justify) {
103
+ styles.placeContent = this.justify;
104
+ }
105
+
106
+ // 处理响应式断点
107
+ if (Object.keys(this.responsive).length > 0) {
108
+ this.addResponsiveStyles(styles);
109
+ }
110
+
111
+ return styles;
112
+ }
113
+ },
114
+ methods: {
115
+ addResponsiveStyles(styles) {
116
+ // 响应式断点映射
117
+ const breakpoints = {
118
+ xs: '(max-width: 575px)',
119
+ sm: '(min-width: 576px)',
120
+ md: '(min-width: 768px)',
121
+ lg: '(min-width: 992px)',
122
+ xl: '(min-width: 1200px)'
32
123
  };
124
+
125
+ Object.entries(this.responsive).forEach(([key, value]) => {
126
+ if (breakpoints[key]) {
127
+ const mediaQuery = `@media ${breakpoints[key]}`;
128
+ // 注意:内联样式不支持媒体查询,这里预留接口
129
+ // 实际响应式需要通过 CSS 类或其他方式实现
130
+ }
131
+ });
33
132
  }
34
133
  }
35
134
  };
36
135
  </script>
37
-
38
- <style lang="scss">
39
- .ex-grid-box{
40
- display: grid;
41
- }
42
- </style>
@@ -0,0 +1,93 @@
1
+ @import '../../../styles/variables.scss';
2
+
3
+ .xt-grid-box {
4
+ display: grid;
5
+ box-sizing: border-box;
6
+ min-height: 0;
7
+ }
8
+
9
+ // 默认间距变量
10
+ :root {
11
+ --xt-grid-box-gap: 8px;
12
+ }
13
+
14
+ // 响应式网格类
15
+ .xt-grid-box--auto-fill {
16
+ grid-template-columns: repeat(auto-fill, minmax(var(--xt-grid-item-min-width, 200px), 1fr));
17
+ }
18
+
19
+ .xt-grid-box--auto-fit {
20
+ grid-template-columns: repeat(auto-fit, minmax(var(--xt-grid-item-min-width, 200px), 1fr));
21
+ }
22
+
23
+ // 常见列数快捷类
24
+ .xt-grid-box--cols-2 {
25
+ grid-template-columns: repeat(2, 1fr);
26
+ }
27
+
28
+ .xt-grid-box--cols-3 {
29
+ grid-template-columns: repeat(3, 1fr);
30
+ }
31
+
32
+ .xt-grid-box--cols-4 {
33
+ grid-template-columns: repeat(4, 1fr);
34
+ }
35
+
36
+ .xt-grid-box--cols-6 {
37
+ grid-template-columns: repeat(6, 1fr);
38
+ }
39
+
40
+ .xt-grid-box--cols-12 {
41
+ grid-template-columns: repeat(12, 1fr);
42
+ }
43
+
44
+ // 子项默认样式
45
+ .xt-grid-item {
46
+ box-sizing: border-box;
47
+ }
48
+
49
+ // 响应式断点
50
+ @media (min-width: 576px) {
51
+ .xt-grid-box--sm-cols-2 {
52
+ grid-template-columns: repeat(2, 1fr);
53
+ }
54
+ .xt-grid-box--sm-cols-3 {
55
+ grid-template-columns: repeat(3, 1fr);
56
+ }
57
+ }
58
+
59
+ @media (min-width: 768px) {
60
+ .xt-grid-box--md-cols-2 {
61
+ grid-template-columns: repeat(2, 1fr);
62
+ }
63
+ .xt-grid-box--md-cols-3 {
64
+ grid-template-columns: repeat(3, 1fr);
65
+ }
66
+ .xt-grid-box--md-cols-4 {
67
+ grid-template-columns: repeat(4, 1fr);
68
+ }
69
+ }
70
+
71
+ @media (min-width: 992px) {
72
+ .xt-grid-box--lg-cols-3 {
73
+ grid-template-columns: repeat(3, 1fr);
74
+ }
75
+ .xt-grid-box--lg-cols-4 {
76
+ grid-template-columns: repeat(4, 1fr);
77
+ }
78
+ .xt-grid-box--lg-cols-6 {
79
+ grid-template-columns: repeat(6, 1fr);
80
+ }
81
+ }
82
+
83
+ @media (min-width: 1200px) {
84
+ .xt-grid-box--xl-cols-4 {
85
+ grid-template-columns: repeat(4, 1fr);
86
+ }
87
+ .xt-grid-box--xl-cols-6 {
88
+ grid-template-columns: repeat(6, 1fr);
89
+ }
90
+ .xt-grid-box--xl-cols-12 {
91
+ grid-template-columns: repeat(12, 1fr);
92
+ }
93
+ }
@@ -0,0 +1,2 @@
1
+ import XtGridItem from './index.vue'
2
+ export default XtGridItem
@@ -0,0 +1,107 @@
1
+ <template>
2
+ <div class="xt-grid-item" :style="styleAttrs">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: "XtGridItem",
10
+ props: {
11
+ // 跨列数
12
+ span: {
13
+ type: Number,
14
+ default: 1,
15
+ validator: (val) => val > 0
16
+ },
17
+ // 跨行数
18
+ rowSpan: {
19
+ type: Number,
20
+ default: 1,
21
+ validator: (val) => val > 0
22
+ },
23
+ // 起始列
24
+ start: {
25
+ type: Number,
26
+ default: 0,
27
+ validator: (val) => val >= 0
28
+ },
29
+ // 起始行
30
+ rowStart: {
31
+ type: Number,
32
+ default: 0,
33
+ validator: (val) => val >= 0
34
+ },
35
+ // 命名区域
36
+ area: {
37
+ type: String,
38
+ default: ""
39
+ },
40
+ // 对齐方式(justify-self)
41
+ justifySelf: {
42
+ type: String,
43
+ default: "auto",
44
+ validator: (val) => ['auto', 'start', 'end', 'center', 'stretch'].includes(val)
45
+ },
46
+ // 对齐方式(align-self)
47
+ alignSelf: {
48
+ type: String,
49
+ default: "auto",
50
+ validator: (val) => ['auto', 'start', 'end', 'center', 'stretch', 'baseline'].includes(val)
51
+ },
52
+ // 自定义样式类
53
+ customClass: {
54
+ type: String,
55
+ default: ""
56
+ }
57
+ },
58
+ computed: {
59
+ styleAttrs() {
60
+ const styles = {};
61
+
62
+ // 处理跨列
63
+ if (this.span > 1) {
64
+ styles.gridColumnEnd = `span ${this.span}`;
65
+ }
66
+
67
+ // 处理跨行
68
+ if (this.rowSpan > 1) {
69
+ styles.gridRowEnd = `span ${this.rowSpan}`;
70
+ }
71
+
72
+ // 处理起始列
73
+ if (this.start > 0) {
74
+ styles.gridColumnStart = this.start;
75
+ }
76
+
77
+ // 处理起始行
78
+ if (this.rowStart > 0) {
79
+ styles.gridRowStart = this.rowStart;
80
+ }
81
+
82
+ // 处理命名区域
83
+ if (this.area) {
84
+ styles.gridArea = this.area;
85
+ }
86
+
87
+ // 处理 justify-self
88
+ if (this.justifySelf && this.justifySelf !== 'auto') {
89
+ styles.justifySelf = this.justifySelf;
90
+ }
91
+
92
+ // 处理 align-self
93
+ if (this.alignSelf && this.alignSelf !== 'auto') {
94
+ styles.alignSelf = this.alignSelf;
95
+ }
96
+
97
+ return styles;
98
+ }
99
+ }
100
+ };
101
+ </script>
102
+
103
+ <style lang="scss" scoped>
104
+ .xt-grid-item {
105
+ box-sizing: border-box;
106
+ }
107
+ </style>
@@ -3,6 +3,7 @@
3
3
  class="xt-text"
4
4
  :class="[
5
5
  type ? 'xt-text--' + type : '',
6
+ 'xt-text--' + size,
6
7
  { 'xt-text--bold': bold },
7
8
  { 'xt-text--money': money }
8
9
  ]"
@@ -27,6 +28,11 @@ export default {
27
28
  default: '',
28
29
  validator: (val) => ['', 'primary', 'success', 'warning', 'danger'].includes(val)
29
30
  },
31
+ size: {
32
+ type: String,
33
+ default: 'base',
34
+ validator: (val) => ['extra-large', 'large', 'medium', 'base', 'small', 'extra-small'].includes(val)
35
+ },
30
36
  bold: {
31
37
  type: Boolean,
32
38
  default: false
@@ -2,7 +2,32 @@
2
2
 
3
3
  // 文字组件
4
4
  .xt-text {
5
- letter-spacing: $xt-spacing-xs;
5
+ letter-spacing: normal;
6
+ }
7
+
8
+ // 字体大小 - 使用增量方式
9
+ .xt-text--extra-large {
10
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-extra-large);
11
+ }
12
+
13
+ .xt-text--large {
14
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-large);
15
+ }
16
+
17
+ .xt-text--medium {
18
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-medium);
19
+ }
20
+
21
+ .xt-text--base {
22
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-base);
23
+ }
24
+
25
+ .xt-text--small {
26
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-small);
27
+ }
28
+
29
+ .xt-text--extra-small {
30
+ font-size: calc(var(--xt-font-size-base) + $xt-font-size-increment-extra-small);
6
31
  }
7
32
 
8
33
  // 不同类型文字颜色
@@ -8,8 +8,8 @@ export const existingExComponents = [
8
8
  'Button', // ExButton 已存在
9
9
  'Card', // ExCard 已存在
10
10
  'Input', // XtInput 已存在(用户要求不自动注册)
11
- 'Table', // ExTable 已存在(在 xt-table 目录中)
12
- 'TableColumn', // ExColumn 已存在(在 xt-table 目录中)
11
+ 'Table', // ExTable 已存在(在 ex-table 目录中)
12
+ 'TableColumn', // ExColumn 已存在(在 ex-table 目录中)
13
13
  'Chart' // ExChart 已存在
14
14
  ]
15
15
 
package/src/index.js CHANGED
@@ -24,10 +24,12 @@ import XtCardItem from './components/xt-card-item'
24
24
  import XtConfigProvider from './components/xt-config-provider'
25
25
  import XtText from './components/xt-text'
26
26
  import XtGridBox from './components/xt-grid-box'
27
+ import XtGridItem from './components/xt-grid-item'
27
28
  import XtDatePicker from './components/xt-date-picker'
28
29
  import ExButton from './components/ex-button'
29
30
  import ExChart from './components/ex-chart' // ExChart 组件(基于 ECharts 封装)
30
31
  import ExCard from './components/ex-card'
32
+ import ExTable from './components/ex-table' // ExTable 组件(基于 ElementUI Table 封装)
31
33
 
32
34
  // 导入 Element UI 组件注册配置
33
35
  import { registerElementExComponents } from './config/element-registry'
@@ -42,10 +44,12 @@ const components = [
42
44
  XtConfigProvider,
43
45
  XtText,
44
46
  XtGridBox,
47
+ XtGridItem,
45
48
  XtDatePicker,
46
49
  ExButton,
47
50
  ExChart,
48
- ExCard
51
+ ExCard,
52
+ ExTable
49
53
  ]
50
54
 
51
55
  // 定义 install 方法,Vue.use() 会自动调用
@@ -124,9 +128,11 @@ export default {
124
128
  XtConfigProvider,
125
129
  XtText,
126
130
  XtGridBox,
131
+ XtGridItem,
127
132
  XtDatePicker,
128
133
  ExButton,
129
- ExCard
134
+ ExCard,
135
+ ExTable
130
136
  }
131
137
 
132
138
  // ExChart 组件按需导出(使用时需自行安装 echarts 依赖)
@@ -5,6 +5,9 @@ $xt-font-size-base: 14px; // 基准字体 - Element UI 默认
5
5
  $xt-font-size-small: 13px; // 小字体基础值
6
6
  $xt-font-size-extra-small: 12px; // 特小字体基础值
7
7
 
8
- $xt-font-size-increment-small: 0px; // 小尺寸增量
9
- $xt-font-size-increment-medium: 2px; // 中尺寸增量
10
- $xt-font-size-increment-large: 4px; // 大尺寸增量
8
+ $xt-font-size-increment-extra-small: -2px; // 特小尺寸增量
9
+ $xt-font-size-increment-small: -1px; // 小尺寸增量
10
+ $xt-font-size-increment-base: 0px; // 基准尺寸增量
11
+ $xt-font-size-increment-medium: 2px; // 中尺寸增量
12
+ $xt-font-size-increment-large: 4px; // 大尺寸增量
13
+ $xt-font-size-increment-extra-large: 6px; // 特大尺寸增量
File without changes