"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.SettingsModalLayout = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _designSystem = require("@wix/design-system");
var _react = _interopRequireWildcard(require("react"));
var _lodash = _interopRequireDefault(require("lodash"));
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/test-utils/SettingsModalLayout.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 features = {
  initialError: '',
  refreshError: '',
  fetchNextPageError: '',
  fetchTranslationsError: '',
  groupType: [{
    key: 'views',
    value: 'Views'
  }, {
    key: 'tabs',
    value: 'Tabs'
  }],
  addNew: 'Add New Item',
  bulkActions: 'Bulk Actions',
  customColumns: 'Custom Columns',
  dnd: 'Drag & Drop',
  filters: 'Filters',
  advancedSorting: 'Advanced Sorting',
  limit: 'Limit'
};
const SettingsModalLayout = props => {
  const {
    ok,
    cancel,
    preferences: oldPreferences,
    ...rest
  } = props;
  const [preferences, setPreferences] = (0, _react.useState)({
    ...oldPreferences
  });
  return /*#__PURE__*/_react.default.createElement(_designSystem.CustomModalLayout, (0, _extends2.default)({
    primaryButtonText: "Save",
    primaryButtonOnClick: () => {
      ok(preferences);
    },
    secondaryButtonOnClick: () => cancel(),
    onCloseButtonClick: () => cancel(),
    secondaryButtonText: "Cancel",
    title: "Demo Settings"
  }, rest, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 64,
      columnNumber: 5
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    gap: "SP3",
    direction: "vertical",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 75,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    gap: "SP2",
    paddingBottom: "SP3",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 76,
      columnNumber: 9
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 77,
      columnNumber: 11
    }
  }, "Features:"), _lodash.default.reduce(features, (acc, value, key) => {
    const feature = key;
    if (_lodash.default.isArray(value)) {
      return _lodash.default.concat(acc, value.map(option => /*#__PURE__*/_react.default.createElement(_designSystem.Checkbox, {
        key: option.key,
        checked: preferences[feature] === option.key,
        onChange: () => setPreferences({
          ...preferences,
          [key]: preferences[feature] !== option.key ? option.key : undefined
        }),
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 86,
          columnNumber: 21
        }
      }, option.value)));
    }
    if (typeof preferences[feature] === 'number') {
      acc.push(/*#__PURE__*/_react.default.createElement(_designSystem.FormField, {
        key: key,
        label: value,
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 107,
          columnNumber: 19
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Input, {
        key: key,
        value: preferences[feature],
        onChange: e => {
          const {
            value: newValue
          } = e.target;
          setPreferences({
            ...preferences,
            [key]: newValue ? parseInt(newValue, 10) : 10
          });
        },
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 108,
          columnNumber: 21
        }
      })));
      return acc;
    }
    acc.push(/*#__PURE__*/_react.default.createElement(_designSystem.Checkbox, {
      key: key,
      checked: !!preferences[feature],
      onChange: () => setPreferences({
        ...preferences,
        [key]: !preferences[feature]
      }),
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 124,
        columnNumber: 17
      }
    }, value || _lodash.default.startCase(key)));
    return acc;
  }, []))));
};
exports.SettingsModalLayout = SettingsModalLayout;
//# sourceMappingURL=SettingsModalLayout.js.map