toggle-components-library 1.37.0-beta.6 → 1.37.0-beta.7
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 +11 -121
- 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 +11 -121
- 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 +14 -121
- package/src/sass/includes/_as_breadcrumb.scss +0 -42
- package/dist/img/edit-icon.9a5af324.svg +0 -1
package/package.json
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toggle-breadcrumb" v-if="breadcrumb_computed">
|
|
3
3
|
<div v-for="(crumb, index) in breadcrumb_computed" :key="index">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class="toggle-breadcrumb-editable-input"
|
|
9
|
-
@input="handleInput"
|
|
10
|
-
@keypress="handleKeypress"
|
|
11
|
-
@keydown.enter.prevent="handleEnterKey"
|
|
12
|
-
@paste.prevent="handlePaste"
|
|
13
|
-
>{{ crumb.name }}</span>
|
|
14
|
-
</template>
|
|
15
|
-
<template v-else>
|
|
16
|
-
<router-link :to="{ name: crumb.link}" class="back-product" v-if="crumb.link && !isNuxt">{{ crumb.name }}</router-link>
|
|
17
|
-
<NuxtLink :to="{ name: crumb.link}" class="back-product" v-if="crumb.link && isNuxt">{{ crumb.name }}</NuxtLink>
|
|
18
|
-
<i class="toggle-breadcrumb-arrow-right" v-if="crumb.link"></i>
|
|
19
|
-
<h1 class="toggle-breadcrumb-h1" v-if="!crumb.link">{{ crumb.name }}</h1>
|
|
20
|
-
</template>
|
|
4
|
+
<router-link :to="{ name: crumb.link}" class="back-product" v-if="crumb.link && !isNuxt">{{ crumb.name }}</router-link>
|
|
5
|
+
<NuxtLink :to="{ name: crumb.link}" class="back-product" v-if="crumb.link && isNuxt">{{ crumb.name }}</NuxtLink>
|
|
6
|
+
<i class="toggle-breadcrumb-arrow-right" v-if="crumb.link"></i>
|
|
7
|
+
<h1 class="toggle-breadcrumb-h1" v-if="!crumb.link">{{ crumb.name }}</h1>
|
|
21
8
|
</div>
|
|
22
9
|
</div>
|
|
23
10
|
</template>
|
|
24
11
|
|
|
25
12
|
<script>
|
|
13
|
+
|
|
14
|
+
|
|
26
15
|
export default {
|
|
16
|
+
|
|
17
|
+
mixins: [],
|
|
27
18
|
props: {
|
|
28
19
|
isNuxt: {
|
|
29
20
|
type: Boolean,
|
|
@@ -32,119 +23,21 @@ export default {
|
|
|
32
23
|
breadcrumb: {
|
|
33
24
|
type: Array,
|
|
34
25
|
required: false
|
|
35
|
-
},
|
|
36
|
-
editable: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false,
|
|
39
|
-
required: false
|
|
40
|
-
},
|
|
41
|
-
maxChars: {
|
|
42
|
-
type: Number,
|
|
43
|
-
default: 50,
|
|
44
|
-
required: false
|
|
45
26
|
}
|
|
46
27
|
},
|
|
47
28
|
|
|
48
|
-
data() {
|
|
49
|
-
return {
|
|
50
|
-
lastValidContent: ''
|
|
51
|
-
}
|
|
52
|
-
},
|
|
29
|
+
data: function () {
|
|
53
30
|
|
|
54
|
-
computed: {
|
|
55
|
-
breadcrumb_computed() {
|
|
56
|
-
return this.isNuxt ? this.breadcrumb : this.$route.meta.breadcrumb;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
31
|
|
|
60
|
-
|
|
61
|
-
this.updateContent();
|
|
32
|
+
return {};
|
|
62
33
|
},
|
|
63
34
|
|
|
64
|
-
|
|
65
|
-
updateContent() {
|
|
66
|
-
if (this.$refs.editableSpan && this.breadcrumb_computed?.length) {
|
|
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
|
-
},
|
|
35
|
+
computed: {
|
|
113
36
|
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
}
|
|
37
|
+
breadcrumb_computed() {
|
|
38
|
+
return this.isNuxt ? this.breadcrumb : this.$route.meta.breadcrumb
|
|
133
39
|
},
|
|
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
|
|
147
|
-
}
|
|
148
40
|
}
|
|
41
|
+
|
|
149
42
|
}
|
|
150
43
|
</script>
|
|
@@ -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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#abb7c5"><path d="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z"/></svg>
|