@razorpay/blade 12.19.0 → 12.20.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.
Files changed (117) hide show
  1. package/build/lib/native/components/ActionList/ActionListItem.js +1 -1
  2. package/build/lib/native/components/ActionList/ActionListItem.js.map +1 -1
  3. package/build/lib/native/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.native.js +7 -0
  4. package/build/lib/native/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.native.js.map +1 -0
  5. package/build/lib/native/components/Dropdown/Dropdown.js +1 -1
  6. package/build/lib/native/components/Dropdown/Dropdown.js.map +1 -1
  7. package/build/lib/native/components/Dropdown/FilterChipGroup.native.js +7 -0
  8. package/build/lib/native/components/Dropdown/FilterChipGroup.native.js.map +1 -0
  9. package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js +7 -0
  10. package/build/lib/native/components/Dropdown/FilterChipSelectInput.native.js.map +1 -0
  11. package/build/lib/native/components/Dropdown/dropdownComponentIds.js +1 -1
  12. package/build/lib/native/components/Dropdown/dropdownComponentIds.js.map +1 -1
  13. package/build/lib/native/components/Dropdown/useDropdown.js +1 -1
  14. package/build/lib/native/components/Dropdown/useDropdown.js.map +1 -1
  15. package/build/lib/native/components/ListView/ListView.native.js +12 -0
  16. package/build/lib/native/components/ListView/ListView.native.js.map +1 -0
  17. package/build/lib/native/components/ListView/ListViewFilters.native.js +12 -0
  18. package/build/lib/native/components/ListView/ListViewFilters.native.js.map +1 -0
  19. package/build/lib/native/components/index.js +5 -0
  20. package/build/lib/native/components/index.js.map +1 -1
  21. package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
  22. package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
  23. package/build/lib/web/development/components/ActionList/ActionListItem.js +32 -17
  24. package/build/lib/web/development/components/ActionList/ActionListItem.js.map +1 -1
  25. package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js +516 -0
  26. package/build/lib/web/development/components/DatePicker/BaseDatePicker.web.js.map +1 -0
  27. package/build/lib/web/development/components/DatePicker/DatePicker.web.js +7 -421
  28. package/build/lib/web/development/components/DatePicker/DatePicker.web.js.map +1 -1
  29. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +67 -0
  30. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -0
  31. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.web.js +14 -0
  32. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.web.js.map +1 -0
  33. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/index.js +2 -0
  34. package/build/lib/web/development/components/DatePicker/FilterChipDatePicker/index.js.map +1 -0
  35. package/build/lib/web/development/components/DatePicker/index.js +1 -0
  36. package/build/lib/web/development/components/DatePicker/index.js.map +1 -1
  37. package/build/lib/web/development/components/DatePicker/useDatesState.js +7 -1
  38. package/build/lib/web/development/components/DatePicker/useDatesState.js.map +1 -1
  39. package/build/lib/web/development/components/Dropdown/Dropdown.js +21 -12
  40. package/build/lib/web/development/components/Dropdown/Dropdown.js.map +1 -1
  41. package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js +74 -0
  42. package/build/lib/web/development/components/Dropdown/FilterChipGroup.web.js.map +1 -0
  43. package/build/lib/web/development/components/Dropdown/FilterChipGroupContext.web.js +18 -0
  44. package/build/lib/web/development/components/Dropdown/FilterChipGroupContext.web.js.map +1 -0
  45. package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js +217 -0
  46. package/build/lib/web/development/components/Dropdown/FilterChipSelectInput.web.js.map +1 -0
  47. package/build/lib/web/development/components/Dropdown/dropdownComponentIds.js +2 -1
  48. package/build/lib/web/development/components/Dropdown/dropdownComponentIds.js.map +1 -1
  49. package/build/lib/web/development/components/Dropdown/index.js +2 -0
  50. package/build/lib/web/development/components/Dropdown/index.js.map +1 -1
  51. package/build/lib/web/development/components/Dropdown/useDropdown.js +2 -0
  52. package/build/lib/web/development/components/Dropdown/useDropdown.js.map +1 -1
  53. package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js +218 -0
  54. package/build/lib/web/development/components/FilterChip/BaseFilterChip.web.js.map +1 -0
  55. package/build/lib/web/development/components/FilterChip/tokens.js +9 -0
  56. package/build/lib/web/development/components/FilterChip/tokens.js.map +1 -0
  57. package/build/lib/web/development/components/ListView/ListView.web.js +28 -0
  58. package/build/lib/web/development/components/ListView/ListView.web.js.map +1 -0
  59. package/build/lib/web/development/components/ListView/ListViewFilters.web.js +240 -0
  60. package/build/lib/web/development/components/ListView/ListViewFilters.web.js.map +1 -0
  61. package/build/lib/web/development/components/ListView/ListViewFiltersContext.web.js +16 -0
  62. package/build/lib/web/development/components/ListView/ListViewFiltersContext.web.js.map +1 -0
  63. package/build/lib/web/development/components/ListView/index.js +3 -0
  64. package/build/lib/web/development/components/ListView/index.js.map +1 -0
  65. package/build/lib/web/development/components/index.js +6 -0
  66. package/build/lib/web/development/components/index.js.map +1 -1
  67. package/build/lib/web/development/utils/metaAttribute/metaConstants.js +4 -0
  68. package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
  69. package/build/lib/web/production/components/ActionList/ActionListItem.js +32 -17
  70. package/build/lib/web/production/components/ActionList/ActionListItem.js.map +1 -1
  71. package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js +516 -0
  72. package/build/lib/web/production/components/DatePicker/BaseDatePicker.web.js.map +1 -0
  73. package/build/lib/web/production/components/DatePicker/DatePicker.web.js +7 -421
  74. package/build/lib/web/production/components/DatePicker/DatePicker.web.js.map +1 -1
  75. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js +67 -0
  76. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/DatePickerFilterChip.web.js.map +1 -0
  77. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.web.js +14 -0
  78. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/FilterChipDatePicker.web.js.map +1 -0
  79. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/index.js +2 -0
  80. package/build/lib/web/production/components/DatePicker/FilterChipDatePicker/index.js.map +1 -0
  81. package/build/lib/web/production/components/DatePicker/index.js +1 -0
  82. package/build/lib/web/production/components/DatePicker/index.js.map +1 -1
  83. package/build/lib/web/production/components/DatePicker/useDatesState.js +7 -1
  84. package/build/lib/web/production/components/DatePicker/useDatesState.js.map +1 -1
  85. package/build/lib/web/production/components/Dropdown/Dropdown.js +21 -12
  86. package/build/lib/web/production/components/Dropdown/Dropdown.js.map +1 -1
  87. package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js +74 -0
  88. package/build/lib/web/production/components/Dropdown/FilterChipGroup.web.js.map +1 -0
  89. package/build/lib/web/production/components/Dropdown/FilterChipGroupContext.web.js +18 -0
  90. package/build/lib/web/production/components/Dropdown/FilterChipGroupContext.web.js.map +1 -0
  91. package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js +217 -0
  92. package/build/lib/web/production/components/Dropdown/FilterChipSelectInput.web.js.map +1 -0
  93. package/build/lib/web/production/components/Dropdown/dropdownComponentIds.js +2 -1
  94. package/build/lib/web/production/components/Dropdown/dropdownComponentIds.js.map +1 -1
  95. package/build/lib/web/production/components/Dropdown/index.js +2 -0
  96. package/build/lib/web/production/components/Dropdown/index.js.map +1 -1
  97. package/build/lib/web/production/components/Dropdown/useDropdown.js +2 -0
  98. package/build/lib/web/production/components/Dropdown/useDropdown.js.map +1 -1
  99. package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js +218 -0
  100. package/build/lib/web/production/components/FilterChip/BaseFilterChip.web.js.map +1 -0
  101. package/build/lib/web/production/components/FilterChip/tokens.js +9 -0
  102. package/build/lib/web/production/components/FilterChip/tokens.js.map +1 -0
  103. package/build/lib/web/production/components/ListView/ListView.web.js +28 -0
  104. package/build/lib/web/production/components/ListView/ListView.web.js.map +1 -0
  105. package/build/lib/web/production/components/ListView/ListViewFilters.web.js +240 -0
  106. package/build/lib/web/production/components/ListView/ListViewFilters.web.js.map +1 -0
  107. package/build/lib/web/production/components/ListView/ListViewFiltersContext.web.js +16 -0
  108. package/build/lib/web/production/components/ListView/ListViewFiltersContext.web.js.map +1 -0
  109. package/build/lib/web/production/components/ListView/index.js +3 -0
  110. package/build/lib/web/production/components/ListView/index.js.map +1 -0
  111. package/build/lib/web/production/components/index.js +6 -0
  112. package/build/lib/web/production/components/index.js.map +1 -1
  113. package/build/lib/web/production/utils/metaAttribute/metaConstants.js +4 -0
  114. package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
  115. package/build/types/components/index.d.ts +143 -589
  116. package/build/types/components/index.native.d.ts +82 -1
  117. package/package.json +1 -1
@@ -83,6 +83,11 @@ function useDatesState(_ref) {
83
83
  }
84
84
  return false;
85
85
  };
86
+ var handleReset = function handleReset() {
87
+ setPickedDate(null);
88
+ setHoveredDate(null);
89
+ setValue([null, null]);
90
+ };
86
91
  var onRootMouseLeave = type === 'range' ? function (event) {
87
92
  onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(event);
88
93
  setHoveredDate(null);
@@ -141,7 +146,8 @@ function useDatesState(_ref) {
141
146
  setPickedDate: setPickedDate,
142
147
  pickedDate: pickedDate,
143
148
  controlledValue: _value,
144
- setControlledValue: setValue
149
+ setControlledValue: setValue,
150
+ handleReset: handleReset
145
151
  };
146
152
  }
147
153
 
@@ -1 +1 @@
1
- {"version":3,"file":"useDatesState.js","sources":["../../../../../../src/components/DatePicker/useDatesState.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { DatePickerType, PickerBaseProps } from '@mantine/dates';\nimport dayjs from 'dayjs';\nimport { useEffect, useState } from 'react';\nimport { useUncontrolledDates } from './useControlledDates';\n\ninterface UseDatesRangeInput<Type extends DatePickerType = 'default'>\n extends PickerBaseProps<Type> {\n level: 'year' | 'month' | 'day';\n type: Type;\n onMouseLeave?: (event: React.MouseEvent<HTMLDivElement>) => void;\n applyTimezone?: boolean;\n}\n\nfunction isInRange(date: Date, range: [Date, Date]) {\n const _range = [...range].sort((a, b) => a.getTime() - b.getTime());\n return (\n dayjs(_range[0]).startOf('day').subtract(1, 'ms').isBefore(date) &&\n dayjs(_range[1]).endOf('day').add(1, 'ms').isAfter(date)\n );\n}\n\nexport function useDatesState<Type extends DatePickerType = 'default'>({\n type,\n level,\n value,\n defaultValue,\n onChange,\n allowSingleDateInRange,\n allowDeselect,\n onMouseLeave,\n applyTimezone = true,\n}: UseDatesRangeInput<Type>) {\n const [_value, setValue] = useUncontrolledDates({\n type,\n value,\n defaultValue,\n onChange,\n applyTimezone,\n });\n\n const [pickedDate, setPickedDate] = useState<Date | null>(\n type === 'range' ? (_value[0] && !_value[1] ? _value[0] : null) : null,\n );\n const [hoveredDate, setHoveredDate] = useState<Date | null>(null);\n\n const onDateChange = (date: Date) => {\n if (type === 'range') {\n if (pickedDate instanceof Date && !_value[1]) {\n if (dayjs(date).isSame(pickedDate, level) && !allowSingleDateInRange) {\n setPickedDate(null);\n setHoveredDate(null);\n setValue([null, null]);\n return;\n }\n\n const result: [Date, Date] = [date, pickedDate];\n result.sort((a, b) => a.getTime() - b.getTime());\n setValue(result);\n setHoveredDate(null);\n setPickedDate(null);\n return;\n }\n\n if (\n _value[0] &&\n !_value[1] &&\n dayjs(date).isSame(_value[0], level) &&\n !allowSingleDateInRange\n ) {\n setPickedDate(null);\n setHoveredDate(null);\n setValue([null, null]);\n return;\n }\n\n setValue([date, null]);\n setHoveredDate(null);\n setPickedDate(date);\n return;\n }\n\n if (_value && allowDeselect && dayjs(date).isSame(_value, level)) {\n setValue(null);\n } else {\n setValue(date);\n }\n };\n\n const isDateInRange = (date: Date) => {\n if (pickedDate instanceof Date && hoveredDate instanceof Date) {\n return isInRange(date, [hoveredDate, pickedDate]);\n }\n\n if (_value[0] instanceof Date && _value[1] instanceof Date) {\n return isInRange(date, _value);\n }\n\n return false;\n };\n\n const onRootMouseLeave =\n type === 'range'\n ? (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n setHoveredDate(null);\n }\n : onMouseLeave;\n\n const isFirstInRange = (date: Date) => {\n if (!(_value[0] instanceof Date)) {\n return false;\n }\n\n if (dayjs(date).isSame(_value[0], level)) {\n return !(hoveredDate && dayjs(hoveredDate).isBefore(_value[0]));\n }\n\n return false;\n };\n\n const isLastInRange = (date: Date) => {\n if (_value[1] instanceof Date) {\n return dayjs(date).isSame(_value[1], level);\n }\n\n if (!(_value[0] instanceof Date) || !hoveredDate) {\n return false;\n }\n\n return dayjs(hoveredDate).isBefore(_value[0]) && dayjs(date).isSame(_value[0], level);\n };\n\n const getControlProps = (date: Date) => {\n if (type === 'range') {\n return {\n selected: _value.some(\n (selection: Date) => selection && dayjs(selection).isSame(date, level),\n ),\n inRange: isDateInRange(date),\n firstInRange: isFirstInRange(date),\n lastInRange: isLastInRange(date),\n 'data-autofocus': (!!_value[0] && dayjs(_value[0]).isSame(date, level)) || undefined,\n 'data-celltype': level,\n 'data-date': `${date.getMonth()}-${date.getDate()}`,\n };\n }\n\n const selected = dayjs(_value).isSame(date, level);\n return {\n selected,\n 'data-autofocus': selected || undefined,\n 'data-celltype': level,\n 'data-date': `${date.getMonth()}-${date.getDate()}`,\n };\n };\n\n const onHoveredDateChange = type === 'range' && pickedDate ? setHoveredDate : () => {};\n\n useEffect(() => {\n if (type === 'range' && !_value[0] && !_value[1]) {\n setPickedDate(null);\n }\n }, [value]);\n\n return {\n onDateChange,\n onRootMouseLeave,\n onHoveredDateChange,\n getControlProps,\n setPickedDate,\n pickedDate,\n controlledValue: _value,\n setControlledValue: setValue,\n } as const;\n}\n"],"names":["isInRange","date","range","_range","_toConsumableArray","sort","a","b","getTime","dayjs","startOf","subtract","isBefore","endOf","add","isAfter","useDatesState","_ref","type","level","value","defaultValue","onChange","allowSingleDateInRange","allowDeselect","onMouseLeave","_ref$applyTimezone","applyTimezone","_useUncontrolledDates","useUncontrolledDates","_useUncontrolledDates2","_slicedToArray","_value","setValue","_useState","useState","_useState2","pickedDate","setPickedDate","_useState3","_useState4","hoveredDate","setHoveredDate","onDateChange","Date","isSame","result","isDateInRange","onRootMouseLeave","event","isFirstInRange","isLastInRange","getControlProps","selected","some","selection","inRange","firstInRange","lastInRange","undefined","concat","getMonth","getDate","onHoveredDateChange","useEffect","controlledValue","setControlledValue"],"mappings":";;;;;;AAeA,SAASA,SAASA,CAACC,IAAU,EAAEC,KAAmB,EAAE;EAClD,IAAMC,MAAM,GAAGC,kBAAA,CAAIF,KAAK,CAAEG,CAAAA,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAA;IAAA,OAAKD,CAAC,CAACE,OAAO,EAAE,GAAGD,CAAC,CAACC,OAAO,EAAE,CAAA;GAAC,CAAA,CAAA;EACnE,OACEC,KAAK,CAACN,MAAM,CAAC,CAAC,CAAC,CAAC,CAACO,OAAO,CAAC,KAAK,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAACC,QAAQ,CAACX,IAAI,CAAC,IAChEQ,KAAK,CAACN,MAAM,CAAC,CAAC,CAAC,CAAC,CAACU,KAAK,CAAC,KAAK,CAAC,CAACC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAACC,OAAO,CAACd,IAAI,CAAC,CAAA;AAE5D,CAAA;AAEO,SAASe,aAAaA,CAAAC,IAAA,EAUA;AAAA,EAAA,IAT3BC,IAAI,GAAAD,IAAA,CAAJC,IAAI;IACJC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACLC,YAAY,GAAAJ,IAAA,CAAZI,YAAY;IACZC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,sBAAsB,GAAAN,IAAA,CAAtBM,sBAAsB;IACtBC,aAAa,GAAAP,IAAA,CAAbO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A;AACrB,KAAA;AACF,GAAC,EAAE,CAAClB,KAAK,CAAC,CAAC,CAAA;EAEX,OAAO;AACLuB,IAAAA,YAAY,EAAZA,YAAY;AACZK,IAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBe,IAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBX,IAAAA,eAAe,EAAfA,eAAe;AACfd,IAAAA,aAAa,EAAbA,aAAa;AACbD,IAAAA,UAAU,EAAVA,UAAU;AACV4B,IAAAA,eAAe,EAAEjC,MAAM;AACvBkC,IAAAA,kBAAkB,EAAEjC,QAAAA;GACrB,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"useDatesState.js","sources":["../../../../../../src/components/DatePicker/useDatesState.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { DatePickerType, PickerBaseProps } from '@mantine/dates';\nimport dayjs from 'dayjs';\nimport { useEffect, useState } from 'react';\nimport { useUncontrolledDates } from './useControlledDates';\n\ninterface UseDatesRangeInput<Type extends DatePickerType = 'default'>\n extends PickerBaseProps<Type> {\n level: 'year' | 'month' | 'day';\n type: Type;\n onMouseLeave?: (event: React.MouseEvent<HTMLDivElement>) => void;\n applyTimezone?: boolean;\n}\n\nfunction isInRange(date: Date, range: [Date, Date]) {\n const _range = [...range].sort((a, b) => a.getTime() - b.getTime());\n return (\n dayjs(_range[0]).startOf('day').subtract(1, 'ms').isBefore(date) &&\n dayjs(_range[1]).endOf('day').add(1, 'ms').isAfter(date)\n );\n}\n\nexport function useDatesState<Type extends DatePickerType = 'default'>({\n type,\n level,\n value,\n defaultValue,\n onChange,\n allowSingleDateInRange,\n allowDeselect,\n onMouseLeave,\n applyTimezone = true,\n}: UseDatesRangeInput<Type>) {\n const [_value, setValue] = useUncontrolledDates({\n type,\n value,\n defaultValue,\n onChange,\n applyTimezone,\n });\n\n const [pickedDate, setPickedDate] = useState<Date | null>(\n type === 'range' ? (_value[0] && !_value[1] ? _value[0] : null) : null,\n );\n const [hoveredDate, setHoveredDate] = useState<Date | null>(null);\n\n const onDateChange = (date: Date) => {\n if (type === 'range') {\n if (pickedDate instanceof Date && !_value[1]) {\n if (dayjs(date).isSame(pickedDate, level) && !allowSingleDateInRange) {\n setPickedDate(null);\n setHoveredDate(null);\n setValue([null, null]);\n return;\n }\n\n const result: [Date, Date] = [date, pickedDate];\n result.sort((a, b) => a.getTime() - b.getTime());\n setValue(result);\n setHoveredDate(null);\n setPickedDate(null);\n return;\n }\n\n if (\n _value[0] &&\n !_value[1] &&\n dayjs(date).isSame(_value[0], level) &&\n !allowSingleDateInRange\n ) {\n setPickedDate(null);\n setHoveredDate(null);\n setValue([null, null]);\n return;\n }\n\n setValue([date, null]);\n setHoveredDate(null);\n setPickedDate(date);\n return;\n }\n\n if (_value && allowDeselect && dayjs(date).isSame(_value, level)) {\n setValue(null);\n } else {\n setValue(date);\n }\n };\n\n const isDateInRange = (date: Date) => {\n if (pickedDate instanceof Date && hoveredDate instanceof Date) {\n return isInRange(date, [hoveredDate, pickedDate]);\n }\n\n if (_value[0] instanceof Date && _value[1] instanceof Date) {\n return isInRange(date, _value);\n }\n\n return false;\n };\n\n const handleReset = () => {\n setPickedDate(null);\n setHoveredDate(null);\n setValue([null, null]);\n };\n const onRootMouseLeave =\n type === 'range'\n ? (event: React.MouseEvent<HTMLDivElement>) => {\n onMouseLeave?.(event);\n setHoveredDate(null);\n }\n : onMouseLeave;\n\n const isFirstInRange = (date: Date) => {\n if (!(_value[0] instanceof Date)) {\n return false;\n }\n\n if (dayjs(date).isSame(_value[0], level)) {\n return !(hoveredDate && dayjs(hoveredDate).isBefore(_value[0]));\n }\n\n return false;\n };\n\n const isLastInRange = (date: Date) => {\n if (_value[1] instanceof Date) {\n return dayjs(date).isSame(_value[1], level);\n }\n\n if (!(_value[0] instanceof Date) || !hoveredDate) {\n return false;\n }\n\n return dayjs(hoveredDate).isBefore(_value[0]) && dayjs(date).isSame(_value[0], level);\n };\n\n const getControlProps = (date: Date) => {\n if (type === 'range') {\n return {\n selected: _value.some(\n (selection: Date) => selection && dayjs(selection).isSame(date, level),\n ),\n inRange: isDateInRange(date),\n firstInRange: isFirstInRange(date),\n lastInRange: isLastInRange(date),\n 'data-autofocus': (!!_value[0] && dayjs(_value[0]).isSame(date, level)) || undefined,\n 'data-celltype': level,\n 'data-date': `${date.getMonth()}-${date.getDate()}`,\n };\n }\n\n const selected = dayjs(_value).isSame(date, level);\n return {\n selected,\n 'data-autofocus': selected || undefined,\n 'data-celltype': level,\n 'data-date': `${date.getMonth()}-${date.getDate()}`,\n };\n };\n\n const onHoveredDateChange = type === 'range' && pickedDate ? setHoveredDate : () => {};\n\n useEffect(() => {\n if (type === 'range' && !_value[0] && !_value[1]) {\n setPickedDate(null);\n }\n }, [value]);\n\n return {\n onDateChange,\n onRootMouseLeave,\n onHoveredDateChange,\n getControlProps,\n setPickedDate,\n pickedDate,\n controlledValue: _value,\n setControlledValue: setValue,\n handleReset,\n } as const;\n}\n"],"names":["isInRange","date","range","_range","_toConsumableArray","sort","a","b","getTime","dayjs","startOf","subtract","isBefore","endOf","add","isAfter","useDatesState","_ref","type","level","value","defaultValue","onChange","allowSingleDateInRange","allowDeselect","onMouseLeave","_ref$applyTimezone","applyTimezone","_useUncontrolledDates","useUncontrolledDates","_useUncontrolledDates2","_slicedToArray","_value","setValue","_useState","useState","_useState2","pickedDate","setPickedDate","_useState3","_useState4","hoveredDate","setHoveredDate","onDateChange","Date","isSame","result","isDateInRange","handleReset","onRootMouseLeave","event","isFirstInRange","isLastInRange","getControlProps","selected","some","selection","inRange","firstInRange","lastInRange","undefined","concat","getMonth","getDate","onHoveredDateChange","useEffect","controlledValue","setControlledValue"],"mappings":";;;;;;AAeA,SAASA,SAASA,CAACC,IAAU,EAAEC,KAAmB,EAAE;EAClD,IAAMC,MAAM,GAAGC,kBAAA,CAAIF,KAAK,CAAEG,CAAAA,IAAI,CAAC,UAACC,CAAC,EAAEC,CAAC,EAAA;I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A,UAAU;AACV6B,IAAAA,eAAe,EAAElC,MAAM;AACvBmC,IAAAA,kBAAkB,EAAElC,QAAQ;AAC5Be,IAAAA,WAAW,EAAXA,WAAAA;GACD,CAAA;AACH;;;;"}
@@ -31,7 +31,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
31
31
  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; }
32
32
  var validDropdownChildren = [
33
33
  // TODO: Remove Box once CountrySelector's button sizing is fixed
34
- dropdownComponentIds.BaseBox, dropdownComponentIds.triggers.SelectInput, dropdownComponentIds.triggers.SearchInput, dropdownComponentIds.triggers.DropdownButton, dropdownComponentIds.triggers.DropdownIconButton, dropdownComponentIds.triggers.DropdownLink, dropdownComponentIds.DropdownOverlay, dropdownComponentIds.triggers.AutoComplete, ComponentIds.BottomSheet];
34
+ dropdownComponentIds.BaseBox, dropdownComponentIds.triggers.SelectInput, dropdownComponentIds.triggers.SearchInput, dropdownComponentIds.triggers.DropdownButton, dropdownComponentIds.triggers.DropdownIconButton, dropdownComponentIds.triggers.DropdownLink, dropdownComponentIds.DropdownOverlay, dropdownComponentIds.triggers.AutoComplete, ComponentIds.BottomSheet, dropdownComponentIds.triggers.FilterChipSelectInput];
35
35
 
36
36
  /**
37
37
  * ### Dropdown component
@@ -106,21 +106,25 @@ var _Dropdown = function _Dropdown(_ref, ref) {
106
106
  setHasAutoCompleteInBottomSheetHeader = _React$useState18[1];
107
107
  var _React$useState19 = React__default.useState(false),
108
108
  _React$useState20 = _slicedToArray(_React$useState19, 2),
109
- isKeydownPressed = _React$useState20[0],
110
- setIsKeydownPressed = _React$useState20[1];
111
- var _React$useState21 = React__default.useState(0),
109
+ hasUnControlledFilterChipSelectInput = _React$useState20[0],
110
+ setHasUnControlledFilterChipSelectInput = _React$useState20[1];
111
+ var _React$useState21 = React__default.useState(false),
112
112
  _React$useState22 = _slicedToArray(_React$useState21, 2),
113
- changeCallbackTriggerer = _React$useState22[0],
114
- setChangeCallbackTriggerer = _React$useState22[1];
115
- var _React$useState23 = React__default.useState(false),
113
+ isKeydownPressed = _React$useState22[0],
114
+ setIsKeydownPressed = _React$useState22[1];
115
+ var _React$useState23 = React__default.useState(0),
116
116
  _React$useState24 = _slicedToArray(_React$useState23, 2),
117
- isControlled = _React$useState24[0],
118
- setIsControlled = _React$useState24[1];
119
- // keep track if dropdown contains bottomsheet
117
+ changeCallbackTriggerer = _React$useState24[0],
118
+ setChangeCallbackTriggerer = _React$useState24[1];
120
119
  var _React$useState25 = React__default.useState(false),
121
120
  _React$useState26 = _slicedToArray(_React$useState25, 2),
122
- dropdownHasBottomSheet = _React$useState26[0],
123
- setDropdownHasBottomSheet = _React$useState26[1];
121
+ isControlled = _React$useState26[0],
122
+ setIsControlled = _React$useState26[1];
123
+ // keep track if dropdown contains bottomsheet
124
+ var _React$useState27 = React__default.useState(false),
125
+ _React$useState28 = _slicedToArray(_React$useState27, 2),
126
+ dropdownHasBottomSheet = _React$useState28[0],
127
+ setDropdownHasBottomSheet = _React$useState28[1];
124
128
 
125
129
  /**
126
130
  * In inputs, actual input is smaller than the visible input wrapper.
@@ -188,6 +192,9 @@ var _Dropdown = function _Dropdown(_ref, ref) {
188
192
  if (isValidAllowedChildren(child, dropdownComponentIds.triggers.AutoComplete)) {
189
193
  dropdownTriggerer.current = 'AutoComplete';
190
194
  }
195
+ if (isValidAllowedChildren(child, dropdownComponentIds.triggers.FilterChipSelectInput)) {
196
+ dropdownTriggerer.current = 'FilterChipSelectInput';
197
+ }
191
198
  }
192
199
  });
193
200
  var contextValue = React__default.useMemo(function () {
@@ -221,6 +228,8 @@ var _Dropdown = function _Dropdown(_ref, ref) {
221
228
  setHasFooterAction: setHasFooterAction,
222
229
  hasAutoCompleteInBottomSheetHeader: hasAutoCompleteInBottomSheetHeader,
223
230
  setHasAutoCompleteInBottomSheetHeader: setHasAutoCompleteInBottomSheetHeader,
231
+ hasUnControlledFilterChipSelectInput: hasUnControlledFilterChipSelectInput,
232
+ setHasUnControlledFilterChipSelectInput: setHasUnControlledFilterChipSelectInput,
224
233
  dropdownTriggerer: dropdownTriggerer.current,
225
234
  changeCallbackTriggerer: changeCallbackTriggerer,
226
235
  setChangeCallbackTriggerer: setChangeCallbackTriggerer,
@@ -1 +1 @@
1
- {"version":3,"file":"Dropdown.js","sources":["../../../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import React from 'react';\nimport { DropdownContext } from './useDropdown';\nimport type { DropdownContextType } from './useDropdown';\nimport type { DropdownProps } from './types';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useId } from '~utils/useId';\nimport { ComponentIds as bottomSheetComponentIds } from '~components/BottomSheet/componentIds';\nimport { BottomSheetAndDropdownGlueContext } from '~components/BottomSheet/BottomSheetContext';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId, isValidAllowedChildren } from '~utils/isValidAllowedChildren';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\nimport type { BladeElementRef, ContainerElementType } from '~utils/types';\nimport { useControllableState } from '~utils/useControllable';\nimport { mergeRefs } from '~utils/useMergeRefs';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst validDropdownChildren = [\n // TODO: Remove Box once CountrySelector's button sizing is fixed\n dropdownComponentIds.BaseBox,\n dropdownComponentIds.triggers.SelectInput,\n dropdownComponentIds.triggers.SearchInput,\n dropdownComponentIds.triggers.DropdownButton,\n dropdownComponentIds.triggers.DropdownIconButton,\n dropdownComponentIds.triggers.DropdownLink,\n dropdownComponentIds.DropdownOverlay,\n dropdownComponentIds.triggers.AutoComplete,\n bottomSheetComponentIds.BottomSheet,\n];\n\n/**\n * ### Dropdown component\n *\n * Dropdown component is generic component that controls the dropdown functionality.\n * It can be used with multiple triggers and mostly contains ActionList component inside it\n *\n * ---\n *\n * #### Usage\n *\n * ```jsx\n * <Dropdown selectionType=\"single\">\n * <SelectInput />\n * <DropdownOverlay>\n * <ActionList>\n * <ActionListItem />\n * <ActionListItem />\n * </ActionList>\n * </DropdownOverlay>\n * </Dropdown>\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-dropdown-with-select--with-single-select Dropdown Documentation}\n */\nconst _Dropdown = (\n {\n children,\n isOpen: isOpenControlled,\n onOpenChange,\n selectionType = 'single',\n testID,\n _width,\n ...rest\n }: DropdownProps,\n ref: React.Ref<BladeElementRef>,\n): React.ReactElement => {\n const [options, setOptions] = React.useState<DropdownContextType['options']>([]);\n const [filteredValues, setFilteredValues] = React.useState<string[]>([]);\n const [selectedIndices, setSelectedIndices] = React.useState<\n DropdownContextType['selectedIndices']\n >([]);\n const [controlledValueIndices, setControlledValueIndices] = React.useState<\n DropdownContextType['selectedIndices']\n >([]);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [shouldIgnoreBlurAnimation, setShouldIgnoreBlurAnimation] = React.useState(false);\n const [hasFooterAction, setHasFooterAction] = React.useState(false);\n const [\n hasAutoCompleteInBottomSheetHeader,\n setHasAutoCompleteInBottomSheetHeader,\n ] = React.useState(false);\n const [isKeydownPressed, setIsKeydownPressed] = React.useState(false);\n const [changeCallbackTriggerer, setChangeCallbackTriggerer] = React.useState<\n DropdownContextType['changeCallbackTriggerer']\n >(0);\n const [isControlled, setIsControlled] = React.useState(false);\n // keep track if dropdown contains bottomsheet\n const [dropdownHasBottomSheet, setDropdownHasBottomSheet] = React.useState(false);\n\n /**\n * In inputs, actual input is smaller than the visible input wrapper.\n * You can set this reference in such cases so floating ui calculations happen correctly\n * */\n const triggererWrapperRef = React.useRef<ContainerElementType>(null);\n const triggererRef = React.useRef<HTMLButtonElement>(null);\n const actionListItemRef = React.useRef<HTMLDivElement>(null);\n const dropdownTriggerer = React.useRef<DropdownContextType['dropdownTriggerer']>();\n const isTagDismissedRef = React.useRef<{ value: boolean } | null>({ value: false });\n const visibleTagsCountRef = React.useRef<{ value: number }>({ value: 0 });\n const dropdownContainerRef = React.useRef<HTMLDivElement>(null);\n\n const dropdownBaseId = useId('dropdown');\n const isDropdownOpenRef = React.useRef(isOpenControlled);\n\n const [isDropdownOpen, setIsDropdownOpen] = useControllableState({\n value: isOpenControlled,\n defaultValue: false,\n onChange: (isOpenControlledValue) => {\n isDropdownOpenRef.current = isOpenControlledValue;\n onOpenChange?.(isOpenControlledValue);\n },\n });\n\n isDropdownOpenRef.current = isDropdownOpen;\n\n const setIsOpen = (isOpenValue: boolean): void => {\n isDropdownOpenRef.current = isOpenValue;\n setIsDropdownOpen(() => isOpenValue);\n };\n\n const close = React.useCallback(() => {\n setActiveTagIndex(-1);\n setIsOpen(false);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n if (__DEV__) {\n if (!validDropdownChildren.includes(getComponentId(child) ?? '')) {\n throwBladeError({\n message: `Dropdown can only have one of following elements as children - \\n\\n ${validDropdownChildren.join(\n ', ',\n )} \\n\\n Check out: https://blade.razorpay.com/?path=/story/components-dropdown`,\n moduleName: 'Dropdown',\n });\n }\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.SelectInput)) {\n dropdownTriggerer.current = 'SelectInput';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.SearchInput)) {\n dropdownTriggerer.current = 'SearchInput';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.DropdownButton)) {\n dropdownTriggerer.current = 'DropdownButton';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.DropdownIconButton)) {\n dropdownTriggerer.current = 'DropdownIconButton';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.AutoComplete)) {\n dropdownTriggerer.current = 'AutoComplete';\n }\n }\n });\n\n const contextValue = React.useMemo<DropdownContextType>(\n () => ({\n isOpen: isDropdownOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n controlledValueIndices,\n setControlledValueIndices,\n options,\n setOptions,\n filteredValues,\n setFilteredValues,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n shouldIgnoreBlurAnimation,\n setShouldIgnoreBlurAnimation,\n isKeydownPressed,\n setIsKeydownPressed,\n dropdownBaseId,\n triggererRef,\n triggererWrapperRef,\n actionListItemRef,\n selectionType,\n hasFooterAction,\n setHasFooterAction,\n hasAutoCompleteInBottomSheetHeader,\n setHasAutoCompleteInBottomSheetHeader,\n dropdownTriggerer: dropdownTriggerer.current,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setIsControlled,\n isTagDismissedRef,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n isDropdownOpen,\n isOpenControlled,\n selectedIndices,\n controlledValueIndices,\n options,\n filteredValues,\n activeIndex,\n activeTagIndex,\n shouldIgnoreBlurAnimation,\n selectionType,\n hasFooterAction,\n isKeydownPressed,\n changeCallbackTriggerer,\n isControlled,\n ],\n );\n\n const BottomSheetAndDropdownGlueContextValue = React.useMemo((): BottomSheetAndDropdownGlueContext => {\n return {\n isOpen: isDropdownOpen,\n dropdownHasBottomSheet,\n hasAutoCompleteInBottomSheetHeader,\n setDropdownHasBottomSheet,\n // This is the dismiss function which will be injected into the BottomSheet\n // Basically <BottomSheet onDismiss={onBottomSheetDismiss} />\n onBottomSheetDismiss: close,\n };\n }, [dropdownHasBottomSheet, hasAutoCompleteInBottomSheetHeader, isDropdownOpen, close]);\n\n return (\n <BottomSheetAndDropdownGlueContext.Provider value={BottomSheetAndDropdownGlueContextValue}>\n <DropdownContext.Provider value={contextValue}>\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={mergeRefs(ref, dropdownContainerRef as any)}\n {...metaAttribute({ name: MetaConstants.Dropdown, testID })}\n {...getStyledProps(rest)}\n {...makeAnalyticsAttribute(rest)}\n width={_width}\n >\n <BaseBox position=\"relative\" textAlign={'left' as never}>\n {children}\n </BaseBox>\n </BaseBox>\n </DropdownContext.Provider>\n </BottomSheetAndDropdownGlueContext.Provider>\n );\n};\n\nconst Dropdown = assignWithoutSideEffects(React.forwardRef(_Dropdown), {\n componentId: dropdownComponentIds.Dropdown,\n});\n\nexport { Dropdown };\n"],"names":["validDropdownChildren","dropdownComponentIds","BaseBox","triggers","SelectInput","SearchInput","DropdownButton","DropdownIconButton","DropdownLink","DropdownOverlay","AutoComplete","bottomSheetComponentIds","BottomSheet","_Dropdown","_ref","ref","children","isOpenControlled","isOpen","onOpenChange","_ref$selectionType","selectionType","testID","_width","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","options","setOptions","_React$useState3","_React$useState4","filteredValues","setFilteredValues","_React$useState5","_React$useState6","selectedIndices","setSelectedIndices","_React$useState7","_React$useState8","controlledValueIndices","setControlledValueIndices","_React$useState9","_React$useState10","activeIndex","setActiveIndex","_React$useState11","_React$useState12","activeTagIndex","setActiveTagIndex","_React$useState13","_React$useState14","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","_React$useState15","_React$useState16","hasFooterAction","setHasFooterAction","_React$useState17","_React$useState18","hasAutoCompleteInBottomSheetHeader","setHasAutoCompleteInBottomSheetHeader","_React$useState19","_React$useState20","isKeydownPressed","setIsKeydownPressed","_React$useState21","_React$useState22","changeCallbackTriggerer","setChangeCallbackTriggerer","_React$useState23","_React$useState24","isControlled","setIsControlled","_React$useState25","_React$useState26","dropdownHasBottomSheet","setDropdownHasBottomSheet","triggererWrapperRef","useRef","triggererRef","actionListItemRef","dropdownTriggerer","isTagDismissedRef","value","visibleTagsCountRef","dropdownContainerRef","dropdownBaseId","useId","isDropdownOpenRef","_useControllableState","useControllableState","defaultValue","onChange","isOpenControlledValue","current","_useControllableState2","isDropdownOpen","setIsDropdownOpen","setIsOpen","isOpenValue","close","useCallback","Children","map","child","isValidElement","_getComponentId","includes","getComponentId","throwBladeError","message","concat","join","moduleName","isValidAllowedChildren","contextValue","useMemo","BottomSheetAndDropdownGlueContextValue","onBottomSheetDismiss","_jsx","BottomSheetAndDropdownGlueContext","Provider","DropdownContext","_objectSpread","mergeRefs","metaAttribute","name","MetaConstants","Dropdown","getStyledProps","makeAnalyticsAttribute","width","position","textAlign","assignWithoutSideEffects","forwardRef","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAMA,qBAAqB,GAAG;AAC5B;AACAC,oBAAoB,CAACC,OAAO,EAC5BD,oBAAoB,CAACE,QAAQ,CAACC,WAAW,EACzCH,oBAAoB,CAACE,QAAQ,CAACE,WAAW,EACzCJ,oBAAoB,CAACE,QAAQ,CAACG,cAAc,EAC5CL,oBAAoB,CAACE,QAAQ,CAACI,kBAAkB,EAChDN,oBAAoB,CAACE,QAAQ,CAACK,YAAY,EAC1CP,oBAAoB,CAACQ,eAAe,EACpCR,oBAAoB,CAACE,QAAQ,CAACO,YAAY,EAC1CC,YAAuB,CAACC,WAAW,CACpC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAAC,IAAA,EAUbC,GAA+B,EACR;AAAA,EAAA,IATrBC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACAC,gBAAgB,GAAAH,IAAA,CAAxBI,MAAM;IACNC,YAAY,GA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ourcesContent":["import React from 'react';\nimport { DropdownContext } from './useDropdown';\nimport type { DropdownContextType } from './useDropdown';\nimport type { DropdownProps } from './types';\nimport { dropdownComponentIds } from './dropdownComponentIds';\nimport { useId } from '~utils/useId';\nimport { ComponentIds as bottomSheetComponentIds } from '~components/BottomSheet/componentIds';\nimport { BottomSheetAndDropdownGlueContext } from '~components/BottomSheet/BottomSheetContext';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport BaseBox from '~components/Box/BaseBox';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getComponentId, isValidAllowedChildren } from '~utils/isValidAllowedChildren';\nimport { MetaConstants, metaAttribute } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\nimport type { BladeElementRef, ContainerElementType } from '~utils/types';\nimport { useControllableState } from '~utils/useControllable';\nimport { mergeRefs } from '~utils/useMergeRefs';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\nconst validDropdownChildren = [\n // TODO: Remove Box once CountrySelector's button sizing is fixed\n dropdownComponentIds.BaseBox,\n dropdownComponentIds.triggers.SelectInput,\n dropdownComponentIds.triggers.SearchInput,\n dropdownComponentIds.triggers.DropdownButton,\n dropdownComponentIds.triggers.DropdownIconButton,\n dropdownComponentIds.triggers.DropdownLink,\n dropdownComponentIds.DropdownOverlay,\n dropdownComponentIds.triggers.AutoComplete,\n bottomSheetComponentIds.BottomSheet,\n dropdownComponentIds.triggers.FilterChipSelectInput,\n];\n\n/**\n * ### Dropdown component\n *\n * Dropdown component is generic component that controls the dropdown functionality.\n * It can be used with multiple triggers and mostly contains ActionList component inside it\n *\n * ---\n *\n * #### Usage\n *\n * ```jsx\n * <Dropdown selectionType=\"single\">\n * <SelectInput />\n * <DropdownOverlay>\n * <ActionList>\n * <ActionListItem />\n * <ActionListItem />\n * </ActionList>\n * </DropdownOverlay>\n * </Dropdown>\n * ```\n *\n * ---\n *\n * Checkout {@link https://blade.razorpay.com/?path=/docs/components-dropdown-with-select--with-single-select Dropdown Documentation}\n */\nconst _Dropdown = (\n {\n children,\n isOpen: isOpenControlled,\n onOpenChange,\n selectionType = 'single',\n testID,\n _width,\n ...rest\n }: DropdownProps,\n ref: React.Ref<BladeElementRef>,\n): React.ReactElement => {\n const [options, setOptions] = React.useState<DropdownContextType['options']>([]);\n const [filteredValues, setFilteredValues] = React.useState<string[]>([]);\n const [selectedIndices, setSelectedIndices] = React.useState<\n DropdownContextType['selectedIndices']\n >([]);\n const [controlledValueIndices, setControlledValueIndices] = React.useState<\n DropdownContextType['selectedIndices']\n >([]);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [activeTagIndex, setActiveTagIndex] = React.useState(-1);\n const [shouldIgnoreBlurAnimation, setShouldIgnoreBlurAnimation] = React.useState(false);\n const [hasFooterAction, setHasFooterAction] = React.useState(false);\n const [\n hasAutoCompleteInBottomSheetHeader,\n setHasAutoCompleteInBottomSheetHeader,\n ] = React.useState(false);\n const [\n hasUnControlledFilterChipSelectInput,\n setHasUnControlledFilterChipSelectInput,\n ] = React.useState(false);\n const [isKeydownPressed, setIsKeydownPressed] = React.useState(false);\n const [changeCallbackTriggerer, setChangeCallbackTriggerer] = React.useState<\n DropdownContextType['changeCallbackTriggerer']\n >(0);\n const [isControlled, setIsControlled] = React.useState(false);\n // keep track if dropdown contains bottomsheet\n const [dropdownHasBottomSheet, setDropdownHasBottomSheet] = React.useState(false);\n\n /**\n * In inputs, actual input is smaller than the visible input wrapper.\n * You can set this reference in such cases so floating ui calculations happen correctly\n * */\n const triggererWrapperRef = React.useRef<ContainerElementType>(null);\n const triggererRef = React.useRef<HTMLButtonElement>(null);\n const actionListItemRef = React.useRef<HTMLDivElement>(null);\n const dropdownTriggerer = React.useRef<DropdownContextType['dropdownTriggerer']>();\n const isTagDismissedRef = React.useRef<{ value: boolean } | null>({ value: false });\n const visibleTagsCountRef = React.useRef<{ value: number }>({ value: 0 });\n const dropdownContainerRef = React.useRef<HTMLDivElement>(null);\n\n const dropdownBaseId = useId('dropdown');\n const isDropdownOpenRef = React.useRef(isOpenControlled);\n\n const [isDropdownOpen, setIsDropdownOpen] = useControllableState({\n value: isOpenControlled,\n defaultValue: false,\n onChange: (isOpenControlledValue) => {\n isDropdownOpenRef.current = isOpenControlledValue;\n onOpenChange?.(isOpenControlledValue);\n },\n });\n\n isDropdownOpenRef.current = isDropdownOpen;\n\n const setIsOpen = (isOpenValue: boolean): void => {\n isDropdownOpenRef.current = isOpenValue;\n setIsDropdownOpen(() => isOpenValue);\n };\n\n const close = React.useCallback(() => {\n setActiveTagIndex(-1);\n setIsOpen(false);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n if (__DEV__) {\n if (!validDropdownChildren.includes(getComponentId(child) ?? '')) {\n throwBladeError({\n message: `Dropdown can only have one of following elements as children - \\n\\n ${validDropdownChildren.join(\n ', ',\n )} \\n\\n Check out: https://blade.razorpay.com/?path=/story/components-dropdown`,\n moduleName: 'Dropdown',\n });\n }\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.SelectInput)) {\n dropdownTriggerer.current = 'SelectInput';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.SearchInput)) {\n dropdownTriggerer.current = 'SearchInput';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.DropdownButton)) {\n dropdownTriggerer.current = 'DropdownButton';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.DropdownIconButton)) {\n dropdownTriggerer.current = 'DropdownIconButton';\n }\n\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.AutoComplete)) {\n dropdownTriggerer.current = 'AutoComplete';\n }\n if (isValidAllowedChildren(child, dropdownComponentIds.triggers.FilterChipSelectInput)) {\n dropdownTriggerer.current = 'FilterChipSelectInput';\n }\n }\n });\n\n const contextValue = React.useMemo<DropdownContextType>(\n () => ({\n isOpen: isDropdownOpen,\n setIsOpen,\n close,\n selectedIndices,\n setSelectedIndices,\n controlledValueIndices,\n setControlledValueIndices,\n options,\n setOptions,\n filteredValues,\n setFilteredValues,\n activeIndex,\n setActiveIndex,\n activeTagIndex,\n setActiveTagIndex,\n visibleTagsCountRef,\n shouldIgnoreBlurAnimation,\n setShouldIgnoreBlurAnimation,\n isKeydownPressed,\n setIsKeydownPressed,\n dropdownBaseId,\n triggererRef,\n triggererWrapperRef,\n actionListItemRef,\n selectionType,\n hasFooterAction,\n setHasFooterAction,\n hasAutoCompleteInBottomSheetHeader,\n setHasAutoCompleteInBottomSheetHeader,\n hasUnControlledFilterChipSelectInput,\n setHasUnControlledFilterChipSelectInput,\n dropdownTriggerer: dropdownTriggerer.current,\n changeCallbackTriggerer,\n setChangeCallbackTriggerer,\n isControlled,\n setIsControlled,\n isTagDismissedRef,\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n isDropdownOpen,\n isOpenControlled,\n selectedIndices,\n controlledValueIndices,\n options,\n filteredValues,\n activeIndex,\n activeTagIndex,\n shouldIgnoreBlurAnimation,\n selectionType,\n hasFooterAction,\n isKeydownPressed,\n changeCallbackTriggerer,\n isControlled,\n ],\n );\n\n const BottomSheetAndDropdownGlueContextValue = React.useMemo((): BottomSheetAndDropdownGlueContext => {\n return {\n isOpen: isDropdownOpen,\n dropdownHasBottomSheet,\n hasAutoCompleteInBottomSheetHeader,\n setDropdownHasBottomSheet,\n // This is the dismiss function which will be injected into the BottomSheet\n // Basically <BottomSheet onDismiss={onBottomSheetDismiss} />\n onBottomSheetDismiss: close,\n };\n }, [dropdownHasBottomSheet, hasAutoCompleteInBottomSheetHeader, isDropdownOpen, close]);\n\n return (\n <BottomSheetAndDropdownGlueContext.Provider value={BottomSheetAndDropdownGlueContextValue}>\n <DropdownContext.Provider value={contextValue}>\n <BaseBox\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={mergeRefs(ref, dropdownContainerRef as any)}\n {...metaAttribute({ name: MetaConstants.Dropdown, testID })}\n {...getStyledProps(rest)}\n {...makeAnalyticsAttribute(rest)}\n width={_width}\n >\n <BaseBox position=\"relative\" textAlign={'left' as never}>\n {children}\n </BaseBox>\n </BaseBox>\n </DropdownContext.Provider>\n </BottomSheetAndDropdownGlueContext.Provider>\n );\n};\n\nconst Dropdown = assignWithoutSideEffects(React.forwardRef(_Dropdown), {\n componentId: dropdownComponentIds.Dropdown,\n});\n\nexport { Dropdown };\n"],"names":["validDropdownChildren","dropdownComponentIds","BaseBox","triggers","SelectInput","SearchInput","DropdownButton","DropdownIconButton","DropdownLink","DropdownOverlay","AutoComplete","bottomSheetComponentIds","BottomSheet","FilterChipSelectInput","_Dropdown","_ref","ref","children","isOpenControlled","isOpen","onOpenChange","_ref$selectionType","selectionType","testID","_width","rest","_objectWithoutProperties","_excluded","_React$useState","React","useState","_React$useState2","_slicedToArray","options","setOptions","_React$useState3","_React$useState4","filteredValues","setFilteredValues","_React$useState5","_React$useState6","selectedIndices","setSelectedIndices","_React$useState7","_React$useState8","controlledValueIndices","setControlledValueIndices","_React$useState9","_React$useState10","activeIndex","setActiveIndex","_React$useState11","_React$useState12","activeTagIndex","setActiveTagIndex","_React$useState13","_React$useState14","shouldIgnoreBlurAnimation","setShouldIgnoreBlurAnimation","_React$useState15","_React$useState16","hasFooterAction","setHasFooterAction","_React$useState17","_React$useState18","hasAutoCompleteInBottomSheetHeader","setHasAutoCompleteInBottomSheetHeader","_React$useState19","_React$useState20","hasUnControlledFilterChipSelectInput","setHasUnControlledFilterChipSelectInput","_React$useState21","_React$useState22","isKeydownPressed","setIsKeydownPressed","_React$useState23","_React$useState24","changeCallbackTriggerer","setChangeCallbackTriggerer","_React$useState25","_React$useState26","isControlled","setIsControlled","_React$useState27","_React$useState28","dropdownHasBottomSheet","setDropdownHasBottomSheet","triggererWrapperRef","useRef","triggererRef","actionListItemRef","dropdownTriggerer","isTagDismissedRef","value","visibleTagsCountRef","dropdownContainerRef","dropdownBaseId","useId","isDropdownOpenRef","_useControllableState","useControllableState","defaultValue","onChange","isOpenControlledValue","current","_useControllableState2","isDropdownOpen","setIsDropdownOpen","setIsOpen","isOpenValue","close","useCallback","Children","map","child","isValidElement","_getComponentId","includes","getComponentId","throwBladeError","message","concat","join","moduleName","isValidAllowedChildren","contextValue","useMemo","BottomSheetAndDropdownGlueContextValue","onBottomSheetDismiss","_jsx","BottomSheetAndDropdownGlueContext","Provider","DropdownContext","_objectSpread","mergeRefs","metaAttribute","name","MetaConstants","Dropdown","getStyledProps","makeAnalyticsAttribute","width","position","textAlign","assignWithoutSideEffects","forwardRef","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAMA,qBAAqB,GAAG;AAC5B;AACAC,oBAAoB,CAACC,OAAO,EAC5BD,oBAAoB,CAACE,QAAQ,CAACC,WAAW,EACzCH,oBAAoB,CAACE,QAAQ,CAACE,WAAW,EACzCJ,oBAAoB,CAACE,QAAQ,CAACG,cAAc,EAC5CL,oBAAoB,CAACE,QAAQ,CAACI,kBAAkB,EAChDN,oBAAoB,CAACE,QAAQ,CAACK,YAAY,EAC1CP,oBAAoB,CAACQ,eAAe,EACpCR,oBAAoB,CAACE,QAAQ,CAACO,YAAY,EAC1CC,YAAuB,CAACC,WAAW,EACnCX,oBAAoB,CAACE,QAAQ,CAACU,qBAAqB,CACpD,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAAC,IAAA,EAUbC,GAA+B,EACR;AAAA,EAAA,IATrBC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACAC,gBAAgB,GAAAH,IAAA,CAAxBI,MAAM;IACNC,YAAY,GAAAL,IAAA,CAAZK,YAAY;IAAAC,kBAAA,GAAAN,IAAA,CACZO,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAG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U;AAACC,UAAAA,SAAS,EAAE,MAAgB;AAAA9H,UAAAA,QAAA,EACrDA,QAAAA;SACM,CAAA;OACF,CAAA,CAAA;KACe,CAAA;AAAC,GACe,CAAC,CAAA;AAEjD,CAAC,CAAA;AAEKyH,IAAAA,QAAQ,gBAAGM,wBAAwB,eAACnH,cAAK,CAACoH,UAAU,CAACnI,SAAS,CAAC,EAAE;EACrEoI,WAAW,EAAEjJ,oBAAoB,CAACyI,QAAAA;AACpC,CAAC;;;;"}
@@ -0,0 +1,74 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import { useState } from 'react';
5
+ import { useListViewFilterContext } from '../ListView/ListViewFiltersContext.web.js';
6
+ import { FilterChipGroupProvider } from './FilterChipGroupContext.web.js';
7
+ import '../../utils/makeAnalyticsAttribute/index.js';
8
+ import '../Box/BaseBox/index.js';
9
+ import '../../utils/metaAttribute/index.js';
10
+ import '../Link/index.js';
11
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
+ import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
13
+ import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
14
+ import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
15
+ import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
16
+ import Link from '../Link/Link/Link.js';
17
+
18
+ var _excluded = ["testID", "children", "showClearButton", "onClearButtonClick"];
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
+ 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
+ var FilterChipGroup = function FilterChipGroup(_ref) {
22
+ var testID = _ref.testID,
23
+ children = _ref.children,
24
+ _ref$showClearButton = _ref.showClearButton,
25
+ showClearButton = _ref$showClearButton === void 0 ? true : _ref$showClearButton,
26
+ onClearButtonClick = _ref.onClearButtonClick,
27
+ rest = _objectWithoutProperties(_ref, _excluded);
28
+ var _useState = useState([]),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ filterChipGroupSelectedFilters = _useState2[0],
31
+ setFilterChipGroupSelectedFilters = _useState2[1];
32
+ var _useState3 = useState(0),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ clearFilterCallbackTriggerer = _useState4[0],
35
+ setClearFilterCallbackTriggerer = _useState4[1];
36
+ var _useListViewFilterCon = useListViewFilterContext(),
37
+ selectedFiltersCount = _useListViewFilterCon.selectedFiltersCount,
38
+ setListViewSelectedFilters = _useListViewFilterCon.setListViewSelectedFilters;
39
+ var handleClearButtonClick = function handleClearButtonClick() {
40
+ onClearButtonClick === null || onClearButtonClick === void 0 ? void 0 : onClearButtonClick();
41
+ setListViewSelectedFilters({});
42
+ setFilterChipGroupSelectedFilters([]);
43
+ setClearFilterCallbackTriggerer(function (prev) {
44
+ return prev + 1;
45
+ });
46
+ };
47
+ return /*#__PURE__*/jsx(FilterChipGroupProvider, {
48
+ value: {
49
+ filterChipGroupSelectedFilters: filterChipGroupSelectedFilters,
50
+ setFilterChipGroupSelectedFilters: setFilterChipGroupSelectedFilters,
51
+ clearFilterCallbackTriggerer: clearFilterCallbackTriggerer,
52
+ setClearFilterCallbackTriggerer: setClearFilterCallbackTriggerer
53
+ },
54
+ children: /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({}, metaAttribute({
55
+ name: MetaConstants.FilterChipGroup,
56
+ testID: testID
57
+ })), makeAnalyticsAttribute(rest)), {}, {
58
+ display: "flex",
59
+ padding: "spacing.4",
60
+ alignItems: "center",
61
+ justifyContent: "flex-start",
62
+ width: "100%",
63
+ gap: "spacing.3",
64
+ flexWrap: "wrap",
65
+ children: [children, showClearButton && (filterChipGroupSelectedFilters.length > 0 || selectedFiltersCount > 0) ? /*#__PURE__*/jsx(Link, {
66
+ onClick: handleClearButtonClick,
67
+ children: "Clear Filter".concat(filterChipGroupSelectedFilters.length > 1 || selectedFiltersCount > 1 ? 's' : '')
68
+ }) : null]
69
+ }))
70
+ });
71
+ };
72
+
73
+ export { FilterChipGroup };
74
+ //# sourceMappingURL=FilterChipGroup.web.js.map
@@ -0,0 +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 handleClearButtonClick = (): void => {\n onClearButtonClick?.();\n setListViewSelectedFilters({});\n setFilterChipGroupSelectedFilters([]);\n setClearFilterCallbackTriggerer((prev) => prev + 1);\n };\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\"\n alignItems=\"center\"\n justifyContent=\"flex-start\"\n width=\"100%\"\n gap=\"spacing.3\"\n flexWrap=\"wrap\"\n >\n {children}\n {showClearButton &&\n (filterChipGroupSelectedFilters.length > 0 || selectedFiltersCount > 0) ? (\n <Link onClick={handleClearButtonClick}>{`Clear Filter${\n filterChipGroupSelectedFilters.length > 1 || selectedFiltersCount > 1 ? 's' : ''\n }`}</Link>\n ) : null}\n </BaseBox>\n </FilterChipGroupProvider>\n );\n};\n\nexport { FilterChipGroup };\n"],"names":["FilterChipGroup","_ref","testID","children","_ref$showClearButton","showClearButton","onClearButtonClick","rest","_objectWithoutProperties","_excluded","_useState","useState","_useState2","_slicedToArray","filterChipGroupSelectedFilters","setFilterChipGroupSelectedFilters","_useState3","_useState4","clearFilterCallbackTriggerer","setClearFilterCallbackTriggerer","_useListViewFilterCon","useListViewFilterContext","selectedFiltersCount","setListViewSelectedFilters","handleClearButtonClick","prev","_jsx","FilterChipGroupProvider","value","_jsxs","BaseBox","_objectSpread","metaAttribute","name","MetaConstants","makeAnalyticsAttribute","display","padding","alignItems","justifyContent","width","gap","flexWrap","length","Link","onClick","concat"],"mappings":";;;;;;;;;;;;;;;;;;;;AASA,IAAMA,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAM2B;AAAA,EAAA,IAL9CC,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,CAAlB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A4B,EAA5BA,4BAA4B;AAC5BC,MAAAA,+BAA+B,EAA/BA,+BAAAA;KACA;AAAAhB,IAAAA,QAAA,eAEF0B,IAAA,CAACC,OAAO,EAAAC,aAAA,CAAAA,aAAA,CAAAA,aAAA,CACFC,EAAAA,EAAAA,aAAa,CAAC;MAAEC,IAAI,EAAEC,aAAa,CAAClC,eAAe;AAAEE,MAAAA,MAAM,EAANA,MAAAA;AAAO,KAAC,CAAC,CAAA,EAC9DiC,sBAAsB,CAAC5B,IAAI,CAAC,CAAA,EAAA,EAAA,EAAA;AAChC6B,MAAAA,OAAO,EAAC,MAAM;AACdC,MAAAA,OAAO,EAAC,WAAW;AACnBC,MAAAA,UAAU,EAAC,QAAQ;AACnBC,MAAAA,cAAc,EAAC,YAAY;AAC3BC,MAAAA,KAAK,EAAC,MAAM;AACZC,MAAAA,GAAG,EAAC,WAAW;AACfC,MAAAA,QAAQ,EAAC,MAAM;AAAAvC,MAAAA,QAAA,GAEdA,QAAQ,EACRE,eAAe,KACfS,8BAA8B,CAAC6B,MAAM,GAAG,CAAC,IAAIrB,oBAAoB,GAAG,CAAC,CAAC,gBACrEI,GAAA,CAACkB,IAAI,EAAA;AAACC,QAAAA,OAAO,EAAErB,sBAAuB;AAAArB,QAAAA,QAAA,EAAA2C,cAAAA,CAAAA,MAAA,CACpChC,8BAA8B,CAAC6B,MAAM,GAAG,CAAC,IAAIrB,oBAAoB,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA;OACzE,CAAC,GACR,IAAI,CAAA;KACD,CAAA,CAAA;AAAC,GACa,CAAC,CAAA;AAE9B;;;;"}
@@ -0,0 +1,18 @@
1
+ import React__default from 'react';
2
+
3
+ var FilterChipGroupContext = /*#__PURE__*/React__default.createContext({
4
+ filterChipGroupSelectedFilters: [],
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
6
+ setFilterChipGroupSelectedFilters: function setFilterChipGroupSelectedFilters() {},
7
+ clearFilterCallbackTriggerer: 0,
8
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
9
+ setClearFilterCallbackTriggerer: function setClearFilterCallbackTriggerer() {}
10
+ });
11
+ var FilterChipGroupProvider = FilterChipGroupContext.Provider;
12
+ var useFilterChipGroupContext = function useFilterChipGroupContext() {
13
+ var context = React__default.useContext(FilterChipGroupContext);
14
+ return context;
15
+ };
16
+
17
+ export { FilterChipGroupProvider, useFilterChipGroupContext };
18
+ //# sourceMappingURL=FilterChipGroupContext.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterChipGroupContext.web.js","sources":["../../../../../../src/components/Dropdown/FilterChipGroupContext.web.tsx"],"sourcesContent":["import React from 'react';\nimport type { FilterChipGroupContextType } from './types';\n\nconst FilterChipGroupContext = React.createContext<FilterChipGroupContextType>({\n filterChipGroupSelectedFilters: [],\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n setFilterChipGroupSelectedFilters: () => {},\n clearFilterCallbackTriggerer: 0,\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n setClearFilterCallbackTriggerer: () => {},\n});\nconst FilterChipGroupProvider = FilterChipGroupContext.Provider;\n\nconst useFilterChipGroupContext = (): FilterChipGroupContextType => {\n const context = React.useContext(FilterChipGroupContext);\n return context;\n};\n\nexport { useFilterChipGroupContext, FilterChipGroupProvider };\n"],"names":["FilterChipGroupContext","React","createContext","filterChipGroupSelectedFilters","setFilterChipGroupSelectedFilters","clearFilterCallbackTriggerer","setClearFilterCallbackTriggerer","FilterChipGroupProvider","Provider","useFilterChipGroupContext","context","useContext"],"mappings":";;AAGA,IAAMA,sBAAsB,gBAAGC,cAAK,CAACC,aAAa,CAA6B;AAC7EC,EAAAA,8BAA8B,EAAE,EAAE;AAClC;AACAC,EAAAA,iCAAiC,EAAE,SAAAA,iCAAA,GAAM,EAAE;AAC3CC,EAAAA,4BAA4B,EAAE,CAAC;AAC/B;AACAC,EAAAA,+BAA+B,EAAE,SAAAA,+BAAA,GAAM,EAAC;AAC1C,CAAC,CAAC,CAAA;AACF,IAAMC,uBAAuB,GAAGP,sBAAsB,CAACQ,SAAQ;AAE/D,IAAMC,yBAAyB,GAAG,SAA5BA,yBAAyBA,GAAqC;AAClE,EAAA,IAAMC,OAAO,GAAGT,cAAK,CAACU,UAAU,CAACX,sBAAsB,CAAC,CAAA;AACxD,EAAA,OAAOU,OAAO,CAAA;AAChB;;;;"}
@@ -0,0 +1,217 @@
1
+ import _typeof from '@babel/runtime/helpers/typeof';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
+ import React__default, { useEffect } from 'react';
7
+ import { useDropdown } from './useDropdown.js';
8
+ import { dropdownComponentIds } from './dropdownComponentIds.js';
9
+ import { useFilterChipGroupContext } from './FilterChipGroupContext.web.js';
10
+ import '../../utils/assignWithoutSideEffects/index.js';
11
+ import { BaseFilterChip } from '../FilterChip/BaseFilterChip.web.js';
12
+ import { getActionListContainerRole } from '../ActionList/getA11yRoles.js';
13
+ import { useId } from '../../utils/useId.js';
14
+ import { useListViewFilterContext } from '../ListView/ListViewFiltersContext.web.js';
15
+ import { useFirstRender } from '../../utils/useFirstRender.js';
16
+ import { jsx } from 'react/jsx-runtime';
17
+ import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
18
+
19
+ var _excluded = ["onClick", "onBlur", "onKeyDown", "accessibilityLabel", "testID", "value", "onClearButtonClick", "label", "onChange", "name"];
20
+ 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
+ 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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
23
+ 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
+ var _FilterChipSelectInput = function _FilterChipSelectInput(props) {
25
+ var idBase = useId('filter-chip-select-input');
26
+ var _onClick = props.onClick,
27
+ _onBlur = props.onBlur,
28
+ _onKeyDown = props.onKeyDown,
29
+ accessibilityLabel = props.accessibilityLabel,
30
+ testID = props.testID,
31
+ value = props.value,
32
+ onClearButtonClick = props.onClearButtonClick,
33
+ label = props.label,
34
+ onChange = props.onChange,
35
+ name = props.name,
36
+ rest = _objectWithoutProperties(props, _excluded);
37
+ var _React$useState = React__default.useState([]),
38
+ _React$useState2 = _slicedToArray(_React$useState, 2),
39
+ uncontrolledInputValue = _React$useState2[0],
40
+ setUncontrolledInputValue = _React$useState2[1];
41
+ var isFirstRender = useFirstRender();
42
+ var _useDropdown = useDropdown(),
43
+ options = _useDropdown.options,
44
+ selectedIndices = _useDropdown.selectedIndices,
45
+ onTriggerClick = _useDropdown.onTriggerClick,
46
+ onTriggerKeydown = _useDropdown.onTriggerKeydown,
47
+ dropdownBaseId = _useDropdown.dropdownBaseId,
48
+ isOpen = _useDropdown.isOpen,
49
+ activeIndex = _useDropdown.activeIndex,
50
+ hasFooterAction = _useDropdown.hasFooterAction,
51
+ triggererRef = _useDropdown.triggererRef,
52
+ selectionType = _useDropdown.selectionType,
53
+ isControlled = _useDropdown.isControlled,
54
+ setHasUnControlledFilterChipSelectInput = _useDropdown.setHasUnControlledFilterChipSelectInput,
55
+ setSelectedIndices = _useDropdown.setSelectedIndices,
56
+ controlledValueIndices = _useDropdown.controlledValueIndices,
57
+ changeCallbackTriggerer = _useDropdown.changeCallbackTriggerer;
58
+ var isUnControlled = options.length > 0 && props.value === undefined;
59
+ // Currently we are having 2 context for selectedFilters. One is for FilterChipGroup and other is for ListView
60
+ var _useListViewFilterCon = useListViewFilterContext(),
61
+ listViewSelectedFilters = _useListViewFilterCon.listViewSelectedFilters,
62
+ setListViewSelectedFilters = _useListViewFilterCon.setListViewSelectedFilters;
63
+ var _useFilterChipGroupCo = useFilterChipGroupContext(),
64
+ clearFilterCallbackTriggerer = _useFilterChipGroupCo.clearFilterCallbackTriggerer,
65
+ setFilterChipGroupSelectedFilters = _useFilterChipGroupCo.setFilterChipGroupSelectedFilters;
66
+ var getValuesArrayFromIndices = function getValuesArrayFromIndices() {
67
+ var indices = [];
68
+ if (isControlled) {
69
+ indices = controlledValueIndices;
70
+ } else {
71
+ indices = selectedIndices;
72
+ }
73
+ return indices.map(function (selectionIndex) {
74
+ return options[selectionIndex].value;
75
+ });
76
+ };
77
+ useEffect(function () {
78
+ if (isUnControlled) {
79
+ setHasUnControlledFilterChipSelectInput(true);
80
+ if (listViewSelectedFilters[label]) {
81
+ var _value = listViewSelectedFilters[label];
82
+ setSelectedIndices(_value);
83
+ var inputValue = _value.map(function (selectionIndex) {
84
+ return options[selectionIndex].value;
85
+ });
86
+ setUncontrolledInputValue(inputValue);
87
+ setFilterChipGroupSelectedFilters(function (prev) {
88
+ return prev.includes(label) ? prev : [].concat(_toConsumableArray(prev), [label]);
89
+ });
90
+ }
91
+ } else if (listViewSelectedFilters[label]) {
92
+ var _value2 = listViewSelectedFilters[label];
93
+ setSelectedIndices(_value2);
94
+ }
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
+ }, [isUnControlled]);
97
+ var getTitleFromValue = function getTitleFromValue(value) {
98
+ var option = options.find(function (option) {
99
+ return option.value === value;
100
+ });
101
+ return option ? option.title : '';
102
+ };
103
+ var getUnControlledFilterChipValue = function getUnControlledFilterChipValue() {
104
+ if (selectionType === 'single') {
105
+ if (uncontrolledInputValue.length > 0) {
106
+ return getTitleFromValue(uncontrolledInputValue[0]);
107
+ }
108
+ return '';
109
+ }
110
+ return uncontrolledInputValue;
111
+ };
112
+ var handleClearButtonClick = function handleClearButtonClick() {
113
+ var _props$onClearButtonC, _props$onChange;
114
+ (_props$onClearButtonC = props.onClearButtonClick) === null || _props$onClearButtonC === void 0 ? void 0 : _props$onClearButtonC.call(props, {
115
+ name: name !== null && name !== void 0 ? name : idBase,
116
+ values: getValuesArrayFromIndices()
117
+ });
118
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
119
+ name: name !== null && name !== void 0 ? name : idBase,
120
+ values: []
121
+ });
122
+ if (isUnControlled) {
123
+ setUncontrolledInputValue([]);
124
+ setSelectedIndices([]);
125
+ }
126
+ setFilterChipGroupSelectedFilters(function (prev) {
127
+ return prev.filter(function (filter) {
128
+ return filter !== label;
129
+ });
130
+ });
131
+ setListViewSelectedFilters(function (prev) {
132
+ var _ = prev[label],
133
+ updatedFilters = _objectWithoutProperties(prev, [label].map(_toPropertyKey));
134
+ return updatedFilters;
135
+ });
136
+ };
137
+ useEffect(function () {
138
+ if (clearFilterCallbackTriggerer) {
139
+ handleClearButtonClick();
140
+ }
141
+ // eslint-disable-next-line react-hooks/exhaustive-deps
142
+ }, [clearFilterCallbackTriggerer]);
143
+ useEffect(function () {
144
+ if (!isFirstRender) {
145
+ var _props$onChange2;
146
+ (_props$onChange2 = props.onChange) === null || _props$onChange2 === void 0 ? void 0 : _props$onChange2.call(props, {
147
+ name: props.name || idBase,
148
+ values: getValuesArrayFromIndices()
149
+ });
150
+ if (isUnControlled) {
151
+ setUncontrolledInputValue(getValuesArrayFromIndices());
152
+ }
153
+ }
154
+ // eslint-disable-next-line react-hooks/exhaustive-deps
155
+ }, [changeCallbackTriggerer]);
156
+ useEffect(function () {
157
+ var isValueEmpty = selectedIndices.length === 0;
158
+ if (!isFirstRender && !isValueEmpty) {
159
+ setFilterChipGroupSelectedFilters(function (prev) {
160
+ return prev.includes(label) ? prev : [].concat(_toConsumableArray(prev), [label]);
161
+ });
162
+ setListViewSelectedFilters(function (prev) {
163
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, label, selectedIndices));
164
+ });
165
+ } else if (!isFirstRender && isValueEmpty) {
166
+ setFilterChipGroupSelectedFilters(function (prev) {
167
+ return prev.filter(function (filter) {
168
+ return filter !== label;
169
+ });
170
+ });
171
+ setListViewSelectedFilters(function (prev) {
172
+ var _ = prev[label],
173
+ updatedFilters = _objectWithoutProperties(prev, [label].map(_toPropertyKey));
174
+ return updatedFilters;
175
+ });
176
+ }
177
+ // eslint-disable-next-line react-hooks/exhaustive-deps
178
+ }, [changeCallbackTriggerer]);
179
+ return /*#__PURE__*/jsx(BaseFilterChip, _objectSpread(_objectSpread({
180
+ label: label,
181
+ value: value !== null && value !== void 0 ? value : getUnControlledFilterChipValue(),
182
+ onClearButtonClick: handleClearButtonClick,
183
+ selectionType: selectionType
184
+ }, rest), {}, {
185
+ ref: triggererRef,
186
+ accessibilityProps: {
187
+ label: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : label,
188
+ hasPopup: getActionListContainerRole(hasFooterAction, 'FilterChipSelectInput'),
189
+ expanded: isOpen,
190
+ controls: "".concat(dropdownBaseId, "-actionlist"),
191
+ activeDescendant: activeIndex >= 0 ? "".concat(dropdownBaseId, "-").concat(activeIndex) : undefined
192
+ },
193
+ onClick: function onClick(e) {
194
+ onTriggerClick();
195
+ // Setting it for web fails it on native typecheck and vice versa
196
+ _onClick === null || _onClick === void 0 ? void 0 : _onClick(e);
197
+ },
198
+ onBlur: function onBlur(e) {
199
+ // With button trigger, there is no "value" as such. It's just clickable items
200
+ // Setting it for web fails it on native typecheck and vice versa
201
+ _onBlur === null || _onBlur === void 0 ? void 0 : _onBlur(e);
202
+ },
203
+ onKeyDown: function onKeyDown(e) {
204
+ onTriggerKeydown === null || onTriggerKeydown === void 0 ? void 0 : onTriggerKeydown({
205
+ event: e
206
+ });
207
+ // Setting it for web fails it on native typecheck and vice versa
208
+ _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(e);
209
+ }
210
+ }));
211
+ };
212
+ var FilterChipSelectInput = /*#__PURE__*/assignWithoutSideEffects(_FilterChipSelectInput, {
213
+ componentId: dropdownComponentIds.triggers.FilterChipSelectInput
214
+ });
215
+
216
+ export { FilterChipSelectInput };
217
+ //# sourceMappingURL=FilterChipSelectInput.web.js.map