@veritree/ui 0.76.1-0 → 0.76.1-10

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/nuxt.js CHANGED
@@ -23,6 +23,7 @@ const components = [
23
23
  'src/components/Tooltip',
24
24
  'src/components/Switch',
25
25
  'src/components/Separator',
26
+ 'src/components/ScrollShadows',
26
27
  ];
27
28
 
28
29
  export default function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.76.1-0",
3
+ "version": "0.76.1-10",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -15,10 +15,11 @@
15
15
  "release": "np --no-tests --no-2fa"
16
16
  },
17
17
  "dependencies": {
18
- "@floating-ui/dom": "^1.2.0",
18
+ "@floating-ui/dom": "^1.6.5",
19
19
  "@linusborg/vue-simple-portal": "^0.1.5",
20
- "@veritree/icons": "^0.60.0",
21
- "v-calendar": "^2.4.2"
20
+ "@sum.cumo/vue-datepicker": "^4.0.0",
21
+ "@veritree/icons": "^0.62.0",
22
+ "dayjs": "^1.11.11"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@babel/eslint-parser": "^7.23.10",
@@ -33,7 +34,7 @@
33
34
  "stylelint-config-prettier": "^9.0.5",
34
35
  "stylelint-config-recommended-vue": "^1.5.0",
35
36
  "stylelint-config-standard": "^36.0.0",
36
- "tailwindcss": "^3.4.1"
37
+ "tailwindcss": "^3.4.3"
37
38
  },
38
39
  "engines": {
39
40
  "npm": ">=8.0.0",
@@ -7,7 +7,7 @@
7
7
  : '-mx-4 flex items-center justify-between gap-x-3 p-4 md:-mx-6 md:px-6 md:py-5',
8
8
  ]"
9
9
  >
10
- <slot></slot>
10
+ <slot :hide="hide"></slot>
11
11
  </component>
12
12
  </template>
13
13
 
@@ -15,6 +15,8 @@
15
15
  export default {
16
16
  name: 'VTDialogFooter',
17
17
 
18
+ inject: ['apiDialog'],
19
+
18
20
  props: {
19
21
  headless: {
20
22
  type: Boolean,
@@ -25,5 +27,11 @@ export default {
25
27
  default: 'footer',
26
28
  },
27
29
  },
30
+
31
+ methods: {
32
+ hide() {
33
+ this.apiDialog().hide();
34
+ },
35
+ },
28
36
  };
29
37
  </script>
@@ -2,30 +2,35 @@
2
2
  <VTPopover>
3
3
  <VTPopoverTrigger ref="trigger">
4
4
  <button :class="classComputed" :disabled="disabled" @click.prevent>
5
- <span v-if="valueModel">{{
6
- new Date(valueModel).toISOString().split('T')[0]
7
- }}</span>
8
- <span class="text-gray-500" v-else>yyyy-mm-dd</span>
5
+ <span v-if="valueModel">{{ valueModelFormatted }}</span>
6
+ <span class="text-gray-500" v-else>{{ format }}</span>
9
7
  <span
10
8
  v-if="!iconless"
11
9
  class="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2"
12
- :class="[disabled ? 'bg-gray-100' : 'bg-white']"
10
+ :class="[disabled ? 'bg-gray-200' : 'bg-white']"
13
11
  >
14
12
  <IconCalendar class="-z-0 h-5 w-5 scale-90 text-gray-600" />
15
13
  </span>
16
14
  </button>
17
15
  </VTPopoverTrigger>
18
- <VTPopoverContent @hidden="$emit('hidden')" @shown="$emit('shown')">
19
- <DatePicker
16
+ <VTPopoverContent @hidden="$emit('hidden')" @shown="onShown">
17
+ <Datepicker
20
18
  v-model="valueModel"
21
- :min-date="min"
22
- :max-date="max"
23
- :model-config="modelConfig"
24
- :available-dates="availableDates"
25
- color="null"
26
- class="min-w-full"
27
- @dayclick="onDayClick"
28
- />
19
+ :inline="true"
20
+ :initial-view="initialView"
21
+ :minimum-view="minimumView"
22
+ :maximum-view="maximumView"
23
+ :show-edge-dates="showEdgeDates"
24
+ :disabled-dates="disabledDatesComputed"
25
+ @input="onInput"
26
+ >
27
+ <template #prevIntervalBtn>
28
+ <IconChevronLeft />
29
+ </template>
30
+ <template #nextIntervalBtn>
31
+ <IconChevronRight />
32
+ </template>
33
+ </Datepicker>
29
34
  </VTPopoverContent>
30
35
  </VTPopover>
31
36
  </template>
@@ -38,7 +43,9 @@ import {
38
43
  import VTPopover from './../Popover/VTPopover.vue';
39
44
  import VTPopoverTrigger from './../Popover/VTPopoverTrigger.vue';
40
45
  import VTPopoverContent from './../Popover/VTPopoverContent.vue';
41
- import DatePicker from 'v-calendar/lib/components/date-picker.umd';
46
+ import Datepicker from '@sum.cumo/vue-datepicker';
47
+ import { IconChevronLeft, IconChevronRight } from '@veritree/icons';
48
+ import dayjs from 'dayjs';
42
49
 
43
50
  export default {
44
51
  name: 'VTInputDate',
@@ -46,17 +53,23 @@ export default {
46
53
  mixins: [formControlMixin, formControlStyleMixin],
47
54
 
48
55
  components: {
56
+ Datepicker,
57
+ IconChevronLeft,
58
+ IconChevronRight,
49
59
  VTPopover,
50
60
  VTPopoverTrigger,
51
61
  VTPopoverContent,
52
- DatePicker,
53
62
  },
54
63
 
55
64
  props: {
56
- availableDates: {
57
- type: Object,
65
+ disabledDates: {
66
+ type: [Function, Object],
58
67
  default: null,
59
68
  },
69
+ format: {
70
+ type: String,
71
+ default: 'YYYY-MM-DD',
72
+ },
60
73
  min: {
61
74
  type: [String, Date],
62
75
  default: null,
@@ -65,17 +78,26 @@ export default {
65
78
  type: [String, Date],
66
79
  default: null,
67
80
  },
81
+ initialView: {
82
+ type: String,
83
+ default: 'day',
84
+ },
85
+ minimumView: {
86
+ type: String,
87
+ default: 'day',
88
+ },
89
+ maximumView: {
90
+ type: String,
91
+ default: 'year',
92
+ },
93
+ showEdgeDates: {
94
+ type: Boolean,
95
+ default: true,
96
+ },
68
97
  iconless: {
69
98
  type: Boolean,
70
99
  default: false,
71
100
  },
72
- modelConfig: {
73
- type: Object,
74
- default: () => ({
75
- type: 'string',
76
- mask: 'YYYY-MM-DD',
77
- }),
78
- },
79
101
  },
80
102
 
81
103
  computed: {
@@ -88,12 +110,315 @@ export default {
88
110
  this.$emit('change', newDate);
89
111
  },
90
112
  },
113
+
114
+ valueModelFormatted() {
115
+ return dayjs(this.value).format(this.format);
116
+ },
117
+
118
+ disabledDatesComputed() {
119
+ if (this.disabledDates) {
120
+ return this.disabledDates;
121
+ }
122
+
123
+ return {
124
+ to: this.min,
125
+ from: this.max,
126
+ };
127
+ },
91
128
  },
92
129
 
93
130
  methods: {
94
- onDayClick() {
131
+ onShown() {
132
+ this.$emit('shown');
133
+ this.setFocus();
134
+ },
135
+
136
+ /**
137
+ * Sets the focus on the datepicker element.
138
+ * If there is a selected date, it focuses on that date.
139
+ * If there is no selected date, it focuses on today's date.
140
+ */
141
+ setFocus() {
142
+ const elDatepicker = document.querySelector('.vdp-datepicker');
143
+
144
+ if (!elDatepicker) {
145
+ return;
146
+ }
147
+
148
+ const elSelected = elDatepicker.querySelector('.selected');
149
+
150
+ if (elSelected) {
151
+ elSelected.focus();
152
+ return;
153
+ }
154
+
155
+ const elToday = elDatepicker.querySelector('.today');
156
+
157
+ if (elToday) {
158
+ elToday.focus();
159
+ }
160
+ },
161
+
162
+ onInput() {
95
163
  this.$refs.trigger.cancel();
96
164
  },
97
165
  },
98
166
  };
99
167
  </script>
168
+
169
+ <style>
170
+ .rtl {
171
+ direction: rtl;
172
+ }
173
+
174
+ .vdp-datepicker {
175
+ font-size: 14px;
176
+ }
177
+
178
+ .vdp-datepicker__calendar .today {
179
+ background-color: #f2f2f2;
180
+ }
181
+
182
+ .vdp-datepicker__calendar {
183
+ & button {
184
+ background: inherit;
185
+ text-align: center;
186
+ }
187
+
188
+ & button:disabled {
189
+ color: #ddd;
190
+ }
191
+ }
192
+
193
+ /* header */
194
+ .vdp-datepicker__calendar header {
195
+ display: flex;
196
+
197
+ & button {
198
+ border: none;
199
+ }
200
+
201
+ & button:hover:not(:disabled) {
202
+ background: #f2f2f2;
203
+ }
204
+
205
+ & button.vdp-datepicker__up {
206
+ color: inherit;
207
+ font-weight: 500;
208
+ flex-grow: 1;
209
+ }
210
+
211
+ & .next,
212
+ & .prev {
213
+ border-radius: 50%;
214
+ display: flex;
215
+ align-items: center;
216
+ justify-content: center;
217
+ flex-shrink: 0;
218
+ height: 2rem;
219
+ aspect-ratio: 1 / 1;
220
+ position: relative;
221
+ }
222
+
223
+ & .next .default,
224
+ & .prev .default {
225
+ display: flex;
226
+ text-indent: -10000px;
227
+ }
228
+
229
+ & .next .default:after,
230
+ & .prev .default:after {
231
+ border: 6px solid transparent;
232
+ content: '';
233
+ left: 50%;
234
+ position: absolute;
235
+ top: 50%;
236
+ transform: translateX(-50%) translateY(-50%);
237
+ }
238
+
239
+ & .next.rtl,
240
+ & .prev.rtl {
241
+ transform: rotate(180deg);
242
+ }
243
+
244
+ & .prev .default:after {
245
+ border-right: 10px solid #000;
246
+ margin-left: -5px;
247
+ }
248
+
249
+ & .prev:disabled .default:after {
250
+ border-right: 10px solid #ddd;
251
+ }
252
+
253
+ & .next .default:after {
254
+ border-left: 10px solid #000;
255
+ margin-left: 5px;
256
+ }
257
+
258
+ & .next:disabled .default:after {
259
+ border-left: 10px solid #ddd;
260
+ }
261
+ }
262
+
263
+ /* body (days, months and years) */
264
+ .vdp-datepicker__calendar .picker-cells {
265
+ display: grid;
266
+ list-style: none;
267
+ margin: 0;
268
+ padding: 0;
269
+
270
+ &:has(.cell.day) {
271
+ grid-template-columns: repeat(7, 1fr);
272
+ }
273
+
274
+ &:has(.cell.month),
275
+ &:has(.cell.year) {
276
+ min-height: calc(6 * 2rem);
277
+ grid-template-columns: repeat(3, 1fr);
278
+ }
279
+
280
+ & .cell {
281
+ border: 1px solid transparent;
282
+ }
283
+
284
+ & .cell:not(.selected):focus {
285
+ border-color: #cccccc;
286
+ }
287
+
288
+ & .cell.day {
289
+ border-radius: 50%;
290
+ /* height: 2rem; */
291
+ aspect-ratio: 1 / 1;
292
+ }
293
+ }
294
+
295
+ /* cell states */
296
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).day,
297
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).month,
298
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).year {
299
+ cursor: pointer;
300
+ }
301
+
302
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).day:hover,
303
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).month:hover,
304
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).year:hover {
305
+ border-color: #333;
306
+ }
307
+
308
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).day:focus,
309
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).month:focus,
310
+ .vdp-datepicker__calendar .cell:not(.blank):not(.disabled).year:focus {
311
+ z-index: 1;
312
+ }
313
+
314
+ .vdp-datepicker__calendar .cell.muted {
315
+ color: #ccc;
316
+ }
317
+
318
+ .vdp-datepicker__calendar .cell.selected {
319
+ background: #333;
320
+ color: #fff;
321
+ }
322
+
323
+ .vdp-datepicker__calendar .cell.selected.highlighted,
324
+ .vdp-datepicker__calendar .cell.selected:hover {
325
+ background: #333;
326
+ }
327
+
328
+ .vdp-datepicker__calendar .cell.highlighted {
329
+ background: #cae5ed;
330
+ color: #104756;
331
+ }
332
+
333
+ .vdp-datepicker__calendar .cell.highlighted.disabled {
334
+ color: #accad2;
335
+ }
336
+
337
+ .vdp-datepicker__calendar .cell.muted.disabled:not(.selected) {
338
+ color: #ddd;
339
+ }
340
+
341
+ .vdp-datepicker__calendar .cell.muted.disabled:not(.selected).highlighted {
342
+ color: #accad2;
343
+ }
344
+
345
+ .vdp-datepicker__calendar .day-header {
346
+ display: grid;
347
+ grid-template-columns: repeat(7, 1fr);
348
+
349
+ & span {
350
+ display: flex;
351
+ align-items: center;
352
+ justify-content: center;
353
+ aspect-ratio: 1 / 1;
354
+ height: 2rem;
355
+ color: #767676;
356
+ font-size: 14px;
357
+ white-space: nowrap;
358
+ }
359
+ }
360
+
361
+ /* .vdp-datepicker__calendar .picker-view {
362
+ width: inherit;
363
+ } */
364
+
365
+ .vdp-datepicker__calendar .picker-view .cells-wrapper {
366
+ overflow: hidden;
367
+ position: relative;
368
+ }
369
+
370
+ .vdp-datepicker__calendar .picker-view .cells-wrapper .picker-cells {
371
+ transition: all 0.25s ease-in-out;
372
+ }
373
+
374
+ .vdp-datepicker__calendar .picker-view .slide-right-enter-active {
375
+ top: 0;
376
+ }
377
+
378
+ .vdp-datepicker__calendar .picker-view .slide-right-leave-active {
379
+ position: absolute;
380
+ top: 0;
381
+ }
382
+
383
+ .vdp-datepicker__calendar .picker-view .slide-right-enter {
384
+ transform: translate(100%);
385
+ }
386
+
387
+ .vdp-datepicker__calendar .picker-view .slide-right-leave-to {
388
+ transform: translate(-100%);
389
+ }
390
+
391
+ .vdp-datepicker__calendar .picker-view .slide-left-enter-active {
392
+ top: 0;
393
+ }
394
+
395
+ .vdp-datepicker__calendar .picker-view .slide-left-leave-active {
396
+ position: absolute;
397
+ top: 0;
398
+ }
399
+
400
+ .vdp-datepicker__calendar .picker-view .slide-left-enter {
401
+ transform: translate(-100%);
402
+ }
403
+
404
+ .vdp-datepicker__calendar .picker-view .slide-left-leave-to {
405
+ transform: translate(100%);
406
+ }
407
+
408
+ .view-leave-active {
409
+ position: absolute;
410
+ }
411
+
412
+ .vdp-datepicker__calendar-button,
413
+ .vdp-datepicker__clear-button {
414
+ border: none;
415
+ font-style: normal;
416
+ }
417
+
418
+ .vdp-datepicker__calendar-button.input-group-append,
419
+ .vdp-datepicker__calendar-button.input-group-prepend,
420
+ .vdp-datepicker__clear-button.input-group-append,
421
+ .vdp-datepicker__clear-button.input-group-prepend {
422
+ padding: 0;
423
+ }
424
+ </style>
@@ -3,7 +3,7 @@
3
3
  :class="[
4
4
  headless
5
5
  ? 'progress-bar'
6
- : 'relative min-h-[12px] w-full overflow-hidden rounded bg-gray-200',
6
+ : 'relative min-h-[12px] w-full flex items-stretch overflow-hidden rounded bg-gray-200',
7
7
  ]"
8
8
  role="progressbar"
9
9
  aria-valuemin="0"
@@ -11,14 +11,13 @@
11
11
  :aria-valuenow="value"
12
12
  :aria-label="label"
13
13
  >
14
- <div
15
- :class="[
16
- headless
17
- ? 'progress-bar__indicator'
18
- : 'bg-secondary-300 absolute left-0 h-full transition-all duration-500',
19
- ]"
20
- :style="{ width: `${percentageComputed}%` }"
21
- ></div>
14
+ <slot>
15
+ <VTProgressBarIndicator
16
+ :headless="headless"
17
+ :percentage="percentageComputed"
18
+ :variant="variant"
19
+ />
20
+ </slot>
22
21
  </div>
23
22
  </template>
24
23
 
@@ -49,6 +48,10 @@ export default {
49
48
  type: String,
50
49
  default: 'rounded-full',
51
50
  },
51
+ variant: {
52
+ type: String,
53
+ default: 'default', // default, alert, warning
54
+ },
52
55
  },
53
56
 
54
57
  computed: {
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <div
3
+ :class="[
4
+ headless
5
+ ? 'progress-bar__indicator'
6
+ : `${backgroundComputed} min-h-min transition-all duration-500`,
7
+ ]"
8
+ :style="{ width: `${percentage}%` }"
9
+ ></div>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ name: 'VTProgressBarIndicator',
15
+
16
+ props: {
17
+ headless: {
18
+ type: Boolean,
19
+ default: false,
20
+ },
21
+ percentage: {
22
+ type: [String, Number],
23
+ default: null,
24
+ },
25
+ variant: {
26
+ type: String,
27
+ default: 'default', // default, alert, warning
28
+ },
29
+ },
30
+
31
+ computed: {
32
+ backgroundComputed() {
33
+ if (this.variant === 'default') {
34
+ return 'bg-secondary-300';
35
+ }
36
+
37
+ if (this.variant === 'error') {
38
+ return 'bg-error-500';
39
+ }
40
+
41
+ if (this.variant === 'warning') {
42
+ return 'bg-warning-500';
43
+ }
44
+ },
45
+ },
46
+ };
47
+ </script>
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <component :is="tag" :class="`scroll-shadows-${orientation}`">
3
+ <slot></slot>
4
+ </component>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ name: 'VTScrollShadows',
10
+
11
+ props: {
12
+ tag: {
13
+ type: String,
14
+ default: 'div',
15
+ },
16
+ orientation: {
17
+ type: String,
18
+ default: 'vertical', // horizontal
19
+ },
20
+ },
21
+ };
22
+ </script>
23
+
24
+ <style scoped>
25
+ .scroll-shadows-vertical {
26
+ background:
27
+ /* Shadow Cover TOP */
28
+ linear-gradient(white 30%, rgba(255, 255, 255, 0)) center top,
29
+ /* Shadow Cover BOTTOM */ linear-gradient(rgba(255, 255, 255, 0), white 70%)
30
+ center bottom,
31
+ /* Shadow TOP */
32
+ radial-gradient(
33
+ farthest-side at 50% 0,
34
+ rgba(0, 0, 0, 0.1),
35
+ rgba(0, 0, 0, 0)
36
+ )
37
+ center top,
38
+ /* Shadow BOTTOM */
39
+ radial-gradient(
40
+ farthest-side at 50% 100%,
41
+ rgba(0, 0, 0, 0.1),
42
+ rgba(0, 0, 0, 0)
43
+ )
44
+ center bottom;
45
+
46
+ background-repeat: no-repeat;
47
+ background-size:
48
+ 100% 30px,
49
+ 100% 30px,
50
+ 100% 8px,
51
+ 100% 8px;
52
+ background-attachment: local, local, scroll, scroll;
53
+ }
54
+
55
+ .scroll-shadows-horizontal {
56
+ background:
57
+ linear-gradient(90deg, white 30%, rgba(255, 255, 255, 0)),
58
+ linear-gradient(90deg, rgba(255, 255, 255, 0), white 70%) 0 100%,
59
+ radial-gradient(farthest-side at 0% 50%, rgba(0, 0, 0, 0.2), white),
60
+ radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.2), white) 0 100%;
61
+
62
+ background-repeat: no-repeat;
63
+ background-color: white;
64
+ background-position:
65
+ top left,
66
+ top right,
67
+ top left,
68
+ top right;
69
+ background-size:
70
+ 10px 100%,
71
+ 10px 100%,
72
+ 5px 100%,
73
+ 5px 100%;
74
+ background-attachment: local, local, scroll, scroll;
75
+ }
76
+ </style>