@@ -16,9 +14,9 @@
diff --git a/src/entry.esm.js b/src/entry.esm.js
index f95d466..e5a83d7 100644
--- a/src/entry.esm.js
+++ b/src/entry.esm.js
@@ -1,16 +1,15 @@
-
// Import vue component
import component from '@/litepie-datepicker.vue';
// Default export is installable instance of component.
// IIFE injects install function into component, allowing component
// to be registered via Vue.use() as well as Vue.component(),
-export default /*#__PURE__*/(() => {
+export default /*#__PURE__*/ (() => {
// Get component instance
const installable = component;
// Attach install function executed by Vue.use()
- installable.install = (app) => {
+ installable.install = (app, options) => {
app.component('LitepieDatepicker', installable);
};
return installable;
diff --git a/src/lib/fn.js b/src/lib/fn.js
index 3e641f3..9fa8bfb 100644
--- a/src/lib/fn.js
+++ b/src/lib/fn.js
@@ -87,6 +87,12 @@ export const useDirective = binding => {
if ($event.target.classList.contains(`${arg}-cancel-picker`)) {
return (instance.isShow = false);
}
+ if (
+ $event.target.classList.contains(`litepie-shortcuts`) &&
+ autoApply
+ ) {
+ return (instance.isShow = false);
+ }
return (instance.isShow =
instance.LitepieDatepickerRef.contains($event.target) ||
diff --git a/src/litepie-datepicker.vue b/src/litepie-datepicker.vue
index 21e94d8..a460564 100644
--- a/src/litepie-datepicker.vue
+++ b/src/litepie-datepicker.vue
@@ -86,13 +86,13 @@
:shortcuts="shortcuts"
:as-range="asRange()"
:as-single="asSingle"
- :i18n="i18n"
+ :i18n="options.shortcuts"
/>
@@ -253,8 +241,7 @@ import {
isProxy,
watchEffect,
watch,
- unref,
- onUpdated
+ unref
} from 'vue';
import {
useCurrentDate,
@@ -354,9 +341,21 @@ export default /*#__PURE__*/ defineComponent({
type: [Object, String],
default: () => new Date()
},
- footer: {
+ options: {
type: Object,
- default: () => undefined
+ default: () => ({
+ shortcuts: {
+ today: 'Today',
+ yesterday: 'Yesterday',
+ past: period => `Last ${period} Days`,
+ currentMonth: 'This Month',
+ pastMonth: 'Last Month'
+ },
+ footer: {
+ apply: 'Apply',
+ cancel: 'Cancel'
+ }
+ })
}
},
inheritAttrs: false,
@@ -367,7 +366,6 @@ export default /*#__PURE__*/ defineComponent({
const LitepieInputRef = ref(null);
const isShow = ref(false);
const placement = ref(true);
- const jsonLocale = ref(null);
const givenPlaceholder = ref('');
const selection = ref(null);
const pickerValue = ref('');
@@ -1240,6 +1238,9 @@ export default /*#__PURE__*/ defineComponent({
) {
datepicker.value.next = datepicker.value.previous.add(1, 'month');
}
+ nextTick(() => {
+ force();
+ });
};
const emitShortcut = (s, e) => {
@@ -1354,18 +1355,6 @@ export default /*#__PURE__*/ defineComponent({
emitShortcut(s, e);
};
- const locale = () => {
- return import(`./locale/${props.i18n}`)
- .then(async module => {
- return await module.default;
- })
- .catch(() => {
- return import(`./locale/en`).then(async module => {
- return await module.default;
- });
- });
- };
-
watch(
() => isShow.value,
newValue => {
@@ -1422,12 +1411,6 @@ export default /*#__PURE__*/ defineComponent({
}
});
- watchEffect(() => {
- locale().then(v => {
- jsonLocale.value = v;
- });
- });
-
watchEffect(async () => {
const locale = props.i18n;
await import(`dayjs/locale/${locale}.js`)
@@ -1572,13 +1555,6 @@ export default /*#__PURE__*/ defineComponent({
});
});
- onUpdated(() => {
- nextTick(() => {
- placement.value = useVisibleViewport(LitepieRef.value);
- });
- });
-
- provide('jsonLocale', jsonLocale);
provide('isBetweenRange', isBetweenRange);
provide('betweenRangeClasses', betweenRangeClasses);
provide('datepickerClasses', datepickerClasses);
@@ -1596,7 +1572,6 @@ export default /*#__PURE__*/ defineComponent({
LitepieInputRef,
isShow,
placement,
- jsonLocale,
givenPlaceholder,
previous,
next,