diff --git a/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte new file mode 100644 index 0000000000..0d7dad526f --- /dev/null +++ b/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte @@ -0,0 +1,313 @@ + + +{#each Object.keys(components['dateselectcomponent'].initialData.configuration) as key (key)} + +{/each} + +{#each Object.keys(css ?? {}) as key (key)} + +{/each} + + + + + + + + {#if resolvedConfig?.enableDay} + + { + selectedDay = e.detail.value + outputs.day.set(Number(selectedDay)) + }} + on:clear={() => { + selectedDay = '' + outputs.day.set(undefined) + }} + items={Array.from({ length: computeDayPerMonth(selectedMonth, selectedYear) }, (_, i) => { + return { label: String(i + 1), value: String(i + 1) } + })} + class={twMerge('text-clip min-w-0', css?.input?.class, 'wm-date-select')} + containerStyles={(darkMode + ? SELECT_INPUT_DEFAULT_STYLE.containerStylesDark + : SELECT_INPUT_DEFAULT_STYLE.containerStyles) + css?.input?.style} + inputStyles={SELECT_INPUT_DEFAULT_STYLE.inputStyles} + placeholder="Pick a day" + /> + + {/if} + {#if resolvedConfig?.enableMonth} + + { + selectedMonth = e.detail.value + outputs.month.set(monthItems.findIndex((item) => item.value === selectedMonth) + 1) + }} + on:clear={() => { + selectedMonth = '' + outputs.month.set(undefined) + }} + items={monthItems} + placeholder="Pick a month" + class={twMerge('text-clip min-w-0', css?.input?.class, 'wm-date-select')} + containerStyles={(darkMode + ? SELECT_INPUT_DEFAULT_STYLE.containerStylesDark + : SELECT_INPUT_DEFAULT_STYLE.containerStyles) + css?.input?.style} + clearable + /> + + {/if} + {#if resolvedConfig?.enableYear} + + { + selectedYear = e.detail.value + outputs.year.set(Number(selectedYear)) + }} + on:clear={() => { + selectedYear = '' + outputs.year.set(undefined) + }} + items={Array.from({ length: 201 }, (_, i) => `${1900 + i}`)} + placeholder="Pick a year" + inputStyles={SELECT_INPUT_DEFAULT_STYLE.inputStyles} + class={twMerge('text-clip min-w-0', css?.input?.class, 'wm-date-select')} + containerStyles={(darkMode + ? SELECT_INPUT_DEFAULT_STYLE.containerStylesDark + : SELECT_INPUT_DEFAULT_STYLE.containerStyles) + css?.input?.style} + clearable + /> + + {/if} + + diff --git a/frontend/src/lib/components/apps/editor/component/Component.svelte b/frontend/src/lib/components/apps/editor/component/Component.svelte index 488aef7bae..668e85341b 100644 --- a/frontend/src/lib/components/apps/editor/component/Component.svelte +++ b/frontend/src/lib/components/apps/editor/component/Component.svelte @@ -76,6 +76,7 @@ import AppSliderInputs from '../../components/inputs/AppSliderInputs.svelte' import AppNumberInput from '../../components/inputs/AppNumberInput.svelte' import AppNavbar from '../../components/display/AppNavbar.svelte' + import AppDateSelect from '../../components/inputs/AppDateSelect.svelte' export let component: AppComponent export let selected: boolean @@ -838,6 +839,14 @@ navbarItems={component.navbarItems} {render} /> + {:else if component.type === 'dateselectcomponent'} + {/if} diff --git a/frontend/src/lib/components/apps/editor/component/components.ts b/frontend/src/lib/components/apps/editor/component/components.ts index ab9c84d338..d9857908ee 100644 --- a/frontend/src/lib/components/apps/editor/component/components.ts +++ b/frontend/src/lib/components/apps/editor/component/components.ts @@ -276,6 +276,8 @@ export type NavBarComponent = BaseComponent<'navbarcomponent'> & { navbarItems: NavbarItem[] } +export type DateSelectComponent = BaseComponent<'dateselectcomponent'> + export type TypedComponent = | DBExplorerComponent | DisplayComponent @@ -351,6 +353,7 @@ export type TypedComponent = | AggridInfiniteComponentEe | MultiSelectComponentV2 | NavBarComponent + | DateSelectComponent export type AppComponent = BaseAppComponent & TypedComponent @@ -3938,6 +3941,60 @@ See date-fns format for more information. By default, it is 'dd.MM.yyyy HH:mm' } } } + }, + dateselectcomponent: { + name: 'Date Select', + icon: Calendar, + documentationLink: `${documentationBaseUrl}/date_select`, + dims: '3:4-6:4' as AppComponentDimensions, + customCss: { + container: { class: '', style: '' }, + input: { class: '', style: '' } + }, + initialData: { + componentInput: undefined, + verticalAlignment: 'center', + + configuration: { + enableDay: { + type: 'static', + value: true, + fieldType: 'boolean' + }, + enableMonth: { + type: 'static', + value: true, + fieldType: 'boolean' + }, + enableYear: { + type: 'static', + value: true, + fieldType: 'boolean' + }, + defaultValue: { + type: 'static', + value: undefined, + fieldType: 'date' + }, + + orientation: { + type: 'static', + value: 'horizontal', + fieldType: 'select', + selectOptions: [ + { value: 'horizontal', label: 'Horizontal' }, + { value: 'vertical', label: 'Vertical' } + ] + }, + locale: { + type: 'static', + value: 'en-US', + fieldType: 'select', + selectOptions: selectOptions.localeOptions, + tooltip: 'Format on the month names' + } + } + } } } as const diff --git a/frontend/src/lib/components/apps/editor/component/sets.ts b/frontend/src/lib/components/apps/editor/component/sets.ts index 88a6966d19..adeedf3cb7 100644 --- a/frontend/src/lib/components/apps/editor/component/sets.ts +++ b/frontend/src/lib/components/apps/editor/component/sets.ts @@ -53,7 +53,8 @@ const inputs: ComponentSet = { 'resourceselectcomponent', 'multiselectcomponentv2', 'selecttabcomponent', - 'selectstepcomponent' + 'selectstepcomponent', + 'dateselectcomponent' ] } as const diff --git a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts index cf01227014..1669c244d9 100644 --- a/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts +++ b/frontend/src/lib/components/apps/editor/componentsPanel/quickStyleProperties.ts @@ -789,5 +789,8 @@ export const quickStyleProperties: Record< }, navbarcomponent: { container: containerDefaultProps + }, + dateselectcomponent: { + input: inputDefaultProps } }