oa-componentbook 1.0.1-stage.453 → 1.0.1-stage.454

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.
@@ -1,19 +1,27 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.weak-map.js");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = CustomInfo;
7
8
  require("core-js/modules/es.symbol.description.js");
8
- var _react = _interopRequireDefault(require("react"));
9
+ require("core-js/modules/web.dom-collections.iterator.js");
10
+ var _react = _interopRequireWildcard(require("react"));
9
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
12
  var _antd = require("antd");
13
+ var _CloseRounded = _interopRequireDefault(require("@material-ui/icons/CloseRounded"));
11
14
  var _styles = require("./styles");
12
15
  var _CustomButton = _interopRequireDefault(require("../oa-component-button/CustomButton"));
13
16
  var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
17
+ var _MaterialIcon = _interopRequireDefault(require("../oa-component-icons/MaterialIcon"));
14
18
  var _colorOptions = require("../../global-css/color-options");
15
19
  require("antd/dist/reset.css");
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
+ /* eslint-disable */
24
+
17
25
  /**
18
26
  * A component for displaying a single piece of information with an optional icon
19
27
  * and/or button. The icon can be placed on either the left or right of the text.
@@ -28,6 +36,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
36
  * @param {object} iconConfig - Configuration for the icon.
29
37
  * @param {string} title - The title to be displayed.
30
38
  * @param {string} borderColor - The border color of the component.
39
+ * @param {boolean} closable - Whether to show a close button.
40
+ * @param {function} onClose - Callback function called when close button is clicked.
31
41
  *
32
42
  * @returns {ReactElement} A styled component with the specified properties.
33
43
  */
@@ -39,8 +49,20 @@ function CustomInfo(_ref) {
39
49
  fontColor,
40
50
  iconConfig,
41
51
  title,
42
- borderColor
52
+ borderColor,
53
+ closable,
54
+ onClose
43
55
  } = _ref;
56
+ const [visible, setVisible] = (0, _react.useState)(true);
57
+ const handleClose = () => {
58
+ setVisible(false);
59
+ if (onClose) {
60
+ onClose();
61
+ }
62
+ };
63
+ if (!visible) {
64
+ return null;
65
+ }
44
66
  /**
45
67
  * Renders the icon based on the presence of a title.
46
68
  * If a title is not provided and the icon is a valid React element,
@@ -69,7 +91,15 @@ function CustomInfo(_ref) {
69
91
  return /*#__PURE__*/_react.default.createElement(_styles.InfoContainer, {
70
92
  $color: color,
71
93
  $borderColor: borderColor
72
- }, /*#__PURE__*/_react.default.createElement(_styles.RowFlex, null, iconConfig.position === 'left' && conditionallyAddTooltipToIcon(), /*#__PURE__*/_react.default.createElement(_styles.ColFlex, null, title && /*#__PURE__*/_react.default.createElement(_Typography.default, {
94
+ }, /*#__PURE__*/_react.default.createElement(_styles.RowFlex, {
95
+ style: {
96
+ width: '100%'
97
+ }
98
+ }, iconConfig.position === 'left' && conditionallyAddTooltipToIcon(), /*#__PURE__*/_react.default.createElement(_styles.ColFlex, {
99
+ style: {
100
+ flex: 1
101
+ }
102
+ }, title && /*#__PURE__*/_react.default.createElement(_Typography.default, {
73
103
  color: fontColor,
74
104
  typography: "type-t2-700"
75
105
  }, title), description && /*#__PURE__*/_react.default.createElement("div", {
@@ -77,7 +107,13 @@ function CustomInfo(_ref) {
77
107
  style: {
78
108
  color: "var(--color-".concat(fontColor, ")")
79
109
  }
80
- }, description)), iconConfig.position === 'right' && conditionallyAddTooltipToIcon()), (buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.label) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, buttonConfig));
110
+ }, description)), iconConfig.position === 'right' && conditionallyAddTooltipToIcon(), closable && /*#__PURE__*/_react.default.createElement(_styles.CloseButton, {
111
+ onClick: handleClose
112
+ }, /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
113
+ icon: _CloseRounded.default,
114
+ color: "secondary-content",
115
+ size: title ? 24 : 20
116
+ }))), (buttonConfig === null || buttonConfig === void 0 ? void 0 : buttonConfig.label) && /*#__PURE__*/_react.default.createElement(_CustomButton.default, buttonConfig));
81
117
  }
82
118
  CustomInfo.propTypes = {
83
119
  buttonConfig: _propTypes.default.shape({
@@ -100,7 +136,9 @@ CustomInfo.propTypes = {
100
136
  tooltipText: _propTypes.default.string
101
137
  }),
102
138
  title: _propTypes.default.string,
103
- borderColor: _propTypes.default.string
139
+ borderColor: _propTypes.default.string,
140
+ closable: _propTypes.default.bool,
141
+ onClose: _propTypes.default.func
104
142
  };
105
143
  CustomInfo.defaultProps = {
106
144
  buttonConfig: {
@@ -115,5 +153,7 @@ CustomInfo.defaultProps = {
115
153
  fontColor: 'primary-content',
116
154
  title: '',
117
155
  description: '',
118
- borderColor: ''
156
+ borderColor: '',
157
+ closable: false,
158
+ onClose: null
119
159
  };
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RowFlex = exports.InfoContainer = exports.ColFlex = void 0;
6
+ exports.RowFlex = exports.InfoContainer = exports.ColFlex = exports.CloseButton = void 0;
7
7
  var _styledComponents = _interopRequireDefault(require("styled-components"));
8
- var _templateObject, _templateObject2, _templateObject3;
8
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
11
11
  const RowFlex = exports.RowFlex = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n gap: 8px;\n"])));
12
12
  const ColFlex = exports.ColFlex = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 8px;\n"])));
13
13
  const InfoContainer = exports.InfoContainer = (0, _styledComponents.default)(RowFlex).attrs({
14
14
  as: 'section'
15
- })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 12px;\n align-items: center;\n border-radius: 8px;\n background-color: var(--color-", ");\n border: 1px solid var(--color-", ");\n\n button {\n margin-left: 8px;\n }\n"])), props => props.$color, props => props.$borderColor);
15
+ })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 12px;\n align-items: center;\n border-radius: 8px;\n background-color: var(--color-", ");\n border: 1px solid var(--color-", ");\n\n button {\n margin-left: 8px;\n }\n"])), props => props.$color, props => props.$borderColor);
16
+ const CloseButton = exports.CloseButton = _styledComponents.default.button(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n margin-left: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 16px;\n transition: opacity 0.2s;\n\n &:hover {\n opacity: 0.7;\n }\n\n &:active {\n opacity: 0.5;\n }\n"])));
@@ -251,9 +251,10 @@ function CustomTableV1(_ref2) {
251
251
  label: (option === null || option === void 0 ? void 0 : option.label) || (record === null || record === void 0 ? void 0 : record[option === null || option === void 0 ? void 0 : option.key]) || "",
252
252
  onClick: () => customTableChange(record, config)
253
253
  }) : (option === null || option === void 0 ? void 0 : option.type) === "tag" ? /*#__PURE__*/_react.default.createElement(_CustomTag.default, {
254
+ style: _objectSpread({}, typeof getByPath(record, option === null || option === void 0 ? void 0 : option.styleKey) === "object" ? getByPath(record, option === null || option === void 0 ? void 0 : option.styleKey) : {}),
254
255
  label: getByPath(record, option === null || option === void 0 ? void 0 : option.key) || "",
255
- type: getByPath(record, option === null || option === void 0 ? void 0 : option.tagType) || (option === null || option === void 0 ? void 0 : option.tagType) || "primary",
256
- visible: true
256
+ type: getByPath(record, option === null || option === void 0 ? void 0 : option.tagType) || (option === null || option === void 0 ? void 0 : option.tagType) || "primary"
257
+ // visible={option?.visible??true}
257
258
  }) : /*#__PURE__*/_react.default.createElement(_Typography.default, {
258
259
  typography: (option === null || option === void 0 ? void 0 : option.typography) || (col === null || col === void 0 ? void 0 : col.customStyle) && (record === null || record === void 0 || (_record$option$styleK = record[option === null || option === void 0 ? void 0 : option.styleKey]) === null || _record$option$styleK === void 0 ? void 0 : _record$option$styleK.typography) || "type-b2-400",
259
260
  color: (option === null || option === void 0 ? void 0 : option.color) || (col === null || col === void 0 ? void 0 : col.customStyle) && (record === null || record === void 0 || (_record$option$styleK2 = record[option === null || option === void 0 ? void 0 : option.styleKey]) === null || _record$option$styleK2 === void 0 ? void 0 : _record$option$styleK2.color)
@@ -10,9 +10,12 @@ var _react = _interopRequireDefault(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _antd = require("antd");
12
12
  var _utils = require("../../utils");
13
+ var _CustomToggle = _interopRequireDefault(require("../oa-component-toggle/CustomToggle"));
14
+ var _Typography = _interopRequireDefault(require("../oa-component-typography/Typography"));
13
15
  var _styles = require("./styles");
14
- const _excluded = ["data", "data-test", "defaultActiveKey", "disabled", "style", "tabPosition", "type"],
16
+ const _excluded = ["data", "data-test", "defaultActiveKey", "disabled", "extraAction", "style", "tabPosition", "type"],
15
17
  _excluded2 = ["body", "disabled", "key", "label"];
18
+ /* eslint-disable */
16
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
20
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -29,6 +32,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
29
32
  * @param {string} [data-test] - A string to be used as data-test attribute.
30
33
  * @param {string} defaultActiveKey - Key of the initially active tab.
31
34
  * @param {boolean} disabled - Whether the tabs are disabled.
35
+ * @param {Object} extraAction - Configuration for extra action on the right side of tabs.
36
+ * @param {string} extraAction.type - Type of extra action ('switch').
37
+ * @param {boolean} extraAction.visible - Whether to show the extra action (default: true).
38
+ * @param {Object} extraAction.props - Props to pass to the extra action component.
32
39
  * @param {Object} style - An object containing CSS styles for the component.
33
40
  * @param {'top'|'right'|'bottom'|'left'} tabPosition - Position of the tab headers.
34
41
  * @param {'line'|'card'} type - Type of the tabs.
@@ -41,6 +48,7 @@ function CustomTabs(_ref) {
41
48
  'data-test': dataTest,
42
49
  defaultActiveKey,
43
50
  disabled,
51
+ extraAction,
44
52
  style,
45
53
  tabPosition,
46
54
  type
@@ -63,13 +71,42 @@ function CustomTabs(_ref) {
63
71
  }, label) : label
64
72
  }, otherProps);
65
73
  });
74
+
75
+ /**
76
+ * Renders the extra action component based on the type.
77
+ * @returns {React.ReactNode} The rendered extra action component or null.
78
+ */
79
+ const renderExtraAction = () => {
80
+ if (!extraAction || !extraAction.type) {
81
+ return null;
82
+ }
83
+
84
+ // Check if extraAction is visible (defaults to true if not specified)
85
+ if (extraAction.visible === false) {
86
+ return null;
87
+ }
88
+ switch (extraAction.type) {
89
+ case 'switch':
90
+ return /*#__PURE__*/_react.default.createElement(_styles.ExtraActionWrapper, null, extraAction.label && /*#__PURE__*/_react.default.createElement(_Typography.default, {
91
+ color: extraAction.labelColor || 'secondary-content',
92
+ typography: extraAction.labelTypography || 'type-b2-400'
93
+ }, extraAction.label), /*#__PURE__*/_react.default.createElement(_CustomToggle.default, _extends({
94
+ "data-test": dataTest ? "".concat(dataTest, "--extra-action-switch") : undefined,
95
+ size: extraAction.size || 'small'
96
+ }, extraAction.props)));
97
+ default:
98
+ return null;
99
+ }
100
+ };
101
+ const tabBarExtraContent = renderExtraAction();
66
102
  return /*#__PURE__*/_react.default.createElement(_styles.StyledTabs, null, /*#__PURE__*/_react.default.createElement(_antd.Tabs, _extends({
67
103
  defaultActiveKey: defaultActiveKey,
68
- disabled: true,
104
+ disabled: disabled,
69
105
  items: items,
70
106
  style: _objectSpread({}, style),
71
107
  tabPosition: tabPosition,
72
- type: type
108
+ type: type,
109
+ tabBarExtraContent: tabBarExtraContent
73
110
  }, antDesignProps)));
74
111
  }
75
112
  CustomTabs.propTypes = {
@@ -84,6 +121,15 @@ CustomTabs.propTypes = {
84
121
  'data-test': _propTypes.default.string,
85
122
  defaultActiveKey: _propTypes.default.string,
86
123
  disabled: _propTypes.default.bool,
124
+ extraAction: _propTypes.default.shape({
125
+ type: _propTypes.default.oneOf(['switch']).isRequired,
126
+ visible: _propTypes.default.bool,
127
+ label: _propTypes.default.string,
128
+ labelColor: _propTypes.default.string,
129
+ labelTypography: _propTypes.default.string,
130
+ size: _propTypes.default.oneOf(['large', 'small']),
131
+ props: _propTypes.default.objectOf(_propTypes.default.any)
132
+ }),
87
133
  tabPosition: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left']),
88
134
  type: _propTypes.default.oneOf(['line', 'card'
89
135
  // 'editable-card',
@@ -97,6 +143,7 @@ CustomTabs.defaultProps = {
97
143
  tabPosition: 'top',
98
144
  type: 'line',
99
145
  disabled: false,
146
+ extraAction: null,
100
147
  style: {}
101
148
  };
102
149
  var _default = exports.default = CustomTabs;
@@ -3,11 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.StyledTabs = void 0;
6
+ exports.default = exports.StyledTabs = exports.ExtraActionWrapper = void 0;
7
7
  var _antd = require("antd");
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
- var _templateObject;
9
+ var _templateObject, _templateObject2;
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
12
  var _default = exports.default = {};
13
- const StyledTabs = exports.StyledTabs = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.ant-tabs .ant-tabs-tab{\n color: var(--color-secondary-content);\n padding: 12px;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n }\n .ant-tabs-tab-disabled{\n color: var(--color-disabled-button) !important;\n }\n s.ant-tabs-tab-disabled:hover {\n color: var(--color-disabled-button) !important;\n}\n .ant-tabs .ant-tabs-tab+.ant-tabs-tab{\n margin: 0;\n }\n .ant-tabs-top >.ant-tabs-nav::before{\n border-bottom: 1px solid var(--color-divider)\n }\n .ant-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {\n color: var(--color-primary);\n font-size: 14px;\n font-weight: 500;\n line-height: 20px; \n }\n .ant-tabs .ant-tabs-tab:hover{\n color: var(--color-primary-hover);\n }\n .ant-tabs .ant-tabs-ink-bar{\n background: var(--color-primary);\n }\n"])));
13
+ const StyledTabs = exports.StyledTabs = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.ant-tabs .ant-tabs-tab{\n color: var(--color-secondary-content);\n padding: 12px;\n font-size: 14px;\n font-weight: 400;\n line-height: 20px;\n }\n .ant-tabs-tab-disabled{\n color: var(--color-disabled-button) !important;\n }\n s.ant-tabs-tab-disabled:hover {\n color: var(--color-disabled-button) !important;\n}\n .ant-tabs .ant-tabs-tab+.ant-tabs-tab{\n margin: 0;\n }\n .ant-tabs-top >.ant-tabs-nav::before{\n border-bottom: 1px solid var(--color-divider)\n }\n .ant-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {\n color: var(--color-primary);\n font-size: 14px;\n font-weight: 500;\n line-height: 20px; \n }\n .ant-tabs .ant-tabs-tab:hover{\n color: var(--color-primary-hover);\n }\n .ant-tabs .ant-tabs-ink-bar{\n background: var(--color-primary);\n }\n"])));
14
+ const ExtraActionWrapper = exports.ExtraActionWrapper = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n gap: 12px;\n"])));
@@ -32,6 +32,7 @@ function CustomTag(_ref) {
32
32
  textColor,
33
33
  style
34
34
  } = _ref;
35
+ console.log("style", style);
35
36
  return /*#__PURE__*/_react.default.createElement(_styles.StyledTag, _extends({
36
37
  "data-test": dataTest,
37
38
  type: type,
@@ -53,7 +53,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
53
53
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
54
54
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable */
55
55
  function GenricLayOut(_ref) {
56
- var _state$misc30, _sidebar$mobileMenuIt, _imageViewer$content, _imageViewer$content2, _leftHeaderFirstButto, _leftHeaderFirstButto2, _infoPanel$data, _infoPanel$data2, _infoPanel$data3, _infoPanel$data4, _infoPanel$data5, _state$customDrawer3, _state$customDrawer4, _tabs$list, _tables$columns3, _tables$columns4, _tabs$active3, _state$tables5, _tables$selectionType, _tabs$active4, _tables$selectionType2, _tables$pagination17, _drawer$data, _tabs$active5, _drawer$data$drawer$a, _drawer$data2, _tabs$active6, _tabs$active7, _nestedDrawer$data, _nestedDrawer$data$ca, _nestedDrawer$data2, _customDrawer$data, _customDrawer$data2, _contentPanel$dataSou, _tables$tableFooter, _tables$selectedRowKe, _tables$tableFooter2, _tables$tableFooter3, _tables$tableFooter5;
56
+ var _state$misc30, _sidebar$mobileMenuIt, _imageViewer$content, _imageViewer$content2, _infoData$iconConfig, _infoData$iconConfig2, _infoData$iconConfig3, _infoData$iconConfig4, _leftHeaderFirstButto, _leftHeaderFirstButto2, _infoPanel$data, _infoPanel$data2, _infoPanel$data3, _infoPanel$data4, _infoPanel$data5, _state$customDrawer3, _state$customDrawer4, _tabs$list, _ref6, _tabs$extraAction$che, _tabs$extraAction$pro, _tables$columns3, _tables$columns4, _tabs$active3, _state$tables5, _tables$selectionType, _tabs$active4, _tables$selectionType2, _tables$pagination19, _drawer$data, _tabs$active5, _drawer$data$drawer$a, _drawer$data2, _tabs$active6, _tabs$active7, _nestedDrawer$data, _nestedDrawer$data$ca, _nestedDrawer$data2, _customDrawer$data, _customDrawer$data2, _contentPanel$dataSou, _tables$tableFooter, _tables$selectedRowKe, _tables$tableFooter2, _tables$tableFooter3, _tables$tableFooter5;
57
57
  let {
58
58
  config,
59
59
  getInitialData,
@@ -83,7 +83,8 @@ function GenricLayOut(_ref) {
83
83
  handleTableFooterApi,
84
84
  handleSwitchSelectItem,
85
85
  handleTableColumnClickParent,
86
- handleLeftHeaderFirstButton
86
+ handleLeftHeaderFirstButton,
87
+ handleTabExtraActionChange
87
88
  } = {}
88
89
  } = _ref;
89
90
  const [state, dispatch] = (0, _react.useReducer)(_layoutReducer.genericLayoutReducer, config !== null && config !== void 0 ? config : _layoutReducer.initialState);
@@ -110,7 +111,8 @@ function GenricLayOut(_ref) {
110
111
  customDrawer,
111
112
  staticFilter,
112
113
  profileData,
113
- infoPanel
114
+ infoPanel,
115
+ infoData
114
116
  } = state !== null && state !== void 0 ? state : {};
115
117
  (0, _react.useEffect)(() => {
116
118
  init();
@@ -253,6 +255,18 @@ function GenricLayOut(_ref) {
253
255
  });
254
256
  };
255
257
 
258
+ /**
259
+ * Resets the tabs extra action switch state to unchecked
260
+ */
261
+ const resetTabsExtraActionSwitch = () => {
262
+ if (tabs !== null && tabs !== void 0 && tabs.extraAction) {
263
+ dispatch({
264
+ type: _layoutReducer.actionTypes.SET_TABS_EXTRA_ACTION_CHECKED,
265
+ payload: false
266
+ });
267
+ }
268
+ };
269
+
256
270
  /**
257
271
  * Handles the change of the search input value.
258
272
  *
@@ -275,6 +289,7 @@ function GenricLayOut(_ref) {
275
289
  payload: value
276
290
  });
277
291
  if (value === "") {
292
+ resetTabsExtraActionSwitch();
278
293
  if (handleInputSearchChange) {
279
294
  var _state$inputSearch, _state$tabs, _customDrawer$applied, _config$tables, _config$tables2, _tables$sorting, _tables$sorting2, _header$subHeading, _header$subHeading2, _state$misc;
280
295
  dispatch({
@@ -353,6 +368,7 @@ function GenricLayOut(_ref) {
353
368
  type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_VALUE,
354
369
  payload: trimedValue
355
370
  });
371
+ resetTabsExtraActionSwitch();
356
372
  if (handleInputSearchEnter) {
357
373
  var _state$tabs2, _config$tables5, _config$tables6, _tables$sorting3, _tables$sorting4, _customDrawer$applied2, _header$subHeading3, _header$subHeading4, _state$misc2;
358
374
  const {
@@ -420,6 +436,7 @@ function GenricLayOut(_ref) {
420
436
  payload: value
421
437
  });
422
438
  if (value === "") {
439
+ resetTabsExtraActionSwitch();
423
440
  if (handleDropdownSearchInputChange) {
424
441
  var _state$tabs3, _config$tables9, _config$tables10, _tables$sorting5, _tables$sorting6, _tables$filter, _staticFilter$data2, _customDrawer$applied3, _header$subHeading5, _header$subHeading6, _state$misc3, _state$staticFilter$m, _state$staticFilter;
425
442
  dispatch({
@@ -512,6 +529,7 @@ function GenricLayOut(_ref) {
512
529
  type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_VALUE,
513
530
  payload: value
514
531
  });
532
+ resetTabsExtraActionSwitch();
515
533
  if (handleDropdownSearchEnter) {
516
534
  var _state$tabs4, _config$tables13, _config$tables14, _tables$sorting7, _tables$sorting8, _tables$filter2, _staticFilter$data3, _customDrawer$applied4, _header$subHeading7, _header$subHeading8, _state$misc4, _state$staticFilter$m2, _state$staticFilter2;
517
535
  const {
@@ -572,6 +590,7 @@ function GenricLayOut(_ref) {
572
590
  * @returns {Promise<void>} - Resolves when the data has been fetched and the state has been updated.
573
591
  */
574
592
  const onDropdownSearchOptionChange = async option => {
593
+ resetTabsExtraActionSwitch();
575
594
  dispatch({
576
595
  type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_OPTION,
577
596
  payload: option === null || option === void 0 ? void 0 : option.value
@@ -690,6 +709,7 @@ function GenricLayOut(_ref) {
690
709
  * @returns {Promise<void>} - Resolves when the table data has been updated.
691
710
  */
692
711
  const onDropdownSearchClear = async () => {
712
+ resetTabsExtraActionSwitch();
693
713
  dispatch({
694
714
  type: _layoutReducer.actionTypes.SET_DROPDOWN_SEARCH_VALUE,
695
715
  payload: null
@@ -754,6 +774,7 @@ function GenricLayOut(_ref) {
754
774
  * @returns {Promise<void>} - Resolves when the table data has been updated.
755
775
  */
756
776
  const onInputSearchClear = async () => {
777
+ resetTabsExtraActionSwitch();
757
778
  dispatch({
758
779
  type: _layoutReducer.actionTypes.SET_INPUT_SEARCH_VALUE,
759
780
  payload: null
@@ -1144,6 +1165,7 @@ function GenricLayOut(_ref) {
1144
1165
  sortDirection: (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "ascend" && "ASC" || (sorter === null || sorter === void 0 ? void 0 : sorter.order) === "descend" && "DESC" || ""
1145
1166
  }
1146
1167
  });
1168
+ resetTabsExtraActionSwitch();
1147
1169
  if (handleTableChange) {
1148
1170
  var _state$dropdownSearch3, _state$inputSearch4, _state$tabs8, _header$subHeading15, _header$subHeading16, _staticFilter$data6, _customDrawer$applied8, _state$misc15, _state$staticFilter$m5, _state$staticFilter5;
1149
1171
  dispatch({
@@ -1202,6 +1224,7 @@ function GenricLayOut(_ref) {
1202
1224
  */
1203
1225
  const onTabClick = async key => {
1204
1226
  var _tables$filter5, _tables$columns2, _staticFilter$data$fi2;
1227
+ resetTabsExtraActionSwitch();
1205
1228
  dispatch({
1206
1229
  type: _layoutReducer.actionTypes.TAB_CLICK,
1207
1230
  payload: {
@@ -1392,6 +1415,7 @@ function GenricLayOut(_ref) {
1392
1415
  };
1393
1416
  const onRemoveAppliedFilter = async filterKey => {
1394
1417
  var _state$customDrawer;
1418
+ resetTabsExtraActionSwitch();
1395
1419
  const currentFilters = _objectSpread({}, state === null || state === void 0 || (_state$customDrawer = state.customDrawer) === null || _state$customDrawer === void 0 ? void 0 : _state$customDrawer.appliedFilters);
1396
1420
 
1397
1421
  // Remove the specific filter
@@ -1674,6 +1698,7 @@ function GenricLayOut(_ref) {
1674
1698
  };
1675
1699
  const onClearAllAppliedFilters = async () => {
1676
1700
  var _state$dropdownSearch9, _state$inputSearch9, _state$tabs15, _tables$pagination9, _tables$pagination10, _tables$filter10, _tables$sorting23, _header$subHeading27, _header$subHeading28, _staticFilter$data11, _tables$sorting24, _state$misc23, _state$staticFilter$m11, _state$staticFilter11;
1701
+ resetTabsExtraActionSwitch();
1677
1702
  const {
1678
1703
  error,
1679
1704
  data
@@ -1895,6 +1920,7 @@ function GenricLayOut(_ref) {
1895
1920
  const rightHeaderSecondButtonClick = async () => {
1896
1921
  if ((rightHeaderSecondButton === null || rightHeaderSecondButton === void 0 ? void 0 : rightHeaderSecondButton.action) === "RESET_CUSTOM_DRAWER") {
1897
1922
  var _state$dropdownSearch10, _state$inputSearch10, _state$tabs16, _tables$pagination11, _tables$pagination12, _tables$filter11, _tables$sorting25, _header$subHeading29, _header$subHeading30, _staticFilter$data12, _tables$sorting26, _state$misc26, _state$staticFilter$m12, _state$staticFilter12;
1923
+ resetTabsExtraActionSwitch();
1898
1924
  const {
1899
1925
  error,
1900
1926
  data
@@ -2004,6 +2030,7 @@ function GenricLayOut(_ref) {
2004
2030
  * @param {string} filterValue - The value of the selected filter
2005
2031
  */
2006
2032
  const onStaticFilterSelect = async filterValue => {
2033
+ resetTabsExtraActionSwitch();
2007
2034
  const selectedFilterStatus = staticFilter.data.map(item => item.selected ? item.value : null).filter(Boolean);
2008
2035
  const currentSelectedIndex = selectedFilterStatus.indexOf(filterValue);
2009
2036
  if (currentSelectedIndex === -1) {
@@ -2078,6 +2105,7 @@ function GenricLayOut(_ref) {
2078
2105
  current,
2079
2106
  pageSize
2080
2107
  } = _ref5;
2108
+ resetTabsExtraActionSwitch();
2081
2109
  dispatch({
2082
2110
  type: _layoutReducer.actionTypes.SET_PAGINATION,
2083
2111
  payload: {
@@ -2187,7 +2215,26 @@ function GenricLayOut(_ref) {
2187
2215
  url: imageViewer === null || imageViewer === void 0 || (_imageViewer$content3 = imageViewer.content) === null || _imageViewer$content3 === void 0 ? void 0 : _imageViewer$content3.url
2188
2216
  });
2189
2217
  }
2190
- }), (cards === null || cards === void 0 ? void 0 : cards.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2218
+ }), (infoData === null || infoData === void 0 ? void 0 : infoData.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2219
+ loading: state === null || state === void 0 ? void 0 : state.isLoading,
2220
+ active: true,
2221
+ paragraph: {
2222
+ rows: 1
2223
+ }
2224
+ }, /*#__PURE__*/_react.default.createElement("div", {
2225
+ className: "margin-bottom-12"
2226
+ }, /*#__PURE__*/_react.default.createElement(_CustomInfo.default, {
2227
+ closable: infoData === null || infoData === void 0 ? void 0 : infoData.closable,
2228
+ description: infoData === null || infoData === void 0 ? void 0 : infoData.description,
2229
+ iconConfig: {
2230
+ icon: /*#__PURE__*/_react.default.createElement(_MaterialIcon.default, {
2231
+ color: (infoData === null || infoData === void 0 || (_infoData$iconConfig = infoData.iconConfig) === null || _infoData$iconConfig === void 0 ? void 0 : _infoData$iconConfig.color) || "primary-content",
2232
+ icon: infoData === null || infoData === void 0 || (_infoData$iconConfig2 = infoData.iconConfig) === null || _infoData$iconConfig2 === void 0 ? void 0 : _infoData$iconConfig2.icon,
2233
+ size: (infoData === null || infoData === void 0 || (_infoData$iconConfig3 = infoData.iconConfig) === null || _infoData$iconConfig3 === void 0 ? void 0 : _infoData$iconConfig3.size) || 16
2234
+ }),
2235
+ position: (infoData === null || infoData === void 0 || (_infoData$iconConfig4 = infoData.iconConfig) === null || _infoData$iconConfig4 === void 0 ? void 0 : _infoData$iconConfig4.position) || "left"
2236
+ }
2237
+ }))), (cards === null || cards === void 0 ? void 0 : cards.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2191
2238
  loading: state === null || state === void 0 ? void 0 : state.isLoading,
2192
2239
  active: true,
2193
2240
  paragraph: {
@@ -2306,7 +2353,73 @@ function GenricLayOut(_ref) {
2306
2353
  }))
2307
2354
  },
2308
2355
  activeKey: tabs === null || tabs === void 0 ? void 0 : tabs.active,
2309
- onTabClick: onTabClick
2356
+ onTabClick: onTabClick,
2357
+ extraAction: tabs !== null && tabs !== void 0 && tabs.extraAction ? _objectSpread(_objectSpread({}, tabs.extraAction), {}, {
2358
+ props: _objectSpread(_objectSpread({}, tabs.extraAction.props), {}, {
2359
+ checked: (_ref6 = (_tabs$extraAction$che = tabs.extraAction.checked) !== null && _tabs$extraAction$che !== void 0 ? _tabs$extraAction$che : (_tabs$extraAction$pro = tabs.extraAction.props) === null || _tabs$extraAction$pro === void 0 ? void 0 : _tabs$extraAction$pro.defaultChecked) !== null && _ref6 !== void 0 ? _ref6 : false,
2360
+ onChange: async checked => {
2361
+ var _tabs$extraAction$pro2;
2362
+ // Update switch state immediately
2363
+ dispatch({
2364
+ type: _layoutReducer.actionTypes.SET_TABS_EXTRA_ACTION_CHECKED,
2365
+ payload: checked
2366
+ });
2367
+ // Call the original onChange if provided
2368
+ if ((_tabs$extraAction$pro2 = tabs.extraAction.props) !== null && _tabs$extraAction$pro2 !== void 0 && _tabs$extraAction$pro2.onChange) {
2369
+ tabs.extraAction.props.onChange(checked);
2370
+ }
2371
+ // Call handleTabExtraActionChange
2372
+ if (handleTabExtraActionChange) {
2373
+ var _tables$pagination17, _tables$pagination18, _tables$sorting31, _tables$sorting32, _tables$filter13, _staticFilter$data14, _state$misc31;
2374
+ dispatch({
2375
+ type: _layoutReducer.actionTypes.SET_LOADING,
2376
+ payload: true
2377
+ });
2378
+ const {
2379
+ error,
2380
+ data
2381
+ } = await handleTabExtraActionChange(_objectSpread(_objectSpread(_objectSpread({
2382
+ checked,
2383
+ selectedTab: tabs === null || tabs === void 0 ? void 0 : tabs.active,
2384
+ current: tables === null || tables === void 0 || (_tables$pagination17 = tables.pagination) === null || _tables$pagination17 === void 0 ? void 0 : _tables$pagination17.current,
2385
+ pageSize: tables === null || tables === void 0 || (_tables$pagination18 = tables.pagination) === null || _tables$pagination18 === void 0 ? void 0 : _tables$pagination18.pageSize,
2386
+ field: tables === null || tables === void 0 || (_tables$sorting31 = tables.sorting) === null || _tables$sorting31 === void 0 ? void 0 : _tables$sorting31.sortBy,
2387
+ order: tables === null || tables === void 0 || (_tables$sorting32 = tables.sorting) === null || _tables$sorting32 === void 0 ? void 0 : _tables$sorting32.sortDirection
2388
+ }, (tables === null || tables === void 0 || (_tables$filter13 = tables.filter) === null || _tables$filter13 === void 0 ? void 0 : _tables$filter13.key) && {
2389
+ columnFilterStatus: tables === null || tables === void 0 ? void 0 : tables.filter
2390
+ }), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && ((_staticFilter$data14 = staticFilter.data) === null || _staticFilter$data14 === void 0 || (_staticFilter$data14 = _staticFilter$data14.find(item => item.selected)) === null || _staticFilter$data14 === void 0 ? void 0 : _staticFilter$data14.value) && {
2391
+ staticFilter: staticFilter.data.find(item => item.selected).value
2392
+ }), (_state$misc31 = state === null || state === void 0 ? void 0 : state.misc) !== null && _state$misc31 !== void 0 ? _state$misc31 : {}));
2393
+ if (error) {
2394
+ showErrorNotification(error);
2395
+ dispatch({
2396
+ type: _layoutReducer.actionTypes.SET_TABLE_EMPTY
2397
+ });
2398
+ } else {
2399
+ var _config$tables33, _config$tables34;
2400
+ if (staticFilter !== null && staticFilter !== void 0 && staticFilter.visible) {
2401
+ setStaticFilterData(data);
2402
+ }
2403
+ dispatch({
2404
+ type: _layoutReducer.actionTypes.SET_TABLE_DATA,
2405
+ payload: data
2406
+ });
2407
+ dispatch({
2408
+ type: _layoutReducer.actionTypes.SET_PAGINATION,
2409
+ payload: {
2410
+ current: config === null || config === void 0 || (_config$tables33 = config.tables) === null || _config$tables33 === void 0 || (_config$tables33 = _config$tables33.pagination) === null || _config$tables33 === void 0 ? void 0 : _config$tables33.current,
2411
+ pageSize: config === null || config === void 0 || (_config$tables34 = config.tables) === null || _config$tables34 === void 0 || (_config$tables34 = _config$tables34.pagination) === null || _config$tables34 === void 0 ? void 0 : _config$tables34.pageSize
2412
+ }
2413
+ });
2414
+ }
2415
+ dispatch({
2416
+ type: _layoutReducer.actionTypes.SET_LOADING,
2417
+ payload: false
2418
+ });
2419
+ }
2420
+ }
2421
+ })
2422
+ }) : null
2310
2423
  }))), (staticFilter === null || staticFilter === void 0 ? void 0 : staticFilter.visible) && /*#__PURE__*/_react.default.createElement(_antd.Skeleton, {
2311
2424
  loading: state === null || state === void 0 ? void 0 : state.isLoading,
2312
2425
  active: true,
@@ -2338,7 +2451,7 @@ function GenricLayOut(_ref) {
2338
2451
  emptyText: emptyTableState
2339
2452
  },
2340
2453
  emptyStateCard: emptyTableState,
2341
- onMobilePageChange: tables !== null && tables !== void 0 && (_tables$pagination17 = tables.pagination) !== null && _tables$pagination17 !== void 0 && _tables$pagination17.mwebPagination ? onMobilePageChange : undefined
2454
+ onMobilePageChange: tables !== null && tables !== void 0 && (_tables$pagination19 = tables.pagination) !== null && _tables$pagination19 !== void 0 && _tables$pagination19.mwebPagination ? onMobilePageChange : undefined
2342
2455
  })))), (drawer === null || drawer === void 0 ? void 0 : drawer.visible) && /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
2343
2456
  className: "oaDrawer",
2344
2457
  title: drawer === null || drawer === void 0 || (_drawer$data = drawer.data) === null || _drawer$data === void 0 || (_drawer$data = _drawer$data[(_tabs$active5 = tabs === null || tabs === void 0 ? void 0 : tabs.active) !== null && _tabs$active5 !== void 0 ? _tabs$active5 : "default"]) === null || _drawer$data === void 0 || (_drawer$data = _drawer$data[drawer === null || drawer === void 0 ? void 0 : drawer.active]) === null || _drawer$data === void 0 ? void 0 : _drawer$data.title,
@@ -57,7 +57,8 @@ const actionTypes = exports.actionTypes = {
57
57
  UPDATE_FILTER_FORM_VALUES: "UPDATE_FILTER_FORM_VALUES",
58
58
  SET_STATIC_FILTER: "SET_STATIC_FILTER",
59
59
  SET_PROFILE_DATA: "SET_PROFILE_DATA",
60
- CHANGE_ROW: "CHANGE_ROW"
60
+ CHANGE_ROW: "CHANGE_ROW",
61
+ SET_TABS_EXTRA_ACTION_CHECKED: "SET_TABS_EXTRA_ACTION_CHECKED"
61
62
  };
62
63
  function getFieldDefaultValue(widget) {
63
64
  switch (widget) {
@@ -74,7 +75,7 @@ function getFieldDefaultValue(widget) {
74
75
  }
75
76
  }
76
77
  const genericLayoutReducer = exports.genericLayoutReducer = (0, _immer.produce)((draft, action) => {
77
- var _draft$imageViewer, _action$payload, _action$payload2, _draft$tabs, _draft$customDrawer$d, _draft$tables, _action$payload3, _action$payload4, _action$payload5, _draft$tabs$active, _draft$tabs2, _action$payload6, _action$payload7, _action$payload8, _draft$staticFilter, _draft$tables2, _draft$customDrawer$d2, _draft$customDrawer$d3, _draft$customDrawer$d4;
78
+ var _draft$imageViewer, _action$payload, _action$payload2, _draft$tabs, _draft$customDrawer$d, _draft$tables, _action$payload3, _action$payload4, _action$payload5, _draft$tabs$active, _draft$tabs2, _action$payload6, _action$payload7, _action$payload8, _draft$staticFilter, _draft$tables2, _draft$customDrawer$d2, _draft$customDrawer$d3, _draft$customDrawer$d4, _draft$tabs4;
78
79
  switch (action.type) {
79
80
  case actionTypes.INIT:
80
81
  return (0, _staticConfigResolver.removeHidden)(action.payload);
@@ -304,6 +305,11 @@ const genericLayoutReducer = exports.genericLayoutReducer = (0, _immer.produce)(
304
305
  case actionTypes.CHANGE_ROW:
305
306
  draft.tables = action.payload.tables;
306
307
  break;
308
+ case actionTypes.SET_TABS_EXTRA_ACTION_CHECKED:
309
+ if ((_draft$tabs4 = draft.tabs) !== null && _draft$tabs4 !== void 0 && _draft$tabs4.extraAction) {
310
+ draft.tabs.extraAction.checked = action.payload;
311
+ }
312
+ break;
307
313
  default:
308
314
  break;
309
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oa-componentbook",
3
- "version": "1.0.1-stage.453",
3
+ "version": "1.0.1-stage.454",
4
4
  "private": false,
5
5
  "description": "Reusable components",
6
6
  "main": "build/index.js",