frappe-ui 0.1.155 → 0.1.158
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 +1 -1
- package/src/components/Autocomplete/Autocomplete.vue +1 -1
- package/src/components/DatePicker/DatePicker.vue +7 -6
- package/src/components/DatePicker/DateRangePicker.vue +35 -14
- package/src/components/DatePicker/DateTimePicker.vue +7 -7
- package/src/components/DatePicker/types.ts +3 -4
- package/src/components/FormControl/FormControl.vue +0 -7
- package/src/components/Select/types.ts +0 -1
- package/src/components/TextInput/types.ts +0 -1
package/package.json
CHANGED
|
@@ -322,7 +322,7 @@ const makeOption = (option: AutocompleteOption) => {
|
|
|
322
322
|
|
|
323
323
|
const getLabel = (option: AutocompleteOption) => {
|
|
324
324
|
if (isOption(option)) {
|
|
325
|
-
return option?.label || option?.value
|
|
325
|
+
return option?.label || option?.value
|
|
326
326
|
}
|
|
327
327
|
return option
|
|
328
328
|
}
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
:class="inputClass"
|
|
16
16
|
v-bind="$attrs"
|
|
17
17
|
>
|
|
18
|
-
<template v-if="
|
|
18
|
+
<template #prefix v-if="$slots.prefix">
|
|
19
|
+
<slot name="prefix" />
|
|
20
|
+
</template>
|
|
19
21
|
</TextInput>
|
|
20
22
|
</template>
|
|
21
23
|
|
|
@@ -128,16 +130,15 @@
|
|
|
128
130
|
import { computed, onMounted } from 'vue'
|
|
129
131
|
|
|
130
132
|
import { Button } from '../Button'
|
|
131
|
-
import { Popover } from '../Popover'
|
|
132
133
|
import FeatherIcon from '../FeatherIcon.vue'
|
|
134
|
+
import { Popover } from '../Popover'
|
|
133
135
|
import { TextInput } from '../TextInput'
|
|
134
|
-
import LucideCalendar from '~icons/lucide/calendar'
|
|
135
136
|
|
|
136
|
-
import { getDate, getDateValue } from './utils'
|
|
137
|
-
import { useDatePicker } from './useDatePicker'
|
|
138
137
|
import { dayjsLocal } from '../../utils/dayjs'
|
|
138
|
+
import { useDatePicker } from './useDatePicker'
|
|
139
|
+
import { getDate, getDateValue } from './utils'
|
|
139
140
|
|
|
140
|
-
import type {
|
|
141
|
+
import type { DatePickerEmits, DatePickerProps } from './types'
|
|
141
142
|
|
|
142
143
|
const props = defineProps<DatePickerProps>()
|
|
143
144
|
const emit = defineEmits<DatePickerEmits>()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Popover
|
|
3
|
+
ref="popoverRef"
|
|
3
4
|
@open="selectCurrentMonthYear"
|
|
4
5
|
class="flex w-full [&>div:first-child]:w-full"
|
|
5
6
|
:placement="placement"
|
|
@@ -8,14 +9,17 @@
|
|
|
8
9
|
<TextInput
|
|
9
10
|
readonly
|
|
10
11
|
type="text"
|
|
11
|
-
icon-left="calendar"
|
|
12
12
|
:placeholder="placeholder"
|
|
13
13
|
:value="dateValue && formatter ? formatDates(dateValue) : dateValue"
|
|
14
14
|
@focus="!readonly ? togglePopover() : null"
|
|
15
15
|
class="w-full"
|
|
16
16
|
:class="inputClass"
|
|
17
17
|
v-bind="$attrs"
|
|
18
|
-
|
|
18
|
+
>
|
|
19
|
+
<template #prefix v-if="$slots.prefix">
|
|
20
|
+
<slot name="prefix" />
|
|
21
|
+
</template>
|
|
22
|
+
</TextInput>
|
|
19
23
|
</template>
|
|
20
24
|
|
|
21
25
|
<template #body="{ togglePopover }">
|
|
@@ -120,15 +124,13 @@
|
|
|
120
124
|
</template>
|
|
121
125
|
|
|
122
126
|
<script setup lang="ts">
|
|
123
|
-
import { computed,
|
|
127
|
+
import { computed, onMounted, ref } from 'vue'
|
|
124
128
|
|
|
125
|
-
import { Button } from '../Button'
|
|
126
129
|
import { Popover } from '../Popover'
|
|
127
|
-
import FeatherIcon from '../FeatherIcon.vue'
|
|
128
130
|
import { TextInput } from '../TextInput'
|
|
129
131
|
|
|
130
|
-
import { getDate, getDateValue } from './utils'
|
|
131
132
|
import { useDatePicker } from './useDatePicker'
|
|
133
|
+
import { getDate, getDateValue } from './utils'
|
|
132
134
|
|
|
133
135
|
import type { DatePickerEmits, DatePickerProps } from './types'
|
|
134
136
|
|
|
@@ -161,8 +163,8 @@ const dateValue = computed(() => {
|
|
|
161
163
|
return props.value ? props.value : props.modelValue
|
|
162
164
|
})
|
|
163
165
|
|
|
164
|
-
const fromDate = ref<string>(
|
|
165
|
-
const toDate = ref<string>(
|
|
166
|
+
const fromDate = ref<string>('')
|
|
167
|
+
const toDate = ref<string>('')
|
|
166
168
|
|
|
167
169
|
function handleDateClick(date: Date) {
|
|
168
170
|
if (fromDate.value && toDate.value) {
|
|
@@ -215,13 +217,15 @@ function isInRange(date: Date) {
|
|
|
215
217
|
return date >= getDate(fromDate.value) && date <= getDate(toDate.value)
|
|
216
218
|
}
|
|
217
219
|
|
|
218
|
-
function formatDates(value: string) {
|
|
219
|
-
if (!value)
|
|
220
|
-
|
|
220
|
+
function formatDates(value: string | string[]) {
|
|
221
|
+
if (!value) return ''
|
|
222
|
+
|
|
223
|
+
if (typeof value === 'string') {
|
|
224
|
+
value = value.split(',')
|
|
221
225
|
}
|
|
222
|
-
|
|
226
|
+
|
|
223
227
|
return props.formatter
|
|
224
|
-
? props.formatter(
|
|
228
|
+
? props.formatter(value[0]) + ' to ' + props.formatter(value[1])
|
|
225
229
|
: value
|
|
226
230
|
}
|
|
227
231
|
|
|
@@ -231,5 +235,22 @@ function clearDates() {
|
|
|
231
235
|
selectDates()
|
|
232
236
|
}
|
|
233
237
|
|
|
234
|
-
|
|
238
|
+
const popoverRef = ref<InstanceType<typeof Popover>>()
|
|
239
|
+
|
|
240
|
+
onMounted(() => {
|
|
241
|
+
let dates: string | string[] | undefined =
|
|
242
|
+
typeof dateValue?.value === 'string'
|
|
243
|
+
? dateValue.value.split(',')
|
|
244
|
+
: dateValue.value
|
|
245
|
+
fromDate.value = dates?.[0] || ''
|
|
246
|
+
toDate.value = dates?.[1] || ''
|
|
247
|
+
|
|
248
|
+
selectCurrentMonthYear()
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
defineExpose({
|
|
252
|
+
open: () => {
|
|
253
|
+
popoverRef.value?.open()
|
|
254
|
+
},
|
|
255
|
+
})
|
|
235
256
|
</script>
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<TextInput
|
|
9
9
|
readonly
|
|
10
10
|
type="text"
|
|
11
|
-
icon-left="calendar"
|
|
12
11
|
:placeholder="placeholder"
|
|
13
12
|
:value="dateValue && formatter ? formatter(dateValue) : dateValue"
|
|
14
13
|
@focus="!readonly ? togglePopover() : null"
|
|
@@ -16,7 +15,9 @@
|
|
|
16
15
|
:class="inputClass"
|
|
17
16
|
v-bind="$attrs"
|
|
18
17
|
>
|
|
19
|
-
<template v-if="
|
|
18
|
+
<template #prefix v-if="$slots.prefix">
|
|
19
|
+
<slot name="prefix" />
|
|
20
|
+
</template>
|
|
20
21
|
</TextInput>
|
|
21
22
|
</template>
|
|
22
23
|
|
|
@@ -189,17 +190,16 @@
|
|
|
189
190
|
</template>
|
|
190
191
|
|
|
191
192
|
<script setup lang="ts">
|
|
192
|
-
import {
|
|
193
|
+
import { computed, onMounted, ref } from 'vue'
|
|
193
194
|
|
|
194
195
|
import { Button } from '../Button'
|
|
195
|
-
import { Popover } from '../Popover'
|
|
196
196
|
import FeatherIcon from '../FeatherIcon.vue'
|
|
197
|
+
import { Popover } from '../Popover'
|
|
197
198
|
import { TextInput } from '../TextInput'
|
|
198
|
-
import LucideCalendar from '~icons/lucide/calendar'
|
|
199
199
|
|
|
200
|
-
import { getDate } from './utils'
|
|
201
|
-
import { useDatePicker } from './useDatePicker'
|
|
202
200
|
import { dayjs, dayjsLocal, dayjsSystem } from '../../utils/dayjs'
|
|
201
|
+
import { useDatePicker } from './useDatePicker'
|
|
202
|
+
import { getDate } from './utils'
|
|
203
203
|
|
|
204
204
|
import type { DatePickerEmits, DatePickerProps } from './types'
|
|
205
205
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export interface DatePickerProps {
|
|
2
|
-
value?: string
|
|
3
|
-
modelValue?: string
|
|
2
|
+
value?: string | string[] // format: "YYYY-MM-DD,YYYY-MM-DD" or ["YYYY-MM-DD","YYYY-MM-DD"]
|
|
3
|
+
modelValue?: string | string[] // format: "YYYY-MM-DD,YYYY-MM-DD" or ["YYYY-MM-DD","YYYY-MM-DD"]
|
|
4
4
|
placeholder?: string
|
|
5
5
|
formatter?: (date: string) => string
|
|
6
6
|
readonly?: boolean
|
|
7
7
|
inputClass?: string | Array<string> | Record<string, boolean>
|
|
8
|
-
placement?: string
|
|
9
|
-
hideIcon?: boolean
|
|
8
|
+
placement?: string
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export type DatePickerEmits = {
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
v-if="type === 'select'"
|
|
16
16
|
:id="id"
|
|
17
17
|
v-bind="{ ...controlAttrs, size, variant }"
|
|
18
|
-
v-model="model"
|
|
19
18
|
>
|
|
20
19
|
<template #prefix v-if="$slots.prefix">
|
|
21
20
|
<slot name="prefix" />
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
<Autocomplete
|
|
25
24
|
v-else-if="type === 'autocomplete'"
|
|
26
25
|
v-bind="{ ...controlAttrs }"
|
|
27
|
-
v-model="model"
|
|
28
26
|
>
|
|
29
27
|
<template #prefix v-if="$slots.prefix">
|
|
30
28
|
<slot name="prefix" />
|
|
@@ -37,13 +35,11 @@
|
|
|
37
35
|
v-else-if="type === 'textarea'"
|
|
38
36
|
:id="id"
|
|
39
37
|
v-bind="{ ...controlAttrs, size, variant }"
|
|
40
|
-
v-model="model"
|
|
41
38
|
/>
|
|
42
39
|
<TextInput
|
|
43
40
|
v-else
|
|
44
41
|
:id="id"
|
|
45
42
|
v-bind="{ ...controlAttrs, type, size, variant, required }"
|
|
46
|
-
v-model="model"
|
|
47
43
|
>
|
|
48
44
|
<template #prefix v-if="$slots.prefix">
|
|
49
45
|
<slot name="prefix" />
|
|
@@ -60,7 +56,6 @@
|
|
|
60
56
|
v-else
|
|
61
57
|
:id="id"
|
|
62
58
|
v-bind="{ ...controlAttrs, label, size, class: attrs.class }"
|
|
63
|
-
v-model="model"
|
|
64
59
|
/>
|
|
65
60
|
</template>
|
|
66
61
|
<script setup lang="ts">
|
|
@@ -81,8 +76,6 @@ const props = withDefaults(defineProps<FormControlProps>(), {
|
|
|
81
76
|
variant: 'subtle',
|
|
82
77
|
})
|
|
83
78
|
|
|
84
|
-
const model = defineModel()
|
|
85
|
-
|
|
86
79
|
const attrs = useAttrs()
|
|
87
80
|
const controlAttrs = computed(() => {
|
|
88
81
|
// pass everything except class and style
|