lodash#omit JavaScript Examples

The following examples show how to use lodash#omit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: router-utils.js    From ThreatMapper with Apache License 2.0 7 votes vote down vote up
function omitDefaultValues(urlState) {
  // A couple of cases which require special handling because their URL state
  // default values might be in different format than their Redux defaults.
  if (!urlState.controlPipe) {
    urlState = omit(urlState, 'controlPipe');
  }
  if (isEmpty(urlState.nodeDetails)) {
    urlState = omit(urlState, 'nodeDetails');
  }
  if (isEmpty(urlState.topologyOptions)) {
    urlState = omit(urlState, 'topologyOptions');
  }

  // Omit all the fields which match their initial Redux state values.
  return omitBy(urlState, (value, key) => (
    isDeepEqual(fromJS(value), initialRootState.get(key))
  ));
}
Example #2
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
export function omitData(data) {
  return omit(
    data,
    'creationDate',
    'createdBy',
    'lastUpdateDate',
    'lastUpdatedBy',
    'objectVersionNumber',
    '_token',
    'searchId',
    'searchConditionId',
    'searchQueryId',
    'searchOrderId'
  );
}
Example #3
Source File: reducer.js    From e-Pola with MIT License 6 votes vote down vote up
function byId(state = {}, action) {
  switch (action.type) {
    case NOTIFICATION_SHOW:
      return {
        ...state,
        [action.payload.id]: notification(state[action.payload.id], action)
      }
    case NOTIFICATION_DISMISS:
      return omit(state, action.payload)
    default:
      return state
  }
}
Example #4
Source File: icons.jsx    From covid19-testing with Apache License 2.0 6 votes vote down vote up
iconToComponent = (iconName) => {
  const displayName = `${iconName}Icon`;
  /* eslint-disable react/forbid-foreign-prop-types */
  class GenericIcon extends React.Component {
    static propTypes = omit(Icon.propTypes, 'iconName');
    static defaultProps = Icon.defaultProps;
    static displayName = displayName;

    render() {
      return <Icon {...this.props} iconName={iconName} />;
    }
  }

  return GenericIcon;
}
Example #5
Source File: RelativeInternalLink.jsx    From pooltogether-community-ui with MIT License 6 votes vote down vote up
RelativeInternalLink = (props) => {
  const router = useRouter()
  const poolAlias = router.query.poolAlias

  const { chainId } = useNetwork()
  const { data: prizePoolContracts } = usePrizePoolContracts()

  const networkName = getNetworkNameAliasByChainId(chainId)

  let href = `/pools/[networkName]/[prizePoolAddress]${props.link}`
  let as = `/pools/${networkName}/${prizePoolContracts.prizePool.address}${props.link}`

  if (poolAlias) {
    href = `/[poolAlias]${props.link}`
    as = `/${poolAlias}${props.link}`
  }

  const newProps = omit(props, ['link'])

  return (
    <InternalLink {...newProps} href={href} as={as}>
      {props.children}
    </InternalLink>
  )
}
Example #6
Source File: Button.jsx    From pooltogether-landing-site with MIT License 6 votes vote down vote up
Button = (props) => {
  const classes = getButtonClasses(props)

  let newProps = omit(props, [
    'height',
    'rounded',
    'noAnim',
    'outline',
    'secondary',
    'textSize',
  ])

  return <button
    {...newProps}
    className={classes}
  />
}
Example #7
Source File: index.js    From plant-3d-explorer with GNU Affero General Public License v3.0 6 votes vote down vote up
TaintedFormattedMessage = styled((props) => (
  <span className={props.className}>
    <FormattedMessage {...omit(props, ["classNaame"])} />
  </span>
))({}, (props) => {
  return {
    color: props.color,
  };
})
Example #8
Source File: selectors.js    From rysolv with GNU Affero General Public License v3.0 6 votes vote down vote up
makeSelectReposDisabled = () =>
  createSelector(
    makeSelectRepos('repoData'),
    data => {
      const tempData = omit(data, [
        'identiconId',
        'importUrl',
        'organizationUrl',
        'repoId',
        'repoLogo',
      ]);
      return Object.keys(tempData).every(item => tempData[item].value !== '');
    },
  )
Example #9
Source File: index.jsx    From eleventy-react with MIT License 6 votes vote down vote up
export default function Script({ libs, children }) {
    const cssLibsString = libs?.map((lib) => values(omit(lib, 'js')));
    const jsLibsString = libs?.map((lib) => values(omit(lib, 'css')));
    return (
        <div
            hidden
            className="client-script"
            data-js-libs={jsLibsString?.length ? jsLibsString : ''}
            data-css-libs={cssLibsString?.length ? cssLibsString : ''}
            dangerouslySetInnerHTML={{ __html: children }}
        />
    );
}
Example #10
Source File: AppReleasedSubTableDataSet.js    From choerodon-front-base with Apache License 2.0 6 votes vote down vote up
export default function (intl, projectId, appId) {
  return {
    autoQuery: true,
    selection: false,
    paging: false,
    fields: [
      { name: 'id', type: 'string' },
      { name: 'refAppId', type: 'string' },
      { name: 'appEditable', type: 'boolean' },
      { name: 'version', type: 'string', label: '应用版本' },
      { name: 'publishErrorCode', type: 'string' },
      { name: 'status', type: 'string', label: '版本状态' },
      { name: 'sourceAppName', type: 'string', label: '应用服务' },
    ],
    transport: {
      read: ({ data, params }) => ({
        url: `iam/choerodon/v1/projects/${projectId}/publish_applications/versions`,
        method: 'get',
        params: {
          ...params,
          params: (data.params && data.params.length) ? data.params[0] : undefined,
          application_id: appId,
        },
        data: omit(data, ['params']),
      }),
    },
  };
}
Example #11
Source File: DatePicker.jsx    From kube-design with MIT License 6 votes vote down vote up
componentDidUpdate(prevProps) {
    const { props } = this;
    const { options: propsOptions } = this.props;
    const prevOptions = { ...prevProps.options };
    const nextOptions = { ...propsOptions };

    propsKey.forEach((key) => {
      if (key in this.props) {
        nextOptions[key] = props[key];
      }
      if (key in prevProps) {
        prevOptions[key] = prevProps[key];
      }
    });

    let optionsKeys = Object.getOwnPropertyNames(nextOptions);
    optionsKeys = omit(optionsKeys, [
      "onChange",
      "onOpen",
      "onClose",
      "onMonthChange",
      "onYearChange",
      "onReady",
      "onValueUpdate",
      "onDayCreate",
    ]);
    for (let index = optionsKeys.length - 1; index >= 0; index -= 1) {
      const key = optionsKeys[index];
      const value = nextOptions[key];
      if (value !== prevOptions[key]) {
        this.instance.set(key, value);
      }
    }

    if ("value" in this.props && this.instance) {
      this.instance.setDate(props.value, false);
    }
  }
Example #12
Source File: render.jsx    From volto-slate with MIT License 6 votes vote down vote up
Element = ({ element, attributes = {}, extras, ...rest }) => {
  const { slate } = config.settings;
  const { elements } = slate;
  const El = elements[element.type] || elements['default'];

  const out = Object.assign(
    element.styleName ? { className: element.styleName } : {},
    ...Object.keys(attributes || {}).map((k) =>
      !isEmpty(attributes[k]) ? { [k]: attributes[k] } : {},
    ),
  );

  return (
    <El
      element={element}
      {...omit(rest, OMITTED)}
      attributes={out}
      extras={extras}
    />
  );
}
Example #13
Source File: helper.js    From d2admin-permission with MIT License 6 votes vote down vote up
/**
 * @description 将树形数据扁平化 输出对象格式
 * @param {Object} config {Array} data 树形数据
 * @param {Object} config {String} keyChildren 子节点字段名
 * @param {Object} config {String} keyId 唯一 id 字段名
 * @param {Object} config {Boolean} includeChildren 输出的数据中是否包含子节点数据
 */
export function flatTreeToObject ({
  data = [],
  keyChildren = 'children_list',
  keyId = 'id',
  includeChildren = false
} = {}) {
  function maker (result, item) {
    result[item[keyId]] = includeChildren ? item : omit(item, [ keyChildren ])
    if (hasChildren(item, keyChildren)) Object.assign(result, item[keyChildren].reduce(maker, {}))
    return result
  }
  return data.reduce(maker, {})
}
Example #14
Source File: Input.jsx    From kube-design with MIT License 6 votes vote down vote up
render() {
    const { className, innerRef, ...rest } = this.props;
    const { value } = this.state;

    return (
      <input
        {...omit(rest, "onChange", "value", "defaultValue")}
        ref={innerRef || this.inputRef}
        value={value}
        onChange={this.handleChange}
        className={classNames("input", className)}
      />
    );
  }
Example #15
Source File: ToolbarButton.jsx    From volto-slate with MIT License 6 votes vote down vote up
ElementToolbarButton = (props) => {
  const { isActiveElement, insertElement, pluginId, toolbarButtonIcon } = props;
  const editor = useSlate();
  const isElement = isActiveElement(editor);
  const dispatch = useDispatch();
  const pid = `${editor.uid}-${pluginId}`;

  const omittedProps = [
    'insertElement',
    'pluginId',
    'toolbarButtonIcon',
    'isActiveElement',
  ];

  return (
    <>
      {hasRangeSelection(editor) && (
        <ToolbarButton
          {...omit(props, ...omittedProps)}
          active={isElement}
          onMouseDown={() => {
            if (!isElement) insertElement(editor, {});
            dispatch(setPluginOptions(pid, { show_sidebar_editor: true }));
          }}
          icon={toolbarButtonIcon}
        />
      )}
    </>
  );
}
Example #16
Source File: proxy-request.js    From mox with MIT License 6 votes vote down vote up
processProxyResponse = async (
  proxyResponse: ManualProxyInfo,
  req: $Request,
  res: $Response
): any => {
  const body = await (defaultBodyHandler: BodyHandler).parseInterceptedResponseBody(
    proxyResponse.body,
    proxyResponse.response
  );
  if (proxyResponse.response.headers != null) {
    res.set(
      omit(
        proxyResponse.response.headers,
        'Content-Length',
        'content-length',
        'content-encoding',
        'Content-Encoding'
      )
    );
  }
  res.status(proxyResponse.response.statusCode);
  return body;
}
Example #17
Source File: abandoned.js    From ant-simple-pro with MIT License 6 votes vote down vote up
export default function createContextMenu(options) {
  const { event } = options
  event.preventDefault()
  const props = Object.assign({}, omit(options, ['event']), {
    position: {
      x: event.clientX,
      y: event.clientY
    }
  })
  getInstance(props, ins => {
    position = {
      x: event.clientX,
      y: event.clientY
    }
    ins.open()
  })
}
Example #18
Source File: index.js    From gutenberg-forms with GNU General Public License v2.0 6 votes vote down vote up
export function getRootMessages(clientId, blockName) {
	const rootBlock = getRootFormBlock(clientId);
	const currentBlock = getBlock(clientId);

	if (rootBlock.name !== "cwp/block-gutenberg-forms" || isEmpty(currentBlock))
		return [{}];

	let { messages } = rootBlock.attributes;

	const rootMessage = messages.find((v) => v.fieldName === blockName);
	const defaultMessage = defaultFieldMessages.find((field) =>
		isEqual(field.fieldName, blockName)
	);

	const currentMessages = get(currentBlock, "attributes.messages");

	const messages_not_changed = isEqual(
		omit(currentMessages, ["fieldName"]),
		omit(defaultMessage, ["fieldName"])
	);

	if (messages_not_changed) {
		return rootMessage;
	} else {
		return currentMessages;
	}
}
Example #19
Source File: helper.js    From d2admin-permission with MIT License 6 votes vote down vote up
/**
 * @description 将树形数据扁平化 输出数组格式
 * @param {Object} config {Array} data 树形数据
 * @param {Object} config {String} keyChildren 子节点字段名
 * @param {Object} config {Boolean} includeChildren 输出的数据中是否包含子节点数据
 */
export function flatTreeToArray ({
  data = [],
  keyChildren = 'children_list',
  includeChildren = false
} = {}) {
  function maker (result, item) {
    result.push(includeChildren ? item : omit(item, [ keyChildren ]))
    if (hasChildren(item, keyChildren)) result = result.concat(item[keyChildren].reduce(maker, []))
    return result
  }
  return data.reduce(maker, [])
}
Example #20
Source File: processTransformations.js    From ui-data-export with Apache License 2.0 6 votes vote down vote up
export function normalizeTransformationFormValues(transformations) {
  return transformations
    .filter(transformation => Boolean(transformation?.isSelected))
    .map(transformation => ({
      ...omit(transformation, ['isSelected', 'order', 'displayNameKey', 'referenceDataValue', 'displayName']),
      transformation: parseRawTransformation(transformation),
      enabled: true,
    }));
}
Example #21
Source File: AppReleasedTableDataSet.js    From choerodon-front-base with Apache License 2.0 6 votes vote down vote up
export default function (intl, projectId) {
  return {
    autoQuery: false,
    selection: false,
    queryFields: [
      { name: 'name', type: 'string', label: '应用名称' },
      { name: 'version', type: 'string', label: '最新版本' },
      { name: 'free', type: 'string', label: '是否免费', textField: 'value', valueField: 'key', options: freeOptionDataSet },
      { name: 'publish_type', type: 'string', label: '发布类型', textField: 'value', valueField: 'key', options: publishTypeOptionDataSet },
      { name: 'status', type: 'string', label: '应用状态', textField: 'value', valueField: 'key', options: statusOptionDataSet },
      { name: 'source_app_name', type: 'string', label: '应用来源' },
      { name: 'description', type: 'string', label: '应用描述' },
    ],
    fields: [
      { name: 'id', type: 'string' },
      { name: 'refAppId', type: 'string' },
      { name: 'appEditable', type: 'boolean' },
      { name: 'name', type: 'string', label: '应用名称' },
      { name: 'latestVersion', type: 'string', label: '最新版本' },
      { name: 'free', type: 'boolean', label: '是否免费' },
      { name: 'publishType', type: 'string', label: '发布类型' },
      { name: 'status', type: 'string', label: '应用状态' },
      { name: 'sourceAppName', type: 'string', label: '应用来源' },
      { name: 'description', type: 'string', label: '应用描述' },
    ],
    transport: {
      read: ({ data, params }) => ({
        url: `iam/choerodon/v1/projects/${projectId}/publish_applications`,
        method: 'get',
        params: {
          ...params,
          params: data.params ? data.params : undefined,
        },
        data: omit(data, ['params']),
      }),
    },
  };
}
Example #22
Source File: reducer.js    From app with MIT License 6 votes vote down vote up
function byId(state = {}, action) {
  switch (action.type) {
    case NOTIFICATION_SHOW:
      return {
        ...state,
        [action.payload.id]: notification(state[action.payload.id], action),
      };
    case NOTIFICATION_DISMISS:
      return omit(state, action.payload);
    default:
      return state;
  }
}
Example #23
Source File: menuService.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
export async function createMenuDirByOrganizationId(params = {}) {
  const { organizationId } = params;
  return request(`${HZERO_IAM}/hzero/v1/${organizationId}/menus/create`, {
    method: 'POST',
    body: omit(params, 'organizationId'),
  });
}
Example #24
Source File: processRawTransformations.js    From ui-data-export with Apache License 2.0 5 votes vote down vote up
omitRawTransformations = profile => {
  const transformations = profile.transformations.map(transformation => ({ ...omit(transformation, ['rawTransformation']) }));

  return {
    ...profile,
    transformations,
  };
}
Example #25
Source File: BaseComposeTable.js    From hzero-front with Apache License 2.0 5 votes vote down vote up
render() {
    const { computeTableProps = {}, noComputeTableProps = {} } = this.state;
    const { removable, addable, onRowSelectionChange, selectedRowKeys = [] } = this.props;
    const otherProps = omit(this.props, omitProps);
    let rowSelection = null;
    const buttons = [];
    if (addable) {
      buttons.push(
        <Button key="add" onClick={this.handleBtnAddClick}>
          {intl.get('hzero.common.button.add').d('新增')}
        </Button>
      );
    }
    if (removable) {
      buttons.push(
        <Button
          key="remove"
          onClick={this.handleBtnRemoveClick}
          disabled={selectedRowKeys.length === 0}
        >
          {intl.get('hzero.common.button.delete').d('删除')}
        </Button>
      );
      rowSelection = {
        selectedRowKeys,
        onChange: onRowSelectionChange,
      };
    }
    return (
      <React.Fragment key="base-compose-table">
        {buttons.length > 0 && (
          <div key="base-compose-table-options" className="table-list-operator">
            {buttons}
          </div>
        )}
        <Table
          bordered
          pagination={false}
          key="base-compose-table-table"
          {...otherProps}
          {...noComputeTableProps}
          {...computeTableProps}
          rowSelection={rowSelection}
        />
      </React.Fragment>
    );
  }
Example #26
Source File: formatJobProfileFormInitialValues.js    From ui-data-export with Apache License 2.0 5 votes vote down vote up
formatJobProfileFormInitialValues = (jobProfile, additionalOmitFields = []) => {
  return { ...omit(jobProfile, ['metadata', 'userInfo', 'default', ...additionalOmitFields]) };
}
Example #27
Source File: Button.jsx    From pooltogether-community-ui with MIT License 5 votes vote down vote up
Button = (props) => {
  let {
    children,
    color,
    className,
    disabled,
    paddingClasses,
    roundedClasses,
    size,
    textSizeClasses,
    transitionClasses,
    fullWidth,
    noPad
  } = props

  let defaultClasses =
    'inline-block text-center leading-snug tracking-wide outline-none focus:outline-none active:outline-none font-bold '

  if (fullWidth) {
    defaultClasses += 'w-full'
  } else {
    defaultClasses += 'width-max-content'
  }

  const { backgroundClasses, borderClasses, textColorClasses } = getColorClasses(color, disabled)
  paddingClasses = getPaddingClasses(paddingClasses, noPad)
  roundedClasses = getRoundedClasses(roundedClasses)
  textSizeClasses = getTextSizeClasses(textSizeClasses, size)
  transitionClasses = getTransitionClasses(transitionClasses)
  let cursorClasses = getCursorClasses(disabled)

  className = classnames(
    backgroundClasses,
    borderClasses,
    textColorClasses,
    defaultClasses,
    paddingClasses,
    roundedClasses,
    size,
    textSizeClasses,
    transitionClasses,
    cursorClasses,
    className
  )

  const newProps = omit(props, [
    'noAnim',
    'paddingClasses',
    'roundedClasses',
    'size',
    'textSizeClasses',
    'transitionClasses',
    'fullWidth'
  ])

  return (
    <button {...newProps} className={className}>
      {children}
    </button>
  )
}
Example #28
Source File: withTestingFeatures.jsx    From volto-slate with MIT License 5 votes vote down vote up
withTestingFeatures = (WrappedComponent) => {
  return (props) => {
    let ref = React.useRef();

    // Source: https://stackoverflow.com/a/53623568/258462
    const onTestSelectWord = (val) => {
      let slateEditor =
        val.detail.parentElement.parentElement.parentElement.parentElement;

      // Events are special, can't use spread or Object.keys
      let selectEvent = {};
      for (let key in val) {
        if (key === 'currentTarget') {
          selectEvent['currentTarget'] = slateEditor;
        } else if (key === 'type') {
          selectEvent['type'] = 'select';
        } else {
          selectEvent[key] = val[key];
        }
      }

      // Make selection
      let selection = window.getSelection();
      let range = document.createRange();
      range.selectNodeContents(val.detail);
      selection.removeAllRanges();
      selection.addRange(range);

      // Slate monitors DOM selection changes automatically
    };

    const onTestSelectRange = (val) => {
      const newDomRange =
        val && ReactEditor.toDOMRange(window.focusedSlateEditor, val.detail);

      let selection = window.getSelection();
      selection.removeAllRanges();
      selection.addRange(newDomRange);
    };

    React.useEffect(() => {
      document.addEventListener('Test_SelectWord', onTestSelectWord);
      document.addEventListener('Test_SelectRange', onTestSelectRange);
      return () => {
        document.removeEventListener('Test_SelectWord', onTestSelectWord);
        document.removeEventListener('Test_SelectRange', onTestSelectRange);
      };
    });

    const handleFocus = React.useCallback(() => {
      window.focusedSlateEditor = ref?.current;
      if (props.onFocus) {
        props.onFocus();
      }
    }, [props]);

    const managedProps = useMemo(() => {
      return omit(props, 'onFocus');
    }, [props]);

    return (
      <WrappedComponent
        debug
        debug-values={{
          'data-slate-value': JSON.stringify(props.value, null, 2),
          'data-slate-selection': JSON.stringify(
            ref?.current?.selection,
            null,
            2,
          ),
        }}
        testingEditorRef={ref}
        onFocus={handleFocus}
        {...managedProps}
      />
    );
  };
}
Example #29
Source File: ButtonTx.jsx    From v3-ui with MIT License 5 votes vote down vote up
export function ButtonTx (props) {
  const { children, chainId, tx, disabled, isCentered } = props

  const { t } = useTranslation()

  const newProps = omit(props, ['usersAddress', 'chainId', 'tx', 'isCentered'])

  const { network, address: isWalletConnected } = useOnboard()
  const isWalletOnProperNetwork = useIsWalletOnNetwork(network, chainId)

  const txInFlight = !tx?.cancelled && (tx?.sent || tx?.completed)
  const disabledDueToNetwork = Boolean(!isWalletConnected || !isWalletOnProperNetwork)
  const disableButton = Boolean(disabledDueToNetwork || disabled || txInFlight)

  useEffect(() => {
    if (!chainId) {
      console.warn('ButtonTx requires a chainId')
    }
  }, [chainId])

  return (
    <Tooltip
      isEnabled={disabledDueToNetwork}
      id={`button-tx-connect-wallet-tooltip`}
      title={t('connectAWallet')}
      className={classnames({
        'mx-auto': isCentered
      })}
      tip={
        <Tip
          chainId={chainId}
          isWalletConnected={isWalletConnected}
          isWalletOnProperNetwork={isWalletOnProperNetwork}
        />
      }
    >
      <Button {...newProps} disabled={disableButton}>
        {children}
      </Button>
    </Tooltip>
  )
}