"use strict";

exports.__esModule = true;
exports.ValidationAndDefaultsSection = void 0;
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _designSystem = require("@wix/design-system");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _ValidationSubSection = require("./ValidationSubSection");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CmsFieldManagement/Sections/ValidationAndDefaultsSection.tsx";
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); }
const _ValidationAndDefaultsSection = ({
  state
}) => {
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
  const hasValidation = state.supportedValidationRules.length > 0;
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 17,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement("div", {
    role: "button",
    tabIndex: 0,
    style: {
      cursor: 'pointer',
      display: 'flex',
      alignItems: 'center',
      gap: 8,
      padding: '16px 0'
    },
    onClick: () => setIsOpen(v => !v),
    onKeyDown: e => e.key === 'Enter' && setIsOpen(v => !v),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 18,
      columnNumber: 7
    }
  }, isOpen ? /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronDown, {
    size: "18px",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 33,
      columnNumber: 19
    }
  }) : /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.ChevronRight, {
    size: "18px",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 33,
      columnNumber: 49
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 34,
      columnNumber: 9
    }
  }, "Validation and defaults")), isOpen && /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    gap: "SP6",
    paddingBottom: "SP4",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 38,
      columnNumber: 9
    }
  }, hasValidation && /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    gap: "SP2",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 40,
      columnNumber: 13
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    weight: "bold",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 41,
      columnNumber: 15
    }
  }, "Validation"), /*#__PURE__*/_react.default.createElement(_ValidationSubSection.ValidationSubSection, {
    state: state,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 42,
      columnNumber: 15
    }
  })), /*#__PURE__*/_react.default.createElement(_designSystem.Divider, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 46,
      columnNumber: 11
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.FormField, {
    label: "Help text",
    infoContent: "Descriptive text shown below the field in forms.",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 48,
      columnNumber: 11
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Input, {
    value: state.properties.helpText,
    onChange: e => state.setHelpText(e.target.value),
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 52,
      columnNumber: 13
    }
  }))));
};
const ValidationAndDefaultsSection = exports.ValidationAndDefaultsSection = (0, _mobxReactLite.observer)(_ValidationAndDefaultsSection);
//# sourceMappingURL=ValidationAndDefaultsSection.js.map