vue-string-directives 0.1.0 → 1.0.0
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/LICENSE +2 -2
- package/README.md +41 -87
- package/dist/vue-string-directives.js +139 -0
- package/dist/vue-string-directives.umd.cjs +1 -0
- package/package.json +21 -20
- package/.browserslistrc +0 -18
- package/dist/.eslintrc.js +0 -13
- package/dist/vue-string-directives.common.js +0 -312
- package/dist/vue-string-directives.esm.js +0 -298
- package/dist/vue-string-directives.umd.js +0 -318
- package/dist/vue-string-directives.umd.min.js +0 -1
- package/dist/vue-string-directives.zip +0 -0
- package/rollup.config.dev.js +0 -3
- package/rollup.config.js +0 -39
- package/rollup.config.prod.js +0 -3
- package/src/.babelrc.json +0 -5
- package/src/directives/camel.js +0 -24
- package/src/directives/capitalize.js +0 -9
- package/src/directives/kebab.js +0 -15
- package/src/directives/lower.js +0 -11
- package/src/directives/pad.js +0 -30
- package/src/directives/repeat.js +0 -13
- package/src/directives/replace.js +0 -7
- package/src/directives/snake.js +0 -15
- package/src/directives/truncate.js +0 -26
- package/src/directives/upper.js +0 -19
- package/src/helpers/kebabWords.js +0 -7
- package/src/helpers/pad.js +0 -4
- package/src/helpers/snakeWords.js +0 -7
- package/src/helpers/truncate.js +0 -3
- package/src/helpers/upperEvery.js +0 -7
- package/src/helpers/upperFirst.js +0 -8
- package/src/helpers/words.js +0 -7
- package/src/index.js +0 -46
- package/src/mixins/StringDirectivesMixin.js +0 -25
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020
|
|
3
|
+
Copyright (c) 2020-2026 Tarkhov
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,16 +5,13 @@ Vue string directives library can change form input value dynamically. All langu
|
|
|
5
5
|
### Contents
|
|
6
6
|
|
|
7
7
|
1. [Compatibility](#compatibility)
|
|
8
|
-
1. [Version support](#version-support)
|
|
9
8
|
2. [Installation](#installation)
|
|
10
9
|
1. [NodeJS](#nodejs)
|
|
11
10
|
2. [Manually](#manually)
|
|
12
11
|
3. [Usage](#usage)
|
|
13
12
|
1. [CLI](#cli)
|
|
14
|
-
2. [
|
|
15
|
-
|
|
16
|
-
4. [CDN](#cdn)
|
|
17
|
-
4. [Directives](#directives)
|
|
13
|
+
2. [CDN](#cdn)
|
|
14
|
+
4. [Examples](#examples)
|
|
18
15
|
5. [Author](#author)
|
|
19
16
|
6. [License](#license)
|
|
20
17
|
|
|
@@ -22,15 +19,7 @@ Vue string directives library can change form input value dynamically. All langu
|
|
|
22
19
|
|
|
23
20
|
Library | Version
|
|
24
21
|
------- | -------
|
|
25
|
-
Vue | >=
|
|
26
|
-
|
|
27
|
-
We support browsers with ECMAScript 5 features, IE 10 and higher, more details can be founded here https://caniuse.com/es5 and here https://vuejs.org/v2/guide/installation.html#Compatibility-Note.
|
|
28
|
-
|
|
29
|
-
### Version support
|
|
30
|
-
|
|
31
|
-
Vue | Repo
|
|
32
|
-
------- | -------
|
|
33
|
-
2.x | [0.x](https://github.com/tarkhov/vue-string-directives/tree/0.x)
|
|
22
|
+
Vue | >= 3.5
|
|
34
23
|
|
|
35
24
|
## Installation
|
|
36
25
|
|
|
@@ -42,10 +31,10 @@ npm install vue-string-directives
|
|
|
42
31
|
|
|
43
32
|
### Manually
|
|
44
33
|
|
|
45
|
-
[Download](https://github.com/tarkhov/vue-string-directives/releases/download/
|
|
34
|
+
[Download](https://github.com/tarkhov/vue-string-directives/releases/download/v1.0.0/vue-string-directives.zip) package and unpack it or use following commands:
|
|
46
35
|
|
|
47
36
|
```bash
|
|
48
|
-
wget https://github.com/tarkhov/vue-string-directives/releases/download/
|
|
37
|
+
wget https://github.com/tarkhov/vue-string-directives/releases/download/v1.0.0/vue-string-directives.zip
|
|
49
38
|
unzip vue-string-directives.zip
|
|
50
39
|
```
|
|
51
40
|
|
|
@@ -56,33 +45,21 @@ unzip vue-string-directives.zip
|
|
|
56
45
|
Add following code to your `main.js` file created by Vue CLI:
|
|
57
46
|
|
|
58
47
|
```js
|
|
59
|
-
import
|
|
60
|
-
|
|
61
|
-
Vue.use(VueStringDirectives)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Your `main.js` will look like this:
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
import Vue from 'vue'
|
|
48
|
+
import { createApp } from 'vue'
|
|
49
|
+
import { VueStringDirectives } from 'vue-string-directives'
|
|
68
50
|
import App from './App.vue'
|
|
69
|
-
import VueStringDirectives from 'vue-string-directives'
|
|
70
|
-
|
|
71
|
-
Vue.use(VueStringDirectives)
|
|
72
|
-
|
|
73
|
-
Vue.config.productionTip = false
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
const app = createApp(App)
|
|
53
|
+
app.use(VueStringDirectives)
|
|
54
|
+
app.mount('#app')
|
|
78
55
|
```
|
|
79
56
|
|
|
80
57
|
Alternatively you can use a specific directive to import it into a specific component:
|
|
81
58
|
|
|
82
59
|
```js
|
|
83
60
|
import { upper, lower } from 'vue-string-directives'
|
|
61
|
+
|
|
84
62
|
export default {
|
|
85
|
-
name: 'MyComponent',
|
|
86
63
|
directives: {
|
|
87
64
|
upper,
|
|
88
65
|
lower
|
|
@@ -94,51 +71,12 @@ Also you can import all directives to component:
|
|
|
94
71
|
|
|
95
72
|
```js
|
|
96
73
|
import { StringDirectivesMixin } from 'vue-string-directives'
|
|
74
|
+
|
|
97
75
|
export default {
|
|
98
|
-
name: 'MyComponent',
|
|
99
76
|
mixins: [StringDirectivesMixin]
|
|
100
77
|
}
|
|
101
78
|
```
|
|
102
79
|
|
|
103
|
-
### Nuxt
|
|
104
|
-
|
|
105
|
-
If you are using nuxt, you need to create a file **vue-string-directives.js** in the plugins folder of your nuxt project with the following content:
|
|
106
|
-
|
|
107
|
-
```js
|
|
108
|
-
import Vue from 'vue'
|
|
109
|
-
import VueStringDirectives from 'vue-string-directives'
|
|
110
|
-
|
|
111
|
-
Vue.use(VueStringDirectives)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Then add the following lines to the nuxt.config.js:
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
plugins: [
|
|
118
|
-
{ src: '~plugins/vue-string-directives' }
|
|
119
|
-
]
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Local
|
|
123
|
-
|
|
124
|
-
```html
|
|
125
|
-
<!doctype html>
|
|
126
|
-
<html lang="en">
|
|
127
|
-
<head>
|
|
128
|
-
<meta charset="utf-8">
|
|
129
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
130
|
-
|
|
131
|
-
<title>Vue string directives</title>
|
|
132
|
-
</head>
|
|
133
|
-
<body>
|
|
134
|
-
<div id="app"></div>
|
|
135
|
-
|
|
136
|
-
<script src="dist/vue.min.js"></script>
|
|
137
|
-
<script src="vue-string-directives.umd.min.js"></script>
|
|
138
|
-
</body>
|
|
139
|
-
</html>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
80
|
### CDN
|
|
143
81
|
|
|
144
82
|
```html
|
|
@@ -146,36 +84,42 @@ plugins: [
|
|
|
146
84
|
<html lang="en">
|
|
147
85
|
<head>
|
|
148
86
|
<meta charset="utf-8">
|
|
149
|
-
<meta name="viewport" content="width=device-width, initial-scale=1
|
|
150
|
-
|
|
87
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
151
88
|
<title>Vue string directives</title>
|
|
152
89
|
</head>
|
|
153
90
|
<body>
|
|
154
91
|
<div id="app"></div>
|
|
155
|
-
|
|
156
|
-
<script src="https://cdn.
|
|
157
|
-
<script src="https://cdn.rawgit.com/tarkhov/vue-string-directives/v0.1.0/dist/vue-string-directives.umd.min.js"></script>
|
|
92
|
+
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
93
|
+
<script src="https://cdn.rawgit.com/tarkhov/vue-string-directives/v1.0.0/dist/vue-string-directives.umd.cjs"></script>
|
|
158
94
|
</body>
|
|
159
95
|
</html>
|
|
160
96
|
```
|
|
161
97
|
|
|
162
|
-
##
|
|
98
|
+
## Examples
|
|
163
99
|
|
|
164
100
|
Letter case.
|
|
165
101
|
|
|
166
102
|
```html
|
|
167
103
|
<!-- Uppercase -->
|
|
104
|
+
<!-- Input: uppercase. Output: UPPERCASE. -->
|
|
168
105
|
<input type="text" v-model="text" v-upper>
|
|
106
|
+
<!-- Input: uppercase. Output: Uppercase. -->
|
|
169
107
|
<input type="text" v-model="text" v-upper.first>
|
|
108
|
+
<!-- Input: uppercase. Output: Uppercase. -->
|
|
170
109
|
<input type="text" v-model="text" v-upper.first.capitalize>
|
|
110
|
+
<!-- Input: uppercase one two three. Output: Uppercase One Two Three. -->
|
|
171
111
|
<input type="text" v-model="text" v-upper.first.every>
|
|
112
|
+
<!-- Input: uppercase one two three. Output: Uppercase One Two Three. -->
|
|
172
113
|
<input type="text" v-model="text" v-upper.first.capitalize.every>
|
|
173
114
|
|
|
174
115
|
<!-- Lowercase -->
|
|
116
|
+
<!-- Input: UPPERCASE. Output: uppercase. -->
|
|
175
117
|
<input type="text" v-model="text" v-lower>
|
|
118
|
+
<!-- Input: UPPERCASE. Output: uPPERCASE. -->
|
|
176
119
|
<input type="text" v-model="text" v-lower.first>
|
|
177
120
|
|
|
178
121
|
<!-- Capitalize -->
|
|
122
|
+
<!-- Input: uppercase. Output: Uppercase. -->
|
|
179
123
|
<input type="text" v-model="text" v-capitalize>
|
|
180
124
|
```
|
|
181
125
|
|
|
@@ -183,47 +127,57 @@ Word case.
|
|
|
183
127
|
|
|
184
128
|
```html
|
|
185
129
|
<!-- Camelcase -->
|
|
130
|
+
<!-- Input: camel case. Output: camelCase. -->
|
|
186
131
|
<input type="text" v-model="text" v-camel>
|
|
132
|
+
<!-- Input: camel case. Output: CamelCase. -->
|
|
187
133
|
<input type="text" v-model="text" v-camel.first>
|
|
134
|
+
<!-- Input: camel 123 case. Output: camel123Case. -->
|
|
188
135
|
<input type="text" v-model="text" v-camel.numbers>
|
|
136
|
+
<!-- Input: camel 123 case. Output: Camel123Case. -->
|
|
189
137
|
<input type="text" v-model="text" v-camel.first.numbers>
|
|
190
138
|
|
|
191
139
|
<!-- Kebabcase -->
|
|
140
|
+
<!-- Input: kebab case. Output: kebab-case. -->
|
|
192
141
|
<input type="text" v-model="text" v-kebab>
|
|
142
|
+
<!-- Input: kebab 123 case. Output: kebab-123-case. -->
|
|
193
143
|
<input type="text" v-model="text" v-kebab.numbers>
|
|
194
144
|
|
|
195
145
|
<!-- Snakecase -->
|
|
146
|
+
<!-- Input: snake case. Output: snake_case. -->
|
|
196
147
|
<input type="text" v-model="text" v-snake>
|
|
148
|
+
<!-- Input: snake 123 case. Output: snake_123_case. -->
|
|
197
149
|
<input type="text" v-model="text" v-snake.numbers>
|
|
198
150
|
```
|
|
199
151
|
|
|
200
|
-
|
|
152
|
+
Replacing.
|
|
201
153
|
|
|
202
154
|
```html
|
|
203
155
|
<!-- Pad -->
|
|
156
|
+
<!-- Input: pad. Output: ___pad____. -->
|
|
204
157
|
<input type="text" v-model="text" v-pad:10="_">
|
|
158
|
+
<!-- Input: pad. Output: _________pad. -->
|
|
205
159
|
<input type="text" v-model="text" v-pad:10.start="_">
|
|
160
|
+
<!-- Input: pad. Output: pad_______. -->
|
|
206
161
|
<input type="text" v-model="text" v-pad:10.end="_">
|
|
207
162
|
|
|
208
163
|
<!-- Repeat -->
|
|
164
|
+
<!-- Input: repeat. Output: repeat-----. -->
|
|
209
165
|
<input type="text" v-model="text" v-repeat:5="-">
|
|
210
166
|
|
|
211
167
|
<!-- Replace -->
|
|
168
|
+
<!-- Input: replace123. Output: replace---. -->
|
|
212
169
|
<input type="text" v-model="text" v-replace="{ regexp: '[0-9]', flags: 'g', string: '-' }">
|
|
213
170
|
|
|
214
171
|
<!-- Truncate -->
|
|
172
|
+
<!-- Input: truncate. Output: trunc... -->
|
|
215
173
|
<input type="text" v-model="text" v-truncate:5="'...'">
|
|
216
174
|
```
|
|
217
175
|
|
|
218
176
|
## Author
|
|
219
177
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
* [Facebook](https://www.facebook.com/alextarkhov)
|
|
223
|
-
* [Twitter](https://twitter.com/alextarkhov)
|
|
178
|
+
* [Twitter](https://x.com/tarkhovich)
|
|
224
179
|
* [Medium](https://medium.com/@tarkhov)
|
|
225
|
-
* [LinkedIn](https://www.linkedin.com/in/tarkhov/)
|
|
226
180
|
|
|
227
181
|
## License
|
|
228
182
|
|
|
229
|
-
This project is licensed under the **MIT License** - see the `LICENSE` file for details.
|
|
183
|
+
This project is licensed under the **MIT License** - see the `LICENSE` file for details.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
function r(t, e = !1) {
|
|
2
|
+
let u = t.charAt(0).toUpperCase(), a = t.slice(1);
|
|
3
|
+
return e && (a = a.toLowerCase()), `${u}${a}`;
|
|
4
|
+
}
|
|
5
|
+
function d(t, e = !1) {
|
|
6
|
+
return e ? t.match(/[\p{L}\p{N}]+/gu) : t.match(/[\p{L}]+/gu);
|
|
7
|
+
}
|
|
8
|
+
const v = {
|
|
9
|
+
updated: function(t, e) {
|
|
10
|
+
if (t.value.length && (typeof e.value > "u" || e.value)) {
|
|
11
|
+
let u = d(t.value, e.modifiers?.numbers || e.value?.numbers);
|
|
12
|
+
if (u.length > 1) {
|
|
13
|
+
if (e.modifiers?.first || e.value?.first)
|
|
14
|
+
u = u.map(function(a) {
|
|
15
|
+
return r(a);
|
|
16
|
+
});
|
|
17
|
+
else {
|
|
18
|
+
let a = u.shift();
|
|
19
|
+
u = u.map(function(l) {
|
|
20
|
+
return r(l);
|
|
21
|
+
}), u.unshift(a);
|
|
22
|
+
}
|
|
23
|
+
t.value = u.join("");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, f = {
|
|
28
|
+
updated: function(t, e) {
|
|
29
|
+
t.value.length && (typeof e.value > "u" || e.value) && (t.value = r(t.value, !0));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function L(t, e = !1) {
|
|
33
|
+
return e ? t.match(/[\p{L}\p{N}-]+/gu) : t.match(/[\p{L}-]+/gu);
|
|
34
|
+
}
|
|
35
|
+
const o = {
|
|
36
|
+
updated: function(t, e) {
|
|
37
|
+
if (t.value.length && (typeof e.value > "u" || e.value)) {
|
|
38
|
+
let u = L(t.value, e.modifiers?.numbers || e.value?.numbers);
|
|
39
|
+
u.length > 1 && (u = u.map(function(a) {
|
|
40
|
+
return a.toLowerCase();
|
|
41
|
+
}), t.value = u.join("-"));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, s = {
|
|
45
|
+
updated: function(t, e) {
|
|
46
|
+
t.value.length && (typeof e.value > "u" || e.value) && (e.modifiers?.first || e.value?.first ? t.value = t.value.charAt(0).toLowerCase() + t.value.slice(1) : t.value = t.value.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function y(t, e, u = " ") {
|
|
50
|
+
const a = Math.floor((e - t.length) / 2) + t.length;
|
|
51
|
+
return t.padStart(a, u).padEnd(e, u);
|
|
52
|
+
}
|
|
53
|
+
const c = {
|
|
54
|
+
updated: function(t, e) {
|
|
55
|
+
if (t.value.length) {
|
|
56
|
+
let u = 0, a = " ";
|
|
57
|
+
e.value && (typeof e.value == "object" ? e.value.chars && e.value.count && (u = e.value.count, a = e.value.chars) : (u = e.arg, a = e.value)), e.modifiers?.start || e.value?.start ? t.value = t.value.padStart(u, a) : e.modifiers?.end || e.value?.end ? t.value = t.value.padEnd(u, a) : t.value = y(t.value, u, a);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, p = {
|
|
61
|
+
updated: function(t, e) {
|
|
62
|
+
t.value.length && e.value && (typeof e.value == "object" ? e.value.string && e.value.count && (t.value = t.value + e.value.string.repeat(e.value.count)) : e.arg && (t.value = t.value + e.value.repeat(e.arg)));
|
|
63
|
+
}
|
|
64
|
+
}, i = {
|
|
65
|
+
updated: function(t, e) {
|
|
66
|
+
t.value.length && e.value && e.value.regexp && (t.value = t.value.replace(new RegExp(e.value.regexp, e.value.flags), e.value.string || ""));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function w(t, e = !1) {
|
|
70
|
+
return e ? t.match(/[\p{L}\p{N}_]+/gu) : t.match(/[\p{L}_]+/gu);
|
|
71
|
+
}
|
|
72
|
+
const m = {
|
|
73
|
+
updated: function(t, e) {
|
|
74
|
+
if (t.value.length && (typeof e.value > "u" || e.value)) {
|
|
75
|
+
let u = w(t.value, e.modifiers?.numbers || e.value?.numbers);
|
|
76
|
+
u.length > 1 && (u = u.map(function(a) {
|
|
77
|
+
return a.toLowerCase();
|
|
78
|
+
}), t.value = u.join("_"));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function C(t, e = 32, u = "...") {
|
|
83
|
+
return t.substring(0, e) + u;
|
|
84
|
+
}
|
|
85
|
+
const n = {
|
|
86
|
+
updated: function(t, e) {
|
|
87
|
+
let u = t.value.length;
|
|
88
|
+
if (u) {
|
|
89
|
+
let a = "...", l = e.arg;
|
|
90
|
+
e.value && (typeof e.value == "object" ? e.value.count && e.value.omission && (l = e.value.count, a = e.value.omission) : a = e.value), u > l && (t.value = C(t.value, l, a));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function j(t, e = !1) {
|
|
95
|
+
return t.replace(new RegExp("\\p{L}+", "gu"), function(u) {
|
|
96
|
+
return r(u, e);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const h = {
|
|
100
|
+
updated: function(t, e) {
|
|
101
|
+
if (t.value.length && (typeof e.value > "u" || e.value))
|
|
102
|
+
if (e.modifiers?.first || e.value?.first) {
|
|
103
|
+
const u = e.modifiers?.capitalize || e.value?.capitalize;
|
|
104
|
+
e.modifiers?.every || e.value?.every ? t.value = j(t.value, u) : t.value = r(t.value, u);
|
|
105
|
+
} else
|
|
106
|
+
t.value = t.value.toUpperCase();
|
|
107
|
+
}
|
|
108
|
+
}, k = {
|
|
109
|
+
directives: {
|
|
110
|
+
camel: v,
|
|
111
|
+
capitalize: f,
|
|
112
|
+
kebab: o,
|
|
113
|
+
lower: s,
|
|
114
|
+
pad: c,
|
|
115
|
+
repeat: p,
|
|
116
|
+
replace: i,
|
|
117
|
+
snake: m,
|
|
118
|
+
truncate: n,
|
|
119
|
+
upper: h
|
|
120
|
+
}
|
|
121
|
+
}, x = {
|
|
122
|
+
install(t) {
|
|
123
|
+
t.directive("camel", v), t.directive("capitalize", f), t.directive("kebab", o), t.directive("lower", s), t.directive("pad", c), t.directive("repeat", p), t.directive("replace", i), t.directive("snake", m), t.directive("truncate", n), t.directive("upper", h);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
export {
|
|
127
|
+
k as StringDirectivesMixin,
|
|
128
|
+
x as VueStringDirectives,
|
|
129
|
+
v as camel,
|
|
130
|
+
f as capitalize,
|
|
131
|
+
o as kebab,
|
|
132
|
+
s as lower,
|
|
133
|
+
c as pad,
|
|
134
|
+
p as repeat,
|
|
135
|
+
i as replace,
|
|
136
|
+
m as snake,
|
|
137
|
+
n as truncate,
|
|
138
|
+
h as upper
|
|
139
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(l,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(l=typeof globalThis<"u"?globalThis:l||self,r(l.VueStringDirectives={}))})(this,(function(l){"use strict";function r(t,e=!1){let u=t.charAt(0).toUpperCase(),a=t.slice(1);return e&&(a=a.toLowerCase()),`${u}${a}`}function y(t,e=!1){return e?t.match(/[\p{L}\p{N}]+/gu):t.match(/[\p{L}]+/gu)}const f={updated:function(t,e){if(t.value.length&&(typeof e.value>"u"||e.value)){let u=y(t.value,e.modifiers?.numbers||e.value?.numbers);if(u.length>1){if(e.modifiers?.first||e.value?.first)u=u.map(function(a){return r(a)});else{let a=u.shift();u=u.map(function(v){return r(v)}),u.unshift(a)}t.value=u.join("")}}}},c={updated:function(t,e){t.value.length&&(typeof e.value>"u"||e.value)&&(t.value=r(t.value,!0))}};function L(t,e=!1){return e?t.match(/[\p{L}\p{N}-]+/gu):t.match(/[\p{L}-]+/gu)}const o={updated:function(t,e){if(t.value.length&&(typeof e.value>"u"||e.value)){let u=L(t.value,e.modifiers?.numbers||e.value?.numbers);u.length>1&&(u=u.map(function(a){return a.toLowerCase()}),t.value=u.join("-"))}}},s={updated:function(t,e){t.value.length&&(typeof e.value>"u"||e.value)&&(e.modifiers?.first||e.value?.first?t.value=t.value.charAt(0).toLowerCase()+t.value.slice(1):t.value=t.value.toLowerCase())}};function w(t,e,u=" "){const a=Math.floor((e-t.length)/2)+t.length;return t.padStart(a,u).padEnd(e,u)}const i={updated:function(t,e){if(t.value.length){let u=0,a=" ";e.value&&(typeof e.value=="object"?e.value.chars&&e.value.count&&(u=e.value.count,a=e.value.chars):(u=e.arg,a=e.value)),e.modifiers?.start||e.value?.start?t.value=t.value.padStart(u,a):e.modifiers?.end||e.value?.end?t.value=t.value.padEnd(u,a):t.value=w(t.value,u,a)}}},n={updated:function(t,e){t.value.length&&e.value&&(typeof e.value=="object"?e.value.string&&e.value.count&&(t.value=t.value+e.value.string.repeat(e.value.count)):e.arg&&(t.value=t.value+e.value.repeat(e.arg)))}},p={updated:function(t,e){t.value.length&&e.value&&e.value.regexp&&(t.value=t.value.replace(new RegExp(e.value.regexp,e.value.flags),e.value.string||""))}};function S(t,e=!1){return e?t.match(/[\p{L}\p{N}_]+/gu):t.match(/[\p{L}_]+/gu)}const m={updated:function(t,e){if(t.value.length&&(typeof e.value>"u"||e.value)){let u=S(t.value,e.modifiers?.numbers||e.value?.numbers);u.length>1&&(u=u.map(function(a){return a.toLowerCase()}),t.value=u.join("_"))}}};function j(t,e=32,u="..."){return t.substring(0,e)+u}const h={updated:function(t,e){let u=t.value.length;if(u){let a="...",v=e.arg;e.value&&(typeof e.value=="object"?e.value.count&&e.value.omission&&(v=e.value.count,a=e.value.omission):a=e.value),u>v&&(t.value=j(t.value,v,a))}}};function k(t,e=!1){return t.replace(new RegExp("\\p{L}+","gu"),function(u){return r(u,e)})}const d={updated:function(t,e){if(t.value.length&&(typeof e.value>"u"||e.value))if(e.modifiers?.first||e.value?.first){const u=e.modifiers?.capitalize||e.value?.capitalize;e.modifiers?.every||e.value?.every?t.value=k(t.value,u):t.value=r(t.value,u)}else t.value=t.value.toUpperCase()}},C={directives:{camel:f,capitalize:c,kebab:o,lower:s,pad:i,repeat:n,replace:p,snake:m,truncate:h,upper:d}},z={install(t){t.directive("camel",f),t.directive("capitalize",c),t.directive("kebab",o),t.directive("lower",s),t.directive("pad",i),t.directive("repeat",n),t.directive("replace",p),t.directive("snake",m),t.directive("truncate",h),t.directive("upper",d)}};l.StringDirectivesMixin=C,l.VueStringDirectives=z,l.camel=f,l.capitalize=c,l.kebab=o,l.lower=s,l.pad=i,l.repeat=n,l.replace=p,l.snake=m,l.truncate=h,l.upper=d,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-string-directives",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Vue string directives library can change form input value dynamically.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": ["dist"],
|
|
7
|
+
"main": "./dist/vue-string-directives.umd.cjs",
|
|
8
|
+
"module": "./dist/vue-string-directives.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/vue-string-directives.js",
|
|
12
|
+
"require": "./dist/vue-string-directives.umd.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
"keywords": [
|
|
10
16
|
"js",
|
|
11
17
|
"javascript",
|
|
@@ -18,31 +24,26 @@
|
|
|
18
24
|
"form",
|
|
19
25
|
"input"
|
|
20
26
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"start": "rollup --config rollup.config.dev.js",
|
|
23
|
-
"dev": "rollup --config rollup.config.dev.js",
|
|
24
|
-
"build": "rollup --config rollup.config.prod.js"
|
|
25
|
-
},
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
28
29
|
"url": "git+https://github.com/tarkhov/vue-string-directives.git"
|
|
29
30
|
},
|
|
30
|
-
"author": "
|
|
31
|
+
"author": "Tarkhov",
|
|
31
32
|
"license": "MIT",
|
|
32
33
|
"bugs": {
|
|
33
34
|
"url": "https://github.com/tarkhov/vue-string-directives/issues"
|
|
34
35
|
},
|
|
35
36
|
"homepage": "https://tarkhov.github.io/vue-string-directives/",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "vite",
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"preview": "vite preview"
|
|
41
|
+
},
|
|
36
42
|
"dependencies": {
|
|
37
|
-
"vue": "^
|
|
43
|
+
"vue": "^3.5.24"
|
|
38
44
|
},
|
|
39
45
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"
|
|
42
|
-
"@rollup/plugin-babel": "^5.2.1",
|
|
43
|
-
"@rollup/plugin-commonjs": "^15.0.0",
|
|
44
|
-
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
45
|
-
"rollup": "^2.26.11",
|
|
46
|
-
"rollup-plugin-terser": "^7.0.2"
|
|
46
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
47
|
+
"vite": "^7.2.4"
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
+
}
|
package/.browserslistrc
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# https://vuejs.org/v2/guide/installation.html#Compatibility-Note
|
|
2
|
-
# https://caniuse.com/es5
|
|
3
|
-
ie 10
|
|
4
|
-
edge 12
|
|
5
|
-
firefox 21
|
|
6
|
-
chrome 23
|
|
7
|
-
safari 6
|
|
8
|
-
opera 15
|
|
9
|
-
ios_saf 6
|
|
10
|
-
android 4.4
|
|
11
|
-
op_mob 46
|
|
12
|
-
and_chr 85
|
|
13
|
-
and_ff 79
|
|
14
|
-
and_uc 12.12
|
|
15
|
-
samsung 4
|
|
16
|
-
and_qq 10.4
|
|
17
|
-
baidu 7.12
|
|
18
|
-
kaios 2.5
|
package/dist/.eslintrc.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
parserOptions: {
|
|
7
|
-
parser: 'babel-eslint'
|
|
8
|
-
},
|
|
9
|
-
rules: {
|
|
10
|
-
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
11
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
|
12
|
-
}
|
|
13
|
-
}
|