@7365admin1/layer-common 4.1.2-staging.245 → 4.1.2-staging.246

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.
@@ -35,9 +35,15 @@ const dateFormattedReadOnly = ref<string | null>(null)
35
35
 
36
36
  const dateInput = ref<HTMLInputElement | null>(null)
37
37
  const datePickerRef = ref<HTMLInputElement | null>(null)
38
+ let nativeInput: HTMLInputElement | null = null
38
39
 
39
40
  const isInitialLoad = ref(true)
40
41
 
42
+ function handleNativeInputClick(e: MouseEvent) {
43
+ e.stopPropagation()
44
+ openDatePicker()
45
+ }
46
+
41
47
  function clearDate() {
42
48
  date.value = null
43
49
  dateFormattedReadOnly.value = null
@@ -88,15 +94,17 @@ watch(date, () => {
88
94
  onMounted(async () => {
89
95
  await nextTick()
90
96
  isInitialLoad.value = false
91
- const nativeInput = (datePickerRef.value as any)?.$el?.querySelector('input')
97
+ nativeInput = (datePickerRef.value as any)?.$el?.querySelector('input')
92
98
  if (nativeInput) {
93
- nativeInput.addEventListener('click', (e: MouseEvent) => {
94
- e.stopPropagation()
95
- openDatePicker()
96
- })
99
+ nativeInput.addEventListener('click', handleNativeInputClick)
97
100
  }
98
101
  })
99
102
 
103
+ onBeforeUnmount(() => {
104
+ nativeInput?.removeEventListener('click', handleNativeInputClick)
105
+ nativeInput = null
106
+ })
107
+
100
108
  defineExpose({
101
109
  validate
102
110
  })
@@ -70,9 +70,15 @@ const inputPlaceholder = computed(
70
70
 
71
71
  const dateInput = ref<HTMLInputElement | null>(null);
72
72
  const dateTimePickerRef = ref<HTMLInputElement | null>(null);
73
+ let nativeInput: HTMLInputElement | null = null;
73
74
 
74
75
  const isInitialLoad = ref(true);
75
76
 
77
+ function handleNativeInputClick(e: MouseEvent) {
78
+ e.stopPropagation();
79
+ openDatePicker();
80
+ }
81
+
76
82
  function openDatePicker() {
77
83
  setTimeout(() => {
78
84
  dateInput.value?.showPicker?.();
@@ -177,17 +183,19 @@ onMounted(async () => {
177
183
  await nextTick();
178
184
  isInitialLoad.value = false;
179
185
  // Wait until Vuetify renders its internal input
180
- const nativeInput = (dateTimePickerRef.value as any)?.$el?.querySelector(
186
+ nativeInput = (dateTimePickerRef.value as any)?.$el?.querySelector(
181
187
  "input"
182
188
  );
183
189
  if (nativeInput) {
184
- nativeInput.addEventListener("click", (e: MouseEvent) => {
185
- e.stopPropagation();
186
- openDatePicker();
187
- });
190
+ nativeInput.addEventListener("click", handleNativeInputClick);
188
191
  }
189
192
  });
190
193
 
194
+ onBeforeUnmount(() => {
195
+ nativeInput?.removeEventListener("click", handleNativeInputClick);
196
+ nativeInput = null;
197
+ });
198
+
191
199
  defineExpose({
192
200
  validate,
193
201
  });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.1.2-staging.245",
5
+ "version": "4.1.2-staging.246",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",