How to use ts-transformer-keys - 10 common examples

To help you get started, we’ve selected a few ts-transformer-keys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coveo / react-vapor / packages / react-vapor / src / components / subNavigation / SubNavigation.tsx View on Github external
onDestroy?: () => void;
    onClickItem?: (id: string) => void;
}

export interface ISubNavigationItem {
    id: string;
    label: React.ReactNode;
    link?: string;
}

export interface ISubNavigationProps
    extends ISubNavigationOwnProps,
        ISubNavigationStateProps,
        ISubNavigationDispatchProps {}

const ISubNavigationPropsToOmit = keys();

export class SubNavigation extends React.PureComponent> {
    componentWillMount() {
        this.props.onRender?.();
    }

    componentWillUnmount() {
        this.props.onDestroy?.();
    }

    render() {
        const selected = this.props.selected || this.props.defaultSelected;
        const navProps = omit(this.props, ISubNavigationPropsToOmit);
        const items = map(this.props.items, ({id, link, label}: ISubNavigationItem) => (
            <li id="==">
                </li>
github coveo / react-vapor / packages / react-vapor / src / components / numericInput / NumericInputConnected.tsx View on Github external
const decrementEnabled =
            _.isUndefined(this.props.min) || _.isNaN(valueAsNumber) || valueAsNumber &gt; this.props.min;
        return (
            <div>
                <div>
                    <button type="button">
                        <svg></svg>
                    </button>
                    <div>
                        <input>())}
                            className={classNames(
                                'js-numeric-input',
                                {
                                    [`mod-max-${this.props.maxLength}-digit`]:
                                        _.isNumber(this.props.maxLength) &amp;&amp; this.props.maxLength &gt; 0,
                                },
                                this.props.className,
                                styles.numericInput
                            )}
                            value={this.props.value}
                            onChange={this.onChange}
                            onKeyDown={this.onKeyDown}
                        /&gt;
                    </div>
                    </div></div>
github coveo / react-vapor / src / components / select / MultiSelectConnected.tsx View on Github external
export interface IMultiSelectStateProps {
    selected?: string[];
}

export interface IMultiSelectDispatchProps {
    onRemoveClick?: (item: IItemBoxProps) =&gt; void;
    onRemoveAll?: () =&gt; void;
    onReorder?: (values: string[]) =&gt; void;
}

export interface IMultiSelectProps extends
    IMultiSelectOwnProps,
    IMultiSelectStateProps,
    IMultiSelectDispatchProps {}

const selectPropsKeys = keys();

const makeMapStateToProps = () =&gt; {
    const getStateProps = createStructuredSelector({
        selected: SelectSelector.getMultiSelectSelectedValues,
    });

    return (state: IReactVaporState, ownProps: IMultiSelectOwnProps): IMultiSelectStateProps =&gt;
        getStateProps(state, ownProps);
};

const mapDispatchToProps = (dispatch: IDispatch, ownProps: IMultiSelectOwnProps): IMultiSelectDispatchProps =&gt; ({
    onRemoveClick: (item: IItemBoxProps) =&gt; dispatch(unselectListBoxOption(ownProps.id, item.value)),
    onRemoveAll: () =&gt; dispatch(clearListBoxOption(ownProps.id)),
    onReorder: (values: string[]) =&gt; dispatch(reorderListBoxOption(ownProps.id, values)),
});
github coveo / react-vapor / packages / react-vapor / src / components / select / MultiSelectConnected.tsx View on Github external
multiSelectStyle?: React.CSSProperties;
}

export interface IMultiSelectStateProps {
    selected?: string[];
}

export interface IMultiSelectDispatchProps {
    onRemoveClick?: (item: IItemBoxProps) =&gt; void;
    onRemoveAll?: () =&gt; void;
    onReorder?: (values: string[]) =&gt; void;
}

export interface IMultiSelectProps extends IMultiSelectOwnProps, IMultiSelectStateProps, IMultiSelectDispatchProps {}

const selectPropsKeys = keys();

const makeMapStateToProps = () =&gt; {
    const getStateProps = createStructuredSelector({
        selected: SelectSelector.getMultiSelectSelectedValues,
    });

    return (state: IReactVaporState, ownProps: IMultiSelectOwnProps): IMultiSelectStateProps =&gt;
        getStateProps(state, ownProps);
};

const mapDispatchToProps = (dispatch: IDispatch, ownProps: IMultiSelectOwnProps): IMultiSelectDispatchProps =&gt; ({
    onRemoveClick: (item: IItemBoxProps) =&gt; dispatch(unselectListBoxOption(ownProps.id, item.value)),
    onRemoveAll: () =&gt; dispatch(clearListBoxOption(ownProps.id)),
    onReorder: (values: string[]) =&gt; dispatch(reorderListBoxOption(ownProps.id, values)),
});
github coveo / react-vapor / src / components / table-hoc / TableWithPredicate.tsx View on Github external
export interface ITableWithPredicateConfig {
    id: string;
    values: IItemBoxProps[];
    prepend?: React.ReactNode;
    matchPredicate?: (predicate: string, datum: any) =&gt; boolean;
    isServer?: boolean;
}

export interface ITableWithPredicateStateProps {
    predicate: string;
}

export interface ITableWithPredicateProps extends Partial,
    ITableHOCOwnProps {}

const TableWithPredicatePropsToOmit = keys();

const defaultMatchPredicate = (predicate: string, datum: any) =&gt; !predicate || _.some(_.values(datum), (value: string) =&gt; value === predicate);

type TableWithPredicateComponent = React.ComponentClass;

export const tableWithPredicate = (supplier: ConfigSupplier) =&gt; (Component: TableWithPredicateComponent): TableWithPredicateComponent =&gt; {

    const mapStateToProps = (state: IReactVaporState, ownProps: ITableWithPredicateProps): ITableWithPredicateStateProps | ITableHOCOwnProps =&gt; {
        const config = HocUtils.supplyConfig(supplier);
        const predicate = SelectSelector.getListBoxSelected(state, {id: TableHOCUtils.getPredicateId(ownProps.id, config.id)})[0];
        const matchPredicate = config.matchPredicate || defaultMatchPredicate;
        const predicateData = () =&gt; !config.isServer &amp;&amp; predicate
            ? _.filter(ownProps.data, (datum: any) =&gt; matchPredicate(predicate, datum))
            : ownProps.data;
        return {
            predicate: predicate,
github coveo / react-vapor / packages / react-vapor / src / components / table-hoc / TableWithPagination.tsx View on Github external
pageNb: number;
    perPage: number;
}

export interface ITableWithPaginationDispatchProps {
    onMount: () =&gt; void;
    onUnmount: () =&gt; void;
}

export interface ITableWithPaginationProps
    extends Partial,
        Partial,
        ITableHOCOwnProps,
        WithServerSideProcessingProps {}

const TableWithPaginationProps = keys();

const sliceData = (data: any[], startingIndex: number, endingIndex: number) =&gt; data.slice(startingIndex, endingIndex);

export const tableWithPagination = (supplier: ConfigSupplier = {}) =&gt; (
    Component: React.ComponentType
): React.ComponentClass&gt; =&gt; {
    const config = HocUtils.supplyConfig(supplier);
    const mapStateToProps = (
        state: IReactVaporState,
        ownProps: ITableWithPaginationProps
    ): ITableWithPaginationStateProps | ITableHOCOwnProps =&gt; {
        const pageNb = NavigationSelectors.getPaginationPage(state, {id: TableHOCUtils.getPaginationId(ownProps.id)});
        const perPage = NavigationSelectors.getPerPage(state, {id: ownProps.id});
        const isServer = ownProps.isServer || config.isServer;
        const length = TableSelectors.getDataCount(state, {
            id: ownProps.id,
github coveo / react-vapor / packages / react-vapor / src / components / table-hoc / TableRowConnected.tsx View on Github external
tableId: string;
    actions?: IActionOptions[];
    isMultiselect?: boolean;
    collapsible?: CollapsibleRowProps;
    disabled?: boolean;
}

export type ITableRowStateProps = ReturnType;
export type ITableRowDispatchProps = ReturnType;

export interface ITableRowConnectedProps
    extends ITableRowOwnProps,
        Partial,
        Partial {}

const TableRowPropsToOmit = keys();

const isCollapsible = (props: ITableRowOwnProps): boolean =&gt;
    props.collapsible &amp;&amp; (React.isValidElement(props.collapsible.content) || _.isString(props.collapsible.content));

const mapStateToProps = (state: IReactVaporState, ownProps: ITableRowOwnProps) =&gt; {
    const {selected, opened} = TableSelectors.getTableRow(state, {id: ownProps.id}) || {selected: false, opened: false};
    return {
        selected,
        opened,
    };
};

const mapDispatchToProps = (dispatch: IDispatch, ownProps: ITableRowOwnProps) =&gt; {
    const refreshActionBarActions = (isMulti: boolean) =&gt; {
        if (!_.isEmpty(ownProps.actions)) {
            dispatch(addActionsToActionBar(ownProps.tableId, ownProps.actions));
github coveo / react-vapor / packages / react-vapor / src / components / table-hoc / TableWithDatePicker.tsx View on Github external
export interface ITableWithDatePickerStateProps {
    lowerLimit: Date;
    upperLimit: Date;
}

export interface ITableWithFilterDispatchProps {
    onRender: () =&gt; void;
}

export interface ITableWithDatePickerProps
    extends Partial,
        Partial,
        ITableHOCOwnProps,
        WithServerSideProcessingProps {}

const TableWithFilterPropsToOmit = keys();

export type FilterableTableComponent = React.ComponentClass;

const defaultMatchDates = () =&gt; true;

export const tableWithDatePicker = (supplier: ConfigSupplier = {}) =&gt; (
    Component: FilterableTableComponent
): FilterableTableComponent =&gt; {
    const config = HocUtils.supplyConfig(supplier);

    const mapStateToProps = (
        state: IReactVaporState,
        ownProps: ITableWithDatePickerProps
    ): ITableWithDatePickerStateProps | ITableHOCOwnProps =&gt; {
        const [lowerLimit, upperLimit] = DatePickerSelectors.getDatePickerLimits(state, {id: ownProps.id});
        const matchDates = config.matchDates || defaultMatchDates;
github coveo / react-vapor / src / components / table-hoc / TableRowConnected.tsx View on Github external
}

export interface ITableRowDispatchProps {
    onMount: () =&gt; void;
    onUnmount: () =&gt; void;
    onClick: (isMulti: boolean, isOpened: boolean) =&gt; void;
    onUpdateToCollapsibleRow: () =&gt; void;
    onActionBarActionsChanged: () =&gt; void;
}

export interface ITableRowConnectedProps extends
    ITableRowOwnProps,
    Partial,
    Partial {}

const TableRowPropsToOmit = keys();

const isCollapsible = (props: ITableRowOwnProps): boolean =&gt; props.collapsible
    &amp;&amp; (React.isValidElement(props.collapsible.content) || _.isString(props.collapsible.content));

const mapStateToProps = (state: IReactVaporState, ownProps: ITableRowOwnProps) =&gt; {
    const {selected, opened} = TableSelectors.getTableRow(state, {id: ownProps.id}) || {selected: false, opened: false};
    return {
        selected,
        opened,
    };
};

const mapDispatchToProps = (
    dispatch: IDispatch,
    ownProps: ITableRowOwnProps,
): ITableRowDispatchProps =&gt; {
github coveo / react-vapor / packages / react-vapor / src / components / table-hoc / TableWithBlankSlate.tsx View on Github external
import * as _ from 'underscore';

import {IReactVaporState} from '../../ReactVapor';
import {ConfigSupplier, HocUtils} from '../../utils/HocUtils';
import {ReduxConnect} from '../../utils/ReduxUtils';
import {BlankSlate, IBlankSlateProps} from '../blankSlate/BlankSlate';
import {ITableHOCOwnProps} from './TableHOC';
import {TableSelectors} from './TableSelectors';

export interface ITableWithBlankSlateStateProps {
    isEmpty: boolean;
}

export interface ITableWithBlankSlateProps extends Partial {}

const TableWithBlankSlatePropsToOmit = keys();

export const tableWithBlankSlate = (supplier: ConfigSupplier = {}) =&gt; (
    Component: React.ComponentClass
): React.ComponentClass&gt; =&gt; {
    const mapStateToProps = (
        state: IReactVaporState,
        ownProps: ITableHOCOwnProps
    ): ITableWithBlankSlateStateProps | ITableHOCOwnProps =&gt; {
        const isEmpty = TableSelectors.getIsEmpty(state, ownProps);
        return {
            isEmpty,
            data: isEmpty ? null : ownProps.data,
        };
    };

    @ReduxConnect(mapStateToProps)

ts-transformer-keys

A TypeScript custom transformer which enables to obtain keys of given type.

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis

Popular ts-transformer-keys functions