ods-component-lib 1.18.152 → 1.18.153

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,14 +3,5 @@ interface IOnToolbarPreparingOptions {
3
3
  toolbarButtonGroup?: any[];
4
4
  callback?: (e: any) => void;
5
5
  }
6
- /**
7
- * Handles the rendering and configuration of the toolbar for ODS DataGrid.
8
- * This hook prepares the toolbar based on the button configuration provided through props,
9
- * rendering primary and secondary buttons directly and additional buttons in a dropdown if necessary.
10
- *
11
- * @param {Object} props - The properties including configuration for toolbar buttons and the page title.
12
- * @returns {Function} A memoized function that configures and populates the toolbar with buttons and title.
13
- * This function is intended to be used as a callback in the toolbar's preparation phase of the DataGrid component.
14
- */
15
6
  export declare const useOnToolbarButtonHandler: ({ pageTitle, toolbarButtonGroup, callback }: IOnToolbarPreparingOptions) => (e: any) => void;
16
7
  export {};
package/dist/index.js CHANGED
@@ -35026,7 +35026,7 @@ var useStyles$2 = antdStyle.createStyles(function (_ref) {
35026
35026
  var css = _ref.css,
35027
35027
  token = _ref.token;
35028
35028
  return {
35029
- toolbarGrid: css(_templateObject$r || (_templateObject$r = _taggedTemplateLiteralLoose(["\n & .toolbar-primary-button {\n margin-left: ", "px;\n }\n\n & .toolbar-dropdown-container {\n margin-left: ", "px;\n }\n "])), token.margin, token.marginXXS)
35029
+ toolbarGrid: css(_templateObject$r || (_templateObject$r = _taggedTemplateLiteralLoose(["\n & .toolbar-primary-button {\n margin-left: ", "px;\n }\n & .toolbar-dropdown-container {\n margin-left: ", "px;\n }\n & .title-container { \n display: flex;\n margin: 0;\n }\n "])), token.margin, token.marginXXS)
35030
35030
  };
35031
35031
  });
35032
35032
 
@@ -35036,79 +35036,94 @@ var useOnToolbarButtonHandler = function useOnToolbarButtonHandler(_ref) {
35036
35036
  callback = _ref.callback;
35037
35037
  var _useStyles = useStyles$2(),
35038
35038
  styles = _useStyles.styles;
35039
- var onToolbarPreparing = React.useMemo(function () {
35040
- return function (e) {
35041
- if ((toolbarButtonGroup === null || toolbarButtonGroup === void 0 ? void 0 : toolbarButtonGroup.length) > 0) {
35042
- var primaryButtons = toolbarButtonGroup.slice(0, 3);
35043
- var additionalButtons = toolbarButtonGroup.length > 3 ? toolbarButtonGroup.slice(3) : [];
35044
- primaryButtons.forEach(function (button, index) {
35045
- var buttonContainer = document.createElement('div');
35046
- var rootButton = client_1(buttonContainer);
35047
- rootButton.render(React__default.createElement(React__default.Fragment, null, React__default.createElement(OdsButton, Object.assign({
35048
- key: index,
35049
- className: "toolbar-primary-button",
35050
- type: button.type
35051
- }, button.onclick && {
35052
- onClick: button.onclick
35053
- }, {
35054
- disabled: button.disabled
35055
- }), button.label)));
35056
- e.toolbarOptions.items.push({
35057
- location: 'before',
35058
- widget: 'dxTemplate',
35059
- template: function template(_, __, container) {
35060
- container.classList.add(styles.toolbarGrid);
35061
- container.appendChild(buttonContainer);
35062
- }
35063
- });
35039
+ var initialPropsRef = React.useRef({
35040
+ pageTitle: pageTitle,
35041
+ toolbarButtonGroup: toolbarButtonGroup,
35042
+ callback: callback
35043
+ });
35044
+ if (!initialPropsRef.current) {
35045
+ initialPropsRef.current = {
35046
+ pageTitle: pageTitle,
35047
+ toolbarButtonGroup: toolbarButtonGroup,
35048
+ callback: callback
35049
+ };
35050
+ }
35051
+ var onToolbarPreparing = React.useRef(function (e) {
35052
+ var _initialPropsRef$curr = initialPropsRef.current,
35053
+ pageTitle = _initialPropsRef$curr.pageTitle,
35054
+ toolbarButtonGroup = _initialPropsRef$curr.toolbarButtonGroup,
35055
+ callback = _initialPropsRef$curr.callback;
35056
+ if ((toolbarButtonGroup === null || toolbarButtonGroup === void 0 ? void 0 : toolbarButtonGroup.length) > 0) {
35057
+ var primaryButtons = toolbarButtonGroup.slice(0, 3);
35058
+ var additionalButtons = toolbarButtonGroup.length > 3 ? toolbarButtonGroup.slice(3) : [];
35059
+ primaryButtons.forEach(function (button, index) {
35060
+ var buttonContainer = document.createElement('div');
35061
+ var rootButton = client_1(buttonContainer);
35062
+ rootButton.render(React__default.createElement(OdsButton, Object.assign({
35063
+ key: index,
35064
+ className: "toolbar-primary-button",
35065
+ type: button.type
35066
+ }, button.onclick && {
35067
+ onClick: button.onclick
35068
+ }, {
35069
+ disabled: button.disabled
35070
+ }), button.label));
35071
+ e.toolbarOptions.items.push({
35072
+ location: 'before',
35073
+ widget: 'dxTemplate',
35074
+ template: function template(_, __, container) {
35075
+ container.classList.add(styles.toolbarGrid);
35076
+ container.appendChild(buttonContainer);
35077
+ }
35064
35078
  });
35065
- if (additionalButtons.length > 0) {
35066
- var dropdownContainer = document.createElement('div');
35067
- dropdownContainer.classList.add('toolbar-dropdown-container');
35068
- var rootDropdown = client_1(dropdownContainer);
35069
- rootDropdown.render(React__default.createElement(React__default.Fragment, null, React__default.createElement(OdsDropdown, {
35070
- key: "dropdown-custom-toolbar",
35071
- menuItems: additionalButtons.map(function (button) {
35072
- return {
35073
- label: button.label,
35074
- onClick: button.onclick
35075
- };
35076
- })
35077
- }, React__default.createElement(OdsButton, {
35078
- type: "text",
35079
- icon: React__default.createElement(DynamicIcon, {
35080
- iconName: "kebabMenu"
35081
- })
35082
- }))));
35083
- e.toolbarOptions.items.push({
35084
- location: 'before',
35085
- widget: 'dxTemplate',
35086
- template: function template(_, __, container) {
35087
- container.classList.add(styles.toolbarGrid);
35088
- container.appendChild(dropdownContainer);
35089
- }
35090
- });
35091
- }
35092
- }
35093
- if (pageTitle) {
35094
- var titleContainer = document.createElement('div');
35095
- var rootTitle = client_1(titleContainer);
35096
- rootTitle.render(React__default.createElement(React__default.Fragment, null, React__default.createElement(OdsTitle, {
35097
- level: 5
35098
- }, pageTitle)));
35099
- e.toolbarOptions.items.unshift({
35079
+ });
35080
+ if (additionalButtons.length > 0) {
35081
+ var dropdownContainer = document.createElement('div');
35082
+ var rootDropdown = client_1(dropdownContainer);
35083
+ rootDropdown.render(React__default.createElement(OdsDropdown, {
35084
+ key: "dropdown-custom-toolbar",
35085
+ menuItems: additionalButtons.map(function (button) {
35086
+ return {
35087
+ label: button.label,
35088
+ onClick: button.onclick
35089
+ };
35090
+ })
35091
+ }, React__default.createElement(OdsButton, {
35092
+ type: "text",
35093
+ icon: React__default.createElement(DynamicIcon, {
35094
+ iconName: "kebabMenu"
35095
+ })
35096
+ })));
35097
+ e.toolbarOptions.items.push({
35100
35098
  location: 'before',
35101
- cssClass: 'toolbarTitleItem',
35099
+ widget: 'dxTemplate',
35102
35100
  template: function template(_, __, container) {
35103
- container.appendChild(titleContainer);
35101
+ container.classList.add(styles.toolbarGrid);
35102
+ container.appendChild(dropdownContainer);
35104
35103
  }
35105
35104
  });
35106
35105
  }
35107
- if (callback) {
35108
- callback(e);
35109
- }
35110
- };
35111
- }, [pageTitle, toolbarButtonGroup]);
35106
+ }
35107
+ if (pageTitle) {
35108
+ var titleContainer = document.createElement('div');
35109
+ var rootTitle = client_1(titleContainer);
35110
+ rootTitle.render(React__default.createElement(OdsTitle, {
35111
+ level: 5,
35112
+ className: "title-container"
35113
+ }, pageTitle));
35114
+ e.toolbarOptions.items.unshift({
35115
+ location: 'before',
35116
+ widget: 'dxTemplate',
35117
+ template: function template(_, __, container) {
35118
+ container.classList.add(styles.toolbarGrid);
35119
+ container.appendChild(titleContainer);
35120
+ }
35121
+ });
35122
+ }
35123
+ if (callback) {
35124
+ callback(e);
35125
+ }
35126
+ }).current;
35112
35127
  return onToolbarPreparing;
35113
35128
  };
35114
35129