@capillarytech/blaze-ui 6.0.4 → 6.1.1

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.
@@ -3,19 +3,8 @@
3
3
  * MobileDatePicker
4
4
  *
5
5
  */
6
- import PropTypes from 'prop-types';
7
- import './styles.scss';
8
- declare function CapMobileDatePicker({ onChange, value, lastSyncDate }: {
9
- onChange: any;
10
- value: any;
11
- lastSyncDate: any;
12
- }): import("react/jsx-runtime").JSX.Element;
13
- declare namespace CapMobileDatePicker {
14
- var propTypes: {
15
- value: PropTypes.Requireable<object>;
16
- lastSyncDate: PropTypes.Requireable<object>;
17
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
18
- };
19
- }
6
+ import type { CapMobileDatePickerProps } from './types';
7
+ declare function CapMobileDatePicker({ onChange, value, lastSyncDate }: CapMobileDatePickerProps): import("react/jsx-runtime").JSX.Element;
20
8
  export default CapMobileDatePicker;
9
+ export type { CapMobileDatePickerProps } from './types';
21
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapMobileDatePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,SAAS,MAAM,YAAY,CAAC;AAQnC,OAAO,eAAe,CAAC;AAKvB,iBAAS,mBAAmB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE;;;;CAAA,2CA2C7D;kBA3CQ,mBAAmB;;;;;;;AAmD5B,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapMobileDatePicker/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAQxD,iBAAS,mBAAmB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,wBAAwB,2CAwDvF;AAED,eAAe,mBAAmB,CAAC;AACnC,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,63 +1,71 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import moment from "moment";
3
- import PropTypes from "prop-types";
4
3
  import { useState } from "react";
4
+ import { FORMAT_TOKENS } from "../utils/dayjs.js";
5
5
  import CapCalendarDatePicker from "../CapCalendarDatePicker/index.js";
6
6
  import CapIcon from "../CapIcon/index.js";
7
7
  import InputFinal from "../CapInput/index.js";
8
8
  import CapModalWithHoc from "../CapModal/index.js";
9
- import './styles.css';/* empty css */
9
+ import styles from "./styles.module.scss.js";
10
10
  const INCEPTION_DATE = "2000-01-01";
11
- const DATE_CALC_FORMAT = "YYYY-MM-DD";
12
- const DATE_DISPLAY_FORMAT = "DD MMMM YYYY";
11
+ const DATE_CALC_FORMAT = FORMAT_TOKENS.ISO_8601_DATE;
12
+ const DATE_DISPLAY_FORMAT = FORMAT_TOKENS.DATE_DISPLAY_FULL;
13
+ const clsPrefix = "cap-mobile-date-picker";
13
14
  function CapMobileDatePicker({ onChange, value, lastSyncDate }) {
14
- const [visible, setVisible] = useState(false);
15
+ const [open, setOpen] = useState(false);
15
16
  const handleDateChange = (date) => {
16
- onChange(moment(date));
17
- setVisible(false);
17
+ onChange == null ? void 0 : onChange(moment(date));
18
+ setOpen(false);
19
+ };
20
+ const handleModalOpen = () => {
21
+ setOpen(true);
22
+ };
23
+ const handleModalClose = () => {
24
+ setOpen(false);
18
25
  };
19
26
  return /* @__PURE__ */ jsxs(Fragment, { children: [
20
27
  /* @__PURE__ */ jsx(
21
28
  InputFinal,
22
29
  {
23
30
  suffix: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(CapIcon, { type: "calendar", style: { color: "rgb(9, 30, 66)" }, size: "m" }) }),
24
- onClick: () => setVisible(true),
25
- value: moment(value).format(DATE_DISPLAY_FORMAT)
31
+ onClick: handleModalOpen,
32
+ value: value ? moment(value).format(DATE_DISPLAY_FORMAT) : void 0,
33
+ size: "large"
26
34
  }
27
35
  ),
28
36
  /* @__PURE__ */ jsx(
29
37
  CapModalWithHoc,
30
38
  {
31
- visible,
39
+ open,
32
40
  centered: true,
33
- onCancel: () => setVisible(false),
34
- className: "mobile-date-picker-modal",
41
+ onCancel: handleModalClose,
42
+ className: styles[`${clsPrefix}-modal`],
43
+ classNames: {
44
+ root: styles[`${clsPrefix}-modal-root`],
45
+ body: styles[`${clsPrefix}-modal-body`],
46
+ container: styles[`${clsPrefix}-modal-container`],
47
+ footer: styles[`${clsPrefix}-modal-footer`]
48
+ },
35
49
  closable: false,
36
50
  footer: /* @__PURE__ */ jsx(Fragment, {}),
37
51
  children: /* @__PURE__ */ jsx(
38
52
  CapCalendarDatePicker,
39
53
  {
40
54
  inline: true,
55
+ className: styles[`${clsPrefix}-calendar`],
41
56
  minDate: moment(INCEPTION_DATE, DATE_CALC_FORMAT).toDate(),
42
57
  maxDate: lastSyncDate.toDate(),
43
58
  dropdownMode: "select",
44
59
  showMonthDropdown: true,
45
60
  showYearDropdown: true,
46
- readOnly: true,
47
61
  onChange: handleDateChange,
48
- selected: moment(value).toDate(),
49
- disabledDate: (currentDate) => currentDate.isAfter(lastSyncDate) || currentDate.isBefore(moment(INCEPTION_DATE))
62
+ selected: value ? moment(value).toDate() : void 0
50
63
  }
51
64
  )
52
65
  }
53
66
  )
54
67
  ] });
55
68
  }
56
- CapMobileDatePicker.propTypes = {
57
- value: PropTypes.object,
58
- lastSyncDate: PropTypes.object,
59
- onChange: PropTypes.func
60
- };
61
69
  export {
62
70
  CapMobileDatePicker as default
63
71
  };
@@ -1,19 +1,36 @@
1
- .mobile-date-picker-modal {
2
- min-width: 320px;
1
+ /* Color Palette */
2
+ /* Fonts */
3
+ /* Backward Compatibility Aliases */
4
+ /* Component Heights */
5
+ /* Border Radius */
6
+ /* Border Width */
7
+ /* Transition */
8
+ /* Timezones Footer */
9
+ .cap-mobile-date-picker-modal-root {
10
+ min-width: 22.857rem;
3
11
  width: unset !important;
4
12
  }
5
- .mobile-date-picker-modal .ant-modal-content .ant-modal-body, .mobile-date-picker-modal .ant-modal-content .ant-modal-footer {
6
- padding: 0 !important;
13
+ .cap-mobile-date-picker-modal-body {
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
7
17
  }
8
- .mobile-date-picker-modal .ant-modal-content .react-datepicker__day--keyboard-selected {
9
- background-color: rgb(36, 102, 234);
10
- color: #fff !important;
18
+ .cap-mobile-date-picker-modal-body .react-datepicker__day--keyboard-selected {
19
+ background-color: #2466ea;
20
+ color: #ffffff !important;
11
21
  border-radius: 50%;
12
22
  }
13
- .mobile-date-picker-modal .ant-modal-content .react-datepicker__navigation-icon--next, .mobile-date-picker-modal .ant-modal-content .react-datepicker__navigation-icon--previous {
23
+ .cap-mobile-date-picker-modal-container {
24
+ padding: 0 !important;
25
+ }
26
+ .cap-mobile-date-picker-modal-footer {
14
27
  display: none !important;
15
28
  }
16
-
17
- .ant-input-lg {
18
- font-size: 14px !important;
29
+ .cap-mobile-date-picker-calendar {
30
+ box-shadow: none;
31
+ height: 100%;
32
+ width: 100%;
33
+ display: flex;
34
+ justify-content: center;
35
+ align-items: center;
19
36
  }
@@ -0,0 +1,10 @@
1
+ import './styles.css';const styles = {
2
+ "cap-mobile-date-picker-modal-root": "cap-mobile-date-picker-modal-root",
3
+ "cap-mobile-date-picker-modal-body": "cap-mobile-date-picker-modal-body",
4
+ "cap-mobile-date-picker-modal-container": "cap-mobile-date-picker-modal-container",
5
+ "cap-mobile-date-picker-modal-footer": "cap-mobile-date-picker-modal-footer",
6
+ "cap-mobile-date-picker-calendar": "cap-mobile-date-picker-calendar"
7
+ };
8
+ export {
9
+ styles as default
10
+ };
@@ -1,20 +1,41 @@
1
- .mobile-date-picker-modal{
2
- min-width: 320px;
1
+ @import '../styles/_variables.scss';
2
+
3
+ $clsPrefix: 'cap-mobile-date-picker';
4
+
5
+ .#{$clsPrefix}-modal {
6
+ &-root {
7
+ min-width: 22.857rem;
3
8
  width: unset !important;
4
- .ant-modal-content{
5
- .ant-modal-body, .ant-modal-footer{
6
- padding: 0 !important;
7
- }
8
- .react-datepicker__day--keyboard-selected {
9
- background-color: rgb(36, 102, 234);
10
- color: #fff !important;
11
- border-radius: 50%;
12
- }
13
- .react-datepicker__navigation-icon--next, .react-datepicker__navigation-icon--previous{
14
- display: none !important;
15
- }
9
+ }
10
+
11
+ &-body {
12
+ display: flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+
16
+ :global {
17
+ .react-datepicker__day--keyboard-selected {
18
+ background-color: $cap-secondary-base;
19
+ color: $cap-white !important;
20
+ border-radius: 50%;
21
+ }
16
22
  }
23
+ }
24
+
25
+ &-container {
26
+ padding: 0 !important;
27
+ }
28
+
29
+ &-footer {
30
+ display: none !important;
31
+ }
17
32
  }
18
- .ant-input-lg{
19
- font-size: 14px !important;
33
+
34
+ .#{$clsPrefix}-calendar {
35
+ box-shadow: none;
36
+ height: 100%;
37
+ width: 100%;
38
+ display: flex;
39
+ justify-content: center;
40
+ align-items: center;
20
41
  }
@@ -0,0 +1,41 @@
1
+ import moment from 'moment';
2
+ export declare const mockDates: {
3
+ inception: moment.Moment;
4
+ midRange: moment.Moment;
5
+ midRange2: moment.Moment;
6
+ midRange3: moment.Moment;
7
+ lastSync: moment.Moment;
8
+ lastSyncMidYear: moment.Moment;
9
+ boundarySame: moment.Moment;
10
+ beforeInception: moment.Moment;
11
+ afterLastSync: moment.Moment;
12
+ differentYear: moment.Moment;
13
+ };
14
+ export declare const mockProps: {
15
+ default: {
16
+ value: moment.Moment;
17
+ lastSyncDate: moment.Moment;
18
+ };
19
+ withOnChange: {
20
+ value: moment.Moment;
21
+ lastSyncDate: moment.Moment;
22
+ onChange: jest.Mock<any, any, any>;
23
+ };
24
+ boundaryDates: {
25
+ value: moment.Moment;
26
+ lastSyncDate: moment.Moment;
27
+ };
28
+ nullValue: {
29
+ value: unknown;
30
+ lastSyncDate: moment.Moment;
31
+ };
32
+ undefinedValue: {
33
+ value: any;
34
+ lastSyncDate: moment.Moment;
35
+ };
36
+ midYearSync: {
37
+ value: moment.Moment;
38
+ lastSyncDate: moment.Moment;
39
+ };
40
+ };
41
+ //# sourceMappingURL=CapMobileDatePicker.mockData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapMobileDatePicker.mockData.d.ts","sourceRoot":"","sources":["../../../components/CapMobileDatePicker/tests/CapMobileDatePicker.mockData.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,SAAS;;;;;;;;;;;CAWrB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;eAeH,OAAO;;;;;;;;;;;CAWzB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Moment } from 'moment';
2
+ export interface CapMobileDatePickerProps {
3
+ /**
4
+ * Selected date value (moment object)
5
+ */
6
+ value?: Moment;
7
+ /**
8
+ * Last sync date - maximum selectable date (moment object)
9
+ */
10
+ lastSyncDate: Moment;
11
+ /**
12
+ * Callback when date changes
13
+ * @param date - Selected moment object
14
+ */
15
+ onChange?: (date: Moment) => void;
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../components/CapMobileDatePicker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC"}
@@ -0,0 +1 @@
1
+
@@ -1,43 +1,6 @@
1
- import PropTypes from 'prop-types';
2
1
  import React from 'react';
3
- import './styles.scss';
4
- export declare const CapPopoverTree: {
5
- (props: any): import("react/jsx-runtime").JSX.Element;
6
- defaultProps: {
7
- trigger: string;
8
- placement: string;
9
- showIcon: boolean;
10
- blockNode: boolean;
11
- defaultExpandAll: boolean;
12
- isLoadingData: boolean;
13
- switcherIcon: import("react/jsx-runtime").JSX.Element;
14
- renderOnKeyChange: boolean;
15
- };
16
- propTypes: {
17
- trigger: PropTypes.Requireable<string>;
18
- placement: PropTypes.Requireable<string>;
19
- className: PropTypes.Requireable<string>;
20
- defaultExpandAll: PropTypes.Requireable<boolean>;
21
- overlayClassName: PropTypes.Requireable<string>;
22
- showIcon: PropTypes.Requireable<boolean>;
23
- blockNode: PropTypes.Requireable<boolean>;
24
- propsTreeData: PropTypes.Requireable<any[]>;
25
- switcherIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
- TriggerComponent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
27
- componentText: PropTypes.Requireable<string>;
28
- triggerProps: PropTypes.Requireable<object>;
29
- isTriggerDisabled: PropTypes.Requireable<boolean>;
30
- triggerDisabledText: PropTypes.Requireable<string>;
31
- tooltipText: PropTypes.Requireable<string>;
32
- onSelect: PropTypes.Requireable<(...args: any[]) => any>;
33
- propsSelectedKey: PropTypes.Requireable<any[]>;
34
- isLoadingData: PropTypes.Requireable<boolean>;
35
- loadingTip: PropTypes.Requireable<string>;
36
- searchPlaceholder: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
37
- emptyDataMessage: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
38
- renderOnKeyChange: PropTypes.Requireable<boolean>;
39
- };
40
- };
41
- declare const _default: React.ComponentType<Omit<any, "intl">>;
2
+ import type { CapPopoverTreeProps } from './types';
3
+ export declare const CapPopoverTree: (props: CapPopoverTreeProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const _default: React.ComponentType<Omit<CapPopoverTreeProps & import("react-intl").WrappedComponentProps, "intl">>;
42
5
  export default _default;
43
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapPopoverTree/index.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAA8B,MAAM,OAAO,CAAC;AAWnD,OAAO,eAAe,CAAC;AAMvB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0M1B,CAAC;;AAsCF,wBAAoE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapPopoverTree/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAanD,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,SAAS,CAAC;AAKjE,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CA8OxD,CAAC;;AAEF,wBAEG"}
@@ -1,54 +1,56 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { Tree, Tooltip, Icon } from "antd";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { InfoCircleOutlined } from "@ant-design-v5/icons";
3
+ import { Tree, Input, Tooltip } from "antd-v5";
3
4
  import classNames from "classnames";
4
- import PropTypes from "prop-types";
5
5
  import { useState, useEffect } from "react";
6
+ import CapColumn from "../CapColumn/index.js";
6
7
  import CapHeadingWithStatic from "../CapHeading/index.js";
7
- import InputFinal from "../CapInput/index.js";
8
+ import CapIcon from "../CapIcon/index.js";
8
9
  import CapPopover from "../CapPopover/index.js";
9
10
  import CapRow from "../CapRow/index.js";
10
11
  import CapSpin from "../CapSpin/index.js";
11
12
  import CapTooltip from "../CapTooltip/index.js";
13
+ import CapTree from "../CapTree/index.js";
12
14
  import LocaleHoc from "../LocaleHoc/index.js";
13
- import { StyledCapTree, StyledIcon, StyledCapHeading, StyledCapColumn, ExpandIcon } from "./style.js";
14
- import './styles.css';/* empty css */
15
+ import styles from "./styles.module.scss.js";
15
16
  const { TreeNode } = Tree;
16
- const { Search } = InputFinal;
17
17
  const clsPrefix = "cap-popover-tree-v2";
18
18
  const CapPopoverTree = (props) => {
19
19
  var _a;
20
20
  const {
21
21
  treeData: propsTreeData = [],
22
22
  overlayClassName,
23
- trigger,
23
+ trigger = "click",
24
24
  TriggerComponent,
25
25
  componentText,
26
26
  triggerProps,
27
27
  isTriggerDisabled,
28
28
  triggerDisabledText,
29
29
  tooltipText,
30
- isLoadingData,
30
+ isLoadingData = false,
31
31
  loadingTip,
32
- placement,
33
- switcherIcon,
32
+ placement = "rightBottom",
33
+ switcherIcon = /* @__PURE__ */ jsx(CapIcon, { className: styles.expandIcon, size: "m", type: "chevron-down" }),
34
34
  className,
35
- defaultExpandAll,
35
+ defaultExpandAll = false,
36
36
  onSelect,
37
37
  selectedKey: propsSelectedKey,
38
38
  emptyDataMessage,
39
39
  searchPlaceholder,
40
- renderOnKeyChange,
40
+ renderOnKeyChange = false,
41
41
  ...rest
42
42
  } = props || {};
43
- const defaultExpandKey = (propsTreeData == null ? void 0 : propsTreeData.length) === 1 && ((_a = propsTreeData[0]) == null ? void 0 : _a.key);
43
+ const defaultExpandKey = (propsTreeData == null ? void 0 : propsTreeData.length) === 1 && ((_a = propsTreeData[0]) == null ? void 0 : _a.key) ? propsTreeData[0].key : null;
44
44
  const [searchText, setSearchText] = useState(null);
45
45
  const [showPopover, setShowPopover] = useState(null);
46
46
  const [filteredTreeData, setFilteredTreeData] = useState(propsTreeData || []);
47
- const [expandedKeys, setExpandedKeys] = useState(defaultExpandKey ? [defaultExpandKey] : []);
47
+ const [expandedKeys, setExpandedKeys] = useState(
48
+ defaultExpandKey ? [defaultExpandKey] : []
49
+ );
48
50
  useEffect(() => {
49
51
  setFilteredTreeData(propsTreeData);
50
- setExpandedKeys([defaultExpandKey]);
51
- }, [propsTreeData]);
52
+ setExpandedKeys(defaultExpandKey ? [defaultExpandKey] : []);
53
+ }, [propsTreeData, defaultExpandKey]);
52
54
  const handleSearch = (e) => {
53
55
  const { value } = e.target;
54
56
  setSearchText(value);
@@ -63,13 +65,15 @@ const CapPopoverTree = (props) => {
63
65
  }
64
66
  setExpandedKeys(keys);
65
67
  };
66
- const handleSelect = (selectedKey, { node }) => {
67
- const { isLeafNode, eventKey, expanded } = (node == null ? void 0 : node.props) || {};
68
+ const handleSelect = (selectedKey, info) => {
69
+ const { node } = info;
70
+ const nodeProps = node == null ? void 0 : node.props;
71
+ const { isLeafNode, eventKey, expanded } = nodeProps || {};
68
72
  if (isLeafNode) {
69
73
  setShowPopover(false);
70
- onSelect(selectedKey);
74
+ onSelect == null ? void 0 : onSelect(selectedKey);
71
75
  } else {
72
- const key = expanded ? [] : [eventKey];
76
+ const key = expanded ? [] : eventKey !== void 0 ? [eventKey] : [];
73
77
  handleOnExpand(key);
74
78
  }
75
79
  };
@@ -78,25 +82,38 @@ const CapPopoverTree = (props) => {
78
82
  var _a2, _b;
79
83
  const { title, key, icon, children = [], info } = data;
80
84
  if (title) {
81
- const itemName = (_a2 = title == null ? void 0 : title.toLowerCase()) == null ? void 0 : _a2.trim();
85
+ const titleString = typeof title === "string" ? title : String(title);
86
+ const itemName = (_a2 = titleString == null ? void 0 : titleString.toLowerCase()) == null ? void 0 : _a2.trim();
82
87
  const searchValue = (_b = searchText == null ? void 0 : searchText.toLowerCase()) == null ? void 0 : _b.trim();
83
- const searchIndex = searchValue && (itemName == null ? void 0 : itemName.indexOf(searchValue));
84
- const beforeString = title == null ? void 0 : title.substr(0, searchIndex);
85
- const afterString = title == null ? void 0 : title.substr(searchIndex + (searchValue == null ? void 0 : searchValue.length));
86
- const matchedSearch = title == null ? void 0 : title.substr(searchIndex, searchValue == null ? void 0 : searchValue.length);
88
+ const searchIndex = searchValue && itemName ? itemName.indexOf(searchValue) : -1;
89
+ const beforeString = titleString == null ? void 0 : titleString.substr(0, searchIndex >= 0 ? searchIndex : 0);
90
+ const afterString = titleString == null ? void 0 : titleString.substr(
91
+ (searchIndex >= 0 ? searchIndex : 0) + ((searchValue == null ? void 0 : searchValue.length) || 0)
92
+ );
93
+ const matchedSearch = titleString == null ? void 0 : titleString.substr(
94
+ searchIndex >= 0 ? searchIndex : 0,
95
+ (searchValue == null ? void 0 : searchValue.length) || 0
96
+ );
87
97
  const searchResult = /* @__PURE__ */ jsxs(Fragment, { children: [
88
- /* @__PURE__ */ jsx(StyledCapColumn, { children: beforeString }),
89
- /* @__PURE__ */ jsx(StyledCapColumn, { style: { fontWeight: 500 }, children: matchedSearch }),
90
- /* @__PURE__ */ jsx(StyledCapColumn, { children: afterString })
98
+ /* @__PURE__ */ jsx(CapColumn, { className: styles.styledCapColumn, children: beforeString }),
99
+ /* @__PURE__ */ jsx(CapColumn, { className: classNames(styles.styledCapColumn, styles.matchedSearch), children: matchedSearch }),
100
+ /* @__PURE__ */ jsx(CapColumn, { className: styles.styledCapColumn, children: afterString })
91
101
  ] });
92
102
  const treeNodeProps = {
93
- title: /* @__PURE__ */ jsxs(StyledCapHeading, { className: "tree-node-title", children: [
103
+ title: /* @__PURE__ */ jsxs(CapHeadingWithStatic, { className: classNames(styles.styledCapHeading, "tree-node-title"), children: [
94
104
  searchIndex > -1 ? searchResult : title,
95
- info && /* @__PURE__ */ jsx("span", { className: "info-tooltip", children: /* @__PURE__ */ jsx(Tooltip, { placement: "right", title: info, children: /* @__PURE__ */ jsx(Icon, { className: "info-icon", type: "info-circle-o" }) }) })
105
+ info && /* @__PURE__ */ jsx("span", { className: "info-tooltip", children: /* @__PURE__ */ jsx(Tooltip, { placement: "right", title: info, children: /* @__PURE__ */ jsx(InfoCircleOutlined, { className: "info-icon" }) }) })
96
106
  ] }),
97
107
  key,
98
108
  isLeafNode: !(children == null ? void 0 : children.length),
99
- icon: icon && /* @__PURE__ */ jsx(StyledIcon, { className: "tree-node-icon", size: "s", type: icon })
109
+ icon: icon && /* @__PURE__ */ jsx(
110
+ CapIcon,
111
+ {
112
+ className: classNames(styles.styledIcon, "tree-node-icon"),
113
+ size: "s",
114
+ type: icon
115
+ }
116
+ )
100
117
  };
101
118
  result.push(
102
119
  /* @__PURE__ */ jsx(TreeNode, { ...treeNodeProps, children: (children == null ? void 0 : children.length) && getTreeData(children) })
@@ -114,15 +131,15 @@ const CapPopoverTree = (props) => {
114
131
  return;
115
132
  }
116
133
  const filteredData = propsTreeData.reduce((result, currentData) => {
117
- var _a3, _b;
118
- const parentName = (_a3 = currentData == null ? void 0 : currentData.title) == null ? void 0 : _a3.toLowerCase();
134
+ var _a3;
135
+ const titleString = typeof (currentData == null ? void 0 : currentData.title) === "string" ? currentData.title : String((currentData == null ? void 0 : currentData.title) || "");
136
+ const parentName = titleString == null ? void 0 : titleString.toLowerCase();
119
137
  const isParent = (parentName == null ? void 0 : parentName.indexOf(searchString)) > -1;
120
- const childItems = (_b = currentData == null ? void 0 : currentData.children) == null ? void 0 : _b.filter(
121
- (childItem) => {
122
- var _a4, _b2;
123
- return ((_b2 = (_a4 = childItem == null ? void 0 : childItem.title) == null ? void 0 : _a4.toLowerCase()) == null ? void 0 : _b2.indexOf(searchString)) > -1;
124
- }
125
- );
138
+ const childItems = (_a3 = currentData == null ? void 0 : currentData.children) == null ? void 0 : _a3.filter((childItem) => {
139
+ var _a4;
140
+ const childTitleString = typeof (childItem == null ? void 0 : childItem.title) === "string" ? childItem.title : String((childItem == null ? void 0 : childItem.title) || "");
141
+ return ((_a4 = childTitleString == null ? void 0 : childTitleString.toLowerCase()) == null ? void 0 : _a4.indexOf(searchString)) > -1;
142
+ });
126
143
  const hasChildren = !!(childItems == null ? void 0 : childItems.length);
127
144
  const currentDataCopy = { ...currentData };
128
145
  if (hasChildren) {
@@ -141,16 +158,18 @@ const CapPopoverTree = (props) => {
141
158
  /* @__PURE__ */ jsx(
142
159
  CapPopover,
143
160
  {
144
- visible: showPopover,
145
- onVisibleChange: setShowPopover,
161
+ visible: showPopover ?? void 0,
162
+ onVisibleChange: (visible) => setShowPopover(visible),
146
163
  trigger,
147
164
  placement,
148
165
  overlayClassName: classNames(`${clsPrefix}`, overlayClassName),
149
166
  ...rest,
150
167
  content: /* @__PURE__ */ jsx(CapRow, { className: "search-and-tree-wrapper", children: /* @__PURE__ */ jsxs(CapSpin, { spinning: isLoadingData, tip: loadingTip, children: [
151
168
  /* @__PURE__ */ jsx(
152
- Search,
169
+ Input,
153
170
  {
171
+ prefix: /* @__PURE__ */ jsx(CapIcon, { type: "search", size: "s" }),
172
+ variant: "borderless",
154
173
  placeholder: searchPlaceholder,
155
174
  onChange: handleSearch,
156
175
  className: "search-tree-node"
@@ -158,7 +177,7 @@ const CapPopoverTree = (props) => {
158
177
  ),
159
178
  /* @__PURE__ */ jsx("div", { className: "divider" }),
160
179
  (filteredTreeData == null ? void 0 : filteredTreeData.length) ? /* @__PURE__ */ jsx(
161
- StyledCapTree,
180
+ CapTree,
162
181
  {
163
182
  showIcon: true,
164
183
  blockNode: true,
@@ -168,8 +187,11 @@ const CapPopoverTree = (props) => {
168
187
  onExpand: handleOnExpand,
169
188
  onSelect: handleSelect,
170
189
  switcherIcon,
171
- isExpanded: (expandedKeys == null ? void 0 : expandedKeys.length) && !searchText,
172
- className,
190
+ className: classNames(
191
+ styles.styledCapTree,
192
+ (expandedKeys == null ? void 0 : expandedKeys.length) && !searchText && styles.isExpanded,
193
+ className
194
+ ),
173
195
  ...renderOnKeyChange ? { key: JSON.stringify(filteredTreeData) } : {},
174
196
  ...rest,
175
197
  children: getTreeData(searchText ? filteredTreeData : propsTreeData)
@@ -178,44 +200,12 @@ const CapPopoverTree = (props) => {
178
200
  ] }) })
179
201
  }
180
202
  ),
181
- /* @__PURE__ */ jsx(CapRow, { children: !isTriggerDisabled ? /* @__PURE__ */ jsx(CapTooltip, { title: tooltipText, overlayClassName: "add-condition-tooltip", children: /* @__PURE__ */ jsx(TriggerComponent, { ...triggerProps, onClick: () => setShowPopover(true), children: componentText }) }) : /* @__PURE__ */ jsx(CapTooltip, { title: triggerDisabledText, children: /* @__PURE__ */ jsx("span", { className: "button-disabled-tooltip-wrapper", children: /* @__PURE__ */ jsx(TriggerComponent, { ...triggerProps, children: componentText }) }) }) })
203
+ /* @__PURE__ */ jsx(CapRow, { children: !isTriggerDisabled ? /* @__PURE__ */ jsx(CapTooltip, { title: tooltipText, overlayClassName: "add-condition-tooltip", children: TriggerComponent && /* @__PURE__ */ jsx(TriggerComponent, { ...triggerProps, onClick: () => setShowPopover(true), children: componentText }) }) : /* @__PURE__ */ jsx(CapTooltip, { title: triggerDisabledText, children: /* @__PURE__ */ jsx("span", { className: "button-disabled-tooltip-wrapper", children: TriggerComponent && /* @__PURE__ */ jsx(TriggerComponent, { ...triggerProps, children: componentText }) }) }) })
182
204
  ] });
183
205
  };
184
- CapPopoverTree.defaultProps = {
185
- trigger: "click",
186
- placement: "rightBottom",
187
- showIcon: true,
188
- blockNode: true,
189
- defaultExpandAll: false,
190
- isLoadingData: false,
191
- switcherIcon: /* @__PURE__ */ jsx(ExpandIcon, { size: "m", type: "chevron-down" }),
192
- renderOnKeyChange: false
193
- };
194
- CapPopoverTree.propTypes = {
195
- trigger: PropTypes.string,
196
- placement: PropTypes.string,
197
- className: PropTypes.string,
198
- defaultExpandAll: PropTypes.bool,
199
- overlayClassName: PropTypes.string,
200
- showIcon: PropTypes.bool,
201
- blockNode: PropTypes.bool,
202
- propsTreeData: PropTypes.array,
203
- switcherIcon: PropTypes.node,
204
- TriggerComponent: PropTypes.node,
205
- componentText: PropTypes.string,
206
- triggerProps: PropTypes.object,
207
- isTriggerDisabled: PropTypes.bool,
208
- triggerDisabledText: PropTypes.string,
209
- tooltipText: PropTypes.string,
210
- onSelect: PropTypes.func,
211
- propsSelectedKey: PropTypes.array,
212
- isLoadingData: PropTypes.bool,
213
- loadingTip: PropTypes.string,
214
- searchPlaceholder: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
215
- emptyDataMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
216
- renderOnKeyChange: PropTypes.bool
217
- };
218
- const index = LocaleHoc(CapPopoverTree, { key: "CapPopoverTree" });
206
+ const index = LocaleHoc(CapPopoverTree, {
207
+ key: "CapPopoverTree"
208
+ });
219
209
  export {
220
210
  CapPopoverTree,
221
211
  index as default
@@ -1,6 +1,10 @@
1
+ interface StyledCapTreeProps {
2
+ isExpanded?: boolean;
3
+ }
1
4
  export declare const ExpandIcon: import("styled-components").StyledComponent<import("../CapIcon").CapIconComponent, any, {}, never>;
2
5
  export declare const StyledIcon: import("styled-components").StyledComponent<import("../CapIcon").CapIconComponent, any, {}, never>;
3
6
  export declare const StyledCapHeading: import("styled-components").StyledComponent<import("../CapHeading/types").CapHeadingComponent, any, {}, never>;
4
7
  export declare const StyledCapColumn: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../CapColumn").CapColumnProps & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
5
- export declare const StyledCapTree: import("styled-components").StyledComponent<import("react").FC<import("../CapTree").CapTreeProps>, any, {}, never>;
8
+ export declare const StyledCapTree: import("styled-components").StyledComponent<import("react").FC<import("../CapTree").CapTreeProps>, any, StyledCapTreeProps, never>;
9
+ export {};
6
10
  //# sourceMappingURL=style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../components/CapPopoverTree/style.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,oGAMtB,CAAC;AAEF,eAAO,MAAM,UAAU,oGAItB,CAAC;AAEF,eAAO,MAAM,gBAAgB,gHAI5B,CAAC;AAEF,eAAO,MAAM,eAAe,+LAE3B,CAAC;AAEF,eAAO,MAAM,aAAa,oHA4DzB,CAAC"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../components/CapPopoverTree/style.ts"],"names":[],"mappings":"AAQA,UAAU,kBAAkB;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,UAAU,oGAMtB,CAAC;AAEF,eAAO,MAAM,UAAU,oGAItB,CAAC;AAEF,eAAO,MAAM,gBAAgB,gHAI5B,CAAC;AAEF,eAAO,MAAM,eAAe,+LAE3B,CAAC;AAEF,eAAO,MAAM,aAAa,oIA6DzB,CAAC"}