@chayns-components/core 5.2.8-alpha.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/combobox/ComboBox.constants.js +15 -0
- package/lib/cjs/components/combobox/ComboBox.constants.js.map +1 -0
- package/lib/cjs/components/combobox/ComboBox.js +28 -78
- package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
- package/lib/cjs/components/combobox/ComboBox.styles.js +16 -11
- package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
- package/lib/cjs/components/combobox/ComboBox.types.js +24 -0
- package/lib/cjs/components/combobox/ComboBox.types.js.map +1 -1
- package/lib/cjs/components/combobox/ComboBox.utils.js +88 -0
- package/lib/cjs/components/combobox/ComboBox.utils.js.map +1 -0
- package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js +10 -7
- package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
- package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js +10 -4
- package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js.map +1 -1
- package/lib/cjs/components/filter/filter-content/FilterContent.constants.js +8 -0
- package/lib/cjs/components/filter/filter-content/FilterContent.constants.js.map +1 -0
- package/lib/cjs/components/filter/filter-content/FilterContent.js +6 -27
- package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
- package/lib/cjs/components/filter/filter-content/FilterContent.styles.js +10 -24
- package/lib/cjs/components/filter/filter-content/FilterContent.styles.js.map +1 -1
- package/lib/cjs/components/filter/filter-content/FilterContent.types.js +6 -0
- package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -0
- package/lib/cjs/components/filter/filter-content/FilterContent.utils.js +17 -0
- package/lib/cjs/components/filter/filter-content/FilterContent.utils.js.map +1 -0
- package/lib/cjs/components/search-box/SearchBox.js +0 -1
- package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
- package/lib/cjs/components/skeleton/base-skeleton/BaseSkeleton.styles.js +0 -2
- package/lib/cjs/components/skeleton/base-skeleton/BaseSkeleton.styles.js.map +1 -1
- package/lib/cjs/types/filter.js +24 -0
- package/lib/cjs/types/filter.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.constants.js +9 -0
- package/lib/esm/components/combobox/ComboBox.constants.js.map +1 -0
- package/lib/esm/components/combobox/ComboBox.js +28 -77
- package/lib/esm/components/combobox/ComboBox.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.styles.js +16 -11
- package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.types.js +29 -0
- package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
- package/lib/esm/components/combobox/ComboBox.utils.js +81 -0
- package/lib/esm/components/combobox/ComboBox.utils.js.map +1 -0
- package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js +11 -8
- package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
- package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js +10 -4
- package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.js.map +1 -1
- package/lib/esm/components/filter/filter-content/FilterContent.constants.js +2 -0
- package/lib/esm/components/filter/filter-content/FilterContent.constants.js.map +1 -0
- package/lib/esm/components/filter/filter-content/FilterContent.js +8 -29
- package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
- package/lib/esm/components/filter/filter-content/FilterContent.styles.js +9 -23
- package/lib/esm/components/filter/filter-content/FilterContent.styles.js.map +1 -1
- package/lib/esm/components/filter/filter-content/FilterContent.types.js +2 -0
- package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -0
- package/lib/esm/components/filter/filter-content/FilterContent.utils.js +10 -0
- package/lib/esm/components/filter/filter-content/FilterContent.utils.js.map +1 -0
- package/lib/esm/components/search-box/SearchBox.js +0 -1
- package/lib/esm/components/search-box/SearchBox.js.map +1 -1
- package/lib/esm/components/skeleton/base-skeleton/BaseSkeleton.styles.js +0 -2
- package/lib/esm/components/skeleton/base-skeleton/BaseSkeleton.styles.js.map +1 -1
- package/lib/esm/types/filter.js +31 -0
- package/lib/esm/types/filter.js.map +1 -1
- package/lib/types/components/combobox/ComboBox.constants.d.ts +8 -0
- package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -8
- package/lib/types/components/combobox/ComboBox.types.d.ts +102 -0
- package/lib/types/components/combobox/ComboBox.utils.d.ts +23 -0
- package/lib/types/components/dropdown-body-wrapper/DropdownBodyWrapper.d.ts +2 -2
- package/lib/types/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.d.ts +2 -2
- package/lib/types/components/filter/filter-content/FilterContent.constants.d.ts +1 -0
- package/lib/types/components/filter/filter-content/FilterContent.d.ts +1 -9
- package/lib/types/components/filter/filter-content/FilterContent.styles.d.ts +3 -14
- package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +30 -0
- package/lib/types/components/filter/filter-content/FilterContent.utils.d.ts +3 -0
- package/lib/types/types/filter.d.ts +51 -0
- package/package.json +3 -3
|
@@ -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,IA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AAE5B,kBAAkB,CAACJ,IAAI,CAACC,GAAG,CAAC4B,mBAAmB,EAAExB,KAAK,CAAC,EAAEC,WAAW;IACtF,CAAC;EACL;EAEA,MAAMD,KAAK,GAAGD,kBAAkB,CAACmB,gBAAgB,EAAEjB,WAAW,CAAC;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":[]}
|
|
@@ -13,26 +13,26 @@ var _dropdown2 = require("../../hooks/dropdown");
|
|
|
13
13
|
var _container = require("../../hooks/container");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
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); }
|
|
16
|
-
const DropdownBodyWrapper = ({
|
|
16
|
+
const DropdownBodyWrapper = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
17
17
|
anchorElement,
|
|
18
18
|
bodyWidth,
|
|
19
19
|
children,
|
|
20
20
|
container: containerProp,
|
|
21
21
|
contentHeight = 0,
|
|
22
22
|
direction = _dropdown.DropdownDirection.BOTTOM_RIGHT,
|
|
23
|
-
maxHeight
|
|
23
|
+
maxHeight,
|
|
24
24
|
minBodyWidth = 0,
|
|
25
25
|
onClose,
|
|
26
26
|
onOutsideClick,
|
|
27
27
|
onMeasure,
|
|
28
28
|
shouldCaptureEvents = true,
|
|
29
29
|
shouldShowDropdown
|
|
30
|
-
}) => {
|
|
30
|
+
}, ref) => {
|
|
31
31
|
const isInChaynsWalletRef = (0, _react.useRef)(false);
|
|
32
32
|
const [measuredContentHeight, setMeasuredContentHeight] = (0, _react.useState)(0);
|
|
33
33
|
const [measuredContentWidth, setMeasuredContentWidth] = (0, _react.useState)(0);
|
|
34
34
|
const [portal, setPortal] = (0, _react.useState)();
|
|
35
|
-
const
|
|
35
|
+
const contentRef = (0, _react.useRef)(null);
|
|
36
36
|
const shouldPreventClickRef = (0, _react.useRef)(false);
|
|
37
37
|
const touchTimeoutRef = (0, _react.useRef)(undefined);
|
|
38
38
|
const container = (0, _container.useContainer)({
|
|
@@ -61,7 +61,7 @@ const DropdownBodyWrapper = ({
|
|
|
61
61
|
* This function closes the body
|
|
62
62
|
*/
|
|
63
63
|
const handleClick = (0, _react.useCallback)(event => {
|
|
64
|
-
if (
|
|
64
|
+
if (contentRef.current && shouldShowDropdown && !anchorElement.contains(event.target) && !contentRef.current.contains(event.target)) {
|
|
65
65
|
event.preventDefault();
|
|
66
66
|
event.stopPropagation();
|
|
67
67
|
const shouldPreventCloseOnClick = (onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick()) ?? false;
|
|
@@ -143,11 +143,14 @@ const DropdownBodyWrapper = ({
|
|
|
143
143
|
$minWidth: minBodyWidth,
|
|
144
144
|
$maxHeight: maxHeight,
|
|
145
145
|
$direction: direction,
|
|
146
|
-
ref:
|
|
146
|
+
ref: contentRef,
|
|
147
|
+
className: typeof maxHeight === 'number' ? 'chayns-scrollbar' : undefined,
|
|
148
|
+
tabIndex: 0
|
|
147
149
|
}, children)), container));
|
|
148
150
|
}, [children, container, coordinates, direction, handleContentMeasure, maxHeight, minBodyWidth, shouldShowDropdown, transform, width]);
|
|
151
|
+
(0, _react.useImperativeHandle)(ref, () => contentRef.current, []);
|
|
149
152
|
return /*#__PURE__*/_react.default.createElement(_DropdownBodyWrapper.StyledDropdownBodyWrapper, null, portal);
|
|
150
|
-
};
|
|
153
|
+
});
|
|
151
154
|
DropdownBodyWrapper.displayName = 'DropdownBodyWrapper';
|
|
152
155
|
var _default = exports.default = DropdownBodyWrapper;
|
|
153
156
|
//# sourceMappingURL=DropdownBodyWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownBodyWrapper.js","names":["_react","_interopRequireWildcard","require","_DropdownBodyWrapper","_reactDom","_dropdown","_DelayedDropdownContent","_interopRequireDefault","_dropdown2","_container","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DropdownBodyWrapper","anchorElement","bodyWidth","children","container","containerProp","contentHeight","direction","DropdownDirection","BOTTOM_RIGHT","maxHeight","minBodyWidth","onClose","onOutsideClick","onMeasure","shouldCaptureEvents","shouldShowDropdown","isInChaynsWalletRef","useRef","measuredContentHeight","setMeasuredContentHeight","useState","measuredContentWidth","setMeasuredContentWidth","portal","setPortal","ref","shouldPreventClickRef","touchTimeoutRef","undefined","useContainer","transform","width","coordinates","useDropdown","contentWidth","handleClose","useCallback","handleClick","event","current","contains","target","preventDefault","stopPropagation","shouldPreventCloseOnClick","handleContentMeasure","measurements","height","handleTouchEnd","clearTimeout","handleTouchStart","window","setTimeout","useDropdownListener","onClick","onTouchEnd","onTouchStart","useEffect","isBottomDirection","BOTTOM","BOTTOM_LEFT","includes","reservationWrapperElement","closest","ContainerAnchor","RESERVATION_WRAPPER","availableHeight","innerHeight","getBoundingClientRect","bottom","additionalNeededSpace","style","marginBottom","createPortal","createElement","shouldShowContent","StyledDropdownBodyWrapperContent","$width","$minWidth","$maxHeight","$direction","StyledDropdownBodyWrapper","displayName","_default","exports"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.tsx"],"sourcesContent":["import React, { FC, ReactNode, ReactPortal, useCallback, useEffect, useRef, useState } from 'react';\nimport {\n StyledDropdownBodyWrapper,\n StyledDropdownBodyWrapperContent,\n} from './DropdownBodyWrapper.styles';\nimport { createPortal } from 'react-dom';\nimport { DropdownDirection, DropdownMeasurements } from '../../types/dropdown';\nimport DelayedDropdownContent, {\n DelayedDropdownContentProps,\n} from './delayed-dropdown-content/DelayedDropdownContent';\nimport { useDropdown, useDropdownListener } from '../../hooks/dropdown';\nimport { ContainerAnchor, useContainer } from '../../hooks/container';\n\ninterface DropdownBodyWrapperProps {\n /**\n * The anchor element of the dropdown.\n */\n anchorElement: Element;\n /**\n * The width of the Body.\n */\n bodyWidth?: number;\n /**\n * The content of the dropdown body.\n */\n children: ReactNode;\n /**\n * The element where the content should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The height of the content\n */\n contentHeight?: number;\n /**\n * The direction of the dropdown.\n */\n direction?: DropdownDirection;\n /**\n * The max height of the dropdown.\n */\n maxHeight?: number;\n /**\n * The minimum width of the body.\n */\n minBodyWidth?: number;\n /**\n * Function to be executed when the body is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the user clicks outside the dropdown.\n * If the function returns `true`, the dropdown will not be closed.\n */\n onOutsideClick?: () => boolean | void;\n /**\n * Function to be executed when the content is measured.\n */\n onMeasure?: DelayedDropdownContentProps['onMeasure'];\n /**\n * Whether the dropdown should be visible.\n */\n shouldShowDropdown: boolean;\n /**\n * Whether the outside events should be captured.\n */\n shouldCaptureEvents?: boolean;\n}\n\nconst DropdownBodyWrapper: FC<DropdownBodyWrapperProps> = ({\n anchorElement,\n bodyWidth,\n children,\n container: containerProp,\n contentHeight = 0,\n direction = DropdownDirection.BOTTOM_RIGHT,\n maxHeight = 300,\n minBodyWidth = 0,\n onClose,\n onOutsideClick,\n onMeasure,\n shouldCaptureEvents = true,\n shouldShowDropdown,\n}) => {\n const isInChaynsWalletRef = useRef(false);\n\n const [measuredContentHeight, setMeasuredContentHeight] = useState<number>(0);\n const [measuredContentWidth, setMeasuredContentWidth] = useState<number>(0);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const ref = useRef<HTMLDivElement>(null);\n const shouldPreventClickRef = useRef<boolean>(false);\n const touchTimeoutRef = useRef<number | undefined>(undefined);\n\n const container = useContainer({ anchorElement, container: containerProp });\n\n const { transform, width, coordinates } = useDropdown({\n anchorElement,\n container,\n contentHeight,\n contentWidth: bodyWidth ?? measuredContentWidth,\n direction,\n shouldShowDropdown,\n });\n\n const handleClose = useCallback(() => {\n if (typeof onClose === 'function') {\n onClose();\n }\n }, [onClose]);\n\n /**\n * This function closes the body\n */\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n ref.current &&\n shouldShowDropdown &&\n !anchorElement.contains(event.target as Node) &&\n !ref.current.contains(event.target as Node)\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const shouldPreventCloseOnClick = onOutsideClick?.() ?? false;\n\n if (!shouldPreventClickRef.current && !shouldPreventCloseOnClick) {\n handleClose();\n }\n }\n\n shouldPreventClickRef.current = false;\n },\n [anchorElement, handleClose, onOutsideClick, shouldShowDropdown],\n );\n\n const handleContentMeasure = useCallback(\n (measurements: DropdownMeasurements) => {\n // Measurements are only needed if the content is shown in the chayns wallet. To prevent\n // unnecessary renders, we only set the height if the content is shown in the wallet.\n if (isInChaynsWalletRef.current) {\n setMeasuredContentHeight(measurements.height);\n }\n\n setMeasuredContentWidth(measurements.width);\n\n if (typeof onMeasure === 'function') {\n onMeasure(measurements);\n }\n },\n [onMeasure],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(touchTimeoutRef.current);\n }, []);\n\n const handleTouchStart = useCallback(() => {\n touchTimeoutRef.current = window.setTimeout(() => {\n shouldPreventClickRef.current = true;\n }, 500);\n }, []);\n\n /**\n * This hook listens for clicks\n */\n useDropdownListener({\n onClick: handleClick,\n onClose: handleClose,\n onTouchEnd: handleTouchEnd,\n onTouchStart: handleTouchStart,\n shouldCaptureEvents,\n });\n\n useEffect(() => {\n const isBottomDirection = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n const reservationWrapperElement = anchorElement.closest<HTMLDivElement>(\n ContainerAnchor.RESERVATION_WRAPPER,\n );\n\n isInChaynsWalletRef.current =\n !!(reservationWrapperElement && reservationWrapperElement.contains(anchorElement)) ||\n true;\n\n // This effect checks if additional space is needed to show dropdown content in chayns cards.\n if (\n isBottomDirection &&\n isInChaynsWalletRef.current &&\n measuredContentHeight > 0 &&\n reservationWrapperElement &&\n shouldShowDropdown\n ) {\n const availableHeight =\n window.innerHeight - anchorElement.getBoundingClientRect().bottom;\n\n // If the content height is greater than the available height, we need to add additional space.\n // This is to ensure that the dropdown content is fully visible. The 16 pixels are a buffer for shadows.\n const additionalNeededSpace = measuredContentHeight + 16 - availableHeight;\n\n if (additionalNeededSpace > 0) {\n // Add margin bottom to the reservation wrapper to ensure the dropdown content is fully visible.\n reservationWrapperElement.style.marginBottom = `${additionalNeededSpace}px`;\n } else {\n // Reset the margin bottom if no additional space is needed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n }\n\n if (isInChaynsWalletRef.current && reservationWrapperElement && !shouldShowDropdown) {\n // Reset the margin bottom when the dropdown is closed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n\n return () => {\n if (reservationWrapperElement) {\n reservationWrapperElement.style.marginBottom = '0px';\n }\n };\n }, [anchorElement, direction, measuredContentHeight, shouldShowDropdown]);\n\n useEffect(() => {\n if (!container) return;\n\n setPortal(() =>\n createPortal(\n <DelayedDropdownContent\n coordinates={coordinates}\n onMeasure={handleContentMeasure}\n shouldShowContent={shouldShowDropdown}\n transform={transform}\n >\n <StyledDropdownBodyWrapperContent\n $width={width}\n $minWidth={minBodyWidth}\n $maxHeight={maxHeight}\n $direction={direction}\n ref={ref}\n >\n {children}\n </StyledDropdownBodyWrapperContent>\n </DelayedDropdownContent>,\n container,\n ),\n );\n }, [\n children,\n container,\n coordinates,\n direction,\n handleContentMeasure,\n maxHeight,\n minBodyWidth,\n shouldShowDropdown,\n transform,\n width,\n ]);\n\n return <StyledDropdownBodyWrapper>{portal}</StyledDropdownBodyWrapper>;\n};\n\nDropdownBodyWrapper.displayName = 'DropdownBodyWrapper';\n\nexport default DropdownBodyWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAGA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAAsE,SAAAK,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA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J,CACJ,CAAC;EACL,CAAC,EAAE,CACCD,QAAQ,EACRC,SAAS,EACT6B,WAAW,EACX1B,SAAS,EACTuC,oBAAoB,EACpBpC,SAAS,EACTC,YAAY,EACZK,kBAAkB,EAClBe,SAAS,EACTC,KAAK,CACR,CAAC;EAEF,oBAAO7D,MAAA,CAAAY,OAAA,CAAA4F,aAAA,CAACrG,oBAAA,CAAA4G,yBAAyB,QAAE1D,MAAkC,CAAC;AAC1E,CAAC;AAEDxB,mBAAmB,CAACmF,WAAW,GAAG,qBAAqB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtG,OAAA,GAEzCiB,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DropdownBodyWrapper.js","names":["_react","_interopRequireWildcard","require","_DropdownBodyWrapper","_reactDom","_dropdown","_DelayedDropdownContent","_interopRequireDefault","_dropdown2","_container","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DropdownBodyWrapper","forwardRef","anchorElement","bodyWidth","children","container","containerProp","contentHeight","direction","DropdownDirection","BOTTOM_RIGHT","maxHeight","minBodyWidth","onClose","onOutsideClick","onMeasure","shouldCaptureEvents","shouldShowDropdown","ref","isInChaynsWalletRef","useRef","measuredContentHeight","setMeasuredContentHeight","useState","measuredContentWidth","setMeasuredContentWidth","portal","setPortal","contentRef","shouldPreventClickRef","touchTimeoutRef","undefined","useContainer","transform","width","coordinates","useDropdown","contentWidth","handleClose","useCallback","handleClick","event","current","contains","target","preventDefault","stopPropagation","shouldPreventCloseOnClick","handleContentMeasure","measurements","height","handleTouchEnd","clearTimeout","handleTouchStart","window","setTimeout","useDropdownListener","onClick","onTouchEnd","onTouchStart","useEffect","isBottomDirection","BOTTOM","BOTTOM_LEFT","includes","reservationWrapperElement","closest","ContainerAnchor","RESERVATION_WRAPPER","availableHeight","innerHeight","getBoundingClientRect","bottom","additionalNeededSpace","style","marginBottom","createPortal","createElement","shouldShowContent","StyledDropdownBodyWrapperContent","$width","$minWidth","$maxHeight","$direction","className","tabIndex","useImperativeHandle","StyledDropdownBodyWrapper","displayName","_default","exports"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactNode,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport {\n StyledDropdownBodyWrapper,\n StyledDropdownBodyWrapperContent,\n} from './DropdownBodyWrapper.styles';\nimport { createPortal } from 'react-dom';\nimport { DropdownDirection, DropdownMeasurements } from '../../types/dropdown';\nimport DelayedDropdownContent, {\n DelayedDropdownContentProps,\n} from './delayed-dropdown-content/DelayedDropdownContent';\nimport { useDropdown, useDropdownListener } from '../../hooks/dropdown';\nimport { ContainerAnchor, useContainer } from '../../hooks/container';\n\ninterface DropdownBodyWrapperProps {\n /**\n * The anchor element of the dropdown.\n */\n anchorElement: Element;\n /**\n * The width of the Body.\n */\n bodyWidth?: number;\n /**\n * The content of the dropdown body.\n */\n children: ReactNode;\n /**\n * The element where the content should be rendered via React Portal.\n */\n container?: Element;\n /**\n * The height of the content\n */\n contentHeight?: number;\n /**\n * The direction of the dropdown.\n */\n direction?: DropdownDirection;\n /**\n * The max height of the dropdown.\n */\n maxHeight?: number;\n /**\n * The minimum width of the body.\n */\n minBodyWidth?: number;\n /**\n * Function to be executed when the body is closed.\n */\n onClose?: VoidFunction;\n /**\n * Function to be executed when the user clicks outside the dropdown.\n * If the function returns `true`, the dropdown will not be closed.\n */\n onOutsideClick?: () => boolean | void;\n /**\n * Function to be executed when the content is measured.\n */\n onMeasure?: DelayedDropdownContentProps['onMeasure'];\n /**\n * Whether the dropdown should be visible.\n */\n shouldShowDropdown: boolean;\n /**\n * Whether the outside events should be captured.\n */\n shouldCaptureEvents?: boolean;\n}\n\nconst DropdownBodyWrapper = forwardRef<HTMLDivElement, DropdownBodyWrapperProps>(\n (\n {\n anchorElement,\n bodyWidth,\n children,\n container: containerProp,\n contentHeight = 0,\n direction = DropdownDirection.BOTTOM_RIGHT,\n maxHeight,\n minBodyWidth = 0,\n onClose,\n onOutsideClick,\n onMeasure,\n shouldCaptureEvents = true,\n shouldShowDropdown,\n },\n ref,\n ) => {\n const isInChaynsWalletRef = useRef(false);\n\n const [measuredContentHeight, setMeasuredContentHeight] = useState<number>(0);\n const [measuredContentWidth, setMeasuredContentWidth] = useState<number>(0);\n const [portal, setPortal] = useState<ReactPortal>();\n\n const contentRef = useRef<HTMLDivElement>(null);\n const shouldPreventClickRef = useRef<boolean>(false);\n const touchTimeoutRef = useRef<number | undefined>(undefined);\n\n const container = useContainer({ anchorElement, container: containerProp });\n\n const { transform, width, coordinates } = useDropdown({\n anchorElement,\n container,\n contentHeight,\n contentWidth: bodyWidth ?? measuredContentWidth,\n direction,\n shouldShowDropdown,\n });\n\n const handleClose = useCallback(() => {\n if (typeof onClose === 'function') {\n onClose();\n }\n }, [onClose]);\n\n /**\n * This function closes the body\n */\n const handleClick = useCallback(\n (event: MouseEvent) => {\n if (\n contentRef.current &&\n shouldShowDropdown &&\n !anchorElement.contains(event.target as Node) &&\n !contentRef.current.contains(event.target as Node)\n ) {\n event.preventDefault();\n event.stopPropagation();\n\n const shouldPreventCloseOnClick = onOutsideClick?.() ?? false;\n\n if (!shouldPreventClickRef.current && !shouldPreventCloseOnClick) {\n handleClose();\n }\n }\n\n shouldPreventClickRef.current = false;\n },\n [anchorElement, handleClose, onOutsideClick, shouldShowDropdown],\n );\n\n const handleContentMeasure = useCallback(\n (measurements: DropdownMeasurements) => {\n // Measurements are only needed if the content is shown in the chayns wallet. To prevent\n // unnecessary renders, we only set the height if the content is shown in the wallet.\n if (isInChaynsWalletRef.current) {\n setMeasuredContentHeight(measurements.height);\n }\n\n setMeasuredContentWidth(measurements.width);\n\n if (typeof onMeasure === 'function') {\n onMeasure(measurements);\n }\n },\n [onMeasure],\n );\n\n const handleTouchEnd = useCallback(() => {\n clearTimeout(touchTimeoutRef.current);\n }, []);\n\n const handleTouchStart = useCallback(() => {\n touchTimeoutRef.current = window.setTimeout(() => {\n shouldPreventClickRef.current = true;\n }, 500);\n }, []);\n\n /**\n * This hook listens for clicks\n */\n useDropdownListener({\n onClick: handleClick,\n onClose: handleClose,\n onTouchEnd: handleTouchEnd,\n onTouchStart: handleTouchStart,\n shouldCaptureEvents,\n });\n\n useEffect(() => {\n const isBottomDirection = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n const reservationWrapperElement = anchorElement.closest<HTMLDivElement>(\n ContainerAnchor.RESERVATION_WRAPPER,\n );\n\n isInChaynsWalletRef.current =\n !!(\n reservationWrapperElement && reservationWrapperElement.contains(anchorElement)\n ) || true;\n\n // This effect checks if additional space is needed to show dropdown content in chayns cards.\n if (\n isBottomDirection &&\n isInChaynsWalletRef.current &&\n measuredContentHeight > 0 &&\n reservationWrapperElement &&\n shouldShowDropdown\n ) {\n const availableHeight =\n window.innerHeight - anchorElement.getBoundingClientRect().bottom;\n\n // If the content height is greater than the available height, we need to add additional space.\n // This is to ensure that the dropdown content is fully visible. The 16 pixels are a buffer for shadows.\n const additionalNeededSpace = measuredContentHeight + 16 - availableHeight;\n\n if (additionalNeededSpace > 0) {\n // Add margin bottom to the reservation wrapper to ensure the dropdown content is fully visible.\n reservationWrapperElement.style.marginBottom = `${additionalNeededSpace}px`;\n } else {\n // Reset the margin bottom if no additional space is needed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n }\n\n if (isInChaynsWalletRef.current && reservationWrapperElement && !shouldShowDropdown) {\n // Reset the margin bottom when the dropdown is closed.\n reservationWrapperElement.style.marginBottom = '0px';\n }\n\n return () => {\n if (reservationWrapperElement) {\n reservationWrapperElement.style.marginBottom = '0px';\n }\n };\n }, [anchorElement, direction, measuredContentHeight, shouldShowDropdown]);\n\n useEffect(() => {\n if (!container) return;\n\n setPortal(() =>\n createPortal(\n <DelayedDropdownContent\n coordinates={coordinates}\n onMeasure={handleContentMeasure}\n shouldShowContent={shouldShowDropdown}\n transform={transform}\n >\n <StyledDropdownBodyWrapperContent\n $width={width}\n $minWidth={minBodyWidth}\n $maxHeight={maxHeight}\n $direction={direction}\n ref={contentRef}\n className={\n typeof maxHeight === 'number' ? 'chayns-scrollbar' : undefined\n }\n tabIndex={0}\n >\n {children}\n </StyledDropdownBodyWrapperContent>\n </DelayedDropdownContent>,\n container,\n ),\n );\n }, [\n children,\n container,\n coordinates,\n direction,\n handleContentMeasure,\n maxHeight,\n minBodyWidth,\n shouldShowDropdown,\n transform,\n width,\n ]);\n\n useImperativeHandle(ref, () => contentRef.current!, []);\n\n return <StyledDropdownBodyWrapper>{portal}</StyledDropdownBodyWrapper>;\n },\n);\n\nDropdownBodyWrapper.displayName = 'DropdownBodyWrapper';\n\nexport default DropdownBodyWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAUA,IAAAC,oBAAA,GAAAD,OAAA;AAIA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAGA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAAsE,SAAAK,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAA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AsB;MACnBoD,WAAW,EAAEA,WAAY;MACzBpB,SAAS,EAAEiC,oBAAqB;MAChC8B,iBAAiB,EAAE7D,kBAAmB;MACtCgB,SAAS,EAAEA;IAAU,gBAErB9D,MAAA,CAAAY,OAAA,CAAA8F,aAAA,CAACvG,oBAAA,CAAAyG,gCAAgC;MAC7BC,MAAM,EAAE9C,KAAM;MACd+C,SAAS,EAAErE,YAAa;MACxBsE,UAAU,EAAEvE,SAAU;MACtBwE,UAAU,EAAE3E,SAAU;MACtBU,GAAG,EAAEU,UAAW;MAChBwD,SAAS,EACL,OAAOzE,SAAS,KAAK,QAAQ,GAAG,kBAAkB,GAAGoB,SACxD;MACDsD,QAAQ,EAAE;IAAE,GAEXjF,QAC6B,CACd,CAAC,EACzBC,SACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCD,QAAQ,EACRC,SAAS,EACT8B,WAAW,EACX3B,SAAS,EACTwC,oBAAoB,EACpBrC,SAAS,EACTC,YAAY,EACZK,kBAAkB,EAClBgB,SAAS,EACTC,KAAK,CACR,CAAC;EAEF,IAAAoD,0BAAmB,EAACpE,GAAG,EAAE,MAAMU,UAAU,CAACc,OAAQ,EAAE,EAAE,CAAC;EAEvD,oBAAOvE,MAAA,CAAAY,OAAA,CAAA8F,aAAA,CAACvG,oBAAA,CAAAiH,yBAAyB,QAAE7D,MAAkC,CAAC;AAC1E,CACJ,CAAC;AAED1B,mBAAmB,CAACwF,WAAW,GAAG,qBAAqB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3G,OAAA,GAEzCiB,mBAAmB","ignoreList":[]}
|
|
@@ -12,19 +12,25 @@ const StyledDropdownBodyWrapperContent = exports.StyledDropdownBodyWrapperConten
|
|
|
12
12
|
width: ${({
|
|
13
13
|
$width
|
|
14
14
|
}) => $width}px;
|
|
15
|
-
max-height: ${({
|
|
16
|
-
$maxHeight
|
|
17
|
-
}) => $maxHeight}px;
|
|
18
15
|
min-width: ${({
|
|
19
16
|
$minWidth
|
|
20
17
|
}) => $minWidth}px;
|
|
21
18
|
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
|
|
21
|
+
${({
|
|
22
|
+
$maxHeight
|
|
23
|
+
}) => typeof $maxHeight === 'number' && (0, _styledComponents.css)`
|
|
24
|
+
max-height: ${$maxHeight}px;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
overflow-x: hidden;
|
|
27
|
+
`}
|
|
28
|
+
|
|
22
29
|
// Basic styles
|
|
23
30
|
background: ${({
|
|
24
31
|
theme
|
|
25
32
|
}) => theme['000']};
|
|
26
33
|
border: 1px solid rgba(160, 160, 160, 0.3);
|
|
27
|
-
overflow: hidden;
|
|
28
34
|
box-shadow: 0 0 0 1px
|
|
29
35
|
rgba(${({
|
|
30
36
|
theme
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownBodyWrapper.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_dropdown","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledDropdownBodyWrapper","exports","styled","div","StyledDropdownBodyWrapperContent","$width","$
|
|
1
|
+
{"version":3,"file":"DropdownBodyWrapper.styles.js","names":["_styledComponents","_interopRequireWildcard","require","_dropdown","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledDropdownBodyWrapper","exports","styled","div","StyledDropdownBodyWrapperContent","$width","$minWidth","$maxHeight","css","theme","$direction","DropdownDirection","BOTTOM","BOTTOM_LEFT","BOTTOM_RIGHT","includes"],"sources":["../../../../src/components/dropdown-body-wrapper/DropdownBodyWrapper.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { DropdownDirection } from '../../types/dropdown';\n\nexport const StyledDropdownBodyWrapper = styled.div``;\n\ntype StyledDropdownBodyWrapperContentProps = WithTheme<{\n $width: number;\n $maxHeight?: number;\n $minWidth: number;\n $direction: DropdownDirection;\n}>;\n\nexport const StyledDropdownBodyWrapperContent = styled.div<StyledDropdownBodyWrapperContentProps>`\n width: ${({ $width }) => $width}px;\n min-width: ${({ $minWidth }) => $minWidth}px;\n\n overflow: hidden;\n\n ${({ $maxHeight }) =>\n typeof $maxHeight === 'number' &&\n css`\n max-height: ${$maxHeight}px;\n overflow-y: auto;\n overflow-x: hidden;\n `}\n\n // Basic styles\n background: ${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['000']};\n border: 1px solid rgba(160, 160, 160, 0.3);\n box-shadow: 0 0 0 1px\n rgba(${({ theme }: StyledDropdownBodyWrapperContentProps) => theme['009-rgb']}, 0.08) inset;\n\n ${({ $direction }) => {\n if (\n [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes($direction)\n ) {\n return css`\n border-bottom-left-radius: 3px;\n border-bottom-right-radius: 3px;\n box-shadow: 0 3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }\n\n return css`\n border-top-left-radius: 3px;\n border-top-right-radius: 3px;\n box-shadow: 0 -3px 10px 0 rgba(0, 0, 0, 0.2);\n `;\n }}\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAAyD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAA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CACIC,2BAAiB,CAACC,MAAM,EACxBD,2BAAiB,CAACE,WAAW,EAC7BF,2BAAiB,CAACG,YAAY,CACjC,CAACC,QAAQ,CAACL,UAAU,CAAC,EACxB;IACE,OAAO,IAAAF,qBAAG;AACtB;AACA;AACA;AACA,aAAa;EACL;EAEA,OAAO,IAAAA,qBAAG;AAClB;AACA;AACA;AACA,SAAS;AACL,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -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.
|
|
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.
|
|
75
|
-
|
|
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.
|
|
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,
|
|
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;AAC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jE,cAAA,CAAAiG,yCAAyC,qBAEtCpG,MAAA,CAAAc,OAAA,CAAAsD,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,CAA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Ae,OAAA,CAAA2C,aAAA,CAACvD,cAAA,CAAA6E,iCAAiC,qBAE9BhF,MAAA,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.
|
|
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
|
|
21
|
+
const StyledFilterContentLabeledRow = exports.StyledFilterContentLabeledRow = _styledComponents.default.div`
|
|
21
22
|
display: flex;
|
|
22
23
|
align-items: center;
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
28
|
+
const StyledFilterContentLabel = exports.StyledFilterContentLabel = _styledComponents.default.div`
|
|
44
29
|
flex: 0 0 auto;
|
|
30
|
+
white-space: nowrap;
|
|
45
31
|
`;
|
|
46
|
-
const
|
|
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","
|
|
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 @@
|
|
|
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":[]}
|
|
@@ -578,7 +578,6 @@ const SearchBox = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
578
578
|
anchorElement: boxRef.current,
|
|
579
579
|
container: container,
|
|
580
580
|
direction: dropdownDirection,
|
|
581
|
-
maxHeight: 300,
|
|
582
581
|
onClose: handleClose,
|
|
583
582
|
onOutsideClick: handleDropdownOutsideClick,
|
|
584
583
|
shouldShowDropdown: shouldShowDropdown
|