Liferay.Loader.define("dynamic-data-mapping-form-field-type@5.0.45/FieldSet/Panel.es", ['module', 'exports', 'require', './Panel.scss', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$classnames', 'dynamic-data-mapping-form-renderer', 'frontend-js-react-web$react', './useHeightTransition.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports["default"] = void 0;

    require("./Panel.scss");

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _dynamicDataMappingFormRenderer = require("dynamic-data-mapping-form-renderer");

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

    var _useHeightTransition3 = _interopRequireDefault(require("./useHeightTransition.es"));

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { "default": obj };
    }

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    /**
     * Alternative component for ClayPanel,
     * since the original component don't have to much flexibility
     * for adding items on the ClayPanel trigger.
     */
    var Panel = function Panel(_ref) {
      var children = _ref.children,
          name = _ref.name,
          readOnly = _ref.readOnly,
          repeatable = _ref.repeatable,
          showLabel = _ref.showLabel,
          showRepeatableRemoveButton = _ref.showRepeatableRemoveButton,
          title = _ref.title;

      var panelRef = _react["default"].useRef(null);

      var _React$useState = _react["default"].useState(true),
          _React$useState2 = _slicedToArray(_React$useState, 2),
          expanded = _React$useState2[0],
          setExpanded = _React$useState2[1];

      var dispatch = (0, _dynamicDataMappingFormRenderer.useForm)();

      var _useHeightTransition = (0, _useHeightTransition3["default"])(expanded, setExpanded, panelRef),
          _useHeightTransition2 = _slicedToArray(_useHeightTransition, 3),
          transitioning = _useHeightTransition2[0],
          handleTransitionEnd = _useHeightTransition2[1],
          startTransition = _useHeightTransition2[2];

      return _react["default"].createElement("div", {
        className: (0, _classnames["default"])('collapsable-panel', 'panel', 'panel-unstyled'),
        role: "tablist"
      }, _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement(_button["default"], {
        "aria-expanded": expanded,
        className: (0, _classnames["default"])('collapse-icon', 'collapse-icon-middle', 'panel-header', 'panel-header-link', {
          collapsed: !(!expanded && transitioning || expanded && !transitioning)
        }),
        displayType: "unstyled",
        onClick: startTransition,
        role: "tab"
      }, _react["default"].createElement(_react["default"].Fragment, null, showLabel && _react["default"].createElement("span", {
        className: "panel-title"
      }, _react["default"].createElement("label", {
        className: "text-uppercase"
      }, title)), repeatable && _react["default"].createElement("span", {
        className: "actions collapse-icon-options"
      }, _react["default"].createElement("div", {
        className: "lfr-ddm-form-field-repeatable-toolbar"
      }, showRepeatableRemoveButton && _react["default"].createElement(_button["default"], {
        className: "ddm-form-field-repeatable-delete-button lfr-portal-tooltip p-0",
        disabled: readOnly,
        onClick: function onClick(event) {
          event.stopPropagation();
          dispatch({
            payload: name,
            type: _dynamicDataMappingFormRenderer.EVENT_TYPES.FIELD_REMOVED
          });
        },
        small: true,
        title: Liferay.Language.get('remove')
      }, _react["default"].createElement(_icon["default"], {
        symbol: "hr"
      })), _react["default"].createElement(_button["default"], {
        className: "ddm-form-field-repeatable-add-button lfr-portal-tooltip p-0",
        disabled: readOnly,
        onClick: function onClick(event) {
          event.stopPropagation();
          dispatch({
            payload: name,
            type: _dynamicDataMappingFormRenderer.EVENT_TYPES.FIELD_REPEATED
          });
        },
        small: true,
        title: Liferay.Language.get('duplicate')
      }, _react["default"].createElement(_icon["default"], {
        symbol: "plus"
      })))), _react["default"].createElement("span", {
        className: (0, _classnames["default"])('actions', 'collapse-icon-closed')
      }, _react["default"].createElement(_icon["default"], {
        symbol: "angle-down"
      })), _react["default"].createElement("span", {
        className: (0, _classnames["default"])('actions', 'collapse-icon-open')
      }, _react["default"].createElement(_icon["default"], {
        symbol: "angle-up"
      })))), _react["default"].createElement("div", {
        className: (0, _classnames["default"])('panel-collapse', {
          collapse: !transitioning,
          collapsing: transitioning,
          show: expanded
        }),
        onTransitionEnd: handleTransitionEnd,
        ref: panelRef,
        role: "tabpanel"
      }, children)));
    };

    var _default = Panel;
    exports["default"] = _default;
    //# sourceMappingURL=Panel.es.js.map
  }
});
//# sourceMappingURL=Panel.es.js.map