Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["group", "i18n", "onRemove", "onChange", "attrKeys", "notUsedAttrKeys", "iconPrimaryColor", "dragHandleProps", "showDragHandler", "index", "submited"];
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { useMemo, forwardRef } from 'react';
import { MenuItem, SelectGroup } from '@scaleflex/ui/core';
import { Movable as MovableIcon, DeleteOutline } from '@scaleflex/icons';
import Styled from './Groups.styled';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var GroupItem = function GroupItem(_ref, ref) {
  var group = _ref.group,
    i18n = _ref.i18n,
    onRemove = _ref.onRemove,
    onChange = _ref.onChange,
    attrKeys = _ref.attrKeys,
    notUsedAttrKeys = _ref.notUsedAttrKeys,
    iconPrimaryColor = _ref.iconPrimaryColor,
    dragHandleProps = _ref.dragHandleProps,
    showDragHandler = _ref.showDragHandler,
    index = _ref.index,
    submited = _ref.submited,
    rest = _objectWithoutProperties(_ref, _excluded);
  var attrKeyDetails = useMemo(function () {
    return attrKeys.find(function (attrKey) {
      return attrKey.sys_key === group.attribute_sys_key;
    });
  }, [attrKeys, group.attribute_sys_key]);
  var getItemDesc = function getItemDesc(label, dataType) {
    return /*#__PURE__*/_jsxs(Styled.DescWrapper, {
      hasMarginTop: true,
      children: [/*#__PURE__*/_jsx(Styled.DescItem, {
        isLabel: true,
        children: i18n('collectionDialogGroupApiKeyLabel')
      }), /*#__PURE__*/_jsxs(Styled.DescItem, {
        rightPadding: 4,
        children: [label, ","]
      }), /*#__PURE__*/_jsx(Styled.DescItem, {
        isLabel: true,
        children: i18n('collectionDialogGroupTypeLabel')
      }), /*#__PURE__*/_jsx(Styled.DescItem, {
        children: dataType
      })]
    });
  };
  var groupSlug = attrKeyDetails === null || attrKeyDetails === void 0 ? void 0 : attrKeyDetails.slug;
  return /*#__PURE__*/_jsxs(Styled.Group, _objectSpread(_objectSpread({
    ref: ref
  }, rest), {}, {
    children: [/*#__PURE__*/_jsx(Styled.GroupName, {
      children: i18n('mutualizedLevelLabel', {
        num: index + 1
      })
    }), /*#__PURE__*/_jsxs(Styled.GroupValue, {
      children: [/*#__PURE__*/_jsx(Styled.DragToggleWrap, {
        $hidden: !showDragHandler,
        children: /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, showDragHandler ? dragHandleProps : {}), {}, {
          children: /*#__PURE__*/_jsx(MovableIcon, {
            color: iconPrimaryColor
          })
        }))
      }), /*#__PURE__*/_jsx(SelectGroup, {
        value: groupSlug,
        onChange: onChange,
        fullWidth: true,
        SelectProps: {
          MenuProps: {
            maxHeight: 300
          }
        },
        placeholder: i18n('collectionDialogGroupFieldPlaceholder'),
        error: submited && !group.attribute_sys_key,
        hint: groupSlug ? getItemDesc(groupSlug, attrKeyDetails === null || attrKeyDetails === void 0 ? void 0 : attrKeyDetails.datatype) : null,
        showSelectionKey: true,
        children: [attrKeyDetails].concat(_toConsumableArray(notUsedAttrKeys)).filter(Boolean).map(function (attrKey) {
          var _attrKeyLabel$charAt;
          var attrKeyLabel = attrKey.slug || attrKey.sys_key;
          return /*#__PURE__*/_jsx(MenuItem, {
            value: attrKey.slug,
            children: /*#__PURE__*/_jsxs(Styled.MenuItemContent, {
              children: [/*#__PURE__*/_jsx(Styled.MenuItemTitle, {
                children: (attrKeyLabel === null || attrKeyLabel === void 0 ? void 0 : (_attrKeyLabel$charAt = attrKeyLabel.charAt(0)) === null || _attrKeyLabel$charAt === void 0 ? void 0 : _attrKeyLabel$charAt.toUpperCase()) + (attrKeyLabel === null || attrKeyLabel === void 0 ? void 0 : attrKeyLabel.slice(1))
              }), getItemDesc(attrKeyLabel, attrKey.datatype)]
            })
          }, attrKey.sys_key);
        })
      })]
    }), /*#__PURE__*/_jsx(Styled.GroupActions, {
      children: /*#__PURE__*/_jsx(DeleteOutline, {
        size: 16,
        onClick: onRemove,
        color: iconPrimaryColor
      })
    })]
  }), group.uuid || group.attribute_sys_key);
};
export default /*#__PURE__*/forwardRef(GroupItem);