@chayns-components/core 5.2.5 → 5.2.8

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 (55) hide show
  1. package/lib/cjs/components/combobox/ComboBox.constants.js +15 -0
  2. package/lib/cjs/components/combobox/ComboBox.constants.js.map +1 -0
  3. package/lib/cjs/components/combobox/ComboBox.js +27 -76
  4. package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
  5. package/lib/cjs/components/combobox/ComboBox.styles.js +16 -11
  6. package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
  7. package/lib/cjs/components/combobox/ComboBox.types.js +24 -0
  8. package/lib/cjs/components/combobox/ComboBox.types.js.map +1 -1
  9. package/lib/cjs/components/combobox/ComboBox.utils.js +88 -0
  10. package/lib/cjs/components/combobox/ComboBox.utils.js.map +1 -0
  11. package/lib/cjs/components/filter/filter-content/FilterContent.constants.js +8 -0
  12. package/lib/cjs/components/filter/filter-content/FilterContent.constants.js.map +1 -0
  13. package/lib/cjs/components/filter/filter-content/FilterContent.js +6 -27
  14. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  15. package/lib/cjs/components/filter/filter-content/FilterContent.styles.js +10 -24
  16. package/lib/cjs/components/filter/filter-content/FilterContent.styles.js.map +1 -1
  17. package/lib/cjs/components/filter/filter-content/FilterContent.types.js +6 -0
  18. package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -0
  19. package/lib/cjs/components/filter/filter-content/FilterContent.utils.js +17 -0
  20. package/lib/cjs/components/filter/filter-content/FilterContent.utils.js.map +1 -0
  21. package/lib/cjs/types/filter.js +24 -0
  22. package/lib/cjs/types/filter.js.map +1 -1
  23. package/lib/esm/components/combobox/ComboBox.constants.js +9 -0
  24. package/lib/esm/components/combobox/ComboBox.constants.js.map +1 -0
  25. package/lib/esm/components/combobox/ComboBox.js +27 -75
  26. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  27. package/lib/esm/components/combobox/ComboBox.styles.js +16 -11
  28. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  29. package/lib/esm/components/combobox/ComboBox.types.js +29 -0
  30. package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
  31. package/lib/esm/components/combobox/ComboBox.utils.js +81 -0
  32. package/lib/esm/components/combobox/ComboBox.utils.js.map +1 -0
  33. package/lib/esm/components/filter/filter-content/FilterContent.constants.js +2 -0
  34. package/lib/esm/components/filter/filter-content/FilterContent.constants.js.map +1 -0
  35. package/lib/esm/components/filter/filter-content/FilterContent.js +8 -29
  36. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  37. package/lib/esm/components/filter/filter-content/FilterContent.styles.js +9 -23
  38. package/lib/esm/components/filter/filter-content/FilterContent.styles.js.map +1 -1
  39. package/lib/esm/components/filter/filter-content/FilterContent.types.js +2 -0
  40. package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -0
  41. package/lib/esm/components/filter/filter-content/FilterContent.utils.js +10 -0
  42. package/lib/esm/components/filter/filter-content/FilterContent.utils.js.map +1 -0
  43. package/lib/esm/types/filter.js +31 -0
  44. package/lib/esm/types/filter.js.map +1 -1
  45. package/lib/types/components/combobox/ComboBox.constants.d.ts +8 -0
  46. package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -8
  47. package/lib/types/components/combobox/ComboBox.types.d.ts +102 -0
  48. package/lib/types/components/combobox/ComboBox.utils.d.ts +23 -0
  49. package/lib/types/components/filter/filter-content/FilterContent.constants.d.ts +1 -0
  50. package/lib/types/components/filter/filter-content/FilterContent.d.ts +1 -9
  51. package/lib/types/components/filter/filter-content/FilterContent.styles.d.ts +3 -14
  52. package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +30 -0
  53. package/lib/types/components/filter/filter-content/FilterContent.utils.d.ts +3 -0
  54. package/lib/types/types/filter.d.ts +51 -0
  55. package/package.json +2 -2
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getComboBoxWidthResult = void 0;
7
+ var _calculate = require("../../utils/calculate");
8
+ var _ComboBox = require("./ComboBox.constants");
9
+ const getPrefixWidth = (prefix, prefixMinWidth, functions, values) => {
10
+ if (!prefix) {
11
+ return 0;
12
+ }
13
+ const prefixTextWidth = (0, _calculate.calculateMaxComboBoxItemWidth)({
14
+ list: [{
15
+ text: prefix,
16
+ value: 'prefix'
17
+ }],
18
+ functions,
19
+ values
20
+ });
21
+ return Math.max(prefixTextWidth + _ComboBox.COMBO_BOX_PREFIX_GAP_PX, prefixMinWidth ?? _ComboBox.COMBO_BOX_PREFIX_MIN_WIDTH_PX);
22
+ };
23
+ const clampToParentWidth = (width, parentWidth) => parentWidth > 0 ? Math.min(width, parentWidth) : width;
24
+ const getComboBoxWidthResult = ({
25
+ functions,
26
+ internalSelectedItem,
27
+ lists,
28
+ parentWidth,
29
+ placeholder,
30
+ prefix,
31
+ prefixMinWidth,
32
+ selectedItem,
33
+ shouldDropDownUseMaxItemWidth,
34
+ shouldShowBigImage,
35
+ shouldShowClearIcon,
36
+ shouldUseCurrentItemWidth,
37
+ shouldUseFullWidth,
38
+ values
39
+ }) => {
40
+ const allItems = lists.flatMap(list => list.list);
41
+ const effectiveSelectedItem = selectedItem ?? internalSelectedItem;
42
+ const maxItemWidth = (0, _calculate.calculateMaxComboBoxItemWidth)({
43
+ list: [...allItems, {
44
+ text: placeholder,
45
+ value: 'placeholder'
46
+ }, ...(effectiveSelectedItem ? [effectiveSelectedItem] : [])],
47
+ functions,
48
+ shouldShowBigImage,
49
+ values
50
+ });
51
+ const prefixWidth = getPrefixWidth(prefix, prefixMinWidth, functions, values);
52
+ const triggerWidthBase = maxItemWidth + _ComboBox.COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX + _ComboBox.COMBO_BOX_HEADER_BORDER_WIDTH_PX + _ComboBox.COMBO_BOX_ACTION_ICON_WIDTH_PX + (shouldShowClearIcon ? _ComboBox.COMBO_BOX_CLEAR_ICON_WIDTH_PX : 0) + _ComboBox.COMBO_BOX_ROUNDING_BUFFER_PX + prefixWidth;
53
+ const desiredBodyMinWidth = maxItemWidth + _ComboBox.COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX;
54
+ if (shouldDropDownUseMaxItemWidth) {
55
+ const width = clampToParentWidth(desiredBodyMinWidth, parentWidth);
56
+ return {
57
+ minWidth: width,
58
+ bodyMinWidth: width
59
+ };
60
+ }
61
+ if (shouldUseFullWidth) {
62
+ const width = clampToParentWidth(parentWidth, parentWidth);
63
+ return {
64
+ minWidth: width,
65
+ bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth)
66
+ };
67
+ }
68
+ if (shouldUseCurrentItemWidth && effectiveSelectedItem) {
69
+ const selectedItemWidth = (0, _calculate.calculateMaxComboBoxItemWidth)({
70
+ list: [effectiveSelectedItem],
71
+ functions,
72
+ shouldShowBigImage,
73
+ values
74
+ });
75
+ const width = clampToParentWidth(selectedItemWidth + _ComboBox.COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX + _ComboBox.COMBO_BOX_HEADER_BORDER_WIDTH_PX + _ComboBox.COMBO_BOX_ACTION_ICON_WIDTH_PX + (shouldShowClearIcon ? _ComboBox.COMBO_BOX_CLEAR_ICON_WIDTH_PX : 0) + _ComboBox.COMBO_BOX_ROUNDING_BUFFER_PX + prefixWidth, parentWidth);
76
+ return {
77
+ minWidth: width,
78
+ bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth)
79
+ };
80
+ }
81
+ const width = clampToParentWidth(triggerWidthBase, parentWidth);
82
+ return {
83
+ minWidth: width,
84
+ bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth)
85
+ };
86
+ };
87
+ exports.getComboBoxWidthResult = getComboBoxWidthResult;
88
+ //# sourceMappingURL=ComboBox.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboBox.utils.js","names":["_calculate","require","_ComboBox","getPrefixWidth","prefix","prefixMinWidth","functions","values","prefixTextWidth","calculateMaxComboBoxItemWidth","list","text","value","Math","max","COMBO_BOX_PREFIX_GAP_PX","COMBO_BOX_PREFIX_MIN_WIDTH_PX","clampToParentWidth","width","parentWidth","min","getComboBoxWidthResult","internalSelectedItem","lists","placeholder","selectedItem","shouldDropDownUseMaxItemWidth","shouldShowBigImage","shouldShowClearIcon","shouldUseCurrentItemWidth","shouldUseFullWidth","allItems","flatMap","effectiveSelectedItem","maxItemWidth","prefixWidth","triggerWidthBase","COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX","COMBO_BOX_HEADER_BORDER_WIDTH_PX","COMBO_BOX_ACTION_ICON_WIDTH_PX","COMBO_BOX_CLEAR_ICON_WIDTH_PX","COMBO_BOX_ROUNDING_BUFFER_PX","desiredBodyMinWidth","COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX","minWidth","bodyMinWidth","selectedItemWidth","exports"],"sources":["../../../../src/components/combobox/ComboBox.utils.ts"],"sourcesContent":["import type { ChaynsReactFunctions, ChaynsReactValues } from 'chayns-api';\nimport { calculateMaxComboBoxItemWidth } from '../../utils/calculate';\nimport type { IComboBoxItem, IComboBoxItems } from './ComboBox.types';\nimport {\n COMBO_BOX_ACTION_ICON_WIDTH_PX,\n COMBO_BOX_CLEAR_ICON_WIDTH_PX,\n COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX,\n COMBO_BOX_PREFIX_GAP_PX,\n COMBO_BOX_PREFIX_MIN_WIDTH_PX,\n COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX,\n COMBO_BOX_HEADER_BORDER_WIDTH_PX,\n COMBO_BOX_ROUNDING_BUFFER_PX,\n} from './ComboBox.constants';\n\nexport type ComboBoxWidthOptions = {\n functions: ChaynsReactFunctions;\n internalSelectedItem?: IComboBoxItem;\n lists: IComboBoxItems[];\n parentWidth: number;\n placeholder: string;\n prefix?: string;\n prefixMinWidth?: number;\n selectedItem?: IComboBoxItem;\n shouldDropDownUseMaxItemWidth?: boolean;\n shouldShowBigImage?: boolean;\n shouldShowClearIcon?: boolean;\n shouldUseCurrentItemWidth?: boolean;\n shouldUseFullWidth?: boolean;\n values: ChaynsReactValues;\n};\n\nexport type ComboBoxWidthResult = {\n minWidth?: number;\n bodyMinWidth: number;\n};\n\nconst getPrefixWidth = (\n prefix: ComboBoxWidthOptions['prefix'],\n prefixMinWidth: ComboBoxWidthOptions['prefixMinWidth'],\n functions: ChaynsReactFunctions,\n values: ChaynsReactValues,\n) => {\n if (!prefix) {\n return 0;\n }\n\n const prefixTextWidth = calculateMaxComboBoxItemWidth({\n list: [{ text: prefix, value: 'prefix' }],\n functions,\n values,\n });\n\n return Math.max(\n prefixTextWidth + COMBO_BOX_PREFIX_GAP_PX,\n prefixMinWidth ?? COMBO_BOX_PREFIX_MIN_WIDTH_PX,\n );\n};\n\nconst clampToParentWidth = (width: number, parentWidth: number) =>\n parentWidth > 0 ? Math.min(width, parentWidth) : width;\n\nexport const getComboBoxWidthResult = ({\n functions,\n internalSelectedItem,\n lists,\n parentWidth,\n placeholder,\n prefix,\n prefixMinWidth,\n selectedItem,\n shouldDropDownUseMaxItemWidth,\n shouldShowBigImage,\n shouldShowClearIcon,\n shouldUseCurrentItemWidth,\n shouldUseFullWidth,\n values,\n}: ComboBoxWidthOptions): ComboBoxWidthResult => {\n const allItems = lists.flatMap((list) => list.list);\n const effectiveSelectedItem = selectedItem ?? internalSelectedItem;\n\n const maxItemWidth = calculateMaxComboBoxItemWidth({\n list: [\n ...allItems,\n { text: placeholder, value: 'placeholder' },\n ...(effectiveSelectedItem ? [effectiveSelectedItem] : []),\n ],\n functions,\n shouldShowBigImage,\n values,\n });\n\n const prefixWidth = getPrefixWidth(prefix, prefixMinWidth, functions, values);\n const triggerWidthBase =\n maxItemWidth +\n COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX +\n COMBO_BOX_HEADER_BORDER_WIDTH_PX +\n COMBO_BOX_ACTION_ICON_WIDTH_PX +\n (shouldShowClearIcon ? COMBO_BOX_CLEAR_ICON_WIDTH_PX : 0) +\n COMBO_BOX_ROUNDING_BUFFER_PX +\n prefixWidth;\n\n const desiredBodyMinWidth = maxItemWidth + COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX;\n\n if (shouldDropDownUseMaxItemWidth) {\n const width = clampToParentWidth(desiredBodyMinWidth, parentWidth);\n\n return {\n minWidth: width,\n bodyMinWidth: width,\n };\n }\n\n if (shouldUseFullWidth) {\n const width = clampToParentWidth(parentWidth, parentWidth);\n\n return {\n minWidth: width,\n bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth),\n };\n }\n\n if (shouldUseCurrentItemWidth && effectiveSelectedItem) {\n const selectedItemWidth = calculateMaxComboBoxItemWidth({\n list: [effectiveSelectedItem],\n functions,\n shouldShowBigImage,\n values,\n });\n\n const width = clampToParentWidth(\n selectedItemWidth +\n COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX +\n COMBO_BOX_HEADER_BORDER_WIDTH_PX +\n COMBO_BOX_ACTION_ICON_WIDTH_PX +\n (shouldShowClearIcon ? COMBO_BOX_CLEAR_ICON_WIDTH_PX : 0) +\n COMBO_BOX_ROUNDING_BUFFER_PX +\n prefixWidth,\n parentWidth,\n );\n\n return {\n minWidth: width,\n bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth),\n };\n }\n\n const width = clampToParentWidth(triggerWidthBase, parentWidth);\n\n return {\n minWidth: width,\n bodyMinWidth: clampToParentWidth(Math.max(desiredBodyMinWidth, width), parentWidth),\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAiCA,MAAME,cAAc,GAAGA,CACnBC,MAAsC,EACtCC,cAAsD,EACtDC,SAA+B,EAC/BC,MAAyB,KACxB;EACD,IAAI,CAACH,MAAM,EAAE;IACT,OAAO,CAAC;EACZ;EAEA,MAAM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EAE/D,OAAO;IACHyB,QAAQ,EAAE1B,KAAK;IACf2B,YAAY,EAAE5B,kBAAkB,CAACJ,IAAI,CAACC,GAAG,CAAC4B,mBAAmB,EAAExB,KAAK,CAAC,EAAEC,WAAW;EACtF,CAAC;AACL,CAAC;AAAC4B,OAAA,CAAA1B,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FILTER_CONTENT_ROW_GAP_PX = void 0;
7
+ const FILTER_CONTENT_ROW_GAP_PX = exports.FILTER_CONTENT_ROW_GAP_PX = 10;
8
+ //# sourceMappingURL=FilterContent.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.constants.js","names":["FILTER_CONTENT_ROW_GAP_PX","exports"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.constants.ts"],"sourcesContent":["export const FILTER_CONTENT_ROW_GAP_PX = 10;\n"],"mappings":";;;;;;AAAO,MAAMA,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,EAAE","ignoreList":[]}
@@ -13,9 +13,9 @@ var _ComboBox = _interopRequireDefault(require("../../combobox/ComboBox"));
13
13
  var _Checkbox = _interopRequireDefault(require("../../checkbox/Checkbox"));
14
14
  var _textstring = require("@chayns-components/textstring");
15
15
  var _textStrings = _interopRequireDefault(require("../../../constants/textStrings"));
16
+ var _FilterContent2 = require("./FilterContent.utils");
16
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
19
19
  const FilterContent = ({
20
20
  searchConfig,
21
21
  sortConfig,
@@ -24,9 +24,7 @@ const FilterContent = ({
24
24
  comboboxConfig,
25
25
  shouldAutoFocus
26
26
  }) => {
27
- const sortTextRef = (0, _react.useRef)(null);
28
27
  const searchRef = (0, _react.useRef)(null);
29
- const [sortTextWidth, setSortTextWidth] = (0, _react.useState)(0);
30
28
  const ts = _textStrings.default.components.filter.filterContent;
31
29
  const handleSelectSortItem = (0, _react.useCallback)(item => {
32
30
  if (!item) {
@@ -43,11 +41,6 @@ const FilterContent = ({
43
41
  });
44
42
  }
45
43
  }, [sortConfig]);
46
- (0, _react.useEffect)(() => {
47
- if (sortTextRef.current) {
48
- setSortTextWidth(sortTextRef.current.clientWidth + 20);
49
- }
50
- }, []);
51
44
  (0, _react.useEffect)(() => {
52
45
  if (shouldAutoFocus) {
53
46
  var _searchRef$current;
@@ -67,34 +60,20 @@ const FilterContent = ({
67
60
  leftElement: /*#__PURE__*/_react.default.createElement(_Icon.default, {
68
61
  icons: ['fa fa-search']
69
62
  })
70
- }), filterButtonConfig && /*#__PURE__*/_react.default.createElement(_FilterButtons.default, filterButtonConfig), sortConfig && /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterSort, null, /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterSortText, {
71
- ref: sortTextRef
72
- }, /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
63
+ }), filterButtonConfig && /*#__PURE__*/_react.default.createElement(_FilterButtons.default, filterButtonConfig), sortConfig && /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentLabeledRow, null, /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentLabel, null, /*#__PURE__*/_react.default.createElement(_textstring.Textstring, {
73
64
  textstring: (0, _textstring.ttsToITextString)(ts.sort)
74
- })), /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterComboboxWrapper, {
75
- $textWidth: sortTextWidth
76
- }, /*#__PURE__*/_react.default.createElement(_ComboBox.default, {
77
- lists: [{
78
- list: sortConfig.items.map(({
79
- text,
80
- id
81
- }) => ({
82
- text,
83
- value: id
84
- }))
85
- }],
65
+ })), /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentControlWrapper, null, /*#__PURE__*/_react.default.createElement(_ComboBox.default, {
66
+ lists: (0, _FilterContent2.getSortComboBoxLists)(sortConfig),
86
67
  placeholder: "",
87
68
  selectedItem: {
88
69
  text: sortConfig.selectedItem.text,
89
70
  value: sortConfig.selectedItem.id
90
71
  },
91
72
  onSelect: handleSelectSortItem
92
- }))), comboboxConfig && /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterComboboxInline, null, /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterComboboxInlineLabel, null, comboboxConfig.label), /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterComboboxInlineComboboxWrapper, null, /*#__PURE__*/_react.default.createElement(_ComboBox.default, _extends({
93
- shouldUseCurrentItemWidth: true
94
- }, comboboxConfig)))), checkboxConfig &&
73
+ }))), comboboxConfig && /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentLabeledRow, null, /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentLabel, null, comboboxConfig.label), /*#__PURE__*/_react.default.createElement(_FilterContent.StyledFilterContentControlWrapper, null, /*#__PURE__*/_react.default.createElement(_ComboBox.default, comboboxConfig))), checkboxConfig &&
95
74
  /*#__PURE__*/
96
75
  // eslint-disable-next-line react/jsx-props-no-spreading
97
- _react.default.createElement(_Checkbox.default, checkboxConfig))), [checkboxConfig, comboboxConfig, filterButtonConfig, handleSelectSortItem, searchConfig, sortConfig, sortTextWidth, ts.input.placeholder, ts.sort]);
76
+ _react.default.createElement(_Checkbox.default, checkboxConfig))), [checkboxConfig, comboboxConfig, filterButtonConfig, handleSelectSortItem, searchConfig, sortConfig, ts.input.placeholder, ts.sort]);
98
77
  };
99
78
  FilterContent.displayName = 'FilterContent';
100
79
  var _default = exports.default = FilterContent;
@@ -1 +1 @@
1
- {"version":3,"file":"FilterContent.js","names":["_react","_interopRequireWildcard","require","_FilterContent","_Input","_interopRequireDefault","_Icon","_FilterButtons","_ComboBox","_Checkbox","_textstring","_textStrings","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","FilterContent","searchConfig","sortConfig","filterButtonConfig","checkboxConfig","comboboxConfig","shouldAutoFocus","sortTextRef","useRef","searchRef","sortTextWidth","setSortTextWidth","useState","ts","textStrings","components","filter","filterContent","handleSelectSortItem","useCallback","item","text","value","onSortChange","id","useEffect","current","clientWidth","_searchRef$current","focus","useMemo","createElement","TextstringProvider","libraryName","StyledFilterContent","ref","onChange","ev","onSearchChange","target","placeholder","Textstring","textstring","ttsToITextString","input","searchValue","shouldShowClearIcon","leftElement","icons","StyledFilterSort","StyledFilterSortText","sort","StyledFilterComboboxWrapper","$textWidth","lists","list","items","map","selectedItem","onSelect","StyledFilterComboboxInline","StyledFilterComboboxInlineLabel","label","StyledFilterComboboxInlineComboboxWrapper","shouldUseCurrentItemWidth","displayName","_default","exports"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n StyledFilterComboboxInline,\n StyledFilterComboboxInlineComboboxWrapper,\n StyledFilterComboboxInlineLabel,\n StyledFilterComboboxWrapper,\n StyledFilterContent,\n StyledFilterSort,\n StyledFilterSortText,\n} from './FilterContent.styles';\nimport Input, { InputRef } from '../../input/Input';\nimport Icon from '../../icon/Icon';\nimport FilterButtons from '../../filter-buttons/FilterButtons';\nimport {\n CheckboxConfig,\n ComboboxConfig,\n FilterButtonConfig,\n SearchConfig,\n SortConfig,\n} from '../../../types/filter';\nimport ComboBox from '../../combobox/ComboBox';\nimport Checkbox from '../../checkbox/Checkbox';\nimport { IComboBoxItem } from '../../combobox/ComboBox.types';\nimport { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport textStrings from '../../../constants/textStrings';\n\nexport type FilterContentProps = {\n searchConfig?: SearchConfig;\n filterButtonConfig?: FilterButtonConfig;\n sortConfig?: SortConfig;\n checkboxConfig?: CheckboxConfig;\n comboboxConfig?: ComboboxConfig;\n shouldAutoFocus: boolean;\n};\n\nconst FilterContent: FC<FilterContentProps> = ({\n searchConfig,\n sortConfig,\n filterButtonConfig,\n checkboxConfig,\n comboboxConfig,\n shouldAutoFocus,\n}) => {\n const sortTextRef = useRef<HTMLDivElement>(null);\n const searchRef = useRef<InputRef>(null);\n\n const [sortTextWidth, setSortTextWidth] = useState(0);\n\n const ts = textStrings.components.filter.filterContent;\n\n const handleSelectSortItem = useCallback(\n (item: IComboBoxItem | undefined) => {\n if (!item) {\n return;\n }\n\n const { text, value } = item;\n\n if (sortConfig) {\n sortConfig.onSortChange({ text, id: value });\n }\n },\n [sortConfig],\n );\n\n useEffect(() => {\n if (sortTextRef.current) {\n setSortTextWidth(sortTextRef.current.clientWidth + 20);\n }\n }, []);\n\n useEffect(() => {\n if (shouldAutoFocus) {\n searchRef.current?.focus();\n }\n }, [shouldAutoFocus]);\n\n return useMemo(\n () => (\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledFilterContent>\n {searchConfig && (\n <Input\n ref={searchRef}\n onChange={(ev) => searchConfig.onSearchChange(ev.target.value)}\n placeholder={\n <Textstring textstring={ttsToITextString(ts.input.placeholder)} />\n }\n value={searchConfig.searchValue}\n shouldShowClearIcon={searchConfig.searchValue.length > 0}\n leftElement={<Icon icons={['fa fa-search']} />}\n />\n )}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {filterButtonConfig && <FilterButtons {...filterButtonConfig} />}\n {sortConfig && (\n <StyledFilterSort>\n <StyledFilterSortText ref={sortTextRef}>\n <Textstring textstring={ttsToITextString(ts.sort)} />\n </StyledFilterSortText>\n <StyledFilterComboboxWrapper $textWidth={sortTextWidth}>\n <ComboBox\n lists={[\n {\n list: sortConfig.items.map(({ text, id }) => ({\n text,\n value: id,\n })),\n },\n ]}\n placeholder=\"\"\n selectedItem={{\n text: sortConfig.selectedItem.text,\n value: sortConfig.selectedItem.id,\n }}\n onSelect={handleSelectSortItem}\n />\n </StyledFilterComboboxWrapper>\n </StyledFilterSort>\n )}\n {comboboxConfig && (\n <StyledFilterComboboxInline>\n <StyledFilterComboboxInlineLabel>\n {comboboxConfig.label}\n </StyledFilterComboboxInlineLabel>\n <StyledFilterComboboxInlineComboboxWrapper>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <ComboBox shouldUseCurrentItemWidth {...comboboxConfig} />\n </StyledFilterComboboxInlineComboboxWrapper>\n </StyledFilterComboboxInline>\n )}\n {checkboxConfig && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <Checkbox {...checkboxConfig} />\n )}\n </StyledFilterContent>\n </TextstringProvider>\n ),\n [\n checkboxConfig,\n comboboxConfig,\n filterButtonConfig,\n handleSelectSortItem,\n searchConfig,\n sortConfig,\n sortTextWidth,\n ts.input.placeholder,\n ts.sort,\n ],\n );\n};\n\nFilterContent.displayName = 'FilterContent';\n\nexport default FilterContent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AASA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,cAAA,GAAAF,sBAAA,CAAAH,OAAA;AAQA,IAAAM,SA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AAsD,aAAA,CAAC5D,SAAA,CAAAM,OAAQ,EAAAiB,QAAA;IAACsE,yBAAyB;EAAA,GAAK3D,cAAc,CAAG,CAClB,CACnB,CAC/B,EACAD,cAAc;EAAA;EACX;EACAzC,MAAA,CAAAc,OAAA,CAAAsD,aAAA,CAAC3D,SAAA,CAAAK,OAAQ,EAAK2B,cAAiB,CAElB,CACL,CACvB,EACD,CACIA,cAAc,EACdC,cAAc,EACdF,kBAAkB,EAClBe,oBAAoB,EACpBjB,YAAY,EACZC,UAAU,EACVQ,aAAa,EACbG,EAAE,CAAC+B,KAAK,CAACJ,WAAW,EACpB3B,EAAE,CAACsC,IAAI,CAEf,CAAC;AACL,CAAC;AAEDnD,aAAa,CAACiE,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1F,OAAA,GAE7BuB,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"FilterContent.js","names":["_react","_interopRequireWildcard","require","_FilterContent","_Input","_interopRequireDefault","_Icon","_FilterButtons","_ComboBox","_Checkbox","_textstring","_textStrings","_FilterContent2","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FilterContent","searchConfig","sortConfig","filterButtonConfig","checkboxConfig","comboboxConfig","shouldAutoFocus","searchRef","useRef","ts","textStrings","components","filter","filterContent","handleSelectSortItem","useCallback","item","text","value","onSortChange","id","useEffect","_searchRef$current","current","focus","useMemo","createElement","TextstringProvider","libraryName","StyledFilterContent","ref","onChange","ev","onSearchChange","target","placeholder","Textstring","textstring","ttsToITextString","input","searchValue","shouldShowClearIcon","length","leftElement","icons","StyledFilterContentLabeledRow","StyledFilterContentLabel","sort","StyledFilterContentControlWrapper","lists","getSortComboBoxLists","selectedItem","onSelect","label","displayName","_default","exports"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef } from 'react';\nimport {\n StyledFilterContentControlWrapper,\n StyledFilterContentLabel,\n StyledFilterContentLabeledRow,\n StyledFilterContent,\n} from './FilterContent.styles';\nimport Input, { InputRef } from '../../input/Input';\nimport Icon from '../../icon/Icon';\nimport FilterButtons from '../../filter-buttons/FilterButtons';\nimport ComboBox from '../../combobox/ComboBox';\nimport Checkbox from '../../checkbox/Checkbox';\nimport { Textstring, TextstringProvider, ttsToITextString } from '@chayns-components/textstring';\nimport textStrings from '../../../constants/textStrings';\nimport type { IComboBoxItem } from '../../combobox/ComboBox.types';\nimport type { FilterContentProps } from './FilterContent.types';\nimport { getSortComboBoxLists } from './FilterContent.utils';\n\nconst FilterContent: FC<FilterContentProps> = ({\n searchConfig,\n sortConfig,\n filterButtonConfig,\n checkboxConfig,\n comboboxConfig,\n shouldAutoFocus,\n}) => {\n const searchRef = useRef<InputRef>(null);\n\n const ts = textStrings.components.filter.filterContent;\n\n const handleSelectSortItem = useCallback(\n (item: IComboBoxItem | undefined) => {\n if (!item) {\n return;\n }\n\n const { text, value } = item;\n\n if (sortConfig) {\n sortConfig.onSortChange({ text, id: value });\n }\n },\n [sortConfig],\n );\n\n useEffect(() => {\n if (shouldAutoFocus) {\n searchRef.current?.focus();\n }\n }, [shouldAutoFocus]);\n\n return useMemo(\n () => (\n <TextstringProvider libraryName=\"@chayns-components-core\">\n <StyledFilterContent>\n {searchConfig && (\n <Input\n ref={searchRef}\n onChange={(ev) => searchConfig.onSearchChange(ev.target.value)}\n placeholder={\n <Textstring textstring={ttsToITextString(ts.input.placeholder)} />\n }\n value={searchConfig.searchValue}\n shouldShowClearIcon={searchConfig.searchValue.length > 0}\n leftElement={<Icon icons={['fa fa-search']} />}\n />\n )}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {filterButtonConfig && <FilterButtons {...filterButtonConfig} />}\n {sortConfig && (\n <StyledFilterContentLabeledRow>\n <StyledFilterContentLabel>\n <Textstring textstring={ttsToITextString(ts.sort)} />\n </StyledFilterContentLabel>\n <StyledFilterContentControlWrapper>\n <ComboBox\n lists={getSortComboBoxLists(sortConfig)}\n placeholder=\"\"\n selectedItem={{\n text: sortConfig.selectedItem.text,\n value: sortConfig.selectedItem.id,\n }}\n onSelect={handleSelectSortItem}\n />\n </StyledFilterContentControlWrapper>\n </StyledFilterContentLabeledRow>\n )}\n {comboboxConfig && (\n <StyledFilterContentLabeledRow>\n <StyledFilterContentLabel>\n {comboboxConfig.label}\n </StyledFilterContentLabel>\n <StyledFilterContentControlWrapper>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <ComboBox {...comboboxConfig} />\n </StyledFilterContentControlWrapper>\n </StyledFilterContentLabeledRow>\n )}\n {checkboxConfig && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <Checkbox {...checkboxConfig} />\n )}\n </StyledFilterContent>\n </TextstringProvider>\n ),\n [\n checkboxConfig,\n comboboxConfig,\n filterButtonConfig,\n handleSelectSortItem,\n searchConfig,\n sortConfig,\n ts.input.placeholder,\n ts.sort,\n ],\n );\n};\n\nFilterContent.displayName = 'FilterContent';\n\nexport default FilterContent;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAMA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,cAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,SAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,SAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAN,sBAAA,CAAAH,OAAA;AAGA,IAAAU,eAAA,GAAAV,OAAA;AAA6D,SAAAG,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAZ,wB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AAA,CAAAe,OAAA,CAAA2C,aAAA,CAAClD,SAAA,CAAAO,OAAQ,EAAKsB,cAAiB,CACA,CACR,CAClC,EACAD,cAAc;EAAA;EACX;EACApC,MAAA,CAAAe,OAAA,CAAA2C,aAAA,CAACjD,SAAA,CAAAM,OAAQ,EAAKqB,cAAiB,CAElB,CACL,CACvB,EACD,CACIA,cAAc,EACdC,cAAc,EACdF,kBAAkB,EAClBW,oBAAoB,EACpBb,YAAY,EACZC,UAAU,EACVO,EAAE,CAAC8B,KAAK,CAACJ,WAAW,EACpB1B,EAAE,CAACsC,IAAI,CAEf,CAAC;AACL,CAAC;AAED/C,aAAa,CAACsD,WAAW,GAAG,eAAe;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzE,OAAA,GAE7BiB,aAAa","ignoreList":[]}
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledFilterSortText = exports.StyledFilterSort = exports.StyledFilterContent = exports.StyledFilterComboboxWrapper = exports.StyledFilterComboboxInlineLabel = exports.StyledFilterComboboxInlineComboboxWrapper = exports.StyledFilterComboboxInline = void 0;
6
+ exports.StyledFilterContentLabeledRow = exports.StyledFilterContentLabel = exports.StyledFilterContentControlWrapper = exports.StyledFilterContent = void 0;
7
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _FilterContent = require("./FilterContent.constants");
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
10
  const StyledFilterContent = exports.StyledFilterContent = _styledComponents.default.div`
10
11
  background-color: ${({
@@ -17,36 +18,21 @@ const StyledFilterContent = exports.StyledFilterContent = _styledComponents.defa
17
18
  flex-direction: column;
18
19
  gap: 10px;
19
20
  `;
20
- const StyledFilterSort = exports.StyledFilterSort = _styledComponents.default.div`
21
+ const StyledFilterContentLabeledRow = exports.StyledFilterContentLabeledRow = _styledComponents.default.div`
21
22
  display: flex;
22
23
  align-items: center;
23
- justify-content: space-between;
24
- gap: 10px;
25
- `;
26
- const StyledFilterSortText = exports.StyledFilterSortText = _styledComponents.default.div`
27
- flex: 0 0 auto;
28
- `;
29
- const StyledFilterComboboxWrapper = exports.StyledFilterComboboxWrapper = _styledComponents.default.div`
30
- display: flex;
31
- justify-content: end;
32
-
33
- width: ${({
34
- $textWidth
35
- }) => `calc(100% - ${$textWidth}px)`}}
36
- `;
37
- const StyledFilterComboboxInline = exports.StyledFilterComboboxInline = _styledComponents.default.div`
38
- display: flex;
39
- justify-content: space-between;
40
- align-items: center;
41
- gap: 10px;
24
+ gap: ${_FilterContent.FILTER_CONTENT_ROW_GAP_PX}px;
25
+ width: 100%;
26
+ min-width: 0;
42
27
  `;
43
- const StyledFilterComboboxInlineLabel = exports.StyledFilterComboboxInlineLabel = _styledComponents.default.div`
28
+ const StyledFilterContentLabel = exports.StyledFilterContentLabel = _styledComponents.default.div`
44
29
  flex: 0 0 auto;
30
+ white-space: nowrap;
45
31
  `;
46
- const StyledFilterComboboxInlineComboboxWrapper = exports.StyledFilterComboboxInlineComboboxWrapper = _styledComponents.default.div`
32
+ const StyledFilterContentControlWrapper = exports.StyledFilterContentControlWrapper = _styledComponents.default.div`
47
33
  display: flex;
48
- justify-content: end;
49
34
  flex: 1 1 auto;
50
35
  min-width: 0;
36
+ justify-content: flex-end;
51
37
  `;
52
38
  //# sourceMappingURL=FilterContent.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterContent.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledFilterContent","exports","styled","div","theme","StyledFilterSort","StyledFilterSortText","StyledFilterComboboxWrapper","$textWidth","StyledFilterComboboxInline","StyledFilterComboboxInlineLabel","StyledFilterComboboxInlineComboboxWrapper"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledFilterContentProps = WithTheme<unknown>;\n\nexport const StyledFilterContent = styled.div<StyledFilterContentProps>`\n background-color: ${({ theme }) => theme['100']};\n\n padding: 12px;\n\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\nexport const StyledFilterSort = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n`;\n\nexport const StyledFilterSortText = styled.div`\n flex: 0 0 auto;\n`;\n\ntype StyledFilterComboboxWrapperProps = WithTheme<{\n $textWidth: number;\n}>;\n\nexport const StyledFilterComboboxWrapper = styled.div<StyledFilterComboboxWrapperProps>`\n display: flex;\n justify-content: end;\n \n width: ${({ $textWidth }) => `calc(100% - ${$textWidth}px)`}}\n`;\n\nexport const StyledFilterComboboxInline = styled.div`\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 10px;\n`;\n\nexport const StyledFilterComboboxInlineLabel = styled.div`\n flex: 0 0 auto;\n`;\n\nexport const StyledFilterComboboxInlineComboboxWrapper = styled.div`\n display: flex;\n justify-content: end;\n flex: 1 1 auto;\n min-width: 0;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKhC,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,yBAAM,CAACC,GAA6B;AACvE,wBAAwB,CAAC;EAAEC;AAAM,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,gBAAgB,GAAAJ,OAAA,CAAAI,gBAAA,GAAGH,yBAAM,CAACC,GAAG;AAC1C;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMG,oBAAoB,GAAAL,OAAA,CAAAK,oBAAA,GAAGJ,yBAAM,CAACC,GAAG;AAC9C;AACA,CAAC;AAMM,MAAMI,2BAA2B,GAAAN,OAAA,CAAAM,2BAAA,GAAGL,yBAAM,CAACC,GAAqC;AACvF;AACA;AACA;AACA,aAAa,CAAC;EAAEK;AAAW,CAAC,KAAK,eAAeA,UAAU,KAAK;AAC/D,CAAC;AAEM,MAAMC,0BAA0B,GAAAR,OAAA,CAAAQ,0BAAA,GAAGP,yBAAM,CAACC,GAAG;AACpD;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMO,+BAA+B,GAAAT,OAAA,CAAAS,+BAAA,GAAGR,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC;AAEM,MAAMQ,yCAAyC,GAAAV,OAAA,CAAAU,yCAAA,GAAGT,yBAAM,CAACC,GAAG;AACnE;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"FilterContent.styles.js","names":["_styledComponents","_interopRequireDefault","require","_FilterContent","e","__esModule","default","StyledFilterContent","exports","styled","div","theme","StyledFilterContentLabeledRow","FILTER_CONTENT_ROW_GAP_PX","StyledFilterContentLabel","StyledFilterContentControlWrapper"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\nimport { FILTER_CONTENT_ROW_GAP_PX } from './FilterContent.constants';\n\ntype StyledFilterContentProps = WithTheme<unknown>;\n\nexport const StyledFilterContent = styled.div<StyledFilterContentProps>`\n background-color: ${({ theme }) => theme['100']};\n\n padding: 12px;\n\n display: flex;\n flex-direction: column;\n gap: 10px;\n`;\n\nexport const StyledFilterContentLabeledRow = styled.div`\n display: flex;\n align-items: center;\n gap: ${FILTER_CONTENT_ROW_GAP_PX}px;\n width: 100%;\n min-width: 0;\n`;\n\nexport const StyledFilterContentLabel = styled.div`\n flex: 0 0 auto;\n white-space: nowrap;\n`;\n\nexport const StyledFilterContentControlWrapper = styled.div`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n justify-content: flex-end;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAAsE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI/D,MAAMG,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAGE,yBAAM,CAACC,GAA6B;AACvE,wBAAwB,CAAC;EAAEC;AAAM,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,6BAA6B,GAAAJ,OAAA,CAAAI,6BAAA,GAAGH,yBAAM,CAACC,GAAG;AACvD;AACA;AACA,WAAWG,wCAAyB;AACpC;AACA;AACA,CAAC;AAEM,MAAMC,wBAAwB,GAAAN,OAAA,CAAAM,wBAAA,GAAGL,yBAAM,CAACC,GAAG;AAClD;AACA;AACA,CAAC;AAEM,MAAMK,iCAAiC,GAAAP,OAAA,CAAAO,iCAAA,GAAGN,yBAAM,CAACC,GAAG;AAC3D;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=FilterContent.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.types.js","names":[],"sources":["../../../../../src/components/filter/filter-content/FilterContent.types.ts"],"sourcesContent":["import type {\n CheckboxConfig,\n ComboboxConfig,\n FilterButtonConfig,\n SearchConfig,\n SortConfig,\n} from '../../../types/filter';\n\n/**\n * Props for the `FilterContent` component.\n */\nexport type FilterContentProps = {\n /**\n * Search configuration for the optional search input.\n */\n searchConfig?: SearchConfig;\n /**\n * Configuration for the optional filter button group.\n */\n filterButtonConfig?: FilterButtonConfig;\n /**\n * Configuration for the optional sort combobox.\n */\n sortConfig?: SortConfig;\n /**\n * Configuration for the optional checkbox.\n */\n checkboxConfig?: CheckboxConfig;\n /**\n * Configuration for the optional labeled combobox.\n */\n comboboxConfig?: ComboboxConfig;\n /**\n * Whether the search input should receive focus when the filter opens.\n */\n shouldAutoFocus: boolean;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSortComboBoxLists = void 0;
7
+ const getSortComboBoxLists = sortConfig => [{
8
+ list: sortConfig.items.map(({
9
+ text,
10
+ id
11
+ }) => ({
12
+ text,
13
+ value: id
14
+ }))
15
+ }];
16
+ exports.getSortComboBoxLists = getSortComboBoxLists;
17
+ //# sourceMappingURL=FilterContent.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterContent.utils.js","names":["getSortComboBoxLists","sortConfig","list","items","map","text","id","value","exports"],"sources":["../../../../../src/components/filter/filter-content/FilterContent.utils.ts"],"sourcesContent":["import type { IComboBoxItems } from '../../combobox/ComboBox.types';\nimport type { SortConfig } from '../../../types/filter';\n\nexport const getSortComboBoxLists = (sortConfig: SortConfig): IComboBoxItems[] => [\n {\n list: sortConfig.items.map(({ text, id }) => ({\n text,\n value: id,\n })),\n },\n];\n"],"mappings":";;;;;;AAGO,MAAMA,oBAAoB,GAAIC,UAAsB,IAAuB,CAC9E;EACIC,IAAI,EAAED,UAAU,CAACE,KAAK,CAACC,GAAG,CAAC,CAAC;IAAEC,IAAI;IAAEC;EAAG,CAAC,MAAM;IAC1CD,IAAI;IACJE,KAAK,EAAED;EACX,CAAC,CAAC;AACN,CAAC,CACJ;AAACE,OAAA,CAAAR,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -4,6 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.FilterType = void 0;
7
+ /**
8
+ * Search configuration for the `Filter` component.
9
+ */
10
+ /**
11
+ * Item configuration used by the sort dropdown.
12
+ */
13
+ /**
14
+ * Sort configuration for the `Filter` component.
15
+ */
16
+ /**
17
+ * Checkbox configuration for the `Filter` component.
18
+ */
19
+ /**
20
+ * Filter button group configuration for the `Filter` component.
21
+ */
22
+ /**
23
+ * Combobox configuration used by `FilterContent`.
24
+ */
25
+ /**
26
+ * Ref interface for the `Filter` component.
27
+ */
28
+ /**
29
+ * Different layout modes supported by the `Filter` component.
30
+ */
7
31
  let FilterType = exports.FilterType = /*#__PURE__*/function (FilterType) {
8
32
  FilterType[FilterType["ONLY_SEARCH"] = 0] = "ONLY_SEARCH";
9
33
  FilterType[FilterType["ONLY_FILTER"] = 1] = "ONLY_FILTER";
@@ -1 +1 @@
1
- {"version":3,"file":"filter.js","names":["FilterType","exports"],"sources":["../../../src/types/filter.ts"],"sourcesContent":["import { FilterButtonsProps } from '../components/filter-buttons/FilterButtons';\nimport { CheckboxProps } from '../components/checkbox/Checkbox';\nimport { ComboBoxProps } from '../components/combobox/ComboBox.types';\n\nexport interface SearchConfig {\n onSearchChange: (search: string) => void;\n searchValue: string;\n}\n\nexport interface SortItem {\n text: string;\n id: string | number;\n}\n\nexport interface SortConfig {\n onSortChange: (item: SortItem) => void;\n selectedItem: SortItem;\n items: SortItem[];\n}\n\nexport type CheckboxConfig = CheckboxProps;\n\nexport type FilterButtonConfig = FilterButtonsProps;\n\nexport type ComboboxConfig = ComboBoxProps & { label: string };\n\nexport type FilterRef = {\n hide: VoidFunction;\n show: VoidFunction;\n};\n\nexport enum FilterType {\n ONLY_SEARCH,\n ONLY_FILTER,\n ONLY_SORT,\n ONLY_CHECKBOX,\n ONLY_COMBOBOX,\n MULTIPLE,\n}\n"],"mappings":";;;;;;IA+BYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"filter.js","names":["FilterType","exports"],"sources":["../../../src/types/filter.ts"],"sourcesContent":["import { FilterButtonsProps } from '../components/filter-buttons/FilterButtons';\nimport { CheckboxProps } from '../components/checkbox/Checkbox';\nimport { ComboBoxProps } from '../components/combobox/ComboBox.types';\n\n/**\n * Search configuration for the `Filter` component.\n */\nexport interface SearchConfig {\n /**\n * Callback invoked whenever the search input changes.\n */\n onSearchChange: (search: string) => void;\n /**\n * Current search value.\n */\n searchValue: string;\n}\n\n/**\n * Item configuration used by the sort dropdown.\n */\nexport interface SortItem {\n /**\n * Display text of the item.\n */\n text: string;\n /**\n * Stable value or identifier of the item.\n */\n id: string | number;\n}\n\n/**\n * Sort configuration for the `Filter` component.\n */\nexport interface SortConfig {\n /**\n * Callback invoked when a sort item is selected.\n */\n onSortChange: (item: SortItem) => void;\n /**\n * Currently selected sort item.\n */\n selectedItem: SortItem;\n /**\n * Available sort items.\n */\n items: SortItem[];\n}\n\n/**\n * Checkbox configuration for the `Filter` component.\n */\nexport type CheckboxConfig = CheckboxProps;\n\n/**\n * Filter button group configuration for the `Filter` component.\n */\nexport type FilterButtonConfig = FilterButtonsProps;\n\n/**\n * Combobox configuration used by `FilterContent`.\n */\nexport type ComboboxConfig = ComboBoxProps & { label: string };\n\n/**\n * Ref interface for the `Filter` component.\n */\nexport type FilterRef = {\n /**\n * Hides the filter popup.\n */\n hide: VoidFunction;\n /**\n * Shows the filter popup.\n */\n show: VoidFunction;\n};\n\n/**\n * Different layout modes supported by the `Filter` component.\n */\nexport enum FilterType {\n ONLY_SEARCH,\n ONLY_FILTER,\n ONLY_SORT,\n ONLY_CHECKBOX,\n ONLY_COMBOBOX,\n MULTIPLE,\n}\n"],"mappings":";;;;;;AAIA;AACA;AACA;AAYA;AACA;AACA;AAYA;AACA;AACA;AAgBA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAYA;AACA;AACA;AAFA,IAGYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ export const COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX = 20;
2
+ export const COMBO_BOX_HEADER_BORDER_WIDTH_PX = 2;
3
+ export const COMBO_BOX_ACTION_ICON_WIDTH_PX = 40;
4
+ export const COMBO_BOX_CLEAR_ICON_WIDTH_PX = 40;
5
+ export const COMBO_BOX_ROUNDING_BUFFER_PX = 1;
6
+ export const COMBO_BOX_PREFIX_GAP_PX = 5;
7
+ export const COMBO_BOX_PREFIX_MIN_WIDTH_PX = 32;
8
+ export const COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX = COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX + COMBO_BOX_HEADER_BORDER_WIDTH_PX + COMBO_BOX_ROUNDING_BUFFER_PX;
9
+ //# sourceMappingURL=ComboBox.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboBox.constants.js","names":["COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX","COMBO_BOX_HEADER_BORDER_WIDTH_PX","COMBO_BOX_ACTION_ICON_WIDTH_PX","COMBO_BOX_CLEAR_ICON_WIDTH_PX","COMBO_BOX_ROUNDING_BUFFER_PX","COMBO_BOX_PREFIX_GAP_PX","COMBO_BOX_PREFIX_MIN_WIDTH_PX","COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX"],"sources":["../../../../src/components/combobox/ComboBox.constants.ts"],"sourcesContent":["export const COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX = 20;\nexport const COMBO_BOX_HEADER_BORDER_WIDTH_PX = 2;\nexport const COMBO_BOX_ACTION_ICON_WIDTH_PX = 40;\nexport const COMBO_BOX_CLEAR_ICON_WIDTH_PX = 40;\nexport const COMBO_BOX_ROUNDING_BUFFER_PX = 1;\n\nexport const COMBO_BOX_PREFIX_GAP_PX = 5;\nexport const COMBO_BOX_PREFIX_MIN_WIDTH_PX = 32;\n\nexport const COMBO_BOX_DROPDOWN_HORIZONTAL_PADDING_PX =\n COMBO_BOX_HEADER_HORIZONTAL_PADDING_PX +\n COMBO_BOX_HEADER_BORDER_WIDTH_PX +\n COMBO_BOX_ROUNDING_BUFFER_PX;\n"],"mappings":"AAAA,OAAO,MAAMA,sCAAsC,GAAG,EAAE;AACxD,OAAO,MAAMC,gCAAgC,GAAG,CAAC;AACjD,OAAO,MAAMC,8BAA8B,GAAG,EAAE;AAChD,OAAO,MAAMC,6BAA6B,GAAG,EAAE;AAC/C,OAAO,MAAMC,4BAA4B,GAAG,CAAC;AAE7C,OAAO,MAAMC,uBAAuB,GAAG,CAAC;AACxC,OAAO,MAAMC,6BAA6B,GAAG,EAAE;AAE/C,OAAO,MAAMC,wCAAwC,GACjDP,sCAAsC,GACtCC,gCAAgC,GAChCG,4BAA4B","ignoreList":[]}
@@ -1,6 +1,5 @@
1
1
  import { useFunctions, useValues } from 'chayns-api';
2
2
  import React, { forwardRef, Fragment, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
- import { calculateMaxComboBoxItemWidth } from '../../utils/calculate';
4
3
  import { useIsTouch } from '../../utils/environment';
5
4
  import { AreaContext } from '../area-provider/AreaContextProvider';
6
5
  import Icon from '../icon/Icon';
@@ -10,6 +9,7 @@ import DropdownBodyWrapper from '../dropdown-body-wrapper/DropdownBodyWrapper';
10
9
  import { DropdownDirection } from '../../types/dropdown';
11
10
  import { useElementSize } from '../../hooks/element';
12
11
  import { ComboBoxSize } from './ComboBox.types';
12
+ import { getComboBoxWidthResult } from './ComboBox.utils';
13
13
  const ComboBox = /*#__PURE__*/forwardRef(({
14
14
  bodyWidth,
15
15
  direction = DropdownDirection.RIGHT,
@@ -54,10 +54,31 @@ const ComboBox = /*#__PURE__*/forwardRef(({
54
54
  const isTouch = useIsTouch();
55
55
  const areaProvider = useContext(AreaContext);
56
56
  useEffect(() => {
57
- if (shouldUseFullWidth && parentSize) {
58
- setMinWidth(parentSize.width);
57
+ if (!parentSize) {
58
+ return;
59
59
  }
60
- }, [parentSize, shouldUseFullWidth]);
60
+ const {
61
+ minWidth: calculatedMinWidth,
62
+ bodyMinWidth: calculatedBodyMinWidth
63
+ } = getComboBoxWidthResult({
64
+ functions,
65
+ internalSelectedItem,
66
+ lists,
67
+ parentWidth: parentSize.width,
68
+ placeholder,
69
+ prefix,
70
+ prefixMinWidth,
71
+ selectedItem,
72
+ shouldDropDownUseMaxItemWidth,
73
+ shouldShowBigImage,
74
+ shouldShowClearIcon,
75
+ shouldUseCurrentItemWidth,
76
+ shouldUseFullWidth,
77
+ values
78
+ });
79
+ setMinWidth(calculatedMinWidth);
80
+ setBodyMinWidth(calculatedBodyMinWidth);
81
+ }, [functions, internalSelectedItem, lists, parentSize, placeholder, prefix, prefixMinWidth, selectedItem, shouldDropDownUseMaxItemWidth, shouldShowBigImage, shouldShowClearIcon, shouldUseCurrentItemWidth, shouldUseFullWidth, values]);
61
82
  const shouldChangeColor = useMemo(() => areaProvider.shouldChangeColor ?? false, [areaProvider.shouldChangeColor]);
62
83
  const shouldDisableActions = useMemo(() => {
63
84
  if (!selectedItem) {
@@ -177,73 +198,6 @@ const ComboBox = /*#__PURE__*/forwardRef(({
177
198
  return () => document.removeEventListener('keydown', handleKeyDown);
178
199
  }, [focusedIndex, handleSetSelectedItem, isAnimating, lists]);
179
200
 
180
- /**
181
- * This function calculates the greatest width
182
- */
183
- useEffect(() => {
184
- const allItems = lists.flatMap(list => list.list);
185
- let maxItemWidth = calculateMaxComboBoxItemWidth({
186
- list: [...allItems, {
187
- text: placeholder,
188
- value: 'placeholder'
189
- }, ...(selectedItem ? [selectedItem] : [])],
190
- functions,
191
- shouldShowBigImage,
192
- values
193
- });
194
- if (shouldDropDownUseMaxItemWidth) {
195
- maxItemWidth += 20 + 2 + 1; // 20px padding (left and right), 2px border, 1px puffer for rounding errors
196
-
197
- setBodyMinWidth(maxItemWidth);
198
- setMinWidth(maxItemWidth);
199
- return;
200
- }
201
- const parentWidth = styledComboBoxElementRef.current?.parentElement?.getBoundingClientRect().width ?? 0;
202
- const paddingWidth = 20 + 2 + 40 + (shouldShowClearIcon ? 40 : 0) + 1; // padding + border + arrow icon + optional clear icon + 1px puffer for rounding errors
203
-
204
- let prefixWidth = 0;
205
- if (prefix) {
206
- const prefixTextWidth = calculateMaxComboBoxItemWidth({
207
- list: [{
208
- text: prefix,
209
- value: 'prefix'
210
- }],
211
- functions,
212
- values
213
- });
214
- prefixWidth = Math.max(prefixTextWidth + 5, 32);
215
- }
216
- const calculatedWidth = maxItemWidth + paddingWidth + prefixWidth;
217
- let tmpMinWidth = calculatedWidth;
218
- let tmpBodyMinWidth = calculatedWidth;
219
-
220
- // Full width settings
221
- if (shouldUseFullWidth) {
222
- tmpMinWidth = parentWidth;
223
- tmpBodyMinWidth = parentWidth < calculatedWidth - 20 ? calculatedWidth - 20 : parentWidth;
224
- }
225
- // Current item width settings
226
- else if (shouldUseCurrentItemWidth && internalSelectedItem) {
227
- const internalSelectedItemWidth = calculateMaxComboBoxItemWidth({
228
- list: [internalSelectedItem],
229
- functions,
230
- shouldShowBigImage,
231
- values
232
- });
233
- const itemWidth = internalSelectedItemWidth + paddingWidth + prefixWidth;
234
- tmpMinWidth = itemWidth;
235
- tmpBodyMinWidth = itemWidth < calculatedWidth - 20 ? calculatedWidth - 20 : itemWidth;
236
- }
237
- if (tmpMinWidth > parentWidth) {
238
- tmpMinWidth = parentWidth;
239
- }
240
- if (tmpBodyMinWidth > parentWidth) {
241
- tmpBodyMinWidth = parentWidth;
242
- }
243
- setMinWidth(tmpMinWidth);
244
- setBodyMinWidth(shouldUseCurrentItemWidth ? tmpMinWidth : tmpBodyMinWidth);
245
- }, [functions, internalSelectedItem, lists, placeholder, prefix, selectedItem, shouldDropDownUseMaxItemWidth, shouldShowBigImage, shouldShowClearIcon, shouldUseCurrentItemWidth, shouldUseFullWidth, values]);
246
-
247
201
  /**
248
202
  * This function sets the external selected item
249
203
  */
@@ -320,8 +274,7 @@ const ComboBox = /*#__PURE__*/forwardRef(({
320
274
  return useMemo(() => /*#__PURE__*/React.createElement(StyledComboBox, {
321
275
  ref: styledComboBoxElementRef,
322
276
  $minWidth: minWidth,
323
- $shouldUseFullWidth: shouldUseFullWidth,
324
- $shouldUseCurrentItemWidth: shouldUseCurrentItemWidth
277
+ $shouldUseFullWidth: shouldUseFullWidth
325
278
  }, /*#__PURE__*/React.createElement(StyledComboBoxHeader, {
326
279
  $direction: direction,
327
280
  onClick: handleHeaderClick,
@@ -373,13 +326,12 @@ const ComboBox = /*#__PURE__*/forwardRef(({
373
326
  minBodyWidth: bodyWidth ?? bodyMinWidth,
374
327
  maxHeight: maxHeight
375
328
  }, /*#__PURE__*/React.createElement(StyledComboBoxBody, {
376
- $shouldUseCurrentItemWidth: shouldUseCurrentItemWidth,
377
329
  $maxHeight: maxHeight,
378
330
  $minWidth: bodyWidth ?? bodyMinWidth,
379
331
  className: "chayns-scrollbar",
380
332
  ref: contentRef,
381
333
  tabIndex: 0
382
- }, comboBoxGroups))), [minWidth, shouldUseFullWidth, shouldUseCurrentItemWidth, direction, handleHeaderClick, isAnimating, isTouch, size, shouldShowTransparentBackground, isDisabled, shouldChangeColor, shouldShowBigImage, prefix, prefixMinWidth, selectedItem, internalSelectedItem, placeholderImageUrl, shouldShowRoundPlaceholderImage, placeholderIcon, inputValue, onInputChange, handleInputBlur, handleInputFocus, placeholderText, shouldShowClearIcon, handleClear, shouldDisableActions, bodyWidth, contentHeight, shouldCaptureEvents, handleClose, container, bodyMinWidth, maxHeight, comboBoxGroups]);
334
+ }, comboBoxGroups))), [bodyMinWidth, bodyWidth, comboBoxGroups, container, contentHeight, direction, handleClear, handleClose, handleHeaderClick, handleInputBlur, handleInputFocus, inputValue, internalSelectedItem, isAnimating, isDisabled, isTouch, maxHeight, minWidth, onInputChange, placeholderIcon, placeholderImageUrl, placeholderText, prefix, prefixMinWidth, selectedItem, shouldChangeColor, shouldDisableActions, shouldCaptureEvents, shouldShowBigImage, shouldShowClearIcon, shouldShowRoundPlaceholderImage, shouldShowTransparentBackground, shouldUseFullWidth, size]);
383
335
  });
384
336
  ComboBox.displayName = 'ComboBox';
385
337
  export default ComboBox;