Skip to content

Commit

Permalink
chore(deps): update dependencies (#951)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue committed May 18, 2021
1 parent 5c981d9 commit e48ea78
Show file tree
Hide file tree
Showing 68 changed files with 6,716 additions and 8,210 deletions.
22 changes: 9 additions & 13 deletions packages/create-context-state/src/create-context-hook.tsx
Expand Up @@ -155,19 +155,15 @@ export interface ContextHook<Context extends object> {
/**
* Split but don't allow empty string.
*/
export type Split<
Input extends string,
Splitter extends string
> = Input extends `${infer T}${Splitter}${infer Rest}`
? '' extends T
? [...Split<Rest, Splitter>]
: [T, ...Split<Rest, Splitter>]
: [Input];

export type SplitEmpty<
Input extends string,
Splitter extends string
> = Input extends `${infer T}${Splitter}${infer Rest}` ? [T, ...Split<Rest, Splitter>] : [Input];
export type Split<Input extends string, Splitter extends string> =
Input extends `${infer T}${Splitter}${infer Rest}`
? '' extends T
? [...Split<Rest, Splitter>]
: [T, ...Split<Rest, Splitter>]
: [Input];

export type SplitEmpty<Input extends string, Splitter extends string> =
Input extends `${infer T}${Splitter}${infer Rest}` ? [T, ...Split<Rest, Splitter>] : [Input];

function usePrevious<T>(value: T) {
const ref = useRef<T>();
Expand Down
4 changes: 2 additions & 2 deletions packages/create-context-state/src/create-context-state.tsx
Expand Up @@ -72,7 +72,7 @@ export function createContextState<Context extends object, Props extends object,
export function createContextState<
Context extends object,
Props extends object = object,
State = undefined
State = undefined,
>(
creator: ContextCreator<Context, Props, State>,
hook?: NamedHook<Props, State>,
Expand Down Expand Up @@ -188,7 +188,7 @@ export type NamedHook<Props extends object, State> = (props: Props) => State;
export interface ContextCreatorHelpers<
Context extends object,
Props extends object,
State = undefined
State = undefined,
> {
/**
* Get the context with a partial update.
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-prosemirror/readme.md
Expand Up @@ -152,7 +152,10 @@ test('`keyBindings`', () => {
name: 'at',
keyBindings,
matchOffset: 0,
createCommand: ({ view }) => () => view.dispatch(view.state.tr.insertText('awesome')),
createCommand:
({ view }) =>
() =>
view.dispatch(view.state.tr.insertText('awesome')),
});

createEditor(doc(p('<cursor>')), { plugins: [plugin] })
Expand Down
66 changes: 31 additions & 35 deletions packages/jest-prosemirror/src/jest-prosemirror-messages.ts
Expand Up @@ -4,39 +4,35 @@ import type { TaggedProsemirrorNode } from 'prosemirror-test-builder';

import { selectionFor } from './jest-prosemirror-nodes';

export const transformsNodePassMessage = (
actual: TaggedProsemirrorNode,
expected: TaggedProsemirrorNode,
shouldChange: boolean,
) => (): string =>
`${matcherHint('.not.toTransformNode')}\n\n${shouldChange}`
? `${chalk`Expected the node {bold not} to be:\n`}${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
`Received:\n` +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node to be different from:\n' +
`${printExpected(expected.toString())}\n\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
export const transformsNodePassMessage =
(actual: TaggedProsemirrorNode, expected: TaggedProsemirrorNode, shouldChange: boolean) =>
(): string =>
`${matcherHint('.not.toTransformNode')}\n\n${shouldChange}`
? `${chalk`Expected the node {bold not} to be:\n`}${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
`Received:\n` +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node to be different from:\n' +
`${printExpected(expected.toString())}\n\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;

export const transformsNodeFailMessage = (
actual: TaggedProsemirrorNode,
expected: TaggedProsemirrorNode,
shouldChange: boolean,
) => (): string =>
`${matcherHint('.toTransformNode')}\n\n${shouldChange}`
? 'Expected the node to be transformed to:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node not to be changed from:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
export const transformsNodeFailMessage =
(actual: TaggedProsemirrorNode, expected: TaggedProsemirrorNode, shouldChange: boolean) =>
(): string =>
`${matcherHint('.toTransformNode')}\n\n${shouldChange}`
? 'Expected the node to be transformed to:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node not to be changed from:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
2 changes: 1 addition & 1 deletion packages/jest-prosemirror/src/jest-prosemirror-nodes.ts
Expand Up @@ -161,7 +161,7 @@ export function pmBuild<
NodeTypeAttributes | MarkTypeAttributes
>,
Nodes extends string = string,
Marks extends string = string
Marks extends string = string,
>(testSchema: EditorSchema<Nodes, Marks>, names: Type) {
return pm.builders(testSchema, {
doc: { nodeType: 'doc' },
Expand Down
16 changes: 8 additions & 8 deletions packages/multishift/src/multishift-types.ts
Expand Up @@ -500,7 +500,7 @@ export interface MultishiftStateChangeset<Item = any> {
export type CreateMultishiftAction<
Type extends string,
Payload = any,
Args extends any[] = [Payload]
Args extends any[] = [Payload],
> = (...args: Args) => ActionWithPayload<Type, Payload>;

export interface GetRemoveButtonOptions<Element extends HTMLElement = any, Item = any>
Expand Down Expand Up @@ -528,13 +528,13 @@ export interface GetRemoveButtonReturn<Element extends HTMLElement = any>

export interface GetComboBoxPropsOptions<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> extends RefProps<RefKey>,
HTMLProps<Element> {}

export type GetComboBoxPropsReturn<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> = DetailedHTMLProps<HTMLAttributes<Element>, Element> &
{ [P in RefKey]: Ref<any> } & {
/**
Expand All @@ -549,7 +549,7 @@ export type GetComboBoxPropsReturn<

export interface GetPropsWithRefOptions<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> extends RefProps<RefKey>,
HTMLProps<Element> {
/**
Expand All @@ -560,15 +560,15 @@ export interface GetPropsWithRefOptions<

export type GetPropsWithRefReturn<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> = {
[P in Exclude<RefKey, 'key'>]: Ref<any>;
} &
DetailedHTMLProps<HTMLAttributes<Element>, Element>;

export type GetLabelPropsWithRefReturn<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> = {
[P in Exclude<RefKey, 'key'>]: Ref<any>;
} &
Expand All @@ -579,7 +579,7 @@ export type GetLabelPropsWithRefReturn<
export interface GetItemPropsOptions<
Element extends HTMLElement = any,
RefKey extends string = 'ref',
Item = any
Item = any,
> extends GetPropsWithRefOptions<Element, RefKey> {
/**
* This is the item data that will be selected when the user selects a
Expand Down Expand Up @@ -781,7 +781,7 @@ export interface MultishiftPropGetters<Item = any> {

export interface IgnoredElementOptions<
Element extends HTMLElement = any,
RefKey extends string = 'ref'
RefKey extends string = 'ref',
> extends GetPropsWithRefOptions<Element, RefKey> {}

export interface MultishiftHelpers<Item = any> {
Expand Down
13 changes: 5 additions & 8 deletions packages/multishift/src/multishift-utils.ts
Expand Up @@ -487,11 +487,8 @@ type GetLastHighlightProps = Pick<
* Returns -1 when no highlighted index is found.
*/
export function getMostRecentHighlightIndex(lastHighlight: GetLastHighlightProps): number {
const {
highlightedGroupEndIndex,
highlightedGroupStartIndex,
highlightedIndexes,
} = lastHighlight;
const { highlightedGroupEndIndex, highlightedGroupStartIndex, highlightedIndexes } =
lastHighlight;

const lastIndex = last(highlightedIndexes);
return isValidIndex(highlightedGroupEndIndex)
Expand Down Expand Up @@ -1022,7 +1019,7 @@ export function callAllEventHandlers<
Type extends Event = any,
Node extends Element = any,
Synth extends SyntheticEvent<Element, Type> = SyntheticEvent<Node, Type>,
Method extends (event: Synth, ...args: any[]) => void | undefined | false | true = AnyFunction
Method extends (event: Synth, ...args: any[]) => void | undefined | false | true = AnyFunction,
>(...fns: Array<Method | undefined | null | false>) {
return (event: Synth, ...args: any[]): void => {
fns.some((fn) => {
Expand All @@ -1038,7 +1035,7 @@ export function callAllEventHandlers<
function bindActionCreator<
Action,
Creator extends ActionCreator<Action>,
ActionDispatch extends Dispatch<any>
ActionDispatch extends Dispatch<any>,
>(actionCreator: Creator, dispatch: ActionDispatch) {
return (...args: Parameters<Creator>) => dispatch(actionCreator(...args));
}
Expand All @@ -1051,7 +1048,7 @@ function bindActionCreator<
export function bindActionCreators<
Action,
CreatorMap extends ActionCreatorsMapObject<Action>,
ActionDispatch extends Dispatch<any>
ActionDispatch extends Dispatch<any>,
>(actionCreators: CreatorMap, dispatch: ActionDispatch): ActionCreatorMapToDispatch<CreatorMap> {
const boundActionCreators: ActionCreatorMapToDispatch<CreatorMap> = object();
const creatorKeys = keys(actionCreators);
Expand Down
8 changes: 4 additions & 4 deletions packages/multishift/src/multishift.ts
Expand Up @@ -236,10 +236,10 @@ export const useMultishift = <Item = any>(props: MultishiftProps<Item>): Multish
(item: Item) => selectedItems.map(getItemId).includes(getItemId(item)),
[getItemId, selectedItems],
);
const indexOfItem = useCallback((item: Item) => items.map(getItemId).indexOf(getItemId(item)), [
getItemId,
items,
]);
const indexOfItem = useCallback(
(item: Item) => items.map(getItemId).indexOf(getItemId(item)),
[getItemId, items],
);

const getComboBoxProps = useCallback(
<Element extends HTMLElement = any, RefKey extends string = 'ref'>(
Expand Down
25 changes: 10 additions & 15 deletions packages/prosemirror-suggest/src/suggest-types.ts
Expand Up @@ -825,13 +825,11 @@ export type MakeOptional<Type extends object, Keys extends keyof Type> = Omit<Ty

export type EditorSchema = import('prosemirror-model').Schema<string, string>;

export type ProsemirrorNode<
Schema extends EditorSchema = EditorSchema
> = import('prosemirror-model').Node<Schema>;
export type ProsemirrorNode<Schema extends EditorSchema = EditorSchema> =
import('prosemirror-model').Node<Schema>;

export type Transaction<
Schema extends EditorSchema = EditorSchema
> = import('prosemirror-state').Transaction<Schema>;
export type Transaction<Schema extends EditorSchema = EditorSchema> =
import('prosemirror-state').Transaction<Schema>;

/**
* A parameter builder interface containing the `tr` property.
Expand All @@ -845,9 +843,8 @@ export interface TransactionProps<Schema extends EditorSchema = EditorSchema> {
tr: Transaction<Schema>;
}

export type EditorState<
Schema extends EditorSchema = EditorSchema
> = import('prosemirror-state').EditorState<Schema>;
export type EditorState<Schema extends EditorSchema = EditorSchema> =
import('prosemirror-state').EditorState<Schema>;

/**
* A parameter builder interface containing the `state` property.
Expand All @@ -861,9 +858,8 @@ export interface EditorStateProps<Schema extends EditorSchema = EditorSchema> {
state: EditorState<Schema>;
}

export type ResolvedPos<
Schema extends EditorSchema = EditorSchema
> = import('prosemirror-model').ResolvedPos<Schema>;
export type ResolvedPos<Schema extends EditorSchema = EditorSchema> =
import('prosemirror-model').ResolvedPos<Schema>;

/**
* @template Schema - the underlying editor schema.
Expand All @@ -886,9 +882,8 @@ export interface TextProps {
text: string;
}

export type EditorView<
Schema extends EditorSchema = EditorSchema
> = import('prosemirror-view').EditorView<Schema>;
export type EditorView<Schema extends EditorSchema = EditorSchema> =
import('prosemirror-view').EditorView<Schema>;

/**
* A parameter builder interface containing the `view` property.
Expand Down
26 changes: 8 additions & 18 deletions packages/prosemirror-suggest/src/suggest-utils.ts
Expand Up @@ -30,9 +30,8 @@ import type {
} from './suggest-types';
import { ChangeReason, ExitReason } from './suggest-types';

type CreateMatchWithReasonProps<
Schema extends EditorSchema = EditorSchema
> = SuggestStateMatchProps<Schema> & ReasonProps;
type CreateMatchWithReasonProps<Schema extends EditorSchema = EditorSchema> =
SuggestStateMatchProps<Schema> & ReasonProps;

/**
* Small utility method for creating a match with the reason property available.
Expand Down Expand Up @@ -152,15 +151,8 @@ function findMatch<Schema extends EditorSchema = EditorSchema>(
props: FindMatchProps<Schema>,
): SuggestMatch<Schema> | undefined {
const { $pos, suggester } = props;
const {
char,
name,
startOfLine,
supportedCharacters,
matchOffset,
multiline,
caseInsensitive,
} = suggester;
const { char, name, startOfLine, supportedCharacters, matchOffset, multiline, caseInsensitive } =
suggester;

// Create the regular expression to match the text against
const regexp = createRegexFromSuggester({
Expand All @@ -186,9 +178,8 @@ function findMatch<Schema extends EditorSchema = EditorSchema>(
});
}

type RecheckMatchProps<
Schema extends EditorSchema = EditorSchema
> = SuggestStateMatchProps<Schema> & EditorStateProps<Schema>;
type RecheckMatchProps<Schema extends EditorSchema = EditorSchema> =
SuggestStateMatchProps<Schema> & EditorStateProps<Schema>;

/**
* Checks the provided match and generates a new match. This is useful for
Expand Down Expand Up @@ -300,9 +291,8 @@ function findJumpReason<Schema extends EditorSchema = EditorSchema>(
};
}

type FindExitReasonProps<
Schema extends EditorSchema = EditorSchema
> = SuggestStateMatchProps<Schema> & EditorStateProps<Schema> & ResolvedPosProps<Schema>;
type FindExitReasonProps<Schema extends EditorSchema = EditorSchema> =
SuggestStateMatchProps<Schema> & EditorStateProps<Schema> & ResolvedPosProps<Schema>;

/**
* Find the reason for the exit.
Expand Down
Expand Up @@ -38,7 +38,7 @@ const trailingNodePluginKey = new PluginKey<boolean>('trailingNode');
* @param options - the options that can be provided to this plugin.
*/
export function trailingNode<
Schema extends EditorSchema<string, string> = EditorSchema<string, string>
Schema extends EditorSchema<string, string> = EditorSchema<string, string>,
>(options?: TrailingNodePluginOptions): Plugin<boolean, Schema> {
const { ignoredNodes = [], nodeName = 'paragraph' } = options ?? {};

Expand Down

0 comments on commit e48ea78

Please sign in to comment.