@@ -30,6 +30,7 @@ import {
3030 canRenderDatePickerField ,
3131 DatePickerField ,
3232} from "@/configurator/components/field-date-picker" ;
33+ import { extractDataPickerOptionsFromDimension } from "@/configurator/components/ui-helpers" ;
3334import { FIELD_VALUE_NONE } from "@/configurator/constants" ;
3435import {
3536 Dimension ,
@@ -363,15 +364,17 @@ const DataFilter = ({
363364 ) ;
364365} ;
365366
366- type DataFilterGenericDimensionProps = {
367+ export type DataFilterGenericDimensionProps = {
367368 dimension : Dimension ;
368369 value : string ;
369370 onChange : ( e : SelectChangeEvent < unknown > ) => void ;
370371 options ?: Array < { label : string ; value : string } > ;
371372 disabled : boolean ;
372373} ;
373374
374- const DataFilterGenericDimension = ( props : DataFilterGenericDimensionProps ) => {
375+ export const DataFilterGenericDimension = (
376+ props : DataFilterGenericDimensionProps
377+ ) => {
375378 const { dimension, value, onChange, options : propOptions , disabled } = props ;
376379 const { label, isKeyDimension } = dimension ;
377380 const noneLabel = t ( {
@@ -488,48 +491,17 @@ const DataFilterTemporalDimension = ({
488491 ) => void ;
489492 disabled : boolean ;
490493} ) => {
491- const { isKeyDimension , label, values , timeUnit, timeFormat } = dimension ;
494+ const { label, timeUnit, timeFormat } = dimension ;
492495 const formatLocale = useTimeFormatLocale ( ) ;
493496 const formatDate = formatLocale . format ( timeFormat ) ;
494497 const parseDate = formatLocale . parse ( timeFormat ) ;
495498
496- const noneLabel = t ( {
497- id : "controls.dimensionvalue.none" ,
498- message : "No Filter" ,
499- } ) ;
500499 const { minDate, maxDate, options, optionValues } = useMemo ( ( ) => {
501- if ( values . length ) {
502- const options = values . map ( ( d ) => {
503- return {
504- label : `${ d . value } ` ,
505- value : `${ d . value } ` ,
506- } ;
507- } ) ;
508-
509- return {
510- minDate : parseDate ( values [ 0 ] . value as string ) as Date ,
511- maxDate : parseDate ( values [ values . length - 1 ] . value as string ) as Date ,
512- options : isKeyDimension
513- ? options
514- : [
515- {
516- value : FIELD_VALUE_NONE ,
517- label : noneLabel ,
518- isNoneValue : true ,
519- } ,
520- ...options ,
521- ] ,
522- optionValues : options . map ( ( d ) => d . value ) ,
523- } ;
524- } else {
525- return {
526- minDate : new Date ( ) ,
527- maxDate : new Date ( ) ,
528- options : [ ] ,
529- optionValues : [ ] ,
530- } ;
531- }
532- } , [ isKeyDimension , noneLabel , values , parseDate ] ) ;
500+ return extractDataPickerOptionsFromDimension ( {
501+ dimension,
502+ parseDate,
503+ } ) ;
504+ } , [ dimension , parseDate ] ) ;
533505
534506 return canRenderDatePickerField ( timeUnit ) ? (
535507 < DatePickerField
0 commit comments