Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow an item to have the selecting state without moving the mouse (useful to have a visual indicator that the item is clicked) #108

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"presets": [
"@babel/preset-react",
"@babel/typescript",
["@babel/preset-typescript", { "allowDeclareFields": true }],
["@babel/preset-env", { "modules": false }]
],
"plugins": ["@babel/plugin-proposal-class-properties"]
"plugins": [
[ "@babel/plugin-transform-typescript", { "allowDeclareFields": true } ],
"@babel/plugin-proposal-class-properties"
]
}
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ module.exports = {
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
'prettier'
],
env: {
browser: true,
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
website/bundle.js
lib
dist
#dist
build
node_modules
.DS_Store
Expand Down
7 changes: 7 additions & 0 deletions dist/CreateSelectable.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';
import { TSelectableItemState, TSelectableItemProps } from './Selectable.types';
declare type TAddedProps = Partial<Pick<TSelectableItemProps, 'isSelected'>>;
export declare const createSelectable: <T extends unknown>(WrappedComponent: React.ComponentType<TSelectableItemState & {
selectableRef(node: HTMLElement | null): void;
} & T>) => React.ComponentType<T & Partial<Pick<TSelectableItemProps, "isSelected">>>;
export {};
47 changes: 47 additions & 0 deletions dist/CreateSelectable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/CreateSelectable.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/DeselectAll.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component, FunctionComponent, ReactNode } from 'react';
import { SelectableGroupContext } from './SelectableGroup.context';
declare type TDeselectAllProps = {
children: ReactNode;
component?: string | FunctionComponent;
className?: string;
[key: string]: any;
};
export declare class DeselectAll extends Component<TDeselectAllProps> {
static contextType: React.Context<import("./Selectable.types").TSelectableGroupContext>;
context: React.ContextType<typeof SelectableGroupContext>;
root: HTMLDivElement | null;
componentDidMount(): void;
getRootRef: (ref: HTMLDivElement | null) => void;
render(): JSX.Element;
}
export {};
48 changes: 48 additions & 0 deletions dist/DeselectAll.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/DeselectAll.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/SelectAll.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component, ReactNode, FunctionComponent } from 'react';
import { SelectableGroupContext } from './SelectableGroup.context';
declare type TSelectAllProps = {
children: ReactNode;
component?: string | FunctionComponent;
className?: string;
[key: string]: any;
};
export declare class SelectAll extends Component<TSelectAllProps> {
static contextType: React.Context<import("./Selectable.types").TSelectableGroupContext>;
context: React.ContextType<typeof SelectableGroupContext>;
root: HTMLDivElement | null;
componentDidMount(): void;
getRootRef: (ref: HTMLDivElement | null) => void;
render(): JSX.Element;
}
export {};
48 changes: 48 additions & 0 deletions dist/SelectAll.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/SelectAll.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions dist/Selectable.types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Maybe, TComputedBounds, TGetBoundsForNodeArgs } from './utils';
declare type TSelectableContext = {
register(selectableItem: TSelectableItem): void;
unregister(selectableItem: TSelectableItem): void;
selectAll(): void;
clearSelection(): void;
getScrolledContainer(): Maybe<HTMLElement>;
};
declare type TSelectableGroupContext = {
selectable: TSelectableContext;
};
declare type TSelectableItemState = {
isSelected: boolean;
isSelecting: boolean;
};
declare type TSelectableItem = {
updateBounds(containerScroll?: TGetBoundsForNodeArgs): void;
registerSelectable(containerScroll?: TGetBoundsForNodeArgs): void;
setState(state: any): void;
state: TSelectableItemState;
deselected: boolean;
node: Maybe<HTMLElement>;
bounds: Maybe<TComputedBounds[]>;
};
declare type TSelectableItemProps = TSelectableItemState & {
selectableRef(node: HTMLElement | null): void;
};
export { TSelectableGroupContext, TSelectableItemState, TSelectableItem, TSelectableItemProps };
3 changes: 3 additions & 0 deletions dist/Selectable.types.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/Selectable.types.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/SelectableGroup.context.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import React from 'react';
import { TSelectableGroupContext } from './Selectable.types';
export declare const SelectableGroupContext: React.Context<TSelectableGroupContext>;
18 changes: 18 additions & 0 deletions dist/SelectableGroup.context.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/SelectableGroup.context.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading