The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: started adding DatePicker.
Jonathan Summers-Muir692482abeee0
diff --git a/studio/.storybook/preview.css b/studio/.storybook/preview.cssindex 2afd110d2e3..c12137dbd9d 100644--- a/studio/.storybook/preview.css+++ b/studio/.storybook/preview.css@@ -8,3 +8,106 @@.dark .docs-story {@apply bg-scale-200;}++/* // date picker */+/* !!!! THIS IS A COPY OF THE styles/date-picker.scss !! */++.react-datepicker__input-container input {+ @apply block w-full text-base md:text-sm bg-white border border-scale-300 rounded shadow-sm;+}++.react-datepicker-popper {+ @apply z-40 w-72 text-sm bg-scale-100 dark:bg-scale-300 shadow px-3 py-2 border-2 border-scale-200 rounded;+}++.react-datepicker-left {+ @apply absolute left-0 right-auto top-11 transform-none !important;+}++.react-datepicker-right {+ @apply absolute right-0 left-auto top-11 transform-none !important;+}++.react-datepicker__portal {+ @apply absolute z-10 w-72 text-sm transform-none bg-white shadow px-3 py-2 top-12 right-0 border-2 border-scale-200 rounded;+}++.react-datepicker__month-container {+ @apply flex flex-col;+}++.react-datepicker__month {+ @apply flex flex-col;+ @apply -space-y-px;+}++.react-datepicker__current-month {+ @apply ml-2.5 text-lg font-semibold text-scale-800;+}++.react-datepicker__week {+ @apply flex -space-x-px;+}++.react-datepicker__day-names {+ @apply flex -space-x-px text-scale-900 font-normal text-center text-xs;+}++.react-datepicker__day-name {+ @apply w-10 h-10 flex items-center justify-center py-1 rounded-full;+}++.react-datepicker__navigation {+ @apply absolute top-2;+}++.react-datepicker__navigation--previous {+ @apply right-12 w-10 h-10 rounded transition flex items-center justify-center hover:bg-scale-200;+}++.react-datepicker__navigation--next {+ @apply right-4 w-10 h-10 rounded transition flex items-center justify-center hover:bg-scale-200;+}++.react-datepicker__day {+ @apply w-10 h-10 flex items-center font-normal justify-center text-sm leading-loose transition text-scale-1100;+ /* @apply mb-1 py-1; */+ @apply -space-y-px;+ @apply border border-scale-500;+}++.react-datepicker__day--disabled {+ @apply cursor-not-allowed opacity-40 hover:bg-transparent;+}++.react-datepicker__day--outside-month {+ @apply text-scale-800;+}++.react-datepicker__day--in-range {+ @apply bg-brand-800 text-scale-fixed-100 border-brand-800;+}++.react-datepicker__day--in-selecting-range {+ @apply bg-brand-700 text-scale-fixed-100 border-brand-700;+}++.react-datepicker__day--selecting-range-start {+ @apply bg-scale-200;+}++.react-datepicker__day--selecting-range-end {+ @apply bg-scale-200;+}++.react-datepicker__day--selected {+ @apply bg-brand-800 text-white;+}++.react-datepicker__day--range-start {+ @apply bg-brand-900 text-white hover:text-scale-700 hover:bg-white;+}++.react-datepicker__day--range-end {+ @apply bg-brand-900 text-white hover:text-scale-700 hover:bg-white;+}diff --git a/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx b/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsxindex e650bfd6e0f..4009b9aea69 100644--- a/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx+++ b/studio/components/interfaces/Settings/Logs/PreviewFilterPanel.tsx@@ -23,6 +23,7 @@ import dayjs from 'dayjs'import utc from 'dayjs/plugin/utc'import { FILTER_OPTIONS, LogsTableName } from './Logs.constants'import { LogsFilter } from './Logs.filter'+import { DatePicker } from 'components/ui/DatePicker'interface Props {defaultSearchValue?: stringdefaultToValue?: string@@ -185,10 +186,6 @@ const PreviewFilterPanel: FC<Props> = ({/></form>- <div>- <RefreshButton />- </div>-<div className="flex items-center"><Dropdownsize="small"@@ -220,6 +217,11 @@ const PreviewFilterPanel: FC<Props> = ({>Custom</Button> */}+ <DatePicker />+ </div>++ <div>+ <RefreshButton /></div><div className="flex items-center gap-2">diff --git a/studio/components/ui/DatePicker/DatePicker.stories.tsx b/studio/components/ui/DatePicker/DatePicker.stories.tsxnew file mode 100644index 00000000000..a01b3012be2--- /dev/null+++ b/studio/components/ui/DatePicker/DatePicker.stories.tsx@@ -0,0 +1,37 @@+import React, { useState } from 'react'++import { IconLogIn } from '../Icon/icons/IconLogIn'++import { DatePicker } from '.'+import ReactDatePicker from 'react-datepicker'++export default {+ title: 'Data/DatePicker',+ component: DatePicker,+}++export const Default = (args: any) => (+ <div style={{ margin: '0 auto', minHeight: '420px', marginTop: '220px' }}>+ <DatePicker />+ </div>+)++export const Simple = () => {+ const [startDate, setStartDate] = useState(new Date())+ const [endDate, setEndDate] = useState(null)+ const onChange = (dates) => {+ const [start, end] = dates+ setStartDate(start)+ setEndDate(end)+ }+ return (+ <ReactDatePicker+ selected={startDate}+ onChange={onChange}+ startDate={startDate}+ endDate={endDate}+ selectsRange+ inline+ />+ )+}diff --git a/studio/components/ui/DatePicker/DatePicker.tsx b/studio/components/ui/DatePicker/DatePicker.tsxnew file mode 100644index 00000000000..1fd6d03f92a--- /dev/null+++ b/studio/components/ui/DatePicker/DatePicker.tsx@@ -0,0 +1,406 @@+import React, { useState, forwardRef, useEffect } from 'react'++import DatePicker from 'react-datepicker'++// import dayjs from 'dayjs'++import {+ Button,+ Popover,+ IconChevronLeft,+ IconChevronRight,+ IconArrowRight,+ IconCalendar,+ IconGlobe,+ Input,+ Toggle,+ Select,+} from '@supabase/ui'++import { format } from 'date-fns'++import TimeSplitInput from './TimeSplitInput'+import DividerSlash from './DividerSlash'++import dayjs from 'dayjs'++var utc = require('dayjs/plugin/utc')+var timezone = require('dayjs/plugin/timezone') // dependent on utc plugin++dayjs.extend(utc)+dayjs.extend(timezone)++interface RootProps {+ handleChange?: ({}) => void+}++const START_DATE_DEFAULT = new Date()+const END_DATE_DEFAULT = new Date()++console.log('START_DATE_DEFAULT', START_DATE_DEFAULT)++const TIME_NOW = format(new Date(), 'HH:mm:ss').split(':')++const START_TIME_DEFAULT = { HH: TIME_NOW[0], mm: TIME_NOW[1], ss: TIME_NOW[2] }+const END_TIME_DEFAULT = { HH: TIME_NOW[0], mm: TIME_NOW[1], ss: TIME_NOW[2] }++function _DatePicker({ handleChange }: RootProps) {+ const [open, setOpen] = useState<boolean>(false)++ const [showTime, setShowTime] = useState<boolean>(true)++ const [appliedStartDate, setAppliedStartDate] = useState<any>(null)+ const [appliedEndDate, setAppliedEndDate] = useState<any>(null)++ const [startDate, setStartDate] = useState<any>(START_DATE_DEFAULT)+ const [endDate, setEndDate] = useState<any>(END_DATE_DEFAULT)++ const [startTime, setStartTime] = useState<any>(START_TIME_DEFAULT)+ const [endTime, setEndTime] = useState<any>(END_TIME_DEFAULT)++ function handleSubmit() {+ setOpen(false)++ setAppliedStartDate(startDate)+ setAppliedEndDate(endDate)++ if (handleChange)+ handleChange({+ from: dayjs(+ `${format(new Date(startDate), 'yyyy-MM-dd')} ${Object.values(startTime).join(':')}`+ ).toISOString(),+ to: dayjs(+ `${format(new Date(endDate), 'yyyy-MM-dd')} ${Object.values(endTime).join(':')}`+ ).toISOString(),+ })+ }++ function handleClear() {+ setOpen(false)+ setStartDate(START_DATE_DEFAULT)+ setEndDate(END_DATE_DEFAULT)++ setStartTime(START_DATE_DEFAULT)+ setEndTime(END_TIME_DEFAULT)++ setAppliedStartDate(null)+ setAppliedEndDate(null)+ }++ const DEFAULT_DATE_FORMAT = 'ddd MMM YYYY HH:mm:ss'++ return (+ <>+ <Popover+ open={open}+ onOpenChange={(e) => setOpen(e)}+ size="small"+ align="center"+ side="bottom"+ header={+ <>+ <div className="flex justify-between items-stretch py-2">+ <div className="grow flex flex-col gap-1">+ <div+ className="+ flex items-center justify-center gap-0+ text-xs text-scale-1100 bg-scale-100 dark:bg-scaleA-300 border border-scale-700 h-7 rounded"+ >+ <input+ pattern="[0-9]*"+ placeholder="DD"+ // type="text"+ aria-describedby="DateInput-input-1696-description"+ aria-label="Day"+ className="w-4 bg-transparent text-scale-1200 text-center"+ value={format(new Date(startDate), 'dd')}+ />+ <DividerSlash />+ <input+ pattern="[0-9]*"+ placeholder="MM"+ // type="text"+ aria-describedby="DateInput-input-1853-description"+ aria-label="Month"+ className="w-4 bg-transparent text-scale-1200 text-center"+ value={format(new Date(startDate), 'MM')}+ />+ <DividerSlash />+ <input+ pattern="[0-9]*"+ placeholder="YYYY"+ // type="text"+ aria-describedby="DateInput-input-1860-description"+ aria-label="Year"+ className="w-8 bg-transparent text-scale-1200 text-center"+ value={format(new Date(startDate), 'yyyy')}+ />+ </div>++ {showTime && (+ <TimeSplitInput+ type="start"+ startTime={startTime}+ endTime={endTime}+ time={startTime}+ setTime={setStartTime}+ setStartTime={setStartTime}+ setEndTime={setEndTime}+ startDate={startDate}+ endDate={endDate}+ />+ )}+ </div>+ <div+ className={`+ w-12+ flex+ items-center+ justify-center+ text-scale-900+ `}+ >+ <IconArrowRight strokeWidth={1.5} size={14} />+ </div>+ <div className="grow flex flex-col gap-1">+ <div+ className="+ flex items-center justify-center gap-0+ text-xs text-scale-1100 bg-scale-100 dark:bg-scaleA-300 border border-scale-700 h-7 rounded"+ >+ <input+ className="appearance-none w-4 text-scale-1200 bg-transparent text-center"+ value={format(new Date(endDate), 'dd')}+ />+ <DividerSlash />+ <input+ className="appearance-none w-4 text-scale-1200 bg-transparent text-center"+ value={format(new Date(endDate), 'MM')}+ />+ <DividerSlash />+ <input+ className="appearance-none w-8 text-scale-1200 bg-transparent text-center"+ value={format(new Date(endDate), 'yyyy')}+ />+ </div>+ {showTime && (+ <TimeSplitInput+ type="end"+ startTime={startTime}+ endTime={endTime}+ time={endTime}+ setTime={setEndTime}+ setStartTime={setStartTime}+ setEndTime={setEndTime}+ startDate={startDate}+ endDate={endDate}+ />+ )}+ </div>+ </div>+ </>+ }+ overlay={+ <>+ <div className="px-3 py-4">+ <DatePicker+ selected={startDate}+ onChange={(date) => {+ const [start, end] = date+ console.log('start', start)+ console.log('end', end)+ setStartDate(start)+ // setEndDate(!end ? start : end)+ setEndDate(end)+ }}+ dateFormat="MMMM d, yyyy h:mm aa"+ startDate={startDate}+ endDate={endDate}+ selectsRange+ // showTimeSelect+ // nextMonthButtonLabel=">"+ // previousMonthButtonLabel="<"+ // popperClassName="react-datepicker-left"+ // customInput={<ButtonInput />}+ // dateFormat={DEFAULT_DATE_FORMAT}+ // dateFormat={(locale, date) => dayjs(date).format('MM-YYYY')}+ inline+ renderCustomHeader={({+ date,+ decreaseMonth,+ increaseMonth,+ prevMonthButtonDisabled,+ nextMonthButtonDisabled,+ }) => [+ <div className="flex items-center justify-between px-2 py-2">+ <div className="flex items-center justify-between w-full">+ <button+ onClick={decreaseMonth}+ disabled={prevMonthButtonDisabled}+ type="button"+ className={`+ ${prevMonthButtonDisabled && 'cursor-not-allowed opacity-50'}+ text-scale-1100 hover:text-scale-1200 focus:outline-none+ `}+ >+ <IconChevronLeft size={16} strokeWidth={2} />+ </button>+ <span className="text-sm text-scale-1100">{format(date, 'MMMM yyyy')}</span>+ <button+ onClick={increaseMonth}+ disabled={nextMonthButtonDisabled}+ type="button"+ className={`+ ${nextMonthButtonDisabled && 'cursor-not-allowed opacity-50'}+ text-scale-1100 hover:text-scale-1200 focus:outline-none+ `}+ >+ <IconChevronRight size={16} strokeWidth={2} />+ </button>+ </div>+ </div>,+ ]}+ />+ <div className="flex items-center gap-2 pt-4">+ <Toggle+ size="tiny"+ // @ts-ignore+ onChange={(bool: boolean) => setShowTime(bool)}+ />+ <span className="text-xs text-scale-1100">Show times</span>+ </div>+ {/* <div className="flex items-center gap-2 text-scale-900 pt-4 mb-4">+ <IconGlobe size={14} />+ <div className="grow">+ <Select size="tiny">+ <Select.Option value="GMT">London GMT +0</Select.Option>+ </Select>+ </div>+ </div> */}+ </div>++ <Popover.Seperator />+ <div className="flex items-center justify-end gap-2 py-2 pb-4 px-3">+ <Button type="default" onClick={() => handleClear()}>+ Clear+ </Button>+ <Button onClick={() => handleSubmit()}>Apply</Button>+ </div>+ </>+ }+ >+ <Button type="default" icon={<IconCalendar />}>+ {/* Custom */}+ {appliedStartDate && appliedEndDate ? (+ <>+ {format(new Date(appliedStartDate), 'dd MMM')} -{' '}+ {format(new Date(appliedEndDate), 'dd MMM')}+ </>+ ) : (+ 'Custom'+ )}+ </Button>+ </Popover>++ {/* <div className="relative w-40">+ <DatePicker+ selected={endDate}+ onChange={(date) => setEndDate(date)}+ selectsEnd+ startDate={startDate}+ endDate={endDate}+ nextMonthButtonLabel=">"+ previousMonthButtonLabel="<"+ popperClassName="react-datepicker-right"+ customInput={<ButtonInput />}+ renderCustomHeader={({+ date,+ decreaseMonth,+ increaseMonth,+ prevMonthButtonDisabled,+ nextMonthButtonDisabled,+ }) => (+ <>+ <div className="flex items-center justify-between px-2 py-2">+ <div className="flex items-center justify-between w-full">+ <button+ onClick={decreaseMonth}+ disabled={prevMonthButtonDisabled}+ type="button"+ className={`+ ${+ prevMonthButtonDisabled &&+ 'cursor-not-allowed opacity-50'+ }+ text-scale-1100 hover:text-scale-1200 focus:outline-none+ `}+ >+ <IconChevronLeft size={16} strokeWidth={2} />+ </button>+ <span className="text-sm text-scale-1100">+ {format(date, 'MMMM yyyy')}+ </span>+ <button+ onClick={increaseMonth}+ disabled={nextMonthButtonDisabled}+ type="button"+ className={`+ ${+ nextMonthButtonDisabled &&+ 'cursor-not-allowed opacity-50'+ }+ text-scale-1100 hover:text-scale-1200 focus:outline-none+ `}+ >+ <IconChevronRight size={16} strokeWidth={2} />+ </button>+ </div>+ </div>+ </>+ )}+ />+ </div>+ </div>+ <div className="flex items-center justify-center max-w-2xl py-20 mx-auto space-x-4">+ <span className="font-medium text-gray-900">Default Components:</span>+ <div className="relative w-40">+ <DatePicker+ selected={startDate}+ onChange={(date) => setStartDate(date)}+ selectsStart+ startDate={startDate}+ endDate={endDate}+ nextMonthButtonLabel=">"+ previousMonthButtonLabel="<"+ popperClassName="react-datepicker-left"+ />+ </div>+ <div className="relative w-40">+ <DatePicker+ selected={endDate}+ onChange={(date) => setEndDate(date)}+ selectsEnd+ startDate={startDate}+ endDate={endDate}+ nextMonthButtonLabel=">"+ previousMonthButtonLabel="<"+ popperClassName="react-datepicker-right"+ />+ </div> */}+ </>+ )+}++const ButtonInput = forwardRef(({ value, onClick }: any, ref): any => (+ <button+ onClick={onClick}+ // @ts-ignore+ ref={ref}+ type="button"+ className="inline-flex justify-start w-full px-3 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-0 focus:ring-blue-500"+ >+ {value}+ </button>+))++export default _DatePickerdiff --git a/studio/components/ui/DatePicker/DateSplitInput.tsx b/studio/components/ui/DatePicker/DateSplitInput.tsxnew file mode 100644index 00000000000..3596a985a9a--- /dev/null+++ b/studio/components/ui/DatePicker/DateSplitInput.tsx@@ -0,0 +1,238 @@+import React, { useState } from 'react'+import { IconClock } from '@supabase/ui'++import { format } from 'date-fns'++type TimeType = 'DD' | 'MM' | 'YYYY'++type Time = {+ HH: string+ mm: string+ ss: string+}++interface TimeSplitInputProps {+ time: Time+ setTime: (x: Time) => void+ type: 'start' | 'end'+ setStartTime: (x: Time) => void+ setEndTime: (x: Time) => void+ startTime: Time+ endTime: Time+ startDate: any+ endDate: any+}++const TimeSplitInput = ({+ type,+ time,+ setTime,+ setStartTime,+ setEndTime,+ startTime,+ endTime,+ startDate,+ endDate,+}: TimeSplitInputProps) => {+ const [focus, setFocus] = useState(false)++ function handleOnChange(value: string, valueType: TimeType) {+ // console.log('handleOnChange')++ const payload = {+ HH: time.HH,+ mm: time.mm,+ ss: time.ss,+ }+ if (value.length > 2) return++ switch (valueType) {+ case 'DD':+ if (value && Number(value) > 23) return+ break+ case 'MM':+ if (value && Number(value) > 59) return+ break+ case 'YYYY':+ if (value && Number(value) > 59) return+ break+ default:+ break+ }++ // console.log('got here')++ payload[valueType] = value+ setTime({ ...payload })++ // if (endTimeChanges) {+ // setEndTime(endTimePayload)+ // }+ }++ function handleOnBlur(valueType: TimeType) {+ // console.log('handle blur')+ const _time = time+ // console.log('_time.HH.length', _time.HH.length)++ if (_time.HH.length === 1) _time.HH = '0' + _time.HH+ if (_time.mm.length === 1) _time.mm = '0' + _time.mm+ if (_time.ss.length === 1) _time.ss = '0' + _time.ss++ if (!_time.HH) _time.HH = '00'+ if (!_time.mm) _time.mm = '00'+ if (!_time.ss) _time.ss = '00'++ // console.log('_time', _time)++ let endTimeChanges = false+ let endTimePayload = endTime++ let startTimeChanges = false+ let startTimePayload = startTime++ // Only run time conflicts if+ // startDate and endDate are the same date++ // console.log(startDate)+ // console.log(endDate)+ if (format(new Date(startDate), 'dd/mm/yyyy') == format(new Date(endDate), 'dd/mm/yyyy')) {+ // checks if start time is ahead of end time++ if (type === 'start') {+ // console.log('HH in start switch')+ if (_time.HH && Number(_time.HH) > Number(endTime.HH)) {+ endTimePayload.HH = _time.HH+ endTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) >= Number(endTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) > Number(endTime.mm)+ ) {+ endTimePayload.mm = _time.mm+ endTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) >= Number(endTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) >= Number(endTime.mm) &&+ // check the seconds+ _time.ss &&+ Number(_time.ss) > Number(endTime.ss)+ ) {+ endTimePayload.ss = _time.ss+ endTimeChanges = true+ }+ }++ if (type === 'end') {+ // console.log('HH in start switch')++ if (_time.HH && Number(_time.HH) < Number(startTime.HH)) {+ startTimePayload.HH = _time.HH+ startTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) <= Number(startTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) < Number(startTime.mm)+ ) {+ startTimePayload.mm = _time.mm+ startTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) <= Number(startTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) <= Number(startTime.mm) &&+ // check the seconds+ _time.ss &&+ Number(_time.ss) < Number(startTime.ss)+ ) {+ startTimePayload.ss = _time.ss+ startTimeChanges = true+ }+ }+ }++ setTime({ ..._time })++ if (endTimeChanges) {+ setEndTime({ ...endTimePayload })+ }+ if (startTimeChanges) {+ setStartTime({ ...startTimePayload })+ }++ setFocus(false)+ }++ const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {+ event.target.select()+ setFocus(true)+ }++ return (+ <div+ className={`+ flex items-center justify-center gap-0+ text-xs text-scale-1100 bg-scale-100 dark:bg-scaleA-300 border border-scale-700 h-7 rounded+ ${focus && ' outline outline-2 outline-scale-500 border-scale-800'}+ `}+ >+ <div className="text-scale-900 mr-1">+ <IconClock size={14} strokeWidth={1.5} />+ </div>+ <input+ onBlur={() => handleOnBlur('DD')}+ onFocus={handleFocus}+ pattern="[0-31]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'DD')}+ aria-label="Days"+ className="text-scale-1200 w-5 bg-transparent text-center outline-none"+ value={time.HH}+ />+ <span className="text-scale-900">:</span>+ <input+ onBlur={() => handleOnBlur('MM')}+ onFocus={handleFocus}+ pattern="[0-12]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'MM')}+ aria-label="Months"+ className="text-scale-1200 w-5 bg-transparent text-center outline-none"+ value={time.mm}+ />+ <span className="text-scale-900">:</span>+ <input+ onBlur={() => handleOnBlur('YYYY')}+ onFocus={handleFocus}+ pattern="[2021-2022]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'YYYY')}+ aria-label="Years"+ className="text-scale-1200 w-5 bg-transparent text-center outline-none"+ value={time.ss}+ />+ </div>+ )+}++export default TimeSplitInputdiff --git a/studio/components/ui/DatePicker/DividerSlash.tsx b/studio/components/ui/DatePicker/DividerSlash.tsxnew file mode 100644index 00000000000..8071f95ba06--- /dev/null+++ b/studio/components/ui/DatePicker/DividerSlash.tsx@@ -0,0 +1,19 @@+export default function DividerSlash() {+ return (+ <span className="text-scale-900">+ <svg+ viewBox="0 0 24 24"+ width="14"+ height="14"+ stroke="currentColor"+ strokeWidth="1"+ strokeLinecap="round"+ strokeLinejoin="round"+ fill="none"+ shapeRendering="geometricPrecision"+ >+ <path d="M16 3.549L7.12 20.600"></path>+ </svg>+ </span>+ )+}diff --git a/studio/components/ui/DatePicker/TimeSplitInput.tsx b/studio/components/ui/DatePicker/TimeSplitInput.tsxnew file mode 100644index 00000000000..c5d79314766--- /dev/null+++ b/studio/components/ui/DatePicker/TimeSplitInput.tsx@@ -0,0 +1,272 @@+import React, { useEffect, useState } from 'react'+import { IconClock } from '@supabase/ui'++import { format } from 'date-fns'++type TimeType = 'HH' | 'mm' | 'ss'++type Time = {+ HH: string+ mm: string+ ss: string+}++interface TimeSplitInputProps {+ time: Time+ setTime: (x: Time) => void+ type: 'start' | 'end'+ setStartTime: (x: Time) => void+ setEndTime: (x: Time) => void+ startTime: Time+ endTime: Time+ startDate: any+ endDate: any+}++const TimeSplitInput = ({+ type,+ time,+ setTime,+ setStartTime,+ setEndTime,+ startTime,+ endTime,+ startDate,+ endDate,+}: TimeSplitInputProps) => {+ const [focus, setFocus] = useState(false)++ function handleOnBlur() {+ const _time = time++ if (_time.HH.length === 1) _time.HH = '0' + _time.HH+ if (_time.mm.length === 1) _time.mm = '0' + _time.mm+ if (_time.ss.length === 1) _time.ss = '0' + _time.ss++ if (!_time.HH) _time.HH = '00'+ if (!_time.mm) _time.mm = '00'+ if (!_time.ss) _time.ss = '00'++ let endTimeChanges = false+ let endTimePayload = endTime++ let startTimeChanges = false+ let startTimePayload = startTime++ // Only run time conflicts if+ // startDate and endDate are the same date++ // console.log(startDate)+ // console.log(endDate)+ if (format(new Date(startDate), 'dd/mm/yyyy') == format(new Date(endDate), 'dd/mm/yyyy')) {+ // checks if start time is ahead of end time++ if (type === 'start') {+ // console.log('HH in start switch')+ if (_time.HH && Number(_time.HH) > Number(endTime.HH)) {+ endTimePayload.HH = _time.HH+ endTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) >= Number(endTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) > Number(endTime.mm)+ ) {+ endTimePayload.mm = _time.mm+ endTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) >= Number(endTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) >= Number(endTime.mm) &&+ // check the seconds+ _time.ss &&+ Number(_time.ss) > Number(endTime.ss)+ ) {+ endTimePayload.ss = _time.ss+ endTimeChanges = true+ }+ }++ if (type === 'end') {+ // console.log('HH in start switch')++ if (_time.HH && Number(_time.HH) < Number(startTime.HH)) {+ startTimePayload.HH = _time.HH+ startTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) <= Number(startTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) < Number(startTime.mm)+ ) {+ startTimePayload.mm = _time.mm+ startTimeChanges = true+ }++ if (+ // also check the hour+ _time.HH &&+ Number(_time.HH) <= Number(startTime.HH) &&+ // check the minutes+ _time.mm &&+ Number(_time.mm) <= Number(startTime.mm) &&+ // check the seconds+ _time.ss &&+ Number(_time.ss) < Number(startTime.ss)+ ) {+ startTimePayload.ss = _time.ss+ startTimeChanges = true+ }+ }+ }++ setTime({ ..._time })++ if (endTimeChanges) {+ setEndTime({ ...endTimePayload })+ }+ if (startTimeChanges) {+ setStartTime({ ...startTimePayload })+ }++ setFocus(false)+ }++ function handleOnChange(value: string, valueType: TimeType) {+ // console.log('handleOnChange')++ const payload = {+ HH: time.HH,+ mm: time.mm,+ ss: time.ss,+ }+ if (value.length > 2) return++ switch (valueType) {+ case 'HH':+ if (value && Number(value) > 23) return+ break+ case 'mm':+ if (value && Number(value) > 59) return+ break+ case 'ss':+ if (value && Number(value) > 59) return+ break+ default:+ break+ }++ // console.log('got here')++ payload[valueType] = value+ setTime({ ...payload })++ // if (endTimeChanges) {+ // setEndTime(endTimePayload)+ // }+ }++ const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {+ event.target.select()+ setFocus(true)+ }++ useEffect(() => {+ handleOnBlur()+ }, [startDate, endDate])++ return (+ <div+ className={`+ flex items-center justify-center gap-0+ text-xs text-scale-1100 bg-scale-100 dark:bg-scaleA-300 border border-scale-700 h-7 rounded+ ${focus && ' outline outline-2 outline-scale-500 border-scale-800'}+ `}+ >+ <div className="text-scale-900 mr-1">+ <IconClock size={14} strokeWidth={1.5} />+ </div>++ <input+ type="text"+ onBlur={() => handleOnBlur()}+ onFocus={handleFocus}+ pattern="[0-23]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'HH')}+ aria-label="Hours"+ className="+ w-4+ text-center+ text-xs+ p-0+ text-scale-1200 bg-transparent outline-none+ border-none+ ring-none+ ring-0+ focus:ring-0+ "+ value={time.HH}+ />+ <span className="text-scale-900">:</span>+ <input+ type="text"+ onBlur={() => handleOnBlur()}+ onFocus={handleFocus}+ pattern="[0-12]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'mm')}+ aria-label="Minutes"+ className="+ w-4+ text-center+ text-xs+ p-0+ text-scale-1200 bg-transparent outline-none+ border-none+ ring-none+ ring-0+ focus:ring-0+ "+ value={time.mm}+ />+ <span className="text-scale-900">:</span>+ <input+ type="text"+ onBlur={() => handleOnBlur()}+ onFocus={handleFocus}+ pattern="[0-59]*"+ placeholder="00"+ onChange={(e) => handleOnChange(e.target.value, 'ss')}+ aria-label="Seconds"+ className="+ w-4+ text-center+ text-xs+ p-0+ text-scale-1200 bg-transparent outline-none+ border-none+ ring-none+ ring-0+ focus:ring-0+ "+ value={time.ss}+ />+ </div>+ )+}++export default TimeSplitInputdiff --git a/studio/components/ui/DatePicker/index.tsx b/studio/components/ui/DatePicker/index.tsxnew file mode 100644index 00000000000..25865361516--- /dev/null+++ b/studio/components/ui/DatePicker/index.tsx@@ -0,0 +1 @@+export { default as DatePicker } from './DatePicker'diff --git a/studio/package-lock.json b/studio/package-lock.jsonindex 89228c8e529..74472824ba9 100644--- a/studio/package-lock.json+++ b/studio/package-lock.json@@ -9827,6 +9827,11 @@}}},+ "date-fns": {+ "version": "2.28.0",+ "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.28.0.tgz",+ "integrity": "sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw=="+ },"dayjs": {"version": "1.11.0","resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.0.tgz",@@ -17663,6 +17668,19 @@"resolved": "https://registry.npmjs.org/react-csv/-/react-csv-2.0.3.tgz","integrity": "sha512-exyAdFLAxtuM4wNwLYrlKyPYLiJ7e0mv9tqPAd3kq+k1CiJFtznevR3yP0icv5q/y200w+lzNgi7TQn1Wrhu0w=="},+ "react-datepicker": {+ "version": "4.7.0",+ "resolved": "https://registry.npmjs.org/react-datepicker/-/react-datepicker-4.7.0.tgz",+ "integrity": "sha512-FS8KgbwqpxmJBv/bUdA42MYqYZa+fEYcpc746DZiHvVE2nhjrW/dg7c5B5fIUuI8gZET6FOzuDgezNcj568Czw==",+ "requires": {+ "@popperjs/core": "^2.9.2",+ "classnames": "^2.2.6",+ "date-fns": "^2.24.0",+ "prop-types": "^15.7.2",+ "react-onclickoutside": "^6.12.0",+ "react-popper": "^2.2.5"+ }+ },"react-dnd": {"version": "14.0.5","resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-14.0.5.tgz",@@ -17862,11 +17880,15 @@"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz","integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="},+ "react-onclickoutside": {+ "version": "6.12.1",+ "resolved": "https://registry.npmjs.org/react-onclickoutside/-/react-onclickoutside-6.12.1.tgz",+ "integrity": "sha512-a5Q7CkWznBRUWPmocCvE8b6lEYw1s6+opp/60dCunhO+G6E4tDTO2Sd2jKE+leEnnrLAE2Wj5DlDHNqj5wPv1Q=="+ },"react-popper": {"version": "2.2.5","resolved": "https://registry.npmjs.org/react-popper/-/react-popper-2.2.5.tgz","integrity": "sha512-kxGkS80eQGtLl18+uig1UIf9MKixFSyPxglsgLBxlYnyDf65BiY9B3nZSc6C9XUNDgStROB0fMQlTEz1KxGddw==",- "dev": true,"requires": {"react-fast-compare": "^3.0.1","warning": "^4.0.2"@@ -17875,8 +17897,7 @@"react-fast-compare": {"version": "3.2.0","resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz",- "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==",- "dev": true+ "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA=="}}},diff --git a/studio/package.json b/studio/package.jsonindex cbddbf1e3a3..e94aa9428a3 100644--- a/studio/package.json+++ b/studio/package.json@@ -48,6 +48,7 @@"react": "^17.0.2","react-beautiful-dnd": "^13.1.0","react-csv": "^2.0.3",+ "react-datepicker": "^4.6.0","react-dom": "^17.0.2","react-grid-layout": "^1.3.0","react-hot-toast": "^2.1.1",diff --git a/studio/pages/_app.tsx b/studio/pages/_app.tsxindex c874287d0ca..1ebb8cf841d 100644--- a/studio/pages/_app.tsx+++ b/studio/pages/_app.tsx@@ -8,6 +8,7 @@ import 'styles/code.scss'import 'styles/monaco.scss'import 'styles/contextMenu.scss'import 'styles/react-data-grid-logs.scss'+import 'styles/date-picker.scss'import Head from 'next/head'import type { AppProps } from 'next/app'