zartui 2.0.81 → 2.0.82

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.82';
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'),
@@ -124,7 +125,12 @@ export default createComponent({
124
125
  return _this2.onHeaderClick(colData);
125
126
  }
126
127
  }
127
- }, [h("span", [colData.label]), colData.sorter ? h("span", {
128
+ }, [colData.ellipsis ? h(TextEllipsis, {
129
+ "attrs": {
130
+ "content": colData.label,
131
+ "expandType": "dialog"
132
+ }
133
+ }) : colData.label, colData.sorter ? h("span", {
128
134
  "class": bem('head-sort')
129
135
  }, [h(Icon, {
130
136
  "class": [colData.key === this.sortKey && this.sortOrder === SortOrderEnum.ASCEND ? bem('sort-active') : ''],
@@ -179,7 +185,12 @@ export default createComponent({
179
185
  "rowspan": ((_additionalCellProps5 = additionalCellProps) == null ? void 0 : _additionalCellProps5.rowSpan) !== 1 ? (_additionalCellProps6 = additionalCellProps) == null ? void 0 : _additionalCellProps6.rowSpan : null
180
186
  },
181
187
  "style": style
182
- }, [rowData[colData.key]]);
188
+ }, [colData.ellipsis ? h(TextEllipsis, {
189
+ "attrs": {
190
+ "content": rowData[colData.key],
191
+ "expandType": "dialog"
192
+ }
193
+ }) : rowData[colData.key]]);
183
194
  })]);
184
195
  }
185
196
  },
@@ -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) {