zartui 2.0.81 → 2.0.83

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/index.js CHANGED
@@ -71,13 +71,14 @@ import TabbarItem from './tabbar-item';
71
71
  import Table from './table';
72
72
  import Tabs from './tabs';
73
73
  import Tag from './tag';
74
+ import TextEllipsis from './text-ellipsis';
74
75
  import Timeline from './timeline';
75
76
  import Toast from './toast';
76
77
  import Uploader from './uploader';
77
- var version = '2.0.81';
78
+ var version = '2.0.83';
78
79
 
79
80
  function install(Vue) {
80
- var components = [ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, Timeline, Toast, Uploader];
81
+ var components = [ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, TextEllipsis, Timeline, Toast, Uploader];
81
82
  components.forEach(function (item) {
82
83
  if (item.install) {
83
84
  Vue.use(item);
@@ -91,7 +92,7 @@ if (typeof window !== 'undefined' && window.Vue) {
91
92
  install(window.Vue);
92
93
  }
93
94
 
94
- export { install, version, ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, Timeline, Toast, Uploader };
95
+ export { install, version, ActionSheet, Area, Avatar, BackTop, Badge, Button, Calendar, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Col, Collapse, CollapseItem, CountDown, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, FoldDialog, Form, Grid, GridItem, HierarchySelect, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, Lazyload, List, Loading, Locale, MediaPicker, MediaPlayer, MultiplePicker, NavBar, NoticeBar, NumberKeyboard, Overlay, PasswordInput, Picker, Popover, Popup, PullRefresh, Radio, RadioGroup, Rate, Row, Search, Signature, Skeleton, Slider, Step, Stepper, Steps, Sticky, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Table, Tabs, Tag, TextEllipsis, Timeline, Toast, Uploader };
95
96
  export default {
96
97
  install: install,
97
98
  version: version
package/es/table/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createNamespace } from '../utils';
3
3
  import Icon from '../icon/index';
4
+ import TextEllipsis from '../text-ellipsis/index';
4
5
  import { SortOrderEnum } from './type';
5
6
 
6
7
  var _createNamespace = createNamespace('table'),
@@ -24,6 +25,10 @@ export default createComponent({
24
25
  striped: {
25
26
  type: Boolean,
26
27
  default: false
28
+ },
29
+ hideTableHead: {
30
+ type: Boolean,
31
+ default: false
27
32
  }
28
33
  },
29
34
  data: function data() {
@@ -105,6 +110,9 @@ export default createComponent({
105
110
 
106
111
  var h = this.$createElement;
107
112
 
113
+ var _ref2 = this,
114
+ slots = _ref2.slots;
115
+
108
116
  if ((colData == null ? void 0 : colData.colSpan) !== 0) {
109
117
  return h("th", {
110
118
  "class": bem({
@@ -117,14 +125,19 @@ export default createComponent({
117
125
  "attrs": {
118
126
  "colspan": (colData == null ? void 0 : colData.colSpan) !== 1 ? colData == null ? void 0 : colData.colSpan : null
119
127
  }
120
- }, [h("div", {
128
+ }, [slots("head" + colData.id) || h("div", {
121
129
  "class": bem('head'),
122
130
  "on": {
123
131
  "click": function click() {
124
132
  return _this2.onHeaderClick(colData);
125
133
  }
126
134
  }
127
- }, [h("span", [colData.label]), colData.sorter ? h("span", {
135
+ }, [colData.ellipsis ? h(TextEllipsis, {
136
+ "attrs": {
137
+ "content": colData.label,
138
+ "expandType": "dialog"
139
+ }
140
+ }) : colData.label, colData.sorter ? h("span", {
128
141
  "class": bem('head-sort')
129
142
  }, [h(Icon, {
130
143
  "class": [colData.key === this.sortKey && this.sortOrder === SortOrderEnum.ASCEND ? bem('sort-active') : ''],
@@ -148,6 +161,23 @@ export default createComponent({
148
161
  }
149
162
  },
150
163
  onClick: function onClick() {},
164
+ getElement: function getElement(rowData, colData) {
165
+ var h = this.$createElement;
166
+
167
+ var _ref3 = this,
168
+ slots = _ref3.slots;
169
+
170
+ if (rowData[colData.key] && rowData[colData.key].id && slots("data" + rowData[colData.key].id)) {
171
+ return slots("data" + rowData[colData.key].id)[0];
172
+ }
173
+
174
+ return colData.ellipsis ? h(TextEllipsis, {
175
+ "attrs": {
176
+ "content": rowData[colData.key],
177
+ "expandType": "dialog"
178
+ }
179
+ }) : rowData[colData.key];
180
+ },
151
181
  getBody: function getBody(rowData, rowIndex) {
152
182
  var _this3 = this;
153
183
 
@@ -179,7 +209,7 @@ export default createComponent({
179
209
  "rowspan": ((_additionalCellProps5 = additionalCellProps) == null ? void 0 : _additionalCellProps5.rowSpan) !== 1 ? (_additionalCellProps6 = additionalCellProps) == null ? void 0 : _additionalCellProps6.rowSpan : null
180
210
  },
181
211
  "style": style
182
- }, [rowData[colData.key]]);
212
+ }, [_this3.getElement(rowData, colData)]);
183
213
  })]);
184
214
  }
185
215
  },
@@ -202,6 +232,10 @@ export default createComponent({
202
232
  }
203
233
  });
204
234
  })]), h("thead", {
235
+ "directives": [{
236
+ name: "show",
237
+ value: !this.hideTableHead
238
+ }],
205
239
  "class": bem('thead')
206
240
  }, [h("tr", [this.formatColumns.map(function (colData) {
207
241
  return _this4.getHead(colData);
@@ -1,4 +1,10 @@
1
1
  import '../../style/base.css';
2
+ import '../../overlay/index.css';
2
3
  import '../../info/index.css';
3
4
  import '../../icon/index.css';
5
+ import '../../popup/index.css';
6
+ import '../../loading/index.css';
7
+ import '../../button/index.css';
8
+ import '../../dialog/index.css';
9
+ import '../../text-ellipsis/index.css';
4
10
  import '../index.css';
@@ -1,4 +1,10 @@
1
1
  import '../../style/base.less';
2
+ import '../../overlay/index.less';
2
3
  import '../../info/index.less';
3
4
  import '../../icon/index.less';
5
+ import '../../popup/index.less';
6
+ import '../../loading/index.less';
7
+ import '../../button/index.less';
8
+ import '../../dialog/index.less';
9
+ import '../../text-ellipsis/index.less';
4
10
  import '../index.less';
@@ -0,0 +1 @@
1
+ .zt2-text-ellipsis{width:100%;line-height:calc(200% - 8px);white-space:pre-wrap;word-break:break-all}.zt2-text-ellipsis__action{cursor:pointer;color:#0091fa}
@@ -0,0 +1,213 @@
1
+ import { createNamespace } from '../utils';
2
+ import Dialog from '../dialog/index';
3
+
4
+ var _createNamespace = createNamespace('text-ellipsis'),
5
+ createComponent = _createNamespace[0],
6
+ bem = _createNamespace[1];
7
+
8
+ export default createComponent({
9
+ props: {
10
+ rows: {
11
+ type: Number,
12
+ default: 1
13
+ },
14
+ dots: {
15
+ type: String,
16
+ default: '...'
17
+ },
18
+ content: {
19
+ type: String,
20
+ default: ''
21
+ },
22
+ expandText: {
23
+ type: String,
24
+ default: '展开'
25
+ },
26
+ expandType: {
27
+ type: String,
28
+ default: 'flat'
29
+ },
30
+ collapseText: {
31
+ type: String,
32
+ default: '收起'
33
+ },
34
+ position: {
35
+ type: String,
36
+ default: 'end'
37
+ }
38
+ },
39
+ data: function data() {
40
+ return {
41
+ expanded: false,
42
+ ellipsis: false,
43
+ text: ''
44
+ };
45
+ },
46
+ computed: {
47
+ actionText: function actionText() {
48
+ return this.expanded ? this.collapseText : this.expandText;
49
+ },
50
+ propsData: function propsData() {
51
+ return {
52
+ content: this.content,
53
+ rows: this.rows,
54
+ position: this.position
55
+ };
56
+ }
57
+ },
58
+ watch: {
59
+ propsData: function propsData() {
60
+ this.calcEllipsised();
61
+ }
62
+ },
63
+ methods: {
64
+ pxToNum: function pxToNum(value) {
65
+ if (!value) return 0;
66
+ var match = value.match(/^\d*(\.\d*)?/);
67
+ return match ? Number(match[0]) : 0;
68
+ },
69
+ calcEllipsised: function calcEllipsised() {
70
+ var _this = this;
71
+
72
+ var root = this.$refs.root;
73
+
74
+ var cloneContainer = function cloneContainer() {
75
+ if (!root) return;
76
+ var originStyle = window.getComputedStyle(root);
77
+ var container = document.createElement('div');
78
+ var styleNames = Array.prototype.slice.apply(originStyle);
79
+ styleNames.forEach(function (name) {
80
+ container.style.setProperty(name, originStyle.getPropertyValue(name));
81
+ });
82
+ container.style.position = 'fixed';
83
+ container.style.zIndex = '-9999';
84
+ container.style.top = '-9999px';
85
+ container.style.height = 'auto';
86
+ container.style.minHeight = 'auto';
87
+ container.style.maxHeight = 'auto';
88
+ container.innerText = _this.content;
89
+ document.body.appendChild(container);
90
+ return container;
91
+ };
92
+
93
+ var calcEllipsisText = function calcEllipsisText(container, maxHeight) {
94
+ var content = _this.content,
95
+ position = _this.position,
96
+ dots = _this.dots;
97
+ var end = content.length;
98
+
99
+ var calcEllipse = function calcEllipse() {
100
+ // calculate the former or later content
101
+ var tail = function tail(left, right) {
102
+ if (right - left <= 1) {
103
+ if (position === 'end') {
104
+ return content.slice(0, left) + dots;
105
+ }
106
+
107
+ return dots + content.slice(right, end);
108
+ }
109
+
110
+ var middle = Math.round((left + right) / 2); // Set the interception location
111
+
112
+ if (position === 'end') {
113
+ container.innerText = content.slice(0, middle) + dots + _this.actionText;
114
+ } else {
115
+ container.innerText = dots + content.slice(middle, end) + _this.actionText;
116
+ } // The height after interception still does not match the required height
117
+
118
+
119
+ if (container.offsetHeight > maxHeight) {
120
+ if (position === 'end') {
121
+ return tail(left, middle);
122
+ }
123
+
124
+ return tail(middle, right);
125
+ }
126
+
127
+ if (position === 'end') {
128
+ return tail(middle, right);
129
+ }
130
+
131
+ return tail(left, middle);
132
+ };
133
+
134
+ container.innerText = tail(0, end);
135
+ };
136
+
137
+ var middleTail = function middleTail(leftPart, rightPart) {
138
+ if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
139
+ return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
140
+ }
141
+
142
+ var leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
143
+ var rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
144
+ container.innerText = _this.content.slice(0, leftMiddle) + _this.dots + _this.content.slice(rightMiddle, end) + _this.expandText;
145
+
146
+ if (container.offsetHeight >= maxHeight) {
147
+ return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
148
+ }
149
+
150
+ return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
151
+ };
152
+
153
+ var middle = 0 + end >> 1;
154
+ _this.position === 'middle' ? container.innerText = middleTail([0, middle], [middle, end]) : calcEllipse();
155
+ return container.innerText;
156
+ }; // Calculate the interceptional text
157
+
158
+
159
+ var container = cloneContainer();
160
+ if (!container) return;
161
+ var _container$style = container.style,
162
+ paddingBottom = _container$style.paddingBottom,
163
+ paddingTop = _container$style.paddingTop,
164
+ lineHeight = _container$style.lineHeight;
165
+ var maxHeight = Math.ceil((Number(this.rows) + 0.5) * this.pxToNum(lineHeight) + this.pxToNum(paddingTop) + this.pxToNum(paddingBottom));
166
+
167
+ if (maxHeight < container.offsetHeight) {
168
+ this.ellipsis = true;
169
+ this.text = calcEllipsisText(container, maxHeight);
170
+ } else {
171
+ this.text = this.content;
172
+ this.ellipsis = false;
173
+ }
174
+
175
+ document.body.removeChild(container);
176
+ },
177
+ onClickAction: function onClickAction(event) {
178
+ event.stopPropagation();
179
+ event.preventDefault();
180
+ this.expanded = !this.expanded; // emit('clickAction', event);
181
+ },
182
+ renderAction: function renderAction() {
183
+ var h = this.$createElement;
184
+ return h("span", {
185
+ "class": bem('action'),
186
+ "on": {
187
+ "click": this.onClickAction
188
+ }
189
+ }, [this.actionText]);
190
+ },
191
+ onClick: function onClick() {
192
+ if (this.ellipsis && this.expandType === 'dialog') {
193
+ Dialog.alert({
194
+ message: this.content
195
+ }).then(function () {});
196
+ }
197
+ }
198
+ },
199
+ mounted: function mounted() {
200
+ this.calcEllipsised();
201
+ window.addEventListener("resize", this.calcEllipsised);
202
+ },
203
+ render: function render() {
204
+ var h = arguments[0];
205
+ return h("div", {
206
+ "ref": "root",
207
+ "class": bem(),
208
+ "on": {
209
+ "click": this.onClick
210
+ }
211
+ }, [this.expanded ? this.content : this.text, this.expandType !== 'dialog' && this.ellipsis ? this.renderAction() : null]);
212
+ }
213
+ });
@@ -0,0 +1,13 @@
1
+ @import '../style/var';
2
+
3
+ .@{base-prefix}-text-ellipsis {
4
+ width: 100%;
5
+ line-height: calc(200% - 8px);
6
+ white-space: pre-wrap;
7
+ word-break: break-all;
8
+
9
+ &__action {
10
+ cursor: pointer;
11
+ color: #0091FA;
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ import '../../style/base.css';
2
+ import '../../overlay/index.css';
3
+ import '../../info/index.css';
4
+ import '../../icon/index.css';
5
+ import '../../popup/index.css';
6
+ import '../../loading/index.css';
7
+ import '../../button/index.css';
8
+ import '../../dialog/index.css';
9
+ import '../index.css';
@@ -0,0 +1,9 @@
1
+ import '../../style/base.less';
2
+ import '../../overlay/index.less';
3
+ import '../../info/index.less';
4
+ import '../../icon/index.less';
5
+ import '../../popup/index.less';
6
+ import '../../loading/index.less';
7
+ import '../../button/index.less';
8
+ import '../../dialog/index.less';
9
+ import '../index.less';
@@ -2,8 +2,7 @@
2
2
  * Vue Router support
3
3
  */
4
4
  function isRedundantNavigation(err) {
5
- return err.name === 'NavigationDuplicated' || // compatible with vue-router@3.3
6
- err.message && err.message.indexOf('redundant navigation') !== -1;
5
+ return err.name === 'NavigationDuplicated' || err.message && err.message.indexOf('redundant navigation') !== -1;
7
6
  }
8
7
 
9
8
  export function route(router, config) {