From e359e1683f73ad0be232878340e51affe24c533c Mon Sep 17 00:00:00 2001 From: PabloLec Date: Thu, 9 May 2024 17:51:52 +0200 Subject: [PATCH] Add Calendar for date fields --- test-frontend/package.json | 1 + test-frontend/pnpm-lock.yaml | 3 + .../src/components/ui/button/Button.vue | 26 ++++++++ .../src/components/ui/button/index.ts | 35 +++++++++++ .../ui/search/form/FieldSelector.vue | 1 - .../components/ui/search/form/ValueInput.vue | 55 ++++++++++++++++- .../ui/shadcn/calendar/Calendar.vue | 60 +++++++++++++++++++ .../ui/shadcn/calendar/CalendarCell.vue | 24 ++++++++ .../shadcn/calendar/CalendarCellTrigger.vue | 38 ++++++++++++ .../ui/shadcn/calendar/CalendarGrid.vue | 24 ++++++++ .../ui/shadcn/calendar/CalendarGridBody.vue | 11 ++++ .../ui/shadcn/calendar/CalendarGridHead.vue | 11 ++++ .../ui/shadcn/calendar/CalendarGridRow.vue | 21 +++++++ .../ui/shadcn/calendar/CalendarHeadCell.vue | 21 +++++++ .../ui/shadcn/calendar/CalendarHeader.vue | 21 +++++++ .../ui/shadcn/calendar/CalendarHeading.vue | 27 +++++++++ .../ui/shadcn/calendar/CalendarNextButton.vue | 32 ++++++++++ .../ui/shadcn/calendar/CalendarPrevButton.vue | 32 ++++++++++ .../components/ui/shadcn/calendar/index.ts | 12 ++++ .../components/ui/shadcn/popover/Popover.vue | 15 +++++ .../ui/shadcn/popover/PopoverContent.vue | 48 +++++++++++++++ .../ui/shadcn/popover/PopoverTrigger.vue | 11 ++++ .../src/components/ui/shadcn/popover/index.ts | 3 + .../src/lib/search/fieldsConfiguration.ts | 2 +- 24 files changed, 531 insertions(+), 3 deletions(-) create mode 100644 test-frontend/src/components/ui/button/Button.vue create mode 100644 test-frontend/src/components/ui/button/index.ts create mode 100644 test-frontend/src/components/ui/shadcn/calendar/Calendar.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarCell.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarCellTrigger.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarGrid.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarGridBody.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarGridHead.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarGridRow.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarHeadCell.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarHeader.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarHeading.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarNextButton.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/CalendarPrevButton.vue create mode 100644 test-frontend/src/components/ui/shadcn/calendar/index.ts create mode 100644 test-frontend/src/components/ui/shadcn/popover/Popover.vue create mode 100644 test-frontend/src/components/ui/shadcn/popover/PopoverContent.vue create mode 100644 test-frontend/src/components/ui/shadcn/popover/PopoverTrigger.vue create mode 100644 test-frontend/src/components/ui/shadcn/popover/index.ts diff --git a/test-frontend/package.json b/test-frontend/package.json index 3df5609..2f1a233 100644 --- a/test-frontend/package.json +++ b/test-frontend/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "@internationalized/date": "^3.5.3", "@tanstack/vue-table": "^8.16.0", "@vee-validate/zod": "^4.12.7", "@vueuse/core": "^10.9.0", diff --git a/test-frontend/pnpm-lock.yaml b/test-frontend/pnpm-lock.yaml index 090a829..2f5dac9 100644 --- a/test-frontend/pnpm-lock.yaml +++ b/test-frontend/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@internationalized/date': + specifier: ^3.5.3 + version: 3.5.3 '@tanstack/vue-table': specifier: ^8.16.0 version: 8.16.0(vue@3.4.27(typescript@5.4.5)) diff --git a/test-frontend/src/components/ui/button/Button.vue b/test-frontend/src/components/ui/button/Button.vue new file mode 100644 index 0000000..5cfd668 --- /dev/null +++ b/test-frontend/src/components/ui/button/Button.vue @@ -0,0 +1,26 @@ + + + diff --git a/test-frontend/src/components/ui/button/index.ts b/test-frontend/src/components/ui/button/index.ts new file mode 100644 index 0000000..1b00c32 --- /dev/null +++ b/test-frontend/src/components/ui/button/index.ts @@ -0,0 +1,35 @@ +import { type VariantProps, cva } from 'class-variance-authority' + +export { default as Button } from './Button.vue' + +export const buttonVariants = cva( + 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', + { + variants: { + variant: { + default: 'bg-primary text-primary-foreground hover:bg-primary/90', + destructive: + 'bg-destructive text-destructive-foreground hover:bg-destructive/90', + outline: + 'border border-input bg-background hover:bg-accent hover:text-accent-foreground', + secondary: + 'bg-secondary text-secondary-foreground hover:bg-secondary/80', + ghost: 'hover:bg-accent hover:text-accent-foreground', + link: 'text-primary underline-offset-4 hover:underline', + }, + size: { + default: 'h-10 px-4 py-2', + xs: 'h-7 rounded px-2', + sm: 'h-9 rounded-md px-3', + lg: 'h-11 rounded-md px-8', + icon: 'h-10 w-10', + }, + }, + defaultVariants: { + variant: 'default', + size: 'default', + }, + }, +) + +export type ButtonVariants = VariantProps diff --git a/test-frontend/src/components/ui/search/form/FieldSelector.vue b/test-frontend/src/components/ui/search/form/FieldSelector.vue index 4d16367..adffe76 100644 --- a/test-frontend/src/components/ui/search/form/FieldSelector.vue +++ b/test-frontend/src/components/ui/search/form/FieldSelector.vue @@ -31,7 +31,6 @@ const emit = defineEmits(['update:modelValue', 'change']); const currentFieldsConfig = computed(() => fieldsConfiguration[props.parentField]); const handleChange = (value: string | number) => { - console.log("Value changed to:", value); emit('update:modelValue', value); }; diff --git a/test-frontend/src/components/ui/search/form/ValueInput.vue b/test-frontend/src/components/ui/search/form/ValueInput.vue index 8d732be..f3529eb 100644 --- a/test-frontend/src/components/ui/search/form/ValueInput.vue +++ b/test-frontend/src/components/ui/search/form/ValueInput.vue @@ -1,5 +1,6 @@ + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarCell.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarCell.vue new file mode 100644 index 0000000..fbd0c07 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarCell.vue @@ -0,0 +1,24 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarCellTrigger.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarCellTrigger.vue new file mode 100644 index 0000000..c022db0 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarCellTrigger.vue @@ -0,0 +1,38 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarGrid.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarGrid.vue new file mode 100644 index 0000000..5de6177 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarGrid.vue @@ -0,0 +1,24 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarGridBody.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridBody.vue new file mode 100644 index 0000000..23d71ce --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridBody.vue @@ -0,0 +1,11 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarGridHead.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridHead.vue new file mode 100644 index 0000000..f8101a3 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridHead.vue @@ -0,0 +1,11 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarGridRow.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridRow.vue new file mode 100644 index 0000000..8747911 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarGridRow.vue @@ -0,0 +1,21 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarHeadCell.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeadCell.vue new file mode 100644 index 0000000..b6bc691 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeadCell.vue @@ -0,0 +1,21 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarHeader.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeader.vue new file mode 100644 index 0000000..034d6cf --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeader.vue @@ -0,0 +1,21 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarHeading.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeading.vue new file mode 100644 index 0000000..dd8fbc4 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarHeading.vue @@ -0,0 +1,27 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarNextButton.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarNextButton.vue new file mode 100644 index 0000000..2afcadd --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarNextButton.vue @@ -0,0 +1,32 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/CalendarPrevButton.vue b/test-frontend/src/components/ui/shadcn/calendar/CalendarPrevButton.vue new file mode 100644 index 0000000..de6dcf1 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/CalendarPrevButton.vue @@ -0,0 +1,32 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/calendar/index.ts b/test-frontend/src/components/ui/shadcn/calendar/index.ts new file mode 100644 index 0000000..5239a1b --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/calendar/index.ts @@ -0,0 +1,12 @@ +export { default as Calendar } from './Calendar.vue' +export { default as CalendarCell } from './CalendarCell.vue' +export { default as CalendarCellTrigger } from './CalendarCellTrigger.vue' +export { default as CalendarGrid } from './CalendarGrid.vue' +export { default as CalendarGridBody } from './CalendarGridBody.vue' +export { default as CalendarGridHead } from './CalendarGridHead.vue' +export { default as CalendarGridRow } from './CalendarGridRow.vue' +export { default as CalendarHeadCell } from './CalendarHeadCell.vue' +export { default as CalendarHeader } from './CalendarHeader.vue' +export { default as CalendarHeading } from './CalendarHeading.vue' +export { default as CalendarNextButton } from './CalendarNextButton.vue' +export { default as CalendarPrevButton } from './CalendarPrevButton.vue' diff --git a/test-frontend/src/components/ui/shadcn/popover/Popover.vue b/test-frontend/src/components/ui/shadcn/popover/Popover.vue new file mode 100644 index 0000000..1a5873a --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/popover/Popover.vue @@ -0,0 +1,15 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/popover/PopoverContent.vue b/test-frontend/src/components/ui/shadcn/popover/PopoverContent.vue new file mode 100644 index 0000000..37d9277 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/popover/PopoverContent.vue @@ -0,0 +1,48 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/popover/PopoverTrigger.vue b/test-frontend/src/components/ui/shadcn/popover/PopoverTrigger.vue new file mode 100644 index 0000000..22f4772 --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/popover/PopoverTrigger.vue @@ -0,0 +1,11 @@ + + + diff --git a/test-frontend/src/components/ui/shadcn/popover/index.ts b/test-frontend/src/components/ui/shadcn/popover/index.ts new file mode 100644 index 0000000..495d55a --- /dev/null +++ b/test-frontend/src/components/ui/shadcn/popover/index.ts @@ -0,0 +1,3 @@ +export { default as Popover } from './Popover.vue' +export { default as PopoverTrigger } from './PopoverTrigger.vue' +export { default as PopoverContent } from './PopoverContent.vue' diff --git a/test-frontend/src/lib/search/fieldsConfiguration.ts b/test-frontend/src/lib/search/fieldsConfiguration.ts index 695a812..f50fcf2 100644 --- a/test-frontend/src/lib/search/fieldsConfiguration.ts +++ b/test-frontend/src/lib/search/fieldsConfiguration.ts @@ -28,7 +28,7 @@ const libraryFieldsConfiguration: Record = { establishedDate: { label: "Established Date", fieldType: 'date', - valueComponent: 'input', + valueComponent: 'date', isFieldWithSubCriteria: false }, website: {