@xy-planning-network/trees 0.6.9 → 0.6.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xy-planning-network/trees",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -55,17 +55,15 @@ onMounted(() => {
55
55
  },
56
56
  }
57
57
 
58
- if (props.maxRange) {
59
- // Set the range to a prefilled value given the allowed range
60
- const daysAgo = new Date()
61
- const minDate = daysAgo.setDate(daysAgo.getDate() - props.maxRange)
62
- const maxDate = new Date()
63
- opts.defaultDate = [minDate, maxDate]
64
- updateModelValue({
65
- minDate: Math.floor(minDate / 1000),
66
- maxDate: Math.floor(maxDate.getTime() / 1000),
67
- })
58
+ // Handle initial values if set
59
+ if (props.modelValue.minDate != 0 && props.modelValue.maxDate != 0) {
60
+ opts.defaultDate = [
61
+ props.modelValue.minDate * 1000,
62
+ props.modelValue.maxDate * 1000,
63
+ ]
64
+ }
68
65
 
66
+ if (props.maxRange) {
69
67
  // Handle onChange to dynamically adjust maxDate to x days ahead of the selected start date
70
68
  opts.onChange = (selectedDates, _, self) => {
71
69
  if (selectedDates.length === 1) {
@@ -67,6 +67,20 @@ const reloadTable = (): void => {
67
67
  loadAndRender()
68
68
  }
69
69
 
70
+ const setDateRange = (): void => {
71
+ if (dateSearchProps.value.maxRange) {
72
+ const daysAgo = new Date()
73
+ const minDate = daysAgo.setDate(
74
+ daysAgo.getDate() - dateSearchProps.value.maxRange
75
+ )
76
+ const maxDate = new Date()
77
+ dateRange.value = {
78
+ minDate: Math.floor(minDate / 1000),
79
+ maxDate: Math.floor(maxDate.getTime() / 1000),
80
+ }
81
+ }
82
+ }
83
+
70
84
  const tableData = ref<Record<string, any>[]>([])
71
85
 
72
86
  const publicMethods: DynamicTableAPI = {
@@ -151,6 +165,7 @@ watch(
151
165
  defineExpose(publicMethods)
152
166
 
153
167
  // onCreated
168
+ setDateRange()
154
169
  loadAndRender()
155
170
  </script>
156
171
  <template>