toggle-components-library 1.37.0-beta.5 → 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 +10 -127
- 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 +10 -127
- 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 -127
- 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,19 @@
|
|
|
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="updateContent($event)"
|
|
10
|
-
@keydown.enter.prevent="handleEnterKey"
|
|
11
|
-
@paste.prevent="handlePaste"
|
|
12
|
-
v-text="initialContent"
|
|
13
|
-
></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
|
+
|
|
27
17
|
mixins: [],
|
|
28
18
|
props: {
|
|
29
19
|
isNuxt: {
|
|
@@ -33,124 +23,21 @@ export default {
|
|
|
33
23
|
breadcrumb: {
|
|
34
24
|
type: Array,
|
|
35
25
|
required: false
|
|
36
|
-
},
|
|
37
|
-
editable: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false,
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
maxChars: {
|
|
43
|
-
type: Number,
|
|
44
|
-
default: 50,
|
|
45
|
-
required: false
|
|
46
26
|
}
|
|
47
27
|
},
|
|
48
28
|
|
|
49
|
-
data() {
|
|
50
|
-
return {
|
|
51
|
-
content: '',
|
|
52
|
-
initialContent: '',
|
|
53
|
-
lastSelection: null
|
|
54
|
-
};
|
|
55
|
-
},
|
|
29
|
+
data: function () {
|
|
56
30
|
|
|
57
|
-
computed: {
|
|
58
|
-
breadcrumb_computed() {
|
|
59
|
-
return this.isNuxt ? this.breadcrumb : this.$route.meta.breadcrumb;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
31
|
|
|
63
|
-
|
|
64
|
-
if (this.breadcrumb_computed && this.breadcrumb_computed.length > 0) {
|
|
65
|
-
const lastCrumb = this.breadcrumb_computed[this.breadcrumb_computed.length - 1];
|
|
66
|
-
this.content = lastCrumb.name;
|
|
67
|
-
this.initialContent = lastCrumb.name;
|
|
68
|
-
}
|
|
32
|
+
return {};
|
|
69
33
|
},
|
|
70
34
|
|
|
71
|
-
|
|
72
|
-
saveSelection() {
|
|
73
|
-
if (window.getSelection) {
|
|
74
|
-
const sel = window.getSelection();
|
|
75
|
-
if (sel.getRangeAt && sel.rangeCount) {
|
|
76
|
-
const range = sel.getRangeAt(0);
|
|
77
|
-
this.lastSelection = {
|
|
78
|
-
start: range.startOffset,
|
|
79
|
-
end: range.endOffset
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
restoreSelection() {
|
|
86
|
-
if (!this.lastSelection || !this.$refs.editableSpan) return;
|
|
87
|
-
|
|
88
|
-
const el = this.$refs.editableSpan;
|
|
89
|
-
if (!el.firstChild && typeof el.textContent === 'string') {
|
|
90
|
-
el.textContent = this.content || '';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const range = document.createRange();
|
|
95
|
-
const sel = window.getSelection();
|
|
96
|
-
const textNode = el.firstChild || el;
|
|
97
|
-
|
|
98
|
-
// Ensure we don't exceed the text length
|
|
99
|
-
const start = Math.min(this.lastSelection.start, textNode.length);
|
|
100
|
-
const end = Math.min(this.lastSelection.end, textNode.length);
|
|
101
|
-
|
|
102
|
-
range.setStart(textNode, start);
|
|
103
|
-
range.setEnd(textNode, end);
|
|
104
|
-
sel.removeAllRanges();
|
|
105
|
-
sel.addRange(range);
|
|
106
|
-
} catch (e) {
|
|
107
|
-
console.warn('Failed to restore selection:', e);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
handlePaste(event) {
|
|
112
|
-
const text = (event.clipboardData || window.clipboardData).getData('text');
|
|
113
|
-
const cleanText = text.replace(/[\r\n\s]+/g, ' ').trim();
|
|
114
|
-
|
|
115
|
-
this.saveSelection();
|
|
116
|
-
const selection = window.getSelection();
|
|
117
|
-
const selectionLength = selection.toString().length;
|
|
118
|
-
const currentLength = this.content.length;
|
|
119
|
-
|
|
120
|
-
if (currentLength - selectionLength + cleanText.length <= this.maxChars && selection.rangeCount) {
|
|
121
|
-
const range = selection.getRangeAt(0);
|
|
122
|
-
range.deleteContents();
|
|
123
|
-
range.insertNode(document.createTextNode(cleanText));
|
|
124
|
-
|
|
125
|
-
range.collapse(false);
|
|
126
|
-
selection.removeAllRanges();
|
|
127
|
-
selection.addRange(range);
|
|
128
|
-
|
|
129
|
-
this.content = event.target.innerText;
|
|
130
|
-
this.$emit('update:lastCrumb', this.content);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
35
|
+
computed: {
|
|
133
36
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
event.target.blur();
|
|
37
|
+
breadcrumb_computed() {
|
|
38
|
+
return this.isNuxt ? this.breadcrumb : this.$route.meta.breadcrumb
|
|
137
39
|
},
|
|
138
|
-
|
|
139
|
-
updateContent(event) {
|
|
140
|
-
this.saveSelection();
|
|
141
|
-
const newText = event.target.innerText;
|
|
142
|
-
|
|
143
|
-
if (newText.length > this.maxChars) {
|
|
144
|
-
event.target.innerText = this.content;
|
|
145
|
-
this.restoreSelection();
|
|
146
|
-
} else {
|
|
147
|
-
this.content = newText;
|
|
148
|
-
this.$emit('update:lastCrumb', this.content);
|
|
149
|
-
this.$nextTick(() => {
|
|
150
|
-
this.restoreSelection();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
40
|
}
|
|
155
|
-
|
|
41
|
+
|
|
42
|
+
}
|
|
156
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>
|