toggle-components-library 1.37.0-beta.6 → 1.37.0-beta.8
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/dist/toggle-components-library.common.js +91 -187
- package/dist/toggle-components-library.common.js.map +1 -1
- package/dist/toggle-components-library.css +1 -1
- package/dist/toggle-components-library.umd.js +91 -187
- package/dist/toggle-components-library.umd.js.map +1 -1
- package/dist/toggle-components-library.umd.min.js +110 -110
- package/dist/toggle-components-library.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/breadcrumb/ToggleBreadCrumb.vue +9 -112
- package/src/sass/includes/_as_breadcrumb.scss +23 -43
package/package.json
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="toggle-breadcrumb" v-if="breadcrumb_computed">
|
|
2
|
+
<div :class="['toggle-breadcrumb']" v-if="breadcrumb_computed">
|
|
3
3
|
<div v-for="(crumb, index) in breadcrumb_computed" :key="index">
|
|
4
4
|
<template v-if="index === breadcrumb_computed.length - 1 && editable">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@input="handleInput"
|
|
10
|
-
@keypress="handleKeypress"
|
|
11
|
-
@keydown.enter.prevent="handleEnterKey"
|
|
12
|
-
@paste.prevent="handlePaste"
|
|
13
|
-
>{{ crumb.name }}</span>
|
|
5
|
+
<div class="toggle-breadcrumb-last-element-container">
|
|
6
|
+
<h1 class="toggle-breadcrumb-h1 toggle-breadcrumb-last-element">{{ crumb.name }}</h1>
|
|
7
|
+
<div v-if="editable" class="toggle-breadcrumb-edit-icon" @click="editClicked"></div>
|
|
8
|
+
</div>
|
|
14
9
|
</template>
|
|
15
10
|
<template v-else>
|
|
16
11
|
<router-link :to="{ name: crumb.link}" class="back-product" v-if="crumb.link && !isNuxt">{{ crumb.name }}</router-link>
|
|
@@ -35,115 +30,17 @@ export default {
|
|
|
35
30
|
},
|
|
36
31
|
editable: {
|
|
37
32
|
type: Boolean,
|
|
38
|
-
default: false
|
|
39
|
-
required: false
|
|
40
|
-
},
|
|
41
|
-
maxChars: {
|
|
42
|
-
type: Number,
|
|
43
|
-
default: 50,
|
|
44
|
-
required: false
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
data() {
|
|
49
|
-
return {
|
|
50
|
-
lastValidContent: ''
|
|
33
|
+
default: false
|
|
51
34
|
}
|
|
52
35
|
},
|
|
53
|
-
|
|
54
36
|
computed: {
|
|
55
37
|
breadcrumb_computed() {
|
|
56
|
-
return this.isNuxt ?
|
|
38
|
+
return this.isNuxt ? this.breadcrumb : this.$route.meta.breadcrumb
|
|
57
39
|
}
|
|
58
40
|
},
|
|
59
|
-
|
|
60
|
-
mounted() {
|
|
61
|
-
this.updateContent();
|
|
62
|
-
},
|
|
63
|
-
|
|
64
41
|
methods: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const lastCrumb = this.breadcrumb_computed[this.breadcrumb_computed.length - 1];
|
|
68
|
-
if (this.$refs.editableSpan.textContent !== lastCrumb.name) {
|
|
69
|
-
this.$refs.editableSpan.textContent = lastCrumb.name;
|
|
70
|
-
this.lastValidContent = lastCrumb.name;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
handleKeypress(event) {
|
|
76
|
-
if (event.key.length !== 1) return;
|
|
77
|
-
|
|
78
|
-
const currentLength = this.$refs.editableSpan.textContent.length;
|
|
79
|
-
const selection = window.getSelection();
|
|
80
|
-
const selectedLength = selection.toString().length;
|
|
81
|
-
|
|
82
|
-
if (currentLength - selectedLength >= this.maxChars) {
|
|
83
|
-
event.preventDefault();
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
handleInput(event) {
|
|
89
|
-
const newText = event.target.textContent;
|
|
90
|
-
|
|
91
|
-
if (newText.length <= this.maxChars) {
|
|
92
|
-
this.lastValidContent = newText;
|
|
93
|
-
this.$emit('update:lastCrumb', newText);
|
|
94
|
-
} else {
|
|
95
|
-
// Get cursor position before restoring text
|
|
96
|
-
const selection = window.getSelection();
|
|
97
|
-
const cursorPosition = selection.getRangeAt(0).startOffset;
|
|
98
|
-
|
|
99
|
-
// Restore previous content
|
|
100
|
-
event.target.textContent = this.lastValidContent;
|
|
101
|
-
|
|
102
|
-
// Restore cursor position
|
|
103
|
-
const range = document.createRange();
|
|
104
|
-
const textNode = event.target.firstChild;
|
|
105
|
-
if (textNode) {
|
|
106
|
-
range.setStart(textNode, Math.min(cursorPosition, this.lastValidContent.length));
|
|
107
|
-
range.collapse(true);
|
|
108
|
-
selection.removeAllRanges();
|
|
109
|
-
selection.addRange(range);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
handlePaste(event) {
|
|
115
|
-
event.preventDefault();
|
|
116
|
-
const text = (event.clipboardData || window.clipboardData).getData('text');
|
|
117
|
-
const cleanText = text.replace(/[\r\n\s]+/g, ' ').trim();
|
|
118
|
-
|
|
119
|
-
const selection = window.getSelection();
|
|
120
|
-
const range = selection.getRangeAt(0);
|
|
121
|
-
const currentLength = this.$refs.editableSpan.textContent.length;
|
|
122
|
-
const selectionLength = selection.toString().length;
|
|
123
|
-
|
|
124
|
-
const availableSpace = this.maxChars - (currentLength - selectionLength);
|
|
125
|
-
if (availableSpace > 0) {
|
|
126
|
-
const truncatedText = cleanText.slice(0, availableSpace);
|
|
127
|
-
range.deleteContents();
|
|
128
|
-
range.insertNode(document.createTextNode(truncatedText));
|
|
129
|
-
range.collapse(false);
|
|
130
|
-
this.lastValidContent = this.$refs.editableSpan.textContent;
|
|
131
|
-
this.$emit('update:lastCrumb', this.lastValidContent);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
handleEnterKey(event) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
event.target.blur();
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
watch: {
|
|
142
|
-
'breadcrumb_computed': {
|
|
143
|
-
handler() {
|
|
144
|
-
this.$nextTick(this.updateContent);
|
|
145
|
-
},
|
|
146
|
-
deep: true
|
|
42
|
+
editClicked() {
|
|
43
|
+
this.$emit('edit-clicked')
|
|
147
44
|
}
|
|
148
45
|
}
|
|
149
46
|
}
|
|
@@ -10,48 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.toggle-breadcrumb-editable-input {
|
|
14
|
-
font-size: $toggle-font-size-extra-large;
|
|
15
|
-
font-family: "DIN-2014","Lato",sans-serif;
|
|
16
|
-
color: $toggle-black;
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
display: inline-flex;
|
|
19
|
-
align-items: center;
|
|
20
|
-
min-width: 5rem !important;
|
|
21
|
-
height: 2rem;
|
|
22
|
-
padding-right: 0.5rem;
|
|
23
|
-
padding-left: 10px;
|
|
24
|
-
border: none;
|
|
25
|
-
border-radius: 4px;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
line-height: 1;
|
|
28
|
-
border: 1px solid transparent;
|
|
29
|
-
margin: -1px 0 0 -10px;
|
|
30
|
-
white-space: nowrap
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.toggle-breadcrumb-editable-input:hover {
|
|
34
|
-
border: 1px solid #ccc;
|
|
35
|
-
background-color: $toggle-off-white;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.toggle-breadcrumb-editable-input:focus {
|
|
39
|
-
border: 1px solid #ccc;
|
|
40
|
-
background-color: $toggle-off-white;
|
|
41
|
-
outline: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.toggle-breadcrumb-editable-input::after {
|
|
45
|
-
content: '';
|
|
46
|
-
background-image: url('../assets/icons/edit-icon.svg');
|
|
47
|
-
background-repeat:no-repeat;
|
|
48
|
-
background-size:contain;
|
|
49
|
-
height: 22px;
|
|
50
|
-
width: 22px;
|
|
51
|
-
margin: 0 0 0 10px;
|
|
52
|
-
cursor: text;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
13
|
a {
|
|
56
14
|
|
|
57
15
|
font-size: $toggle-font-size-extra-large;
|
|
@@ -78,4 +36,26 @@
|
|
|
78
36
|
transform: rotate(-45deg);
|
|
79
37
|
-webkit-transform: rotate(-45deg);
|
|
80
38
|
}
|
|
81
|
-
|
|
39
|
+
.toggle-breadcrumb-last-element-container {
|
|
40
|
+
display: flex;
|
|
41
|
+
|
|
42
|
+
.toggle-breadcrumb-last-element {
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
.toggle-breadcrumb-edit-icon {
|
|
46
|
+
margin: 4px 0 0 0;
|
|
47
|
+
background-image: url('../assets/icons/edit-icon.svg');
|
|
48
|
+
background-repeat:no-repeat;
|
|
49
|
+
background-size:contain;
|
|
50
|
+
height: 22px;
|
|
51
|
+
width: 22px;
|
|
52
|
+
margin-left: 15px;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
transition: 0.2s;
|
|
55
|
+
}
|
|
56
|
+
.toggle-breadcrumb-edit-icon:hover {
|
|
57
|
+
filter: invert(0.5) sepia(1) saturate(3) hue-rotate(180deg);
|
|
58
|
+
transform: scale(1.1) rotate(-10deg);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|