@razorpay/blade 12.110.0 → 12.111.0
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/build/lib/native/components/AnimateInteractions/AnimateInteractions.native.js +5 -5
- package/build/lib/native/components/AnimateInteractions/AnimateInteractions.native.js.map +1 -1
- package/build/lib/native/components/AnimateInteractions/AnimateInteractionsProvider.js +6 -0
- package/build/lib/native/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -0
- package/build/lib/native/components/BaseMotion/BaseMotion.native.js +22 -0
- package/build/lib/native/components/BaseMotion/BaseMotion.native.js.map +1 -0
- package/build/lib/native/components/BaseMotion/baseMotionInterpreter.native.js +11 -0
- package/build/lib/native/components/BaseMotion/baseMotionInterpreter.native.js.map +1 -0
- package/build/lib/native/components/BaseMotion/baseMotionUtils.js +4 -0
- package/build/lib/native/components/BaseMotion/baseMotionUtils.js.map +1 -0
- package/build/lib/native/components/BaseMotion/index.js +3 -0
- package/build/lib/native/components/BaseMotion/index.js.map +1 -0
- package/build/lib/native/components/BaseMotion/types.js +2 -0
- package/build/lib/native/components/BaseMotion/types.js.map +1 -0
- package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js +2 -1
- package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js.map +1 -1
- package/build/lib/native/components/Dropdown/filterChipSelectInputUtils.js +4 -0
- package/build/lib/native/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/native/components/Fade/Fade.native.js +7 -5
- package/build/lib/native/components/Fade/Fade.native.js.map +1 -1
- package/build/lib/native/components/FilterChip/BaseFilterChip.native.js +2 -2
- package/build/lib/native/components/FilterChip/BaseFilterChip.native.js.map +1 -1
- package/build/lib/native/components/Morph/Morph.native.js +9 -5
- package/build/lib/native/components/Morph/Morph.native.js.map +1 -1
- package/build/lib/native/components/Move/Move.native.js +8 -5
- package/build/lib/native/components/Move/Move.native.js.map +1 -1
- package/build/lib/native/components/Scale/Scale.native.js +7 -5
- package/build/lib/native/components/Scale/Scale.native.js.map +1 -1
- package/build/lib/native/components/SegmentedControl/SegmentedControl.native.js +27 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControl.native.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlContext.js +8 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlItem.native.js +18 -0
- package/build/lib/native/components/SegmentedControl/SegmentedControlItem.native.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/index.js +3 -0
- package/build/lib/native/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/native/components/SegmentedControl/segmentedControlTokens.js +4 -0
- package/build/lib/native/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/native/components/Slide/Slide.native.js +7 -5
- package/build/lib/native/components/Slide/Slide.native.js.map +1 -1
- package/build/lib/native/components/Stagger/Stagger.native.js +10 -5
- package/build/lib/native/components/Stagger/Stagger.native.js.map +1 -1
- package/build/lib/native/components/Stagger/StaggerProvider.js +6 -0
- package/build/lib/native/components/Stagger/StaggerProvider.js.map +1 -0
- package/build/lib/native/components/index.js +3 -0
- package/build/lib/native/components/index.js.map +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
- package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/native/utils/msToSeconds.js +4 -0
- package/build/lib/native/utils/msToSeconds.js.map +1 -0
- package/build/lib/web/development/_virtual/flatten.js +1 -1
- package/build/lib/web/development/_virtual/flatten3.js +1 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractions.web.js +1 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractionsProvider.js +2 -1
- package/build/lib/web/development/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -1
- package/build/lib/web/development/components/AnimateInteractions/{useFocusWithin.js → useFocusWithin.web.js} +1 -1
- package/build/lib/web/development/components/AnimateInteractions/useFocusWithin.web.js.map +1 -0
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js +8 -1
- package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +4 -1
- package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js +40 -5
- package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js +11 -21
- package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/filterChipSelectInputUtils.js +46 -0
- package/build/lib/web/development/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js +35 -11
- package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js.map +1 -1
- package/build/lib/web/development/components/SegmentedControl/SegmentedControl.web.js +196 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControl.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlContext.js +18 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlIndicator.web.js +109 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlIndicator.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlItem.web.js +170 -0
- package/build/lib/web/development/components/SegmentedControl/SegmentedControlItem.web.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/index.js +3 -0
- package/build/lib/web/development/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/web/development/components/SegmentedControl/segmentedControlTokens.js +53 -0
- package/build/lib/web/development/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/web/development/components/Stagger/StaggerProvider.js.map +1 -1
- package/build/lib/web/development/components/index.js +3 -0
- package/build/lib/web/development/components/index.js.map +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/array/flatten.js +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/flatten.js +1 -1
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/sortBy.js +2 -2
- package/build/lib/web/development/node_modules/es-toolkit/dist/compat/object/omit.js +2 -2
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js +3 -1
- package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractions.web.js +1 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractionsProvider.js +2 -1
- package/build/lib/web/production/components/AnimateInteractions/AnimateInteractionsProvider.js.map +1 -1
- package/build/lib/web/production/components/AnimateInteractions/{useFocusWithin.js → useFocusWithin.web.js} +1 -1
- package/build/lib/web/production/components/AnimateInteractions/useFocusWithin.web.js.map +1 -0
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js +8 -1
- package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +4 -1
- package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js +40 -5
- package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js +11 -21
- package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/filterChipSelectInputUtils.js +46 -0
- package/build/lib/web/production/components/Dropdown/filterChipSelectInputUtils.js.map +1 -0
- package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js +35 -11
- package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js.map +1 -1
- package/build/lib/web/production/components/SegmentedControl/SegmentedControl.web.js +196 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControl.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlContext.js +18 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlContext.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlIndicator.web.js +109 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlIndicator.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlItem.web.js +170 -0
- package/build/lib/web/production/components/SegmentedControl/SegmentedControlItem.web.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/index.js +3 -0
- package/build/lib/web/production/components/SegmentedControl/index.js.map +1 -0
- package/build/lib/web/production/components/SegmentedControl/segmentedControlTokens.js +53 -0
- package/build/lib/web/production/components/SegmentedControl/segmentedControlTokens.js.map +1 -0
- package/build/lib/web/production/components/Stagger/StaggerProvider.js.map +1 -1
- package/build/lib/web/production/components/index.js +3 -0
- package/build/lib/web/production/components/index.js.map +1 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js +3 -1
- package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
- package/build/types/components/index.d.ts +238 -8
- package/build/types/components/index.native.d.ts +410 -14
- package/package.json +1 -1
- package/build/lib/web/development/components/AnimateInteractions/useFocusWithin.js.map +0 -1
- package/build/lib/web/production/components/AnimateInteractions/useFocusWithin.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerFilterChip.web.js","sources":["../../../../../../../src/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { useDatesContext } from '@mantine/dates';\nimport type { DatePickerFilterChipProps } from '../types';\nimport { getFormattedDate, getHumanizedDate } from '../utils';\nimport { useDatePickerContext } from '../DatePickerContext';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport type { BladeElementRef } from '~utils/types';\n\nconst formatDateRange = (\n date: Date | [Date, Date],\n format: string,\n locale: string,\n selectionType: 'single' | 'range',\n): string => {\n const formatOptions = {\n date,\n format,\n labelSeparator: '-',\n locale,\n type: 'default' as const,\n };\n\n if (selectionType === 'single' && date instanceof Date) {\n return getFormattedDate(formatOptions);\n }\n\n if (Array.isArray(date)) {\n const [startDate, endDate] = date;\n if (startDate) {\n return `${getFormattedDate({ ...formatOptions, date: startDate })} ${\n endDate ? ' - ' : ''\n } ${getFormattedDate({\n ...formatOptions,\n date: endDate,\n })}`;\n }\n }\n return '';\n};\n\nconst _DatePickerFilterChip: React.ForwardRefRenderFunction<\n BladeElementRef,\n DatePickerFilterChipProps & {\n onClearButtonChange: (value: string) => void;\n }\n> = (\n {\n ...props\n }: DatePickerFilterChipProps & {\n onClearButtonChange: (value: string) => void;\n },\n ref: React.ForwardedRef<BladeElementRef>,\n): React.ReactElement => {\n const {\n referenceProps,\n label,\n selectionType,\n onClearButtonChange,\n accessibilityLabel,\n date,\n format,\n isDisabled,\n selectedPresetLabel,\n } = props;\n const { locale } = useDatesContext();\n const displayFormat = useDatePickerContext()?.displayFormat ?? 'default';\n\n // Check if there's actually a valid date selection.\n // In range mode both dates need to be present.\n const hasValidSelection =\n selectionType === 'range'\n ? Boolean((date as [Date | null, Date | null])?.[0]) &&\n Boolean((date as [Date | null, Date | null])?.[1])\n : Boolean(date);\n\n // When displayFormat is 'compact' and a defined preset (e.g. \"Last 7 days\") is selected,\n // show the preset label inside the chip instead of the actual date range.\n // For custom range selections there is no preset label, so we fall back to the date range.\n const shouldShowPresetLabel =\n displayFormat === 'compact' && Boolean(selectedPresetLabel) && hasValidSelection;\n\n let dateValue: string;\n if (shouldShowPresetLabel) {\n // A defined preset (e.g. \"Past 7 days\") is selected → show its label.\n dateValue = selectedPresetLabel as string;\n } else if (displayFormat === 'compact' && format === 'DD/MM/YYYY') {\n // Compact mode with a custom/date selection on the day picker → humanised date range.\n // Month/year pickers keep their own format (e.g. MMM/YYYY) which is already readable.\n dateValue = getHumanizedDate({ date, locale, selectionType });\n } else {\n // Default → show the date range using the configured format (e.g. DD/MM/YYYY).\n dateValue = formatDateRange(date, format, locale, selectionType);\n }\n\n return (\n <BaseFilterChip\n ref={ref}\n label={label}\n value={dateValue}\n onClearButtonClick={onClearButtonChange}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: referenceProps['aria-haspopup'],\n expanded: referenceProps['aria-expanded'],\n controls: referenceProps['aria-controls'],\n role: 'combobox',\n }}\n isDisabled={isDisabled}\n {...referenceProps}\n />\n );\n};\n\nconst DatePickerFilterChip = forwardRef(_DatePickerFilterChip);\n\nexport { DatePickerFilterChip };\n"],"names":["formatDateRange","date","format","locale","selectionType","formatOptions","labelSeparator","type","Date","getFormattedDate","Array","isArray","_date","_slicedToArray","startDate","endDate","concat","_objectSpread","_DatePickerFilterChip","_ref","ref","_useDatePickerContext","_useDatePickerContext2","props","_extends","_objectDestructuringEmpty","referenceProps","label","onClearButtonChange","accessibilityLabel","isDisabled","selectedPresetLabel","_useDatesContext","useDatesContext","displayFormat","useDatePickerContext","hasValidSelection","Boolean","shouldShowPresetLabel","dateValue","getHumanizedDate","_jsx","BaseFilterChip","value","onClearButtonClick","accessibilityProps","hasPopup","expanded","controls","role","DatePickerFilterChip","forwardRef"],"mappings":";;;;;;;;;;;;;AAQA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CACnBC,IAAyB,EACzBC,MAAc,EACdC,MAAc,EACdC,aAAiC,EACtB;AACX,EAAA,IAAMC,aAAa,GAAG;AACpBJ,IAAAA,IAAI,EAAJA,IAAI;AACJC,IAAAA,MAAM,EAANA,MAAM;AACNI,IAAAA,cAAc,EAAE,GAAG;AACnBH,IAAAA,MAAM,EAANA,MAAM;AACNI,IAAAA,IAAI,EAAE,SAAA;GACP,CAAA;AAED,EAAA,IAAIH,aAAa,KAAK,QAAQ,IAAIH,IAAI,YAAYO,IAAI,EAAE;IACtD,OAAOC,gBAAgB,CAACJ,aAAa,CAAC,CAAA;AACxC,GAAA;AAEA,EAAA,IAAIK,KAAK,CAACC,OAAO,CAACV,IAAI,CAAC,EAAE;AACvB,IAAA,IAAAW,KAAA,GAAAC,cAAA,CAA6BZ,IAAI,EAAA,CAAA,CAAA;AAA1Ba,MAAAA,SAAS,GAAAF,KAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,OAAO,GAAAH,KAAA,CAAA,CAAA,CAAA,CAAA;AACzB,IAAA,IAAIE,SAAS,EAAE;MACb,OAAAE,EAAAA,CAAAA,MAAA,CAAUP,gBAAgB,CAAAQ,aAAA,CAAAA,aAAA,KAAMZ,aAAa,CAAA,EAAA,EAAA,EAAA;AAAEJ,QAAAA,IAAI,EAAEa,SAAAA;AAAS,OAAA,CAAE,CAAC,EAAAE,IAAAA,CAAAA,CAAAA,MAAA,CAC/DD,OAAO,GAAG,KAAK,GAAG,EAAE,EAAAC,GAAAA,CAAAA,CAAAA,MAAA,CAClBP,gBAAgB,CAAAQ,aAAA,CAAAA,aAAA,KACfZ,aAAa,CAAA,EAAA,EAAA,EAAA;AAChBJ,QAAAA,IAAI,EAAEc,OAAAA;AAAO,OAAA,CACd,CAAC,CAAA,CAAA;AACJ,KAAA;AACF,GAAA;AACA,EAAA,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED,IAAMG,qBAKL,GAAG,SALEA,qBAKLA,CAAAC,IAAA,EAMCC,GAAwC,EACjB;EAAA,IAAAC,qBAAA,EAAAC,sBAAA,CAAA;EAAA,IALlBC,KAAK,GAAAC,QAAA,CAAA,EAAA,GAAAC,yBAAA,CAAAN,IAAA,GAAAA,IAAA,EAAA,CAAA;AAMV,EAAA,IACEO,cAAc,
|
|
1
|
+
{"version":3,"file":"DatePickerFilterChip.web.js","sources":["../../../../../../../src/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { useDatesContext } from '@mantine/dates';\nimport type { DatePickerFilterChipProps } from '../types';\nimport { getFormattedDate, getHumanizedDate } from '../utils';\nimport { useDatePickerContext } from '../DatePickerContext';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport type { BladeElementRef } from '~utils/types';\n\nconst formatDateRange = (\n date: Date | [Date, Date],\n format: string,\n locale: string,\n selectionType: 'single' | 'range',\n): string => {\n const formatOptions = {\n date,\n format,\n labelSeparator: '-',\n locale,\n type: 'default' as const,\n };\n\n if (selectionType === 'single' && date instanceof Date) {\n return getFormattedDate(formatOptions);\n }\n\n if (Array.isArray(date)) {\n const [startDate, endDate] = date;\n if (startDate) {\n return `${getFormattedDate({ ...formatOptions, date: startDate })} ${\n endDate ? ' - ' : ''\n } ${getFormattedDate({\n ...formatOptions,\n date: endDate,\n })}`;\n }\n }\n return '';\n};\n\nconst _DatePickerFilterChip: React.ForwardRefRenderFunction<\n BladeElementRef,\n DatePickerFilterChipProps & {\n onClearButtonChange: (value: string) => void;\n }\n> = (\n {\n ...props\n }: DatePickerFilterChipProps & {\n onClearButtonChange: (value: string) => void;\n },\n ref: React.ForwardedRef<BladeElementRef>,\n): React.ReactElement => {\n const {\n referenceProps,\n label,\n selectionType,\n onClearButtonChange,\n accessibilityLabel,\n date,\n format,\n isDisabled,\n selectedPresetLabel,\n showClearButton = true,\n } = props;\n const { locale } = useDatesContext();\n const displayFormat = useDatePickerContext()?.displayFormat ?? 'default';\n\n // Check if there's actually a valid date selection.\n // In range mode both dates need to be present.\n const hasValidSelection =\n selectionType === 'range'\n ? Boolean((date as [Date | null, Date | null])?.[0]) &&\n Boolean((date as [Date | null, Date | null])?.[1])\n : Boolean(date);\n\n // When displayFormat is 'compact' and a defined preset (e.g. \"Last 7 days\") is selected,\n // show the preset label inside the chip instead of the actual date range.\n // For custom range selections there is no preset label, so we fall back to the date range.\n const shouldShowPresetLabel =\n displayFormat === 'compact' && Boolean(selectedPresetLabel) && hasValidSelection;\n\n let dateValue: string;\n if (shouldShowPresetLabel) {\n // A defined preset (e.g. \"Past 7 days\") is selected → show its label.\n dateValue = selectedPresetLabel as string;\n } else if (displayFormat === 'compact' && format === 'DD/MM/YYYY') {\n // Compact mode with a custom/date selection on the day picker → humanised date range.\n // Month/year pickers keep their own format (e.g. MMM/YYYY) which is already readable.\n dateValue = getHumanizedDate({ date, locale, selectionType });\n } else {\n // Default → show the date range using the configured format (e.g. DD/MM/YYYY).\n dateValue = formatDateRange(date, format, locale, selectionType);\n }\n\n return (\n <BaseFilterChip\n ref={ref}\n label={label}\n value={dateValue}\n showClearButton={showClearButton}\n onClearButtonClick={onClearButtonChange}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: referenceProps['aria-haspopup'],\n expanded: referenceProps['aria-expanded'],\n controls: referenceProps['aria-controls'],\n role: 'combobox',\n }}\n isDisabled={isDisabled}\n {...referenceProps}\n />\n );\n};\n\nconst DatePickerFilterChip = forwardRef(_DatePickerFilterChip);\n\nexport { DatePickerFilterChip };\n"],"names":["formatDateRange","date","format","locale","selectionType","formatOptions","labelSeparator","type","Date","getFormattedDate","Array","isArray","_date","_slicedToArray","startDate","endDate","concat","_objectSpread","_DatePickerFilterChip","_ref","ref","_useDatePickerContext","_useDatePickerContext2","props","_extends","_objectDestructuringEmpty","referenceProps","label","onClearButtonChange","accessibilityLabel","isDisabled","selectedPresetLabel","_props$showClearButto","showClearButton","_useDatesContext","useDatesContext","displayFormat","useDatePickerContext","hasValidSelection","Boolean","shouldShowPresetLabel","dateValue","getHumanizedDate","_jsx","BaseFilterChip","value","onClearButtonClick","accessibilityProps","hasPopup","expanded","controls","role","DatePickerFilterChip","forwardRef"],"mappings":";;;;;;;;;;;;;AAQA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CACnBC,IAAyB,EACzBC,MAAc,EACdC,MAAc,EACdC,aAAiC,EACtB;AACX,EAAA,IAAMC,aAAa,GAAG;AACpBJ,IAAAA,IAAI,EAAJA,IAAI;AACJC,IAAAA,MAAM,EAANA,MAAM;A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GACRJ,EAAAA,cAAc,CACnB,CAAC,CAAA;AAEN,CAAC,CAAA;AAED,IAAM0B,oBAAoB,gBAAGC,UAAU,CAACnC,qBAAqB;;;;"}
|
|
@@ -15,7 +15,7 @@ import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
|
15
15
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
16
16
|
import Link from '../Link/Link/Link.js';
|
|
17
17
|
|
|
18
|
-
var _excluded = ["testID", "children", "showClearButton", "onClearButtonClick"];
|
|
18
|
+
var _excluded = ["testID", "children", "showClearButton", "onClearButtonClick", "onResetButtonClick", "clearButtonText", "resetButtonText"];
|
|
19
19
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
21
|
var FilterChipGroup = function FilterChipGroup(_ref) {
|
|
@@ -24,6 +24,9 @@ var FilterChipGroup = function FilterChipGroup(_ref) {
|
|
|
24
24
|
_ref$showClearButton = _ref.showClearButton,
|
|
25
25
|
showClearButton = _ref$showClearButton === void 0 ? true : _ref$showClearButton,
|
|
26
26
|
onClearButtonClick = _ref.onClearButtonClick,
|
|
27
|
+
onResetButtonClick = _ref.onResetButtonClick,
|
|
28
|
+
clearButtonText = _ref.clearButtonText,
|
|
29
|
+
resetButtonText = _ref.resetButtonText,
|
|
27
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
31
|
var _useState = useState([]),
|
|
29
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -36,14 +39,41 @@ var FilterChipGroup = function FilterChipGroup(_ref) {
|
|
|
36
39
|
var _useListViewFilterCon = useListViewFilterContext(),
|
|
37
40
|
selectedFiltersCount = _useListViewFilterCon.selectedFiltersCount,
|
|
38
41
|
setListViewSelectedFilters = _useListViewFilterCon.setListViewSelectedFilters;
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
|
|
43
|
+
// Shared bookkeeping reset: both actions clear the group's "has changes" tracking so the action
|
|
44
|
+
// link(s) hide after use (a lingering action with nothing to revert is confusing). They reappear
|
|
45
|
+
// on the next filter change.
|
|
46
|
+
var clearGroupBookkeeping = function clearGroupBookkeeping() {
|
|
41
47
|
setListViewSelectedFilters({});
|
|
42
48
|
setFilterChipGroupSelectedFilters([]);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// "Clear" empties every filter. Bumping the triggerer makes each child chip run its clear effect
|
|
52
|
+
// (fires onChange([]) and drops its selection).
|
|
53
|
+
var handleClearButtonClick = function handleClearButtonClick() {
|
|
54
|
+
onClearButtonClick === null || onClearButtonClick === void 0 || onClearButtonClick();
|
|
55
|
+
clearGroupBookkeeping();
|
|
43
56
|
setClearFilterCallbackTriggerer(function (prev) {
|
|
44
57
|
return prev + 1;
|
|
45
58
|
});
|
|
46
59
|
};
|
|
60
|
+
|
|
61
|
+
// "Reset" only fires the consumer callback and clears the group's bookkeeping. We intentionally
|
|
62
|
+
// do NOT bump the clear triggerer, so child chips keep their internal state and do not fire
|
|
63
|
+
// onChange([]) — the consumer restores each filter's default inside onResetButtonClick and those
|
|
64
|
+
// values are not stomped.
|
|
65
|
+
// TODO (FilterChip reset — Phase 2): support restoring defaults for UNCONTROLLED filters. That
|
|
66
|
+
// needs a `defaultValue` on FilterChipSelectInput and a reset path that restores it instead of
|
|
67
|
+
// emptying. See packages/blade/src/components/Dropdown/_decisions/filter-chip-reset.md
|
|
68
|
+
var handleResetButtonClick = function handleResetButtonClick() {
|
|
69
|
+
onResetButtonClick === null || onResetButtonClick === void 0 || onResetButtonClick();
|
|
70
|
+
clearGroupBookkeeping();
|
|
71
|
+
};
|
|
72
|
+
var hasSelectedFilters = filterChipGroupSelectedFilters.length > 0 || selectedFiltersCount > 0;
|
|
73
|
+
var selectedCount = Math.max(filterChipGroupSelectedFilters.length, selectedFiltersCount);
|
|
74
|
+
var isPlural = selectedCount > 1;
|
|
75
|
+
var clearActionText = clearButtonText !== null && clearButtonText !== void 0 ? clearButtonText : "Clear Filter".concat(isPlural ? 's' : '');
|
|
76
|
+
var resetActionText = resetButtonText !== null && resetButtonText !== void 0 ? resetButtonText : 'Reset';
|
|
47
77
|
return /*#__PURE__*/jsx(FilterChipGroupProvider, {
|
|
48
78
|
value: {
|
|
49
79
|
filterChipGroupSelectedFilters: filterChipGroupSelectedFilters,
|
|
@@ -62,11 +92,16 @@ var FilterChipGroup = function FilterChipGroup(_ref) {
|
|
|
62
92
|
width: "100%",
|
|
63
93
|
gap: "spacing.3",
|
|
64
94
|
flexWrap: "wrap",
|
|
65
|
-
children: [children,
|
|
95
|
+
children: [children, hasSelectedFilters && onResetButtonClick ? /*#__PURE__*/jsx(Link, {
|
|
96
|
+
size: "small",
|
|
97
|
+
color: "neutral",
|
|
98
|
+
onClick: handleResetButtonClick,
|
|
99
|
+
children: resetActionText
|
|
100
|
+
}) : null, hasSelectedFilters && showClearButton ? /*#__PURE__*/jsx(Link, {
|
|
66
101
|
size: "small",
|
|
67
102
|
color: "neutral",
|
|
68
103
|
onClick: handleClearButtonClick,
|
|
69
|
-
children:
|
|
104
|
+
children: clearActionText
|
|
70
105
|
}) : null]
|
|
71
106
|
}))
|
|
72
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterChipGroup.web.js","sources":["../../../../../../src/components/Dropdown/FilterChipGroup.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useListViewFilterContext } from '../ListView/ListViewFiltersContext.web';\nimport type { FilterChipGroupProps } from './types';\nimport { FilterChipGroupProvider } from './FilterChipGroupContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { Link } from '~components/Link';\n\nconst FilterChipGroup = ({\n testID,\n children,\n showClearButton = true,\n onClearButtonClick,\n ...rest\n}: FilterChipGroupProps): React.ReactElement => {\n const [filterChipGroupSelectedFilters, setFilterChipGroupSelectedFilters] = useState<string[]>(\n [],\n );\n const [clearFilterCallbackTriggerer, setClearFilterCallbackTriggerer] = useState<number>(0);\n const { selectedFiltersCount, setListViewSelectedFilters } = useListViewFilterContext();\n const
|
|
1
|
+
{"version":3,"file":"FilterChipGroup.web.js","sources":["../../../../../../src/components/Dropdown/FilterChipGroup.web.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useListViewFilterContext } from '../ListView/ListViewFiltersContext.web';\nimport type { FilterChipGroupProps } from './types';\nimport { FilterChipGroupProvider } from './FilterChipGroupContext.web';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\nimport BaseBox from '~components/Box/BaseBox';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { Link } from '~components/Link';\n\nconst FilterChipGroup = ({\n testID,\n children,\n showClearButton = true,\n onClearButtonClick,\n onResetButtonClick,\n clearButtonText,\n resetButtonText,\n ...rest\n}: FilterChipGroupProps): React.ReactElement => {\n const [filterChipGroupSelectedFilters, setFilterChipGroupSelectedFilters] = useState<string[]>(\n [],\n );\n const [clearFilterCallbackTriggerer, setClearFilterCallbackTriggerer] = useState<number>(0);\n const { selectedFiltersCount, setListViewSelectedFilters } = useListViewFilterContext();\n\n // Shared bookkeeping reset: both actions clear the group's \"has changes\" tracking so the action\n // link(s) hide after use (a lingering action with nothing to revert is confusing). They reappear\n // on the next filter change.\n const clearGroupBookkeeping = (): void => {\n setListViewSelectedFilters({});\n setFilterChipGroupSelectedFilters([]);\n };\n\n // \"Clear\" empties every filter. Bumping the triggerer makes each child chip run its clear effect\n // (fires onChange([]) and drops its selection).\n const handleClearButtonClick = (): void => {\n onClearButtonClick?.();\n clearGroupBookkeeping();\n setClearFilterCallbackTriggerer((prev) => prev + 1);\n };\n\n // \"Reset\" only fires the consumer callback and clears the group's bookkeeping. We intentionally\n // do NOT bump the clear triggerer, so child chips keep their internal state and do not fire\n // onChange([]) — the consumer restores each filter's default inside onResetButtonClick and those\n // values are not stomped.\n // TODO (FilterChip reset — Phase 2): support restoring defaults for UNCONTROLLED filters. That\n // needs a `defaultValue` on FilterChipSelectInput and a reset path that restores it instead of\n // emptying. See packages/blade/src/components/Dropdown/_decisions/filter-chip-reset.md\n const handleResetButtonClick = (): void => {\n onResetButtonClick?.();\n clearGroupBookkeeping();\n };\n\n const hasSelectedFilters = filterChipGroupSelectedFilters.length > 0 || selectedFiltersCount > 0;\n const selectedCount = Math.max(filterChipGroupSelectedFilters.length, selectedFiltersCount);\n const isPlural = selectedCount > 1;\n const clearActionText = clearButtonText ?? `Clear Filter${isPlural ? 's' : ''}`;\n const resetActionText = resetButtonText ?? 'Reset';\n return (\n <FilterChipGroupProvider\n value={{\n filterChipGroupSelectedFilters,\n setFilterChipGroupSelectedFilters,\n clearFilterCallbackTriggerer,\n setClearFilterCallbackTriggerer,\n }}\n >\n <BaseBox\n {...metaAttribute({ name: MetaConstants.FilterChipGroup, testID })}\n {...makeAnalyticsAttribute(rest)}\n display=\"flex\"\n padding={['spacing.4', 'spacing.1']}\n alignItems=\"center\"\n justifyContent=\"flex-start\"\n width=\"100%\"\n gap=\"spacing.3\"\n flexWrap=\"wrap\"\n >\n {children}\n {hasSelectedFilters && onResetButtonClick ? (\n <Link size=\"small\" color=\"neutral\" onClick={handleResetButtonClick}>\n {resetActionText}\n </Link>\n ) : null}\n {hasSelectedFilters && showClearButton ? (\n <Link size=\"small\" color=\"neutral\" onClick={handleClearButtonClick}>\n {clearActionText}\n </Link>\n ) : null}\n </BaseBox>\n </FilterChipGroupProvider>\n );\n};\n\nexport { FilterChipGroup };\n"],"names":["FilterChipGroup","_ref","testID","children","_ref$showClearButton","showClearButton","onClearButtonClick","onResetButtonClick","clearButtonText","resetButtonText","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","filterChipGroupSelectedFilters","setFilterChipGroupSelectedFilters","_useState3","_useState4","clearFilterCallbackTriggerer","setClearFilterCallbackTriggerer","_useListViewFilterCon","useListViewFilterContext","selectedFiltersCount","setListViewSelectedFilters","clearGroupBookkeeping","handleClearButtonClick","prev","handleResetButtonClick","hasSelectedFilters","length","selectedCount","Math","max","isPlural","clearActionText","concat","resetActionText","_jsx","FilterChipGroupProvider","value","_jsxs","BaseBox","_objectSpread","metaAttribute","name","MetaConstants","makeAnalyticsAttribute","display","padding","alignItems","justifyContent","width","gap","flexWrap","Link","size","color","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAS2B;AAAA,EAAA,IAR9CC,MAAM,GAAAD,IAAA,CAANC,MAAM;IACNC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAAC,oBAAA,GAAAH,IAAA,CACRI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,oBAAA;IACtBE,kBAAkB,GAAAL,IAAA,CAAlBK,kBAAkB;IAClBC,kBAAkB,GAAAN,IAAA,CAAlBM,kBAAkB;IAClBC,eAAe,GAAAP,IAAA,CAAfO,eAAe;IACfC,eAAe,GAAAR,IAAA,CAAfQ,eAAe;AACZC,IAAAA,IAAI,GAAAC,wBAAA,CAAAV,IAAA,EAAAW,SAAA,CAAA,CAAA;AAEP,EAAA,IAAAC,SAAA,GAA4EC,QAAQ,CAClF,EACF,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,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AAC3BC,MAAAA,KAAK,EAAC,MAAM;AACZC,MAAAA,GAAG,EAAC,WAAW;AACfC,MAAAA,QAAQ,EAAC,MAAM;MAAArD,QAAA,EAAA,CAEdA,QAAQ,EACR4B,kBAAkB,IAAIxB,kBAAkB,gBACvCiC,GAAA,CAACiB,IAAI,EAAA;AAACC,QAAAA,IAAI,EAAC,OAAO;AAACC,QAAAA,KAAK,EAAC,SAAS;AAACC,QAAAA,OAAO,EAAE9B,sBAAuB;AAAA3B,QAAAA,QAAA,EAChEoC,eAAAA;OACG,CAAC,GACL,IAAI,EACPR,kBAAkB,IAAI1B,eAAe,gBACpCmC,GAAA,CAACiB,IAAI,EAAA;AAACC,QAAAA,IAAI,EAAC,OAAO;AAACC,QAAAA,KAAK,EAAC,SAAS;AAACC,QAAAA,OAAO,EAAEhC,sBAAuB;AAAAzB,QAAAA,QAAA,EAChEkC,eAAAA;OACG,CAAC,GACL,IAAI,CAAA;KACD,CAAA,CAAA;AAAC,GACa,CAAC,CAAA;AAE9B;;;;"}
|
|
@@ -6,6 +6,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
6
6
|
import React__default, { useEffect } from 'react';
|
|
7
7
|
import { useDropdown } from './useDropdown.js';
|
|
8
8
|
import { dropdownComponentIds } from './dropdownComponentIds.js';
|
|
9
|
+
import { getFilterChipDisplayValue } from './filterChipSelectInputUtils.js';
|
|
9
10
|
import { useFilterChipGroupContext } from './FilterChipGroupContext.web.js';
|
|
10
11
|
import '../../utils/assignWithoutSideEffects/index.js';
|
|
11
12
|
import { BaseFilterChip } from '../FilterChip/BaseFilterChip.web.js';
|
|
@@ -16,13 +17,12 @@ import { useFirstRender } from '../../utils/useFirstRender.js';
|
|
|
16
17
|
import { jsx } from 'react/jsx-runtime';
|
|
17
18
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
18
19
|
|
|
19
|
-
var _excluded = ["onClick", "onBlur", "onKeyDown", "accessibilityLabel", "testID", "value", "onClearButtonClick", "label", "onChange", "name", "isDisabled"];
|
|
20
|
+
var _excluded = ["onClick", "onBlur", "onKeyDown", "accessibilityLabel", "testID", "value", "onClearButtonClick", "label", "onChange", "name", "isDisabled", "showClearButton"];
|
|
20
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
23
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
24
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
25
|
var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
|
|
25
|
-
var _options$find$title, _options$find;
|
|
26
26
|
var idBase = useId('filter-chip-select-input');
|
|
27
27
|
var _onClick = props.onClick,
|
|
28
28
|
_onBlur = props.onBlur,
|
|
@@ -35,6 +35,8 @@ var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
|
|
|
35
35
|
onChange = props.onChange,
|
|
36
36
|
name = props.name,
|
|
37
37
|
isDisabled = props.isDisabled,
|
|
38
|
+
_props$showClearButto = props.showClearButton,
|
|
39
|
+
showClearButton = _props$showClearButto === void 0 ? true : _props$showClearButto,
|
|
38
40
|
rest = _objectWithoutProperties(props, _excluded);
|
|
39
41
|
var _React$useState = React__default.useState([]),
|
|
40
42
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -56,9 +58,6 @@ var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
|
|
|
56
58
|
setSelectedIndices = _useDropdown.setSelectedIndices,
|
|
57
59
|
controlledValueIndices = _useDropdown.controlledValueIndices,
|
|
58
60
|
changeCallbackTriggerer = _useDropdown.changeCallbackTriggerer;
|
|
59
|
-
var valueTitle = (_options$find$title = (_options$find = options.find(function (option) {
|
|
60
|
-
return option.value === value;
|
|
61
|
-
})) === null || _options$find === void 0 ? void 0 : _options$find.title) !== null && _options$find$title !== void 0 ? _options$find$title : value;
|
|
62
61
|
var isUnControlled = options.length > 0 && props.value === undefined;
|
|
63
62
|
// Currently we are having 2 context for selectedFilters. One is for FilterChipGroup and other is for ListView
|
|
64
63
|
var _useListViewFilterCon = useListViewFilterContext(),
|
|
@@ -121,21 +120,6 @@ var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
|
|
|
121
120
|
}
|
|
122
121
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
122
|
}, [isUnControlled, options]);
|
|
124
|
-
var getTitleFromValue = function getTitleFromValue(value) {
|
|
125
|
-
var option = options.find(function (option) {
|
|
126
|
-
return option.value === value;
|
|
127
|
-
});
|
|
128
|
-
return option ? option.title : '';
|
|
129
|
-
};
|
|
130
|
-
var getUnControlledFilterChipValue = function getUnControlledFilterChipValue() {
|
|
131
|
-
if (selectionType === 'single') {
|
|
132
|
-
if (uncontrolledInputValue.length > 0) {
|
|
133
|
-
return getTitleFromValue(uncontrolledInputValue[0]);
|
|
134
|
-
}
|
|
135
|
-
return '';
|
|
136
|
-
}
|
|
137
|
-
return uncontrolledInputValue;
|
|
138
|
-
};
|
|
139
123
|
var handleClearButtonClick = function handleClearButtonClick() {
|
|
140
124
|
var _props$onClearButtonC, _props$onChange;
|
|
141
125
|
(_props$onClearButtonC = props.onClearButtonClick) === null || _props$onClearButtonC === void 0 || _props$onClearButtonC.call(props, {
|
|
@@ -218,8 +202,14 @@ var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
|
|
|
218
202
|
};
|
|
219
203
|
return /*#__PURE__*/jsx(BaseFilterChip, _objectSpread(_objectSpread({
|
|
220
204
|
label: label,
|
|
221
|
-
value:
|
|
205
|
+
value: getFilterChipDisplayValue({
|
|
206
|
+
value: props.value,
|
|
207
|
+
options: options,
|
|
208
|
+
selectionType: selectionType,
|
|
209
|
+
uncontrolledInputValue: uncontrolledInputValue
|
|
210
|
+
}),
|
|
222
211
|
onClearButtonClick: handleClearButtonClick,
|
|
212
|
+
showClearButton: showClearButton,
|
|
223
213
|
selectionType: selectionType
|
|
224
214
|
}, rest), {}, {
|
|
225
215
|
ref: triggererRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterChipSelectInput.web.js","sources":["../../../../../../src/components/Dropdown/FilterChipSelectInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\n\nimport React, { useEffect } from 'react';\nimport { useDropdown } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useFilterChipGroupContext } from './FilterChipGroupContext.web';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport { getActionListContainerRole } from '~components/ActionList/getA11yRoles';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\nimport { useId } from '~utils/useId';\nimport { useListViewFilterContext } from '~components/ListView/ListViewFiltersContext.web';\nimport { useFirstRender } from '~utils/useFirstRender';\n\ntype FilterChipSelectInputProps = Pick<\n BaseFilterChipProps,\n 'onKeyDown' | 'value' | 'label' | 'testID' | 'onClick' | 'selectionType' | 'onBlur'\n> & {\n accessibilityLabel?: string;\n onChange?: (props: { name: string; values: string[] }) => void;\n name?: string;\n onClearButtonClick?: (props: { name: string; values: string[] }) => void;\n isDisabled?: boolean;\n} & DataAnalyticsAttribute;\n\nconst _FilterChipSelectInput = (props: FilterChipSelectInputProps): React.ReactElement => {\n const idBase = useId('filter-chip-select-input');\n const {\n onClick,\n onBlur,\n onKeyDown,\n accessibilityLabel,\n testID,\n value,\n onClearButtonClick,\n label,\n onChange,\n name,\n isDisabled,\n ...rest\n } = props;\n const [uncontrolledInputValue, setUncontrolledInputValue] = React.useState<string[]>([]);\n const isFirstRender = useFirstRender();\n\n const {\n options,\n selectedIndices,\n onTriggerClick,\n onTriggerKeydown,\n dropdownBaseId,\n isOpen,\n activeIndex,\n hasFooterAction,\n triggererRef,\n selectionType,\n isControlled,\n setSelectedIndices,\n controlledValueIndices,\n changeCallbackTriggerer,\n } = useDropdown();\n const valueTitle = options.find((option) => option.value === value)?.title ?? value;\n\n const isUnControlled = options.length > 0 && props.value === undefined;\n // Currently we are having 2 context for selectedFilters. One is for FilterChipGroup and other is for ListView\n const { listViewSelectedFilters, setListViewSelectedFilters } = useListViewFilterContext();\n const {\n clearFilterCallbackTriggerer,\n setFilterChipGroupSelectedFilters,\n } = useFilterChipGroupContext();\n\n const getValuesArrayFromIndices = (): string[] => {\n let indices: number[] = [];\n if (isControlled) {\n indices = controlledValueIndices;\n } else {\n indices = selectedIndices;\n }\n\n return indices.map((selectionIndex) => options[selectionIndex].value);\n };\n\n useEffect(() => {\n const valueNotEmpty =\n (typeof value === 'string' && value.trim() !== '') ||\n (Array.isArray(value) && value.length > 0);\n\n // Compare actual selected values (not just lengths) to detect controlled value changes\n const currentSelectedValues = selectedIndices.map((i) => options[i]?.value);\n const isSingleValueSynced =\n typeof value === 'string' &&\n currentSelectedValues.length === 1 &&\n currentSelectedValues[0] === value;\n\n const isMultiValueSynced =\n Array.isArray(value) &&\n value.length === currentSelectedValues.length &&\n value.every((v) => currentSelectedValues.includes(v));\n\n const isValueAndSelectedIndicesSynced = isSingleValueSynced || isMultiValueSynced;\n\n if (isUnControlled) {\n if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n const inputValue = savedIndices.map((selectionIndex) => options[selectionIndex].value);\n setUncontrolledInputValue(inputValue);\n setFilterChipGroupSelectedFilters((prev) =>\n prev.includes(label) ? prev : [...prev, label],\n );\n } else {\n setSelectedIndices([]);\n }\n } else if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n // Sync selected indices when controlled value changes or on first render with options loaded\n } else if (valueNotEmpty && !isValueAndSelectedIndicesSynced && options.length > 0) {\n const newSelectedIndices =\n typeof value === 'string'\n ? [options.findIndex((option) => option.value === value)]\n : options\n .map((option, index) => (value.includes(option.value) ? index : -1))\n .filter((index) => index !== -1);\n setSelectedIndices(newSelectedIndices);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isUnControlled, options]);\n\n const getTitleFromValue = (value: string): string => {\n const option = options.find((option) => option.value === value);\n return option ? option.title : '';\n };\n\n const getUnControlledFilterChipValue = (): string | string[] => {\n if (selectionType === 'single') {\n if (uncontrolledInputValue.length > 0) {\n return getTitleFromValue(uncontrolledInputValue[0]);\n }\n return '';\n }\n return uncontrolledInputValue;\n };\n\n const handleClearButtonClick = (): void => {\n props.onClearButtonClick?.({ name: name ?? idBase, values: getValuesArrayFromIndices() });\n props.onChange?.({ name: name ?? idBase, values: [] });\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n setUncontrolledInputValue([]);\n setSelectedIndices([]);\n };\n\n useEffect(() => {\n if (clearFilterCallbackTriggerer) {\n handleClearButtonClick();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clearFilterCallbackTriggerer]);\n\n useEffect(() => {\n if (!isFirstRender) {\n props.onChange?.({\n name: props.name || idBase,\n values: getValuesArrayFromIndices(),\n });\n if (isUnControlled) {\n setUncontrolledInputValue(getValuesArrayFromIndices());\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n useEffect(() => {\n const isValueEmpty = selectedIndices.length === 0;\n if (!isFirstRender && !isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => (prev.includes(label) ? prev : [...prev, label]));\n setListViewSelectedFilters((prev) => ({\n ...prev,\n [label]: selectedIndices as number[],\n }));\n } else if (!isFirstRender && isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n const handleKeyDown = (e: React.KeyboardEvent<Element>): void => {\n onKeyDown?.(e);\n onTriggerKeydown?.({ event: e as React.KeyboardEvent<HTMLInputElement> });\n\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n }\n\n if ((e.key === 'Enter' || e.key === ' ') && !isOpen) {\n e.preventDefault();\n e.stopPropagation();\n onTriggerClick();\n }\n };\n return (\n <BaseFilterChip\n label={label}\n value={valueTitle ?? getUnControlledFilterChipValue()}\n onClearButtonClick={handleClearButtonClick}\n selectionType={selectionType}\n {...rest}\n ref={triggererRef as any}\n onKeyDown={handleKeyDown}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: getActionListContainerRole(hasFooterAction, 'FilterChipSelectInput'),\n expanded: isOpen,\n controls: `${dropdownBaseId}-actionlist`,\n activeDescendant: activeIndex >= 0 ? `${dropdownBaseId}-${activeIndex}` : undefined,\n }}\n onClick={(e) => {\n onTriggerClick();\n onClick?.(e);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n }}\n isDisabled={isDisabled}\n />\n );\n};\n\nconst FilterChipSelectInput = assignWithoutSideEffects(_FilterChipSelectInput, {\n componentId: dropdownComponentIds.triggers.FilterChipSelectInput,\n});\n\nexport { FilterChipSelectInput };\n"],"names":["_FilterChipSelectInput","props","_options$find$title","_options$find","idBase","useId","onClick","onBlur","onKeyDown","accessibilityLabel","testID","value","onClearButtonClick","label","onChange","name","isDisabled","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","uncontrolledInputValue","setUncontrolledInputValue","isFirstRender","useFirstRender","_useDropdown","useDropdown","options","selectedIndices","onTriggerClick","onTriggerKeydown","dropdownBaseId","isOpen","activeIndex","hasFooterAction","triggererRef","selectionType","isControlled","setSelectedIndices","controlledValueIndices","changeCallbackTriggerer","valueTitle","find","option","title","isUnControlled","length","undefined","_useListViewFilterCon","useListViewFilterContext","listViewSelectedFilters","setListViewSelectedFilters","_useFilterChipGroupCo","useFilterChipGroupContext","clearFilterCallbackTriggerer","setFilterChipGroupSelectedFilters","getValuesArrayFromIndices","indices","map","selectionIndex","useEffect","valueNotEmpty","trim","Array","isArray","currentSelectedValues","i","_options$i","isSingleValueSynced","isMultiValueSynced","every","v","includes","isValueAndSelectedIndicesSynced","savedIndices","inputValue","prev","concat","_toConsumableArray","newSelectedIndices","findIndex","index","filter","getTitleFromValue","getUnControlledFilterChipValue","handleClearButtonClick","_props$onClearButtonC","_props$onChange","call","values","_","updatedFilters","_toPropertyKey","_props$onChange2","isValueEmpty","_objectSpread","_defineProperty","handleKeyDown","e","event","key","preventDefault","stopPropagation","_jsx","BaseFilterChip","ref","accessibilityProps","hasPopup","getActionListContainerRole","expanded","controls","activeDescendant","FilterChipSelectInput","assignWithoutSideEffects","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAIC,KAAiC,EAAyB;EAAA,IAAAC,mBAAA,EAAAC,aAAA,CAAA;AACxF,EA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CACxB,CAAC,CAAA;AAEN,CAAC,CAAA;AAED,IAAMoG,qBAAqB,gBAAGC,wBAAwB,CAACrH,sBAAsB,EAAE;AAC7EsH,EAAAA,WAAW,EAAEC,oBAAoB,CAACC,QAAQ,CAACJ,qBAAAA;AAC7C,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"FilterChipSelectInput.web.js","sources":["../../../../../../src/components/Dropdown/FilterChipSelectInput.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\n\nimport React, { useEffect } from 'react';\nimport { useDropdown } from './useDropdown';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { getFilterChipDisplayValue } from './filterChipSelectInputUtils';\nimport { useFilterChipGroupContext } from './FilterChipGroupContext.web';\nimport type { DataAnalyticsAttribute } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { BaseFilterChip } from '~components/FilterChip/BaseFilterChip';\nimport { getActionListContainerRole } from '~components/ActionList/getA11yRoles';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\nimport { useId } from '~utils/useId';\nimport { useListViewFilterContext } from '~components/ListView/ListViewFiltersContext.web';\nimport { useFirstRender } from '~utils/useFirstRender';\n\ntype FilterChipSelectInputProps = Pick<\n BaseFilterChipProps,\n | 'onKeyDown'\n | 'value'\n | 'label'\n | 'testID'\n | 'onClick'\n | 'selectionType'\n | 'onBlur'\n | 'showClearButton'\n> & {\n accessibilityLabel?: string;\n onChange?: (props: { name: string; values: string[] }) => void;\n name?: string;\n onClearButtonClick?: (props: { name: string; values: string[] }) => void;\n isDisabled?: boolean;\n} & DataAnalyticsAttribute;\n\nconst _FilterChipSelectInput = (props: FilterChipSelectInputProps): React.ReactElement => {\n const idBase = useId('filter-chip-select-input');\n const {\n onClick,\n onBlur,\n onKeyDown,\n accessibilityLabel,\n testID,\n value,\n onClearButtonClick,\n label,\n onChange,\n name,\n isDisabled,\n showClearButton = true,\n ...rest\n } = props;\n const [uncontrolledInputValue, setUncontrolledInputValue] = React.useState<string[]>([]);\n const isFirstRender = useFirstRender();\n\n const {\n options,\n selectedIndices,\n onTriggerClick,\n onTriggerKeydown,\n dropdownBaseId,\n isOpen,\n activeIndex,\n hasFooterAction,\n triggererRef,\n selectionType,\n isControlled,\n setSelectedIndices,\n controlledValueIndices,\n changeCallbackTriggerer,\n } = useDropdown();\n const isUnControlled = options.length > 0 && props.value === undefined;\n // Currently we are having 2 context for selectedFilters. One is for FilterChipGroup and other is for ListView\n const { listViewSelectedFilters, setListViewSelectedFilters } = useListViewFilterContext();\n const {\n clearFilterCallbackTriggerer,\n setFilterChipGroupSelectedFilters,\n } = useFilterChipGroupContext();\n\n const getValuesArrayFromIndices = (): string[] => {\n let indices: number[] = [];\n if (isControlled) {\n indices = controlledValueIndices;\n } else {\n indices = selectedIndices;\n }\n\n return indices.map((selectionIndex) => options[selectionIndex].value);\n };\n\n useEffect(() => {\n const valueNotEmpty =\n (typeof value === 'string' && value.trim() !== '') ||\n (Array.isArray(value) && value.length > 0);\n\n // Compare actual selected values (not just lengths) to detect controlled value changes\n const currentSelectedValues = selectedIndices.map((i) => options[i]?.value);\n const isSingleValueSynced =\n typeof value === 'string' &&\n currentSelectedValues.length === 1 &&\n currentSelectedValues[0] === value;\n\n const isMultiValueSynced =\n Array.isArray(value) &&\n value.length === currentSelectedValues.length &&\n value.every((v) => currentSelectedValues.includes(v));\n\n const isValueAndSelectedIndicesSynced = isSingleValueSynced || isMultiValueSynced;\n\n if (isUnControlled) {\n if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n const inputValue = savedIndices.map((selectionIndex) => options[selectionIndex].value);\n setUncontrolledInputValue(inputValue);\n setFilterChipGroupSelectedFilters((prev) =>\n prev.includes(label) ? prev : [...prev, label],\n );\n } else {\n setSelectedIndices([]);\n }\n } else if (listViewSelectedFilters[label]) {\n const savedIndices = (listViewSelectedFilters[label] as unknown) as number[];\n setSelectedIndices(savedIndices);\n // Sync selected indices when controlled value changes or on first render with options loaded\n } else if (valueNotEmpty && !isValueAndSelectedIndicesSynced && options.length > 0) {\n const newSelectedIndices =\n typeof value === 'string'\n ? [options.findIndex((option) => option.value === value)]\n : options\n .map((option, index) => (value.includes(option.value) ? index : -1))\n .filter((index) => index !== -1);\n setSelectedIndices(newSelectedIndices);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [isUnControlled, options]);\n\n const handleClearButtonClick = (): void => {\n props.onClearButtonClick?.({ name: name ?? idBase, values: getValuesArrayFromIndices() });\n props.onChange?.({ name: name ?? idBase, values: [] });\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n setUncontrolledInputValue([]);\n setSelectedIndices([]);\n };\n\n useEffect(() => {\n if (clearFilterCallbackTriggerer) {\n handleClearButtonClick();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clearFilterCallbackTriggerer]);\n\n useEffect(() => {\n if (!isFirstRender) {\n props.onChange?.({\n name: props.name || idBase,\n values: getValuesArrayFromIndices(),\n });\n if (isUnControlled) {\n setUncontrolledInputValue(getValuesArrayFromIndices());\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n useEffect(() => {\n const isValueEmpty = selectedIndices.length === 0;\n if (!isFirstRender && !isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => (prev.includes(label) ? prev : [...prev, label]));\n setListViewSelectedFilters((prev) => ({\n ...prev,\n [label]: selectedIndices as number[],\n }));\n } else if (!isFirstRender && isValueEmpty) {\n setFilterChipGroupSelectedFilters((prev) => prev.filter((filter) => filter !== label));\n setListViewSelectedFilters((prev) => {\n const { [label]: _, ...updatedFilters } = prev;\n return updatedFilters;\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [changeCallbackTriggerer]);\n\n const handleKeyDown = (e: React.KeyboardEvent<Element>): void => {\n onKeyDown?.(e);\n onTriggerKeydown?.({ event: e as React.KeyboardEvent<HTMLInputElement> });\n\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n }\n\n if ((e.key === 'Enter' || e.key === ' ') && !isOpen) {\n e.preventDefault();\n e.stopPropagation();\n onTriggerClick();\n }\n };\n return (\n <BaseFilterChip\n label={label}\n value={getFilterChipDisplayValue({\n value: props.value,\n options,\n selectionType,\n uncontrolledInputValue,\n })}\n onClearButtonClick={handleClearButtonClick}\n showClearButton={showClearButton}\n selectionType={selectionType}\n {...rest}\n ref={triggererRef as any}\n onKeyDown={handleKeyDown}\n accessibilityProps={{\n label: accessibilityLabel ?? label,\n hasPopup: getActionListContainerRole(hasFooterAction, 'FilterChipSelectInput'),\n expanded: isOpen,\n controls: `${dropdownBaseId}-actionlist`,\n activeDescendant: activeIndex >= 0 ? `${dropdownBaseId}-${activeIndex}` : undefined,\n }}\n onClick={(e) => {\n onTriggerClick();\n onClick?.(e);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n }}\n isDisabled={isDisabled}\n />\n );\n};\n\nconst FilterChipSelectInput = assignWithoutSideEffects(_FilterChipSelectInput, {\n componentId: dropdownComponentIds.triggers.FilterChipSelectInput,\n});\n\nexport { FilterChipSelectInput };\n"],"names":["_FilterChipSelectInput","props","idBase","useId","onClick","onBlur","onKeyDown","accessibilityLabel","testID","value","onClearButtonClick","label","onChange","name","isDisabled","_props$showClearButto","showClearButton","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","uncontrolledInputValue","setUncontrolledInputValue","isFirstRender","useFirstRender","_useDropdown","useDropdown","options","selectedIndices","onTriggerClick","onTriggerKeydown","dropdownBaseId","isOpen","activeIndex","hasFooterAction","triggererRef","selectionType","isControlled","setSelectedIndices","controlledValueIndices","changeCallbackTriggerer","isUnControlled","length","undefined","_useListViewFilterCon","useListViewFilterContext","listViewSelectedFilters","setListViewSelectedFilters","_useFilterChipGroupCo","useFilterChipGroupContext","clearFilterCallbackTriggerer","setFilterChipGroupSelectedFilters","getValuesArrayFromIndices","indices","map","selectionIndex","useEffect","valueNotEmpty","trim","Array","isArray","currentSelectedValues","i","_options$i","isSingleValueSynced","isMultiValueSynced","every","v","includes","isValueAndSelectedIndicesSynced","savedIndices","inputValue","prev","concat","_toConsumableArray","newSelectedIndices","findIndex","option","index","filter","handleClearButtonClick","_props$onClearButtonC","_props$onChange","call","values","_","updatedFilters","_toPropertyKey","_props$onChange2","isValueEmpty","_objectSpread","_defineProperty","handleKeyDown","e","event","key","preventDefault","stopPropagation","_jsx","BaseFilterChip","getFilterChipDisplayValue","ref","accessibilityProps","hasPopup","getActionListContainerRole","expanded","controls","activeDescendant","FilterChipSelectInput","assignWithoutSideEffects","componentId","dropdownComponentIds","triggers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAIC,KAAiC,EAAyB;AACxF,EAAA,IAAMC,MAAM,GAAGC,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAChD,EAAA,IACEC,QAAO,GAaLH,KAAK,CAbPG,OAAO;IACPC,OAAM,GAYJJ,KAAK,CAZPI,MAAM;IACNC,SAAS,GAWPL,KAAK,CAXPK,SAAS;IACTC,kBAAkB,GAUhBN,KAAK,CAVPM,kBAAkB;IAClBC,MAAM,GASJP,KAAK,CATPO,MAAM;IACNC,KAAK,GAQHR,KAAK,CARPQ,KAAK;IACLC,kBAAkB,GAOhBT,KAAK,CAPPS,kBAAkB;IAClBC,KAAK,GAMHV,KAAK,CANPU,KAAK;IACLC,QAAQ,GAKNX,KAAK,CALPW,QAAQ;IACRC,IAAI,GAIFZ,KAAK,CAJPY,IAAI;IACJC,UAAU,GAGRb,KAAK,CAHPa,UAAU;IAAAC,qBAAA,GAGRd,KAAK,CAFPe,eAAe;AAAfA,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AqB,gBAAGC,wBAAwB,CAACjH,sBAAsB,EAAE;AAC7EkH,EAAAA,WAAW,EAAEC,oBAAoB,CAACC,QAAQ,CAACJ,qBAAAA;AAC7C,CAAC;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves an option's human-readable title from its value. Returns an empty string when the
|
|
3
|
+
* option isn't found so callers can decide on a fallback.
|
|
4
|
+
*/
|
|
5
|
+
var getTitleFromValue = function getTitleFromValue(options, value) {
|
|
6
|
+
var option = options.find(function (currentOption) {
|
|
7
|
+
return currentOption.value === value;
|
|
8
|
+
});
|
|
9
|
+
return option ? option.title : '';
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the value shown inside the filter chip as option title(s).
|
|
13
|
+
*
|
|
14
|
+
* Shared by the web and native `FilterChipSelectInput` implementations to keep the (non-trivial)
|
|
15
|
+
* controlled-vs-uncontrolled / string-vs-array branching in a single source of truth. In every
|
|
16
|
+
* branch we fall back to the raw value when the title can't be resolved (e.g. options loaded or
|
|
17
|
+
* changed after a selection) so the chip never renders an empty string.
|
|
18
|
+
*/
|
|
19
|
+
var getFilterChipDisplayValue = function getFilterChipDisplayValue(_ref) {
|
|
20
|
+
var value = _ref.value,
|
|
21
|
+
options = _ref.options,
|
|
22
|
+
selectionType = _ref.selectionType,
|
|
23
|
+
uncontrolledInputValue = _ref.uncontrolledInputValue;
|
|
24
|
+
var titleForValue = function titleForValue(selectionValue) {
|
|
25
|
+
return getTitleFromValue(options, selectionValue) || selectionValue;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Uncontrolled: derive display value from the internally tracked selection.
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
if (selectionType === 'single') {
|
|
31
|
+
return uncontrolledInputValue.length > 0 ? titleForValue(uncontrolledInputValue[0]) : '';
|
|
32
|
+
}
|
|
33
|
+
// For multiple selection, hand the chip the option titles (not the raw values) so it can
|
|
34
|
+
// render the selected option name(s) instead of a bare count.
|
|
35
|
+
return uncontrolledInputValue.map(titleForValue);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Controlled: consumer passes option value(s); map them to titles for display.
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return value.map(titleForValue);
|
|
41
|
+
}
|
|
42
|
+
return titleForValue(value);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { getFilterChipDisplayValue };
|
|
46
|
+
//# sourceMappingURL=filterChipSelectInputUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterChipSelectInputUtils.js","sources":["../../../../../../src/components/Dropdown/filterChipSelectInputUtils.ts"],"sourcesContent":["import type { OptionsType } from './useDropdown';\nimport type { BaseFilterChipProps } from '~components/FilterChip/types';\n\n/**\n * Resolves an option's human-readable title from its value. Returns an empty string when the\n * option isn't found so callers can decide on a fallback.\n */\nconst getTitleFromValue = (options: OptionsType, value: string): string => {\n const option = options.find((currentOption) => currentOption.value === value);\n return option ? option.title : '';\n};\n\ntype GetFilterChipDisplayValueParams = {\n /** Controlled value from props (option value or values). `undefined` when uncontrolled. */\n value: BaseFilterChipProps['value'];\n /** All options currently registered in the dropdown. */\n options: OptionsType;\n selectionType: BaseFilterChipProps['selectionType'];\n /** Internally tracked selection used in the uncontrolled case. */\n uncontrolledInputValue: string[];\n};\n\n/**\n * Resolves the value shown inside the filter chip as option title(s).\n *\n * Shared by the web and native `FilterChipSelectInput` implementations to keep the (non-trivial)\n * controlled-vs-uncontrolled / string-vs-array branching in a single source of truth. In every\n * branch we fall back to the raw value when the title can't be resolved (e.g. options loaded or\n * changed after a selection) so the chip never renders an empty string.\n */\nconst getFilterChipDisplayValue = ({\n value,\n options,\n selectionType,\n uncontrolledInputValue,\n}: GetFilterChipDisplayValueParams): string | string[] => {\n const titleForValue = (selectionValue: string): string =>\n getTitleFromValue(options, selectionValue) || selectionValue;\n\n // Uncontrolled: derive display value from the internally tracked selection.\n if (value === undefined) {\n if (selectionType === 'single') {\n return uncontrolledInputValue.length > 0 ? titleForValue(uncontrolledInputValue[0]) : '';\n }\n // For multiple selection, hand the chip the option titles (not the raw values) so it can\n // render the selected option name(s) instead of a bare count.\n return uncontrolledInputValue.map(titleForValue);\n }\n\n // Controlled: consumer passes option value(s); map them to titles for display.\n if (Array.isArray(value)) {\n return value.map(titleForValue);\n }\n return titleForValue(value);\n};\n\nexport { getFilterChipDisplayValue };\n"],"names":["getTitleFromValue","options","value","option","find","currentOption","title","getFilterChipDisplayValue","_ref","selectionType","uncontrolledInputValue","titleForValue","selectionValue","undefined","length","map","Array","isArray"],"mappings":"AAGA;AACA;AACA;AACA;AACA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,OAAoB,EAAEC,KAAa,EAAa;AACzE,EAAA,IAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAAC,UAACC,aAAa,EAAA;AAAA,IAAA,OAAKA,aAAa,CAACH,KAAK,KAAKA,KAAK,CAAA;GAAC,CAAA,CAAA;AAC7E,EAAA,OAAOC,MAAM,GAAGA,MAAM,CAACG,KAAK,GAAG,EAAE,CAAA;AACnC,CAAC,CAAA;AAYD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAAC,IAAA,EAK2B;AAAA,EAAA,IAJxDN,KAAK,GAAAM,IAAA,CAALN,KAAK;IACLD,OAAO,GAAAO,IAAA,CAAPP,OAAO;IACPQ,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,sBAAsB,GAAAF,IAAA,CAAtBE,sBAAsB,CAAA;AAEtB,EAAA,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,cAAsB,EAAA;AAAA,IAAA,OAC3CZ,iBAAiB,CAACC,OAAO,EAAEW,cAAc,CAAC,IAAIA,cAAc,CAAA;AAAA,GAAA,CAAA;;AAE9D;EACA,IAAIV,KAAK,KAAKW,SAAS,EAAE;IACvB,IAAIJ,aAAa,KAAK,QAAQ,EAAE;AAC9B,MAAA,OAAOC,sBAAsB,CAACI,MAAM,GAAG,CAAC,GAAGH,aAAa,CAACD,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;AAC1F,KAAA;AACA;AACA;AACA,IAAA,OAAOA,sBAAsB,CAACK,GAAG,CAACJ,aAAa,CAAC,CAAA;AAClD,GAAA;;AAEA;AACA,EAAA,IAAIK,KAAK,CAACC,OAAO,CAACf,KAAK,CAAC,EAAE;AACxB,IAAA,OAAOA,KAAK,CAACa,GAAG,CAACJ,aAAa,CAAC,CAAA;AACjC,GAAA;EACA,OAAOA,aAAa,CAACT,KAAK,CAAC,CAAA;AAC7B;;;;"}
|
|
@@ -21,9 +21,9 @@ import { getFocusRingStyles } from '../../utils/getFocusRingStyles/getFocusRingS
|
|
|
21
21
|
import { makeSpace } from '../../utils/makeSpace/makeSpace.js';
|
|
22
22
|
import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
|
|
23
23
|
import { makeBorderSize } from '../../utils/makeBorderSize/makeBorderSize.js';
|
|
24
|
+
import { Text } from '../Typography/Text/Text.js';
|
|
24
25
|
import { Box } from '../Box/Box.js';
|
|
25
26
|
import { Counter } from '../Counter/Counter.js';
|
|
26
|
-
import { Text } from '../Typography/Text/Text.js';
|
|
27
27
|
import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.web.js';
|
|
28
28
|
import { getStyledProps } from '../Box/styledProps/getStyledProps.js';
|
|
29
29
|
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
@@ -34,7 +34,7 @@ import CloseIcon from '../Icons/CloseIcon/CloseIcon.js';
|
|
|
34
34
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
35
35
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
36
36
|
|
|
37
|
-
var _excluded = ["value", "onClearButtonClick", "label", "isDisabled", "selectionType", "onClick", "onKeyDown", "accessibilityProps", "id"];
|
|
37
|
+
var _excluded = ["value", "onClearButtonClick", "label", "isDisabled", "selectionType", "showClearButton", "onClick", "onKeyDown", "accessibilityProps", "id"];
|
|
38
38
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
39
39
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
40
40
|
var getInteractiveFilterItemStyles = function getInteractiveFilterItemStyles(_ref) {
|
|
@@ -83,15 +83,17 @@ var StyledFilterTrigger = /*#__PURE__*/styled.button.withConfig({
|
|
|
83
83
|
componentId: "sc-7fl0tf-1"
|
|
84
84
|
})(function (_ref3) {
|
|
85
85
|
var theme = _ref3.theme,
|
|
86
|
-
$
|
|
86
|
+
$hasClearButton = _ref3.$hasClearButton;
|
|
87
87
|
var spacing = theme.spacing;
|
|
88
88
|
return _objectSpread({
|
|
89
89
|
backgroundColor: theme.colors.transparent,
|
|
90
|
-
|
|
90
|
+
// When a clear button follows the trigger its right corners butt against the divider,
|
|
91
|
+
// so they're squared off. Without a clear button the trigger is a self-contained pill.
|
|
92
|
+
borderRadius: $hasClearButton ? theme.border.radius.none : theme.border.radius.small,
|
|
91
93
|
borderTopLeftRadius: theme.border.radius.small,
|
|
92
94
|
borderBottomLeftRadius: theme.border.radius.small,
|
|
93
95
|
paddingLeft: makeSpace(spacing[4]),
|
|
94
|
-
paddingRight: $
|
|
96
|
+
paddingRight: $hasClearButton ? makeSpace(spacing[2]) : makeSpace(spacing[3]),
|
|
95
97
|
gap: makeSpace(spacing[2])
|
|
96
98
|
}, getInteractiveFilterItemStyles({
|
|
97
99
|
theme: theme
|
|
@@ -115,12 +117,31 @@ var StyledFilterCloseButton = /*#__PURE__*/styled.button.withConfig({
|
|
|
115
117
|
}));
|
|
116
118
|
});
|
|
117
119
|
var renderValue = function renderValue(selectionType, value, isDisabled) {
|
|
118
|
-
|
|
120
|
+
var valueColor = isDisabled ? 'interactive.text.gray.disabled' : 'interactive.text.gray.normal';
|
|
121
|
+
|
|
122
|
+
// For multiple selection: when a single option is selected we show its name (no redundant
|
|
123
|
+
// "1" counter); once more than one is selected we collapse to a compact counter.
|
|
124
|
+
// Use an explicit type guard so a non-array value (e.g. a plain string returned by
|
|
125
|
+
// getFilterChipDisplayValue) never enters the array branch where .length would be
|
|
126
|
+
// misinterpreted as character count.
|
|
127
|
+
if (selectionType === 'multiple') {
|
|
128
|
+
var valueArray = Array.isArray(value) ? value : value != null ? [value] : [];
|
|
129
|
+
if (valueArray.length === 1) {
|
|
130
|
+
var _valueArray$;
|
|
131
|
+
return /*#__PURE__*/jsx(Text, {
|
|
132
|
+
as: "span",
|
|
133
|
+
size: "small",
|
|
134
|
+
weight: "medium",
|
|
135
|
+
color: valueColor,
|
|
136
|
+
truncateAfterLines: 1,
|
|
137
|
+
children: String((_valueArray$ = valueArray[0]) !== null && _valueArray$ !== void 0 ? _valueArray$ : '')
|
|
138
|
+
});
|
|
139
|
+
}
|
|
119
140
|
return /*#__PURE__*/jsx(Box, {
|
|
120
141
|
display: "flex",
|
|
121
142
|
alignItems: "center",
|
|
122
143
|
children: /*#__PURE__*/jsx(Counter, {
|
|
123
|
-
value:
|
|
144
|
+
value: valueArray.length,
|
|
124
145
|
color: "neutral",
|
|
125
146
|
size: "small"
|
|
126
147
|
})
|
|
@@ -130,8 +151,8 @@ var renderValue = function renderValue(selectionType, value, isDisabled) {
|
|
|
130
151
|
as: "span",
|
|
131
152
|
size: "small",
|
|
132
153
|
weight: "medium",
|
|
133
|
-
color:
|
|
134
|
-
children: value
|
|
154
|
+
color: valueColor,
|
|
155
|
+
children: value != null ? String(value) : ''
|
|
135
156
|
});
|
|
136
157
|
};
|
|
137
158
|
var _BaseFilterChip = function _BaseFilterChip(_ref5, ref) {
|
|
@@ -142,18 +163,21 @@ var _BaseFilterChip = function _BaseFilterChip(_ref5, ref) {
|
|
|
142
163
|
isDisabled = _ref5.isDisabled,
|
|
143
164
|
_ref5$selectionType = _ref5.selectionType,
|
|
144
165
|
selectionType = _ref5$selectionType === void 0 ? 'single' : _ref5$selectionType,
|
|
166
|
+
_ref5$showClearButton = _ref5.showClearButton,
|
|
167
|
+
showClearButton = _ref5$showClearButton === void 0 ? true : _ref5$showClearButton,
|
|
145
168
|
_onClick = _ref5.onClick,
|
|
146
169
|
_onKeyDown = _ref5.onKeyDown,
|
|
147
170
|
accessibilityProps = _ref5.accessibilityProps,
|
|
148
171
|
id = _ref5.id,
|
|
149
172
|
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
150
173
|
var isSelected = selectionType === 'multiple' ? Array.isArray(value) && value.length > 0 : !!value;
|
|
174
|
+
var shouldShowClearButton = isSelected && showClearButton;
|
|
151
175
|
return /*#__PURE__*/jsxs(StyledFilterChip, {
|
|
152
176
|
$isDisabled: isDisabled,
|
|
153
177
|
$isSelected: isSelected,
|
|
154
178
|
ref: ref,
|
|
155
179
|
children: [/*#__PURE__*/jsxs(StyledFilterTrigger, _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
156
|
-
$
|
|
180
|
+
$hasClearButton: shouldShowClearButton,
|
|
157
181
|
disabled: isDisabled,
|
|
158
182
|
id: id,
|
|
159
183
|
onClick: function onClick(e) {
|
|
@@ -191,7 +215,7 @@ var _BaseFilterChip = function _BaseFilterChip(_ref5, ref) {
|
|
|
191
215
|
color: "interactive.icon.gray.muted"
|
|
192
216
|
})
|
|
193
217
|
})]
|
|
194
|
-
})),
|
|
218
|
+
})), shouldShowClearButton ? /*#__PURE__*/jsxs(Fragment, {
|
|
195
219
|
children: [/*#__PURE__*/jsx(Divider, {
|
|
196
220
|
orientation: "vertical",
|
|
197
221
|
variant: isDisabled ? 'muted' : 'subtle'
|