@verdnatura/vn-front-lib 0.0.12 → 0.1.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/README.md +22 -13
- package/dist/components-BN97tI4h.js +8583 -0
- package/dist/components-zdOTH0ZE.cjs +9 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +2 -2
- package/dist/composables-BTDp8DJ1.cjs +56 -0
- package/dist/composables-CAAnziP1.js +3595 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +2 -2
- package/dist/{rolldown-runtime-mLOUI7ql.cjs → rolldown-runtime-DF3sbh8G.cjs} +1 -1
- package/dist/stores.cjs +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/vn-front-lib.cjs +1 -1
- package/dist/vn-front-lib.css +1 -1
- package/dist/vn-front-lib.js +7 -6
- package/lib/components/dialogs/VnConfirm.vue +3 -3
- package/lib/components/index.js +2 -0
- package/lib/components/inputs/VnDate.vue +34 -0
- package/lib/components/inputs/VnInputDate.vue +275 -0
- package/lib/components/models/VnForm.vue +2 -2
- package/lib/composables/index.js +1 -0
- package/lib/composables/useGlobalMessages.js +15 -0
- package/lib/composables/useNotify.js +6 -7
- package/lib/i18n/locale/en.yml +17 -2
- package/lib/i18n/locale/es.yml +17 -2
- package/lib/main.js +3 -1
- package/package.json +6 -4
- package/dist/components-D0b_k2T_.js +0 -3305
- package/dist/components-DImdPW9s.cjs +0 -2
- package/dist/composables-CAk9XaOa.js +0 -3836
- package/dist/composables-CoozYWaG.cjs +0 -6
package/dist/composables.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./composables-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./composables-BTDp8DJ1.cjs");exports.fetchLocalData=e.n,exports.focusFirstInput=e.p,exports.getObjectByKeys=e.a,exports.getObjectDifferences=e.o,exports.getRemoteAndLocalParams=e.r,Object.defineProperty(exports,"i18n",{enumerable:!0,get:function(){return e.d}}),exports.isComparableObject=e.s,exports.isSameValue=e.c,exports.requestData=e.i,exports.tMobile=e.h,exports.useArrayData=e.m,exports.useGlobalMessages=e.f,exports.useNotify=e.u,exports.useObjectComparison=e.l,exports.useRequired=e.g,exports.useState=e.t,exports.useValidator=e._;
|
package/dist/composables.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./composables-CAAnziP1.js";
|
|
2
|
+
export { u as fetchLocalData, f as focusFirstInput, t as getObjectByKeys, d as getObjectDifferences, p as getRemoteAndLocalParams, r as i18n, m as isComparableObject, n as isSameValue, s as requestData, o as tMobile, l as useArrayData, i as useGlobalMessages, g as useNotify, c as useObjectComparison, a as useRequired, h as useState, e as useValidator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
package/dist/stores.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-DF3sbh8G.cjs");let t=require("vue"),n=require("pinia"),r=require("axios");r=e.r(r,1);var i=(0,n.defineStore)(`validationsStore`,{state:()=>({validations:null}),actions:{async fetchModels(){let{data:e}=await r.default.get(`Schemas/modelinfo`);this.validations=e}}}),a=(0,n.defineStore)(`arrayDataStore`,()=>{let e=(0,t.ref)({}),n={filter:{},userFilter:{},userParams:{},appliedParams:null,rawResponse:null,url:``,limit:20,skip:0,order:``,isLoading:!1,userParamsChanged:!1,exprBuilder:null,dynamicExprBuilder:{},dynamicWhereBuilder:{},searchUrl:`params`,navigate:null,page:1,mapKey:`id`,oneRecord:!1,hasChanges:!1,isLocal:!1,customFilterFn:null,remoteParamsArray:[],keyData:null,isStackableParams:!1,nonStackableParams:[],stackedParams:[],dataAnalyticsFilter:!1,ignoreUrlParams:[]};function r(t){return e.value[t]}function i(t){e.value[t]=s(t)}function a(t){e.value[t]?.channel?.close(),delete e.value[t]}function o(t,r=[]){r.length?r.forEach(r=>{if(r.includes(`.`)){let[i,a]=r.split(`.`);e.value[t][i][a]=n[a]}else Object.hasOwn(e.value[t],r)&&(e.value[t][r]=n[r])}):e.value[t]=s()}function s(e){return Object.assign(JSON.parse(JSON.stringify(n)),{data:(0,t.ref)(),map:(0,t.ref)(new Map),channel:new BroadcastChannel(`channel-data-${e}`)})}function c(e){o(e,[`skip`,`filter.skip`,`page`])}return{get:r,set:i,clear:a,reset:o,resetPagination:c}}),o=(0,n.defineStore)(`stateStore`,()=>{let e=(0,t.ref)(!1),n=(0,t.ref)(!1),r=(0,t.ref)(!1),i=(0,t.ref)(!1),a=(0,t.ref)(!1),o=(0,t.ref)(null),s=(0,t.ref)({});function c(e){o.value=e}function l(){n.value=!n.value}function u(){r.value=!r.value}function d(){i.value=!i.value}function f(e){r.value=e}function p(e){i.value=e}function m(){a.value=!a.value}function h(){e.value=!0}function g(){return e.value}function _(){return n.value}function v(){return r.value}function y(){return a.value}function b(e){s.value=e}return{cardDescriptor:o,cardDescriptorChangeValue:c,leftDrawer:n,rightDrawer:r,rightAdvancedDrawer:i,setMounted:h,isHeaderMounted:g,toggleLeftDrawer:l,toggleRightDrawer:u,toggleRightAdvancedDrawer:d,isLeftDrawerShown:_,isRightDrawerShown:v,isSubToolbarShown:y,toggleSubToolbar:m,rightDrawerChangeValue:f,rightAdvancedDrawerChangeValue:p,descriptors:s,setDescriptors:b}});exports.useArrayDataStore=a,exports.useStateStore=o,exports.useValidationsStore=i;
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-DF3sbh8G.cjs");let t=require("axios");t=e.r(t,1);var n=`eq`,r={eq:{icon:`=`,label:`equal`,operator:`eq`,default:!0,expr:e=>e,localEval:(e,t)=>e==t,isBasic:!0},neq:{icon:`≠`,label:`distinct`,operator:`neq`,expr:e=>({neq:e}),isNegation:!0,localEval:(e,t)=>e!=t},inq:{icon:`∈`,label:`include`,operator:`inq`,isArray:!0,expr:e=>({inq:e}),localEval:(e,t)=>t.includes(e)},nin:{icon:`∉`,label:`exclude`,operator:`nin`,isArray:!0,expr:e=>({nin:e}),isNegation:!0,localEval:(e,t)=>!t.includes(e)},like:{icon:`%`,label:`contains`,operator:`like`,isInput:!0,expr:e=>({like:a(e,`%${e}%`)}),localEval:(e,t)=>o(e,t)},nlike:{icon:`≁`,label:`notContains`,operator:`nlike`,isInput:!0,expr:e=>({nlike:a(e,`%${e}%`)}),isNegation:!0,localEval:(e,t)=>!o(e,t)},lt:{icon:`<`,label:`lessThan`,operator:`lt`,expr:e=>({lt:e}),localEval:(e,t)=>e<t,isInput:!0},gt:{icon:`>`,label:`greaterThan`,operator:`gt`,isInput:!0,expr:e=>({gt:e}),localEval:(e,t)=>e>t},lte:{icon:`≤`,label:`lessThanEqualTo`,operator:`lte`,isInput:!0,expr:e=>({lte:e}),localEval:(e,t)=>e<=t},gte:{icon:`≥`,label:`greaterThanEqualTo`,operator:`gte`,isInput:!0,expr:e=>({gte:e}),localEval:(e,t)=>e>=t},null:{icon:`∅`,label:`null`,operator:`null`,expr:()=>({eq:null}),localEval:e=>e==null,isBasic:!0,isNullable:!0},notNull:{icon:`≠`,label:`notNull`,operator:`notNull`,expr:()=>({neq:null}),localEval:e=>e!=null,isBasic:!0,isNullable:!0}},i=Object.values(r);function a(e,t){return e.includes(`%`)?e:t}function o(e,t){let n=e==null?``:String(e),r=(t==null?``:String(t)).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/%/g,`.*`).replace(/_/g,`.`);return RegExp(`^${r}$`,`i`).test(n)}var s=new Set;async function c(){try{let{data:e}=await t.default.get(`AnalyticPaths`);e.forEach(e=>s.add(e.path))}catch(e){console.error(`Error loading allowed paths:`,e)}}async function l(e,n){s.size||await c(),s.has(n)&&t.default.post(`AnalyticEvents`,{name:e,path:n})}exports.advancedFilters=r,exports.advancedFiltersList=i,exports.defaultOperator=n,exports.trackAnalyticEvent=l;
|
package/dist/vn-front-lib.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./components-zdOTH0ZE.cjs"),t=require("./composables-BTDp8DJ1.cjs");function n(n,r={}){for(let t in e.t)n.component(t,e.t[t]);t.f(r.i18n)}var r={install:n};exports.VnConfirm=e.l,exports.VnDate=e.o,exports.VnFetch=e.r,exports.VnForm=e.n,exports.VnInput=e.a,exports.VnInputDate=e.i,exports.VnSkeletonForm=e.c,exports.VnSpinner=e.s,exports.default=r,exports.fetchLocalData=t.n,exports.focusFirstInput=t.p,exports.getObjectByKeys=t.a,exports.getObjectDifferences=t.o,exports.getRemoteAndLocalParams=t.r,Object.defineProperty(exports,"i18n",{enumerable:!0,get:function(){return t.d}}),exports.isComparableObject=t.s,exports.isSameValue=t.c,exports.requestData=t.i,exports.tMobile=t.h,exports.useArrayData=t.m,exports.useGlobalMessages=t.f,exports.useNotify=t.u,exports.useObjectComparison=t.l,exports.useRequired=t.g,exports.useState=t.t,exports.useValidator=t._;
|
package/dist/vn-front-lib.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.q-card[data-v-
|
|
1
|
+
.q-card[data-v-67508d3b]{white-space:pre-line;min-width:350px}.vn-spinner[data-v-e5edebae]{border:3px solid color-mix(in srgb, var(--vn-label-color) 15%, transparent);border-top-color:var(--q-primary);box-sizing:border-box;border-radius:50%;min-width:16px;min-height:16px;animation:.7s cubic-bezier(.4,.15,.6,.85) infinite vn-spin-e5edebae}@keyframes vn-spin-e5edebae{to{transform:rotate(360deg)}}.vn-spinner-fade-enter-active[data-v-e5edebae],.vn-spinner-fade-leave-active[data-v-e5edebae]{transition:opacity .3s,transform .3s}.vn-spinner-fade-enter-from[data-v-e5edebae],.vn-spinner-fade-leave-to[data-v-e5edebae]{opacity:0;transform:scale(.6)}.q-date[data-v-2705e766]{width:245px;min-width:unset}.q-date[data-v-2705e766] .q-date__calendar{padding-bottom:0}.q-date[data-v-2705e766] .q-date__view{min-height:245px;padding:8px}.q-date[data-v-2705e766] .q-date__calendar-days-container{min-height:160px;height:unset}.q-date[data-v-2705e766] .q-date__header{height:60px;padding:2px 2px 5px 12px}.uppercase-icon{cursor:pointer;transition:color .3s,transform .2s}.uppercase-icon:hover{color:var(--q-color-primary);transform:scale(1.2)}.q-notifications[data-v-4f7a49f7]{color:#000}.q-card[data-v-4f7a49f7]{padding:32px}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/vn-front-lib.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./composables-CAAnziP1.js";
|
|
2
|
+
import { a as _, c as v, i as y, l as b, n as x, o as S, r as C, s as w, t as T } from "./components-BN97tI4h.js";
|
|
3
3
|
//#region lib/main.js
|
|
4
|
-
function
|
|
5
|
-
for (let t in
|
|
4
|
+
function E(e, t = {}) {
|
|
5
|
+
for (let t in T) e.component(t, T[t]);
|
|
6
|
+
i(t.i18n);
|
|
6
7
|
}
|
|
7
|
-
var
|
|
8
|
+
var D = { install: E };
|
|
8
9
|
//#endregion
|
|
9
|
-
export { b as VnConfirm,
|
|
10
|
+
export { b as VnConfirm, S as VnDate, C as VnFetch, x as VnForm, _ as VnInput, y as VnInputDate, v as VnSkeletonForm, w as VnSpinner, D as default, u as fetchLocalData, f as focusFirstInput, t as getObjectByKeys, d as getObjectDifferences, p as getRemoteAndLocalParams, r as i18n, m as isComparableObject, n as isSameValue, s as requestData, o as tMobile, l as useArrayData, i as useGlobalMessages, g as useNotify, c as useObjectComparison, a as useRequired, h as useState, e as useValidator };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref } from 'vue';
|
|
3
|
-
import
|
|
3
|
+
import * as quasarPkg from 'quasar';
|
|
4
4
|
import { useI18n } from 'vue-i18n';
|
|
5
5
|
|
|
6
6
|
const { t } = useI18n();
|
|
@@ -42,11 +42,11 @@ const props = defineProps({
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]);
|
|
45
|
+
const emit = defineEmits(['confirm', 'cancel', ...quasarPkg.useDialogPluginComponent.emits]);
|
|
46
46
|
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
|
|
47
47
|
|
|
48
48
|
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
|
|
49
|
-
useDialogPluginComponent();
|
|
49
|
+
quasarPkg.useDialogPluginComponent();
|
|
50
50
|
|
|
51
51
|
const title = props.title || t('Confirm');
|
|
52
52
|
const message =
|
package/lib/components/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { default as VnConfirm } from './dialogs/VnConfirm.vue';
|
|
2
2
|
export { default as VnSkeletonForm } from './feedback/VnSkeletonForm.vue';
|
|
3
3
|
export { default as VnSpinner } from './feedback/VnSpinner.vue';
|
|
4
|
+
export { default as VnDate } from './inputs/VnDate.vue';
|
|
4
5
|
export { default as VnInput } from './inputs/VnInput.vue';
|
|
6
|
+
export { default as VnInputDate } from './inputs/VnInputDate.vue';
|
|
5
7
|
export { default as VnFetch } from './models/VnFetch.vue';
|
|
6
8
|
export { default as VnForm } from './models/VnForm.vue';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const model = defineModel({type: [String, Number], default: ""});
|
|
3
|
+
</script>
|
|
4
|
+
<template>
|
|
5
|
+
<QDate
|
|
6
|
+
v-model="model"
|
|
7
|
+
:today-btn="true"
|
|
8
|
+
:options="$attrs.options"
|
|
9
|
+
autocomplete="off"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
<style lang="scss" scoped>
|
|
13
|
+
.q-date {
|
|
14
|
+
width: 245px;
|
|
15
|
+
min-width: unset;
|
|
16
|
+
|
|
17
|
+
:deep(.q-date__calendar) {
|
|
18
|
+
padding-bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
:deep(.q-date__view) {
|
|
21
|
+
min-height: 245px;
|
|
22
|
+
padding: 8px;
|
|
23
|
+
}
|
|
24
|
+
:deep(.q-date__calendar-days-container) {
|
|
25
|
+
min-height: 160px;
|
|
26
|
+
height: unset;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:deep(.q-date__header) {
|
|
30
|
+
padding: 2px 2px 5px 12px;
|
|
31
|
+
height: 60px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import {nextTick, watch, computed, ref, useAttrs} from "vue";
|
|
3
|
+
import {useI18n} from "vue-i18n";
|
|
4
|
+
import {date, getCssVar} from "quasar";
|
|
5
|
+
import VnDate from "./VnDate.vue";
|
|
6
|
+
import { useRequired } from '@verdnatura/vn-front-lib/composables';
|
|
7
|
+
|
|
8
|
+
const $attrs = useAttrs();
|
|
9
|
+
const {t} = useI18n();
|
|
10
|
+
const {isRequired, requiredFieldRule} = useRequired($attrs);
|
|
11
|
+
const model = defineModel({type: [String, Date, Object]});
|
|
12
|
+
|
|
13
|
+
const $props = defineProps({
|
|
14
|
+
isOutlined: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
showEvent: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: true,
|
|
21
|
+
},
|
|
22
|
+
hideYearNavigation: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
clearOnHover: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const vnInputDateRef = ref(null);
|
|
33
|
+
const errColor = getCssVar("negative");
|
|
34
|
+
const textColor = ref("");
|
|
35
|
+
|
|
36
|
+
const dateFormat = "DD/MM/YYYY";
|
|
37
|
+
const isPopupOpen = ref();
|
|
38
|
+
const hover = ref();
|
|
39
|
+
|
|
40
|
+
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
|
41
|
+
|
|
42
|
+
const val = computed(() => model.value?.neq || model.value?.nin || model.value);
|
|
43
|
+
const inputTitle = computed(() => {
|
|
44
|
+
if (!val.value) return;
|
|
45
|
+
return Array.isArray(val.value)
|
|
46
|
+
? val.value.map((v) => date.formatDate(new Date(v), dateFormat)).join(", ")
|
|
47
|
+
: date.formatDate(new Date(val.value), dateFormat);
|
|
48
|
+
});
|
|
49
|
+
const popupDate = computed(() => {
|
|
50
|
+
const dateToFormat = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
51
|
+
return dateToFormat
|
|
52
|
+
? date.formatDate(new Date(dateToFormat), "YYYY/MM/DD")
|
|
53
|
+
: dateToFormat;
|
|
54
|
+
});
|
|
55
|
+
const styleAttrs = computed(() => {
|
|
56
|
+
return $props.isOutlined
|
|
57
|
+
? {
|
|
58
|
+
dense: true,
|
|
59
|
+
outlined: true,
|
|
60
|
+
rounded: true,
|
|
61
|
+
}
|
|
62
|
+
: {};
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const inputValue = ref("");
|
|
66
|
+
const dataCy = $attrs["data-cy"] ?? $attrs.label;
|
|
67
|
+
const menuDataCy = dataCy + "_menu";
|
|
68
|
+
const inputDataCy = dataCy + "_inputDate";
|
|
69
|
+
|
|
70
|
+
const validateAndCleanInput = (value) => {
|
|
71
|
+
if (!value && $attrs.clearable) {
|
|
72
|
+
inputValue.value = null;
|
|
73
|
+
model.value = null;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
inputValue.value = value.replace(/[^0-9./-]/g, "");
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const manageDate = (date) => {
|
|
80
|
+
if (!date) return;
|
|
81
|
+
inputValue.value = date.split("/").reverse().join("/");
|
|
82
|
+
formatDate();
|
|
83
|
+
isPopupOpen.value = false;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
watch(
|
|
87
|
+
() => model.value,
|
|
88
|
+
() => {
|
|
89
|
+
const dateToFormat = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
90
|
+
inputValue.value = dateToFormat
|
|
91
|
+
? date.formatDate(new Date(dateToFormat), dateFormat)
|
|
92
|
+
: "";
|
|
93
|
+
},
|
|
94
|
+
{immediate: true},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
watch(isPopupOpen, (val) => {
|
|
98
|
+
if (val && $props.hideYearNavigation) {
|
|
99
|
+
nextTick(() => {
|
|
100
|
+
const navButtons = ["back", "type", "forward"];
|
|
101
|
+
document.querySelectorAll(`.q-date__navigation`).forEach((parent) => {
|
|
102
|
+
for (let i = 0; i < navButtons.length; i++) {
|
|
103
|
+
if (parent.lastElementChild)
|
|
104
|
+
parent.removeChild(parent.lastElementChild);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const formatDate = () => {
|
|
112
|
+
let value = inputValue.value;
|
|
113
|
+
if (!value || value === model.value) {
|
|
114
|
+
textColor.value = "";
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const regex =
|
|
118
|
+
/^([0]?[1-9]|[12][0-9]|3[01])([./-])([0]?[1-9]|1[0-2])([./-](\d{1,4}))?$/;
|
|
119
|
+
if (!regex.test(value)) {
|
|
120
|
+
textColor.value = errColor;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
value = value.replace(/[.-]/g, "/");
|
|
125
|
+
const parts = value.split("/");
|
|
126
|
+
if (parts.length < 2) {
|
|
127
|
+
textColor.value = errColor;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let [day, month, year] = parts;
|
|
132
|
+
if (day.length === 1) day = "0" + day;
|
|
133
|
+
if (month.length === 1) month = "0" + month;
|
|
134
|
+
|
|
135
|
+
const currentYear = Date.vnNew().getFullYear();
|
|
136
|
+
if (!year) year = currentYear;
|
|
137
|
+
const millennium = currentYear.toString().slice(0, 1);
|
|
138
|
+
|
|
139
|
+
switch (year.length) {
|
|
140
|
+
case 1:
|
|
141
|
+
year = `${millennium}00${year}`;
|
|
142
|
+
break;
|
|
143
|
+
case 2:
|
|
144
|
+
year = `${millennium}0${year}`;
|
|
145
|
+
break;
|
|
146
|
+
case 3:
|
|
147
|
+
year = `${millennium}${year}`;
|
|
148
|
+
break;
|
|
149
|
+
case 4:
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let isoCandidate = `${year}/${month}/${day}`;
|
|
154
|
+
isoCandidate = date.formatDate(
|
|
155
|
+
new Date(isoCandidate).toISOString(),
|
|
156
|
+
"YYYY-MM-DDTHH:mm:ss.SSSZ",
|
|
157
|
+
);
|
|
158
|
+
const [isoYear, isoMonth, isoDay] = isoCandidate.split("-").map((e) => parseInt(e));
|
|
159
|
+
const parsedDate = new Date(isoYear, isoMonth - 1, isoDay);
|
|
160
|
+
|
|
161
|
+
const isValidDate =
|
|
162
|
+
parsedDate instanceof Date &&
|
|
163
|
+
!isNaN(parsedDate) &&
|
|
164
|
+
parsedDate.getFullYear() === parseInt(year) &&
|
|
165
|
+
parsedDate.getMonth() === parseInt(month) - 1 &&
|
|
166
|
+
parsedDate.getDate() === parseInt(day);
|
|
167
|
+
|
|
168
|
+
if (!isValidDate) {
|
|
169
|
+
textColor.value = errColor;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (val.value) {
|
|
174
|
+
const originalVal = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
175
|
+
const original =
|
|
176
|
+
originalVal instanceof Date ? originalVal : new Date(originalVal);
|
|
177
|
+
parsedDate.setHours(
|
|
178
|
+
original.getHours(),
|
|
179
|
+
original.getMinutes(),
|
|
180
|
+
original.getSeconds(),
|
|
181
|
+
original.getMilliseconds(),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const iso = parsedDate.toISOString();
|
|
186
|
+
if (model.value?.neq) model.value = {neq: iso};
|
|
187
|
+
else if (model.value?.nin) model.value = {nin: [...model.value.nin, iso]};
|
|
188
|
+
else model.value = iso;
|
|
189
|
+
|
|
190
|
+
textColor.value = "";
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const handleEnter = (event) => {
|
|
194
|
+
formatDate();
|
|
195
|
+
|
|
196
|
+
nextTick(() => {
|
|
197
|
+
const newEvent = new KeyboardEvent("keydown", {
|
|
198
|
+
key: "Enter",
|
|
199
|
+
code: "Enter",
|
|
200
|
+
bubbles: true,
|
|
201
|
+
cancelable: true,
|
|
202
|
+
});
|
|
203
|
+
vnInputDateRef.value?.$el?.dispatchEvent(newEvent);
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
</script>
|
|
207
|
+
|
|
208
|
+
<template>
|
|
209
|
+
<div @mouseover="hover = true" @mouseleave="hover = false">
|
|
210
|
+
<QInput
|
|
211
|
+
ref="vnInputDateRef"
|
|
212
|
+
v-model="inputValue"
|
|
213
|
+
class="vn-input-date"
|
|
214
|
+
placeholder="dd/mm/aaaa"
|
|
215
|
+
v-bind="{...$attrs, ...styleAttrs}"
|
|
216
|
+
:class="{required: isRequired}"
|
|
217
|
+
:rules="mixinRules"
|
|
218
|
+
:clearable="false"
|
|
219
|
+
:input-style="{color: textColor}"
|
|
220
|
+
:input-class="{'text-strike': !!(model?.neq || model?.nin)}"
|
|
221
|
+
:title="inputTitle"
|
|
222
|
+
@click="isPopupOpen = !isPopupOpen"
|
|
223
|
+
@keydown="isPopupOpen = false"
|
|
224
|
+
@focusout="formatDate"
|
|
225
|
+
@keydown.enter.prevent="handleEnter"
|
|
226
|
+
hide-bottom-space
|
|
227
|
+
:data-cy="inputDataCy"
|
|
228
|
+
@update:model-value="validateAndCleanInput"
|
|
229
|
+
autocomplete="off"
|
|
230
|
+
>
|
|
231
|
+
<template #append>
|
|
232
|
+
<QIcon
|
|
233
|
+
name="close"
|
|
234
|
+
size="xs"
|
|
235
|
+
class="cursor-pointer"
|
|
236
|
+
v-if="
|
|
237
|
+
($attrs.clearable == undefined || $attrs.clearable) &&
|
|
238
|
+
(!clearOnHover || hover) &&
|
|
239
|
+
inputValue &&
|
|
240
|
+
!$attrs.disable
|
|
241
|
+
"
|
|
242
|
+
@click="
|
|
243
|
+
vnInputDateRef.focus();
|
|
244
|
+
inputValue = null;
|
|
245
|
+
model = null;
|
|
246
|
+
isPopupOpen = false;
|
|
247
|
+
"
|
|
248
|
+
>
|
|
249
|
+
<QTooltip>{{ t("Remove") }}</QTooltip>
|
|
250
|
+
</QIcon>
|
|
251
|
+
</template>
|
|
252
|
+
<QMenu
|
|
253
|
+
v-if="$q.screen.gt.xs"
|
|
254
|
+
transition-show="scale"
|
|
255
|
+
transition-hide="scale"
|
|
256
|
+
v-model="isPopupOpen"
|
|
257
|
+
anchor="bottom left"
|
|
258
|
+
self="top start"
|
|
259
|
+
:no-focus="true"
|
|
260
|
+
:no-parent-event="true"
|
|
261
|
+
:data-cy="menuDataCy"
|
|
262
|
+
>
|
|
263
|
+
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
264
|
+
</QMenu>
|
|
265
|
+
<QDialog v-else v-model="isPopupOpen">
|
|
266
|
+
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
267
|
+
</QDialog>
|
|
268
|
+
</QInput>
|
|
269
|
+
</div>
|
|
270
|
+
</template>
|
|
271
|
+
<i18n>
|
|
272
|
+
es:
|
|
273
|
+
Open date: Abrir fecha
|
|
274
|
+
Remove: Eliminar
|
|
275
|
+
</i18n>
|
|
@@ -3,7 +3,7 @@ import axios from 'axios';
|
|
|
3
3
|
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
|
4
4
|
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
|
5
5
|
import { useI18n } from 'vue-i18n';
|
|
6
|
-
import
|
|
6
|
+
import * as quasarPkg from 'quasar';
|
|
7
7
|
import {
|
|
8
8
|
useState,
|
|
9
9
|
useValidator,
|
|
@@ -16,7 +16,7 @@ import { useStateStore } from 'lib/stores';
|
|
|
16
16
|
import { VnConfirm, VnSpinner, VnSkeletonForm } from 'lib/components';
|
|
17
17
|
import { onBeforeSave } from 'lib/filters';
|
|
18
18
|
const { push } = useRouter();
|
|
19
|
-
const quasar = useQuasar();
|
|
19
|
+
const quasar = quasarPkg.useQuasar();
|
|
20
20
|
const state = useState();
|
|
21
21
|
const stateStore = useStateStore();
|
|
22
22
|
const { t } = useI18n();
|
package/lib/composables/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { load } from 'js-yaml';
|
|
2
|
+
|
|
3
|
+
export let i18n;
|
|
4
|
+
export function useGlobalMessages(_i18n) {
|
|
5
|
+
i18n = _i18n;
|
|
6
|
+
const files = import.meta.glob('../i18n/locale/*.yml', {
|
|
7
|
+
eager: true,
|
|
8
|
+
import: 'default',
|
|
9
|
+
query: '?raw',
|
|
10
|
+
});
|
|
11
|
+
for (const [file, content] of Object.entries(files)) {
|
|
12
|
+
const lang = file.split('/').pop().split('.')[0];
|
|
13
|
+
i18n.global.mergeLocaleMessage(lang, load(content));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as quasar from 'quasar';
|
|
2
|
+
import { i18n } from './useGlobalMessages';
|
|
3
3
|
|
|
4
4
|
export function useNotify() {
|
|
5
|
-
const { t } = useI18n();
|
|
6
5
|
const notify = (message, type = 'positive', icon, opts = {}) => {
|
|
7
6
|
const defaultIcons = {
|
|
8
7
|
warning: 'warning',
|
|
9
8
|
negative: 'error',
|
|
10
9
|
positive: 'check',
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
message: t(message, opts.translationParams || {}),
|
|
11
|
+
const payload = {
|
|
12
|
+
message: i18n.global.t(message, opts.translationParams || {}),
|
|
15
13
|
type: type,
|
|
16
14
|
icon: icon ? icon : defaultIcons[type],
|
|
17
15
|
...opts,
|
|
18
|
-
}
|
|
16
|
+
};
|
|
17
|
+
quasar.Notify.create(payload);
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
return {
|
package/lib/i18n/locale/en.yml
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
globals:
|
|
2
|
-
fieldRequired:
|
|
3
|
-
valueCantBeEmpty:
|
|
2
|
+
fieldRequired: Field required
|
|
3
|
+
valueCantBeEmpty: Value cannot be empty
|
|
4
|
+
cancel: Cancel
|
|
5
|
+
confirm: Confirm
|
|
6
|
+
pleaseWait: Please wait...
|
|
7
|
+
saveAndContinue: Save and go to
|
|
8
|
+
unsavedPopup:
|
|
9
|
+
title: Unsaved changes will be lost
|
|
10
|
+
subtitle: Are you sure exit without saving?
|
|
11
|
+
pageTitles:
|
|
12
|
+
basicData: Basic data
|
|
4
13
|
inputMin: Must be more than {value}
|
|
14
|
+
inputMax: Must be less than {value}
|
|
15
|
+
maxLength: Must not exceed {value} characters
|
|
16
|
+
Confirm: Confirm
|
|
17
|
+
Are you sure you want to continue?: Are you sure you want to continue?
|
|
18
|
+
Remove: Remove
|
|
19
|
+
Convert to uppercase: Convert to uppercase
|
package/lib/i18n/locale/es.yml
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
globals:
|
|
2
|
-
fieldRequired:
|
|
3
|
-
valueCantBeEmpty:
|
|
2
|
+
fieldRequired: Campo requerido
|
|
3
|
+
valueCantBeEmpty: El valor no puede estar vacío
|
|
4
|
+
cancel: Cancelar
|
|
5
|
+
confirm: Confirmar
|
|
6
|
+
pleaseWait: Por favor espera...
|
|
7
|
+
saveAndContinue: Guardar e ir a
|
|
8
|
+
unsavedPopup:
|
|
9
|
+
title: Los cambios que no haya guardado se perderán
|
|
10
|
+
subtitle: ¿Seguro que quiere salir sin guardar?
|
|
11
|
+
pageTitles:
|
|
12
|
+
basicData: Datos básicos
|
|
4
13
|
inputMin: Debe ser mayor a {value}
|
|
14
|
+
inputMax: Debe ser menor a {value}
|
|
15
|
+
maxLength: No debe superar los {value} caracteres
|
|
16
|
+
Confirm: Confirmar
|
|
17
|
+
Are you sure you want to continue?: ¿Seguro que quieres continuar?
|
|
18
|
+
Remove: Eliminar
|
|
19
|
+
Convert to uppercase: Convertir a mayúsculas
|
package/lib/main.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export * from './composables';
|
|
3
3
|
import * as components from './components';
|
|
4
|
+
import { useGlobalMessages } from './composables/useGlobalMessages';
|
|
4
5
|
|
|
5
|
-
function install(app) {
|
|
6
|
+
function install(app, options = {}) {
|
|
6
7
|
for (const name in components) {
|
|
7
8
|
app.component(name, components[name]);
|
|
8
9
|
}
|
|
10
|
+
useGlobalMessages(options.i18n);
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export default {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdnatura/vn-front-lib",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Vue 3 component and composable library",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"author": "Verdnatura Levante SL",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"fmt:check": "oxfmt --check"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@intlify/unplugin-vue-i18n": "^11.2.
|
|
55
|
+
"@intlify/unplugin-vue-i18n": "^11.2.5",
|
|
56
56
|
"@quasar/vite-plugin": "^1.12.0",
|
|
57
57
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
58
58
|
"@vue/test-utils": "^2.4.11",
|
|
@@ -67,8 +67,7 @@
|
|
|
67
67
|
"vite": "^8.1.1",
|
|
68
68
|
"vitest": "^4.1.10",
|
|
69
69
|
"vue": "^3.5.13",
|
|
70
|
-
"vue-i18n": "^9.14.4"
|
|
71
|
-
"yaml": "^2.9.0"
|
|
70
|
+
"vue-i18n": "^9.14.4"
|
|
72
71
|
},
|
|
73
72
|
"peerDependencies": {
|
|
74
73
|
"axios": ">=1.0.0",
|
|
@@ -78,5 +77,8 @@
|
|
|
78
77
|
"vue": ">=3.5.0",
|
|
79
78
|
"vue-i18n": ">=9.0.0",
|
|
80
79
|
"vue-router": ">=4.5.0"
|
|
80
|
+
},
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"js-yaml": "^5.4.2"
|
|
81
83
|
}
|
|
82
84
|
}
|