@veritree/ui 0.75.0 → 0.75.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.
@@ -14,7 +14,7 @@ export const formControlMixin = {
14
14
  default: false,
15
15
  },
16
16
  value: {
17
- type: [String, Number, Object, Array],
17
+ type: [String, Number, Object, Array, Date],
18
18
  default: null,
19
19
  },
20
20
  variant: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.75.0",
3
+ "version": "0.75.1-0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -17,7 +17,8 @@
17
17
  "dependencies": {
18
18
  "@floating-ui/dom": "^1.2.0",
19
19
  "@linusborg/vue-simple-portal": "^0.1.5",
20
- "@veritree/icons": "^0.60.0"
20
+ "@veritree/icons": "^0.60.0",
21
+ "v-calendar": "^2.4.2"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@babel/eslint-parser": "^7.23.10",
@@ -1,19 +1,27 @@
1
1
  <template>
2
- <div class="relative">
3
- <input
4
- type="date"
5
- :class="classComputed"
6
- :value="date"
7
- :disabled="disabled"
8
- v-bind="$attrs"
9
- v-on="listeners"
10
- />
11
- <span
12
- class="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2"
13
- :class="[disabled ? 'bg-gray-100' : 'bg-white']"
14
- ><IconCalendar class="-z-0 h-5 w-5 scale-90 text-gray-600"
15
- /></span>
16
- </div>
2
+ <VTPopover>
3
+ <VTPopoverTrigger ref="trigger">
4
+ <button :class="classComputed" :disabled="disabled">
5
+ <span>{{ date }}</span>
6
+ <span
7
+ class="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2"
8
+ :class="[disabled ? 'bg-gray-100' : 'bg-white']"
9
+ >
10
+ <IconCalendar class="-z-0 h-5 w-5 scale-90 text-gray-600" />
11
+ </span>
12
+ </button>
13
+ </VTPopoverTrigger>
14
+ <VTPopoverContent>
15
+ <DatePicker
16
+ v-model="date"
17
+ :min-date="min"
18
+ :max-date="max"
19
+ color="null"
20
+ class="min-w-full"
21
+ @dayclick="onDayClick"
22
+ />
23
+ </VTPopoverContent>
24
+ </VTPopover>
17
25
  </template>
18
26
 
19
27
  <script>
@@ -21,27 +29,49 @@ import {
21
29
  formControlMixin,
22
30
  formControlStyleMixin,
23
31
  } from '../../../mixins/form-control';
32
+ import VTPopover from './../Popover/VTPopover.vue';
33
+ import VTPopoverTrigger from './../Popover/VTPopoverTrigger.vue';
34
+ import VTPopoverContent from './../Popover/VTPopoverContent.vue';
35
+ import DatePicker from 'v-calendar/lib/components/date-picker.umd';
24
36
 
25
37
  export default {
26
38
  name: 'VTInputDate',
27
39
 
28
40
  mixins: [formControlMixin, formControlStyleMixin],
29
41
 
42
+ components: {
43
+ VTPopover,
44
+ VTPopoverTrigger,
45
+ VTPopoverContent,
46
+ DatePicker,
47
+ },
48
+
49
+ props: {
50
+ min: {
51
+ type: [String, Date],
52
+ default: null,
53
+ },
54
+ max: {
55
+ type: [String, Date],
56
+ default: null,
57
+ },
58
+ },
59
+
30
60
  computed: {
31
61
  date: {
32
62
  get() {
33
- return this.value ? this.$date.format(this.value, 'YYYY-MM-DD') : null;
63
+ return this.value ? new Date(this.value).toLocaleDateString() : null;
34
64
  },
35
65
  set(newDate) {
36
66
  this.$emit('input', newDate);
37
67
  },
38
68
  },
39
69
  },
70
+
71
+ methods: {
72
+ onDayClick() {
73
+ this.$refs.trigger.cancel();
74
+ },
75
+ },
40
76
  };
41
77
  </script>
42
-
43
- <style scoped lang="postcss">
44
- input[type='date']::-webkit-calendar-picker-indicator {
45
- @apply absolute right-0 z-10 h-10 w-10 cursor-pointer opacity-0;
46
- }
47
- </style>
@@ -1,82 +0,0 @@
1
- <template>
2
- <input
3
- :class="classes"
4
- class="form-control"
5
- :data-theme="theme"
6
- :type="type"
7
- :value="value"
8
- v-on="listeners"
9
- />
10
- </template>
11
-
12
- <script>
13
- export default {
14
- name: 'VTInput',
15
-
16
- props: {
17
- lazy: {
18
- type: Boolean,
19
- default: false,
20
- },
21
- type: {
22
- type: String,
23
- default: 'text',
24
- },
25
- theme: {
26
- type: String,
27
- default: null,
28
- validator(value) {
29
- return ['dark'].includes(value);
30
- },
31
- },
32
- variant: {
33
- type: [String, Object],
34
- default: '',
35
- validator(value) {
36
- if (value === '' || typeof value === 'object') {
37
- return true;
38
- }
39
-
40
- return ['success', 'warning', 'error'].includes(value);
41
- },
42
- },
43
- value: {
44
- type: [String, Number, Object, Array],
45
- default: null,
46
- },
47
- },
48
-
49
- computed: {
50
- classes() {
51
- const classes = {};
52
-
53
- if (this.variant) {
54
- classes[`form-control--${this.variant}`] = true;
55
- }
56
-
57
- return classes;
58
- },
59
-
60
- listeners() {
61
- // `Object.assign` merges objects together to form a new object
62
- return Object.assign(
63
- {},
64
- // We add all the listeners from the parent
65
- this.$listeners,
66
- // Then we can add custom listeners or override the
67
- // behavior of some listeners.
68
- {
69
- // This ensures that the component works with v-model
70
- input: (event) => {
71
- if (this.lazy) return;
72
- this.$emit('input', event.target.value);
73
- },
74
- blur: (event) => {
75
- this.$emit('blur', event);
76
- },
77
- }
78
- );
79
- },
80
- },
81
- };
82
- </script>
@@ -1,36 +0,0 @@
1
- <template>
2
- <VTInput v-model="date" type="date" @change="$emit('change')" />
3
- </template>
4
-
5
- <script>
6
- import VTInput from './VTInput.vue';
7
-
8
- export default {
9
- name: 'VTInputDate',
10
-
11
- components: { VTInput },
12
-
13
- model: {
14
- prop: 'value',
15
- event: 'input',
16
- },
17
-
18
- props: {
19
- value: {
20
- type: String,
21
- default: '',
22
- },
23
- },
24
-
25
- computed: {
26
- date: {
27
- get() {
28
- return this.$date.format(this.value, 'YYYY-MM-DD');
29
- },
30
- set(newDate) {
31
- this.$emit('input', newDate);
32
- },
33
- },
34
- },
35
- };
36
- </script>
@@ -1,60 +0,0 @@
1
- <template>
2
- <div class="flex items-stretch gap-2">
3
- <VTInput
4
- ref="input"
5
- type="file"
6
- :value="value"
7
- :theme="theme"
8
- v-bind="$attrs"
9
- @change="onChange"
10
- />
11
- <VTButton :theme="theme" @click.stop="onButtonClick">Browse</VTButton>
12
- </div>
13
- </template>
14
-
15
- <script>
16
- import VTButton from '../Button/VTButton.vue';
17
- import VTInput from './VTInput.vue';
18
-
19
- export default {
20
- name: 'VTInputFile',
21
-
22
- components: {
23
- VTInput,
24
- VTButton,
25
- },
26
-
27
- inheritAttrs: false,
28
-
29
- props: {
30
- theme: {
31
- type: String,
32
- default: null,
33
- validator(value) {
34
- return ['dark'].includes(value);
35
- },
36
- },
37
- multiple: {
38
- type: Boolean,
39
- default: false,
40
- },
41
- },
42
-
43
- data() {
44
- return {
45
- value: null,
46
- };
47
- },
48
-
49
- methods: {
50
- onChange(event) {
51
- this.value = this.$refs.input.$el.value;
52
- this.$emit('change', event);
53
- },
54
-
55
- onButtonClick() {
56
- this.$refs.input.$el.click();
57
- },
58
- },
59
- };
60
- </script>
@@ -1,54 +0,0 @@
1
- <template>
2
- <label
3
- class="flex h-full w-full flex-col items-center justify-center rounded border-2 border-dotted border-white p-4 text-center hover:border-fl-500 hover:bg-fd-500"
4
- :class="{ 'border-fl-500 bg-fd-500': isDraggingOver }"
5
- @drop.prevent="onDrop"
6
- @dragover.prevent="onDragOver"
7
- @dragleave.prevent="onDragLeave"
8
- >
9
- <IconImagePlaceholder class="mb-3" />
10
- <span>Drop your images here, or click to browse</span>
11
- <VTInput type="file" class="sr-only" v-bind="$attrs" @change="onChange" />
12
- </label>
13
- </template>
14
-
15
- <script>
16
- import { IconImagePlaceholder } from '@veritree/icons';
17
- import VTInput from './VTInput.vue';
18
-
19
- export default {
20
- name: 'VTInputFile',
21
-
22
- components: {
23
- VTInput,
24
- IconImagePlaceholder,
25
- },
26
-
27
- inheritAttrs: false,
28
-
29
- data() {
30
- return {
31
- isDraggingOver: false,
32
- };
33
- },
34
-
35
- methods: {
36
- onDrop(event) {
37
- this.isDraggingOver = false;
38
- this.$emit('drop', event);
39
- },
40
-
41
- onDragOver() {
42
- this.isDraggingOver = true;
43
- },
44
-
45
- onDragLeave() {
46
- this.isDraggingOver = false;
47
- },
48
-
49
- onChange(event) {
50
- this.$emit('change', event);
51
- },
52
- },
53
- };
54
- </script>