renusify 2.1.1 → 2.1.4

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.
@@ -4,7 +4,7 @@ export * as rCalendarYearTab from './year.vue'
4
4
  export * as l_container from '../container/index.js'
5
5
  export * as l_row from '../container/row.js'
6
6
  export * as l_col from '../container/col.js'
7
- export * as l_btn from './index.js'
7
+ export * as l_btn from '../button/index.js'
8
8
  export * as l_icon from '../icon/index.js'
9
9
  export * as l_card from '../card/index.js'
10
10
  export * as l_modal from '../modal/index.js'
@@ -1,2 +1,2 @@
1
- export * as rWorldMap from './worldMap.vue'
1
+ export * as rChartMap from './worldMap.vue'
2
2
  export * as l_float from '../float/index.js'
@@ -1,4 +1,4 @@
1
- export * as rFloat from './index.vue'
1
+ export * as rAddressInput from './index.vue'
2
2
  export * as l_TextInput from '../textInput/index.js'
3
3
  export * as l_TextArea from '../textArea/index.js'
4
4
  export * as l_select from '../selectInput/index.js'
@@ -103,7 +103,7 @@ export const _register = (app, components) => {
103
103
  }
104
104
 
105
105
  } catch (e) {
106
- console.error('component not found', c, e)
106
+ console.error('component not found', name, e)
107
107
  }
108
108
  }
109
109
  }
@@ -1,155 +1 @@
1
- //https://github.com/troxler/headful/blob/master/src/headful.js
2
- export const rMeta= {
3
- name: "r-meta",
4
- created(){
5
- this.build()
6
- },
7
- watch: {
8
- '$attrs': {
9
- handler() {
10
- this.build()
11
- },
12
- deep: true
13
- },
14
- },
15
- activated() {
16
- this.build()
17
- },
18
- deactivated() {
19
- this.removeAll()
20
- },
21
- methods: {
22
- build() {
23
- for (let i in this.$attrs) {
24
- if (this.$helper.hasKey(this.$attrs, i)) {
25
- this[i](this.$attrs[i]);
26
- }
27
- }
28
- },
29
- html(obj) {
30
- /*
31
- :html="{
32
- body: {id: 'aPageId'},
33
- h1: {'data-foo': 'bar'},
34
- }"
35
- */
36
- Object.keys(obj).forEach(selector =>
37
- this.setRootElementAttributes(selector, obj[selector])
38
- );
39
- },
40
- head(obj) {
41
- /*
42
- :head="{
43
- 'meta[charset]': {charset: 'utf-8'},
44
- }"
45
- */
46
- Object.keys(obj).forEach(selector =>
47
- this.setHeadElementAttributes(selector, obj[selector])
48
- );
49
- },
50
- title(val) {
51
- document.title = this.isRemoveValue(val) ? "" : val;
52
- this.setMetaContent('itemprop="name"', val);
53
- this.setMetaContent('property="og:title"', val);
54
- this.setMetaContent('name="twitter:title"', val);
55
- },
56
- description(val) {
57
- this.setMetaContent('name="description"', val);
58
- this.setMetaContent('itemprop="description"', val);
59
- this.setMetaContent('property="og:description"', val);
60
- this.setMetaContent('name="twitter:description"', val);
61
- },
62
- keywords(val) {
63
- this.setMetaContent('name="keywords"',val);
64
- },
65
- image(val) {
66
- this.setMetaContent('itemprop="image"', val);
67
- this.setMetaContent('property="og:image"', val);
68
- this.setMetaContent('name="twitter:image"', val);
69
- },
70
- lang(val) {
71
- this.setRootElementAttributes("html", {lang: val});
72
- this.ogLocaleTag && this.setOgLocaleIfValid(val);
73
- },
74
- ogLocale(val) {
75
- this.setMetaContent('property="og:locale"', val);
76
- },
77
- url(val) {
78
- this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
79
- this.setMetaContent('property="og:url"', val);
80
- this.setMetaContent('name="twitter:url"', val);
81
- },
82
- createChild(parent, selector) {
83
- if (!this.getElement(parent, selector)) {
84
- let property = selector;
85
- property = property.split("[");
86
- const name = property[0];
87
- property = this.$helper.replacer(property[1], "]", "");
88
- property = this.$helper.replacer(property, '"', "");
89
- property = this.$helper.replacer(property, "'", "");
90
- property = property.trim(" ");
91
- property = property.split("=");
92
- let meta = document.createElement(name);
93
- meta.setAttribute("c", "renusify");
94
- meta.setAttribute(property[0], property[1]);
95
- parent.appendChild(meta);
96
- }
97
- },
98
- setMetaContent(attr, val) {
99
- this.createChild(document.head, `meta[${attr}]`);
100
- this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
101
- },
102
- setRootElementAttributes(selector, attributes) {
103
- this.createChild(document, selector);
104
- this.setElementAttributes(
105
- this.getElement(document, selector),
106
- attributes
107
- );
108
- },
109
- setHeadElementAttributes(selector, attributes) {
110
- this.createChild(document.head, selector);
111
- this.setElementAttributes(
112
- this.getElement(document.head, selector),
113
- attributes
114
- );
115
- },
116
- setElementAttributes(element, attributes) {
117
- if (element) {
118
- Object.keys(attributes).forEach(attrName => {
119
- if (this.isRemoveValue(attributes[attrName])) {
120
- element.removeAttribute(attrName);
121
- } else {
122
- element.setAttribute(attrName, attributes[attrName]);
123
- }
124
- });
125
- }
126
- },
127
- getElement(parent, selector) {
128
- return parent.querySelector(selector);
129
- },
130
- setOgLocaleIfValid(locale) {
131
- if (this.isRemoveValue(locale)) {
132
- this.ogLocale(locale);
133
- } else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
134
- const [language, region] = locale.split("-");
135
- const ogLocale = `${language}_${region.toUpperCase()}`;
136
- this.ogLocale(ogLocale);
137
- }
138
- },
139
- isRemoveValue(val) {
140
- return val === undefined || val === null;
141
- },
142
- removeAll() {
143
- let children = document.querySelectorAll("[c='renusify']");
144
- if (children) {
145
- let childArray = Array.prototype.slice.call(children);
146
-
147
- childArray.forEach(function (child) {
148
- child.parentNode.removeChild(child);
149
- });
150
- }
151
- }
152
- },
153
- render() {
154
- }
155
- };
1
+ export * as rMeta from './meta.js'
@@ -0,0 +1,155 @@
1
+ //https://github.com/troxler/headful/blob/master/src/headful.js
2
+ export default {
3
+ name: "r-meta",
4
+ created(){
5
+ this.build()
6
+ },
7
+ watch: {
8
+ '$attrs': {
9
+ handler() {
10
+ this.build()
11
+ },
12
+ deep: true
13
+ },
14
+ },
15
+ activated() {
16
+ this.build()
17
+ },
18
+ deactivated() {
19
+ this.removeAll()
20
+ },
21
+ methods: {
22
+ build() {
23
+ for (let i in this.$attrs) {
24
+ if (this.$helper.hasKey(this.$attrs, i)) {
25
+ this[i](this.$attrs[i]);
26
+ }
27
+ }
28
+ },
29
+ html(obj) {
30
+ /*
31
+ :html="{
32
+ body: {id: 'aPageId'},
33
+ h1: {'data-foo': 'bar'},
34
+ }"
35
+ */
36
+ Object.keys(obj).forEach(selector =>
37
+ this.setRootElementAttributes(selector, obj[selector])
38
+ );
39
+ },
40
+ head(obj) {
41
+ /*
42
+ :head="{
43
+ 'meta[charset]': {charset: 'utf-8'},
44
+ }"
45
+ */
46
+ Object.keys(obj).forEach(selector =>
47
+ this.setHeadElementAttributes(selector, obj[selector])
48
+ );
49
+ },
50
+ title(val) {
51
+ document.title = this.isRemoveValue(val) ? "" : val;
52
+ this.setMetaContent('itemprop="name"', val);
53
+ this.setMetaContent('property="og:title"', val);
54
+ this.setMetaContent('name="twitter:title"', val);
55
+ },
56
+ description(val) {
57
+ this.setMetaContent('name="description"', val);
58
+ this.setMetaContent('itemprop="description"', val);
59
+ this.setMetaContent('property="og:description"', val);
60
+ this.setMetaContent('name="twitter:description"', val);
61
+ },
62
+ keywords(val) {
63
+ this.setMetaContent('name="keywords"',val);
64
+ },
65
+ image(val) {
66
+ this.setMetaContent('itemprop="image"', val);
67
+ this.setMetaContent('property="og:image"', val);
68
+ this.setMetaContent('name="twitter:image"', val);
69
+ },
70
+ lang(val) {
71
+ this.setRootElementAttributes("html", {lang: val});
72
+ this.ogLocaleTag && this.setOgLocaleIfValid(val);
73
+ },
74
+ ogLocale(val) {
75
+ this.setMetaContent('property="og:locale"', val);
76
+ },
77
+ url(val) {
78
+ this.setHeadElementAttributes('link[rel="canonical"]', {href: val});
79
+ this.setMetaContent('property="og:url"', val);
80
+ this.setMetaContent('name="twitter:url"', val);
81
+ },
82
+ createChild(parent, selector) {
83
+ if (!this.getElement(parent, selector)) {
84
+ let property = selector;
85
+ property = property.split("[");
86
+ const name = property[0];
87
+ property = this.$helper.replacer(property[1], "]", "");
88
+ property = this.$helper.replacer(property, '"', "");
89
+ property = this.$helper.replacer(property, "'", "");
90
+ property = property.trim(" ");
91
+ property = property.split("=");
92
+ let meta = document.createElement(name);
93
+ meta.setAttribute("c", "renusify");
94
+ meta.setAttribute(property[0], property[1]);
95
+ parent.appendChild(meta);
96
+ }
97
+ },
98
+ setMetaContent(attr, val) {
99
+ this.createChild(document.head, `meta[${attr}]`);
100
+ this.setHeadElementAttributes(`meta[${attr}]`, {content: val});
101
+ },
102
+ setRootElementAttributes(selector, attributes) {
103
+ this.createChild(document, selector);
104
+ this.setElementAttributes(
105
+ this.getElement(document, selector),
106
+ attributes
107
+ );
108
+ },
109
+ setHeadElementAttributes(selector, attributes) {
110
+ this.createChild(document.head, selector);
111
+ this.setElementAttributes(
112
+ this.getElement(document.head, selector),
113
+ attributes
114
+ );
115
+ },
116
+ setElementAttributes(element, attributes) {
117
+ if (element) {
118
+ Object.keys(attributes).forEach(attrName => {
119
+ if (this.isRemoveValue(attributes[attrName])) {
120
+ element.removeAttribute(attrName);
121
+ } else {
122
+ element.setAttribute(attrName, attributes[attrName]);
123
+ }
124
+ });
125
+ }
126
+ },
127
+ getElement(parent, selector) {
128
+ return parent.querySelector(selector);
129
+ },
130
+ setOgLocaleIfValid(locale) {
131
+ if (this.isRemoveValue(locale)) {
132
+ this.ogLocale(locale);
133
+ } else if (locale.match(/^[a-z]{2}-[a-z]{2}$/i)) {
134
+ const [language, region] = locale.split("-");
135
+ const ogLocale = `${language}_${region.toUpperCase()}`;
136
+ this.ogLocale(ogLocale);
137
+ }
138
+ },
139
+ isRemoveValue(val) {
140
+ return val === undefined || val === null;
141
+ },
142
+ removeAll() {
143
+ let children = document.querySelectorAll("[c='renusify']");
144
+ if (children) {
145
+ let childArray = Array.prototype.slice.call(children);
146
+
147
+ childArray.forEach(function (child) {
148
+ child.parentNode.removeChild(child);
149
+ });
150
+ }
151
+ }
152
+ },
153
+ render() {
154
+ }
155
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "renusify",
3
- "version": "2.1.1",
3
+ "version": "2.1.4",
4
4
  "description": "Vue3 Framework",
5
5
  "keywords": [
6
6
  "vuejs",
@@ -1,161 +1,165 @@
1
- import Axios from 'axios';
2
-
3
1
  export default class Translate {
4
- constructor($r, $storage) {
5
- this.$r = $r
6
- this.$storage = $storage
7
- this._count = 0;
8
- this._failed_messages = {};
9
- this._messages = {};
10
- this._local = 'en';
11
- this._package = null;
12
- this._store = []
13
- }
14
-
15
- get messages() {
16
- return this._messages;
17
- }
18
-
19
- get failed_messages() {
20
- return Object.keys(this._failed_messages);
21
- }
22
-
23
- get local() {
24
- return this._local;
25
- }
26
-
27
- set local(value) {
28
- this._local = value;
29
- }
30
-
31
- set package(value) {
32
- this._package = value;
33
- }
34
-
35
- setMessages(obj, local) {
36
- this._messages[local || this._local] = Object.assign({}, this._messages[local || this._local], obj);
37
- }
2
+ constructor($r, $storage) {
3
+ this.$r = $r
4
+ this.$storage = $storage
5
+ this._count = 0;
6
+ this._failed_messages = {};
7
+ this._messages = {};
8
+ this._local = 'en';
9
+ this._package = $r.package;
10
+ this._store = []
11
+ }
38
12
 
39
- add(key, value) {
40
- if (!this._messages[this._local]) {
41
- this._messages[this._local] = {}
13
+ get messages() {
14
+ return this._messages;
42
15
  }
43
- this._messages[this._local][key] = value;
44
- }
45
16
 
46
- replaceAll(string, search, replace) {
47
- return string.split(search).join(replace);
48
- }
17
+ get failed_messages() {
18
+ return Object.keys(this._failed_messages);
19
+ }
49
20
 
50
- get(key, package_name = null, lang = null) {
51
- if (key === undefined || key === null) {
52
- return ''
21
+ get local() {
22
+ return this._local;
53
23
  }
54
- let variable = []
55
- if (typeof key === 'object') {
56
- variable = key[1]
57
- key = key[0]
58
- if (!variable) {
59
- console.error(
60
- 'object key must have variables. key:' + key + ' variable:' + variable
61
- )
62
- this._failed_messages[key] = true
63
- return key
64
- }
24
+
25
+ set local(value) {
26
+ this._local = value;
65
27
  }
66
28
 
67
- if (package_name && typeof package_name !== 'string') {
68
- console.error(
69
- 'package name must be string. key:' + key + ' package_name:' + package_name
70
- )
71
- this._failed_messages[key] = true
72
- return key
29
+ set package(value) {
30
+ this._package = value;
73
31
  }
74
- if (typeof key !== 'string') {
75
- this._failed_messages[key] = true
76
- return key
32
+
33
+ setMessages(obj, local) {
34
+ this._messages[local || this._local] = Object.assign({}, this._messages[local || this._local], obj);
77
35
  }
78
- key = key.toLowerCase()
79
36
 
80
- const local = lang !== null ? lang : this._local
81
- const pack = package_name !== null ? package_name : this._package
82
- if (!local) {
83
- this._failed_messages[key] = true
84
- return key;
37
+ add(key, value) {
38
+ if (!this._messages[this._local]) {
39
+ this._messages[this._local] = {}
40
+ }
41
+ this._messages[this._local][key] = value;
85
42
  }
86
- if (!this._messages[local]) {
87
- this._failed_messages[key] = true
88
- return key;
43
+
44
+ replaceAll(string, search, replace) {
45
+ return string.split(search).join(replace);
89
46
  }
90
- if (this._messages[local][key]) {
91
- let val = this._messages[local][key];
92
- const lng = variable.length
93
- for (let i = 0; i < lng; i++) {
94
- val = this.replaceAll(val, '{' + i + '}', variable[i]);
95
- }
96
47
 
97
- if (val === null || val === '') {
98
- this._failed_messages[key] = true
99
- return key;
100
- }
101
- return val;
102
- } else if (this.$r && this.$r.autoAddTranslate && pack && this._count < 100 && /^([a-z_.])*$/.test(key)) {
103
- if (!this._store.includes(key)) {
104
- let url = '/translate/' + pack + '/' + key + '?v=';
105
- const lng = variable.length
106
- for (let i = 0; i < lng; i++) {
107
- url += '{' + i + '}';
48
+ get(key, package_name = null, lang = null) {
49
+ if (key === undefined || key === null) {
50
+ return ''
51
+ }
52
+ let variable = []
53
+ if (typeof key === 'object') {
54
+ variable = key[1]
55
+ key = key[0]
56
+ if (!variable) {
57
+ console.error(
58
+ 'object key must have variables. key:' + key + ' variable:' + variable
59
+ )
60
+ this._failed_messages[key] = true
61
+ return key
62
+ }
108
63
  }
109
- Axios.post(url);
110
- this._count++;
111
- this._store.push(key)
112
- }
113
- this._failed_messages[key] = true
114
- return key;
115
- } else {
116
- this._failed_messages[key] = true
117
- return key;
118
- }
119
- }
120
64
 
121
- loads(packages = []) {
122
- packages.forEach((p) => {
123
- this.load(p)
124
- })
125
- }
65
+ if (package_name && typeof package_name !== 'string') {
66
+ console.error(
67
+ 'package name must be string. key:' + key + ' package_name:' + package_name
68
+ )
69
+ this._failed_messages[key] = true
70
+ return key
71
+ }
72
+ if (typeof key !== 'string') {
73
+ this._failed_messages[key] = true
74
+ return key
75
+ }
76
+ key = key.toLowerCase()
126
77
 
127
- load(p) {
128
- const pack = p || this.$r.package;
129
- if (!p) {
130
- this.package = pack;
131
- }
132
- if (!this.$r.store['langs_loaded']) {
133
- this.$r.store['langs_loaded'] = {}
134
- }
135
- this.$r.store['langs_loaded'][pack] = false;
136
- let locale = this.$r.lang;
137
- if (this.$storage.get("lang")) {
138
- locale = this.$storage.get("lang");
139
- }
140
- Axios.get(`/translate/${pack}/${locale}`).then(
141
- res => {
142
- if (res.data.length !== 0) {
143
- const lang = {};
144
- const lng = res.data.length
78
+ const local = lang !== null ? lang : this._local
79
+ const pack = package_name !== null ? package_name : this._package
80
+ if (!local) {
81
+ this._failed_messages[key] = true
82
+ return key;
83
+ }
84
+ if (!this._messages[local]) {
85
+ this._failed_messages[key] = true
86
+ return key;
87
+ }
88
+ if (this._messages[local][key]) {
89
+ let val = this._messages[local][key];
90
+ const lng = variable.length
145
91
  for (let i = 0; i < lng; i++) {
146
- lang[res.data[i].key] = res.data[i][locale];
92
+ val = this.replaceAll(val, '{' + i + '}', variable[i]);
147
93
  }
148
- this.local = locale;
149
- this.setMessages(lang);
150
- } else {
151
- this.local = locale;
152
- this.setMessages({});
153
- }
154
- this.$r.store['langs_loaded'][pack] = true;
155
- },
156
- () => {
157
- this.$r.store['langs_loaded'][pack] = true;
94
+
95
+ if (val === null || val === '') {
96
+ this._failed_messages[key] = true
97
+ return key;
98
+ }
99
+ return val;
100
+ } else if (this.$r && this.$r.autoAddTranslate && pack && this._count < 100 && /^([0-9a-z_.])*$/.test(key)) {
101
+ if (!this._store.includes(key)) {
102
+ let url = '/translate/' + pack + '/' + key + '?v=';
103
+ const lng = variable.length
104
+ for (let i = 0; i < lng; i++) {
105
+ url += '{' + i + '}';
106
+ }
107
+ fetch(url, {
108
+ method: 'POST'
109
+ });
110
+ this._count++;
111
+ this._store.push(key)
112
+ }
113
+ this._failed_messages[key] = true
114
+ return key;
115
+ } else {
116
+ this._failed_messages[key] = true
117
+ return key;
158
118
  }
159
- );
160
- }
119
+ }
120
+
121
+ loads(packages = []) {
122
+ packages.forEach((p) => {
123
+ this.load(p)
124
+ })
125
+ }
126
+
127
+ load(p) {
128
+ const pack = p || this.$r.package;
129
+ if (!p) {
130
+ this.package = pack;
131
+ }
132
+ if (!this.$r.store['langs_loaded']) {
133
+ this.$r.store['langs_loaded'] = {}
134
+ }
135
+ this.$r.store['langs_loaded'][pack] = false;
136
+ let locale = this.$r.lang;
137
+ if (this.$storage.get("lang")) {
138
+ locale = this.$storage.get("lang");
139
+ }
140
+ fetch(`/api/translate/${pack}/${locale}`, {
141
+ method: 'GET',
142
+ }).then(
143
+ res => {
144
+ if (res.ok) {
145
+ let data = res.json()
146
+ if (data.length !== 0) {
147
+ const lang = {};
148
+ const lng = data.length
149
+ for (let i = 0; i < lng; i++) {
150
+ lang[data[i].key] = data[i][locale];
151
+ }
152
+ this.local = locale;
153
+ this.setMessages(lang);
154
+ } else {
155
+ this.local = locale;
156
+ this.setMessages({});
157
+ }
158
+ this.$r.store['langs_loaded'][pack] = true;
159
+ } else {
160
+ this.$r.store['langs_loaded'][pack] = true;
161
+ }
162
+ }
163
+ );
164
+ }
161
165
  }
@@ -72,17 +72,17 @@ export default class Validate {
72
72
 
73
73
  checkType(names) {
74
74
  let filters = [];
75
- if (typeof names === 'object') {
76
- names.forEach((name) => {
77
- let res = name.split(':');
78
- let par1 = res[1] ? res[1] : null;
79
- let par2 = res[2] ? res[2] : null;
80
- let par3 = res[3] ? res[3] : null;
81
- if (this[res[0]]) {
82
- if (par3 === null && par2 === null) {
83
- filters.push(this[res[0]](par1))
84
- } else if (par3 === null) {
85
- filters.push(this[res[0]](par1, par2))
75
+ if (Array.isArray(names)) {
76
+ names.forEach((name) => {
77
+ let res = name.split(':');
78
+ let par1 = res[1] ? res[1] : null;
79
+ let par2 = res[2] ? res[2] : null;
80
+ let par3 = res[3] ? res[3] : null;
81
+ if (this[res[0]]) {
82
+ if (par3 === null && par2 === null) {
83
+ filters.push(this[res[0]](par1))
84
+ } else if (par3 === null) {
85
+ filters.push(this[res[0]](par1, par2))
86
86
  } else {
87
87
  filters.push(this[res[0]](par1, par2, par3))
88
88
  }