diff --git a/README.md b/README.md index dd823e7..0b75809 100644 --- a/README.md +++ b/README.md @@ -59,36 +59,33 @@ Check out the documentation for the package you want to use: * [@viselect/react](packages/react) - [React](https://reactjs.org/) wrapper. * [@viselect/vue](packages/vue) - [Vue3](https://v3.vuejs.org/) wrapper. -> Check out [recipes](packages/vanilla/recipes.md) for commonly asked questions and how to solve them using the standart library! +> Check out [recipes](packages/vanilla/recipes.md) for commonly asked questions and how to solve them using the standard library! > For information about events and more check out the [vanilla readme](packages/vanilla/README.md)! ### Browser support -This library will always have the previous year as its target. For 2021 for example the target will be ES2020. -It always provides both a `UMD` (`.js`) and `.mjs` version. If you want to support legacy browsers, please use the feature of your bundler to transpile dependencie. In case of -webpack and babel (give [vite](https://vitejs.dev/) a try, it's awesome) you'll have to install corresponding plugins such -as [babel-plugin-proposal-optional-chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining) and include the dependency from `node_modules` which is normally -entirely excluded from being processed. +This library will always produce an ESNext bundle. +If you want to support legacy browsers, please use the feature of your bundler to transpile dependencies. +In case of webpack and babel (give [vite](https://vitejs.dev/) a try, it's awesome) you'll have to install corresponding plugins such as [babel-plugin-proposal-optional-chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining) and include the dependency from `node_modules` which is normally entirely excluded from being processed. I do this to provide maximum flexibility and give those who target ESNext a chance to make full use of how this library is bundled. Everything else is just a matter of configuration :) ### Is this library the right choice for me? -Viselect primarily focuses on being a high-performant engine to select elements with various boundaries, behaviours and modes in your browser. -Viselect is to "full-blown libraries" what is [popper.js](https://popper.js.org/) to [tippy.js](https://atomiks.github.io/tippyjs/) - the _core_ of your feature / of another -library. +Viselect primarily focuses on being a high-performant engine to select elements with various boundaries, behaviors, and modes in your browser. +Viselect is to "full-blown libraries" what is [popper.js](https://popper.js.org/) to [tippy.js](https://atomiks.github.io/tippyjs/) - the _core_ of your feature. ### Development Use the following commands to work on this locally (we use [lerna](https://lerna.js.org/) to manage this): -* `npm run dev` _- Spawns a dev-server for all packages. Every framework-dependend package is bundled with the vanilla version._ +* `npm run dev` _- Spawns a dev-server for all packages. Every framework-dependent package is bundled with the vanilla version._ * `npm run build` _- Builds all packages in parallel._ * `npm run lint:fix` _- Lints and fixes all errors in all packages._ For the development servers [vite](https://vitejs.dev/) is used. It's superb, you should give it a try. -To bundle it we use [rollup](https://rollupjs.org/) (which is btw also used by vite behind the scenes) to have full control over how the bundle looks like. +To bundle it, we use [rollup](https://rollupjs.org/) (which is btw also used by vite behind the scenes) to have full control over how the bundle looks like. ### Releasing a new version diff --git a/packages/preact/README.md b/packages/preact/README.md index fdda17e..a7deaba 100644 --- a/packages/preact/README.md +++ b/packages/preact/README.md @@ -45,6 +45,10 @@
+> [!NOTE] +> This is merely a convenience wrapper around [@viselect/vanilla](https://github.com/simonwep/selection/tree/master/packages/vanilla). +> The core API is fairly simple, if you want to have full control over it, you should roll out your own wrapper in your app. + ### Installation Install using your package manager of choice: @@ -53,7 +57,7 @@ Install using your package manager of choice: npm install @viselect/preact ``` -Last but not least you'll need to add some basic styles to make your selection-area visible: +Last but not least, you'll need to add some basic styles to make your selection-area visible: ```css .selection-area { @@ -63,9 +67,9 @@ Last but not least you'll need to add some basic styles to make your selection-a } ``` -Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). This however can cause problems with the actual -selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). If you don't care about -text-selection, add the following to the container where all your selectables are located: +Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). +This, however, can cause problems with the actual selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). +If you don't care about text-selection, add the following to the container where all your selectables are located: ```css .container { diff --git a/packages/preact/src/SelectionArea.tsx b/packages/preact/src/SelectionArea.tsx index 04154e1..e8626ba 100644 --- a/packages/preact/src/SelectionArea.tsx +++ b/packages/preact/src/SelectionArea.tsx @@ -1,10 +1,10 @@ /* eslint-disable no-use-before-define */ import VanillaSelectionArea from '@viselect/vanilla'; -import {SelectionEvents, SelectionOptions} from '@viselect/vanilla'; +import {SelectionEvents, PartialSelectionOptions} from '@viselect/vanilla'; import {createContext, createRef, FunctionalComponent, JSX} from 'preact'; import {useEffect, useContext, useState} from 'preact/hooks'; -export interface SelectionAreaProps extends Omit, 'boundaries'>, JSX.HTMLAttributes { +export interface SelectionAreaProps extends PartialSelectionOptions, JSX.HTMLAttributes { id?: string; className?: string; onBeforeStart?: SelectionEvents['beforestart']; @@ -48,9 +48,13 @@ export const SelectionArea: FunctionalComponent = props => { return ( -
- {props.children} -
+ {props.boundaries ? ( + props.children + ) : ( +
+ {props.children} +
+ )}
); }; diff --git a/packages/react/README.md b/packages/react/README.md index 6c0e4bf..2c32ae2 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -45,6 +45,10 @@
+> [!NOTE] +> This is merely a convenience wrapper around [@viselect/vanilla](https://github.com/simonwep/selection/tree/master/packages/vanilla). +> The core API is fairly simple, if you want to have full control over it, you should roll out your own wrapper in your app. + ### Installation Install using your package manager of choice: @@ -56,7 +60,7 @@ npm install @viselect/react > If you're (still) using CRA, you may run into issues while using the bundle provided. > See [this comment](https://github.com/facebook/create-react-app/issues/8445#issuecomment-588545858) for how to fix it. -Last but not least you'll need to add some basic styles to make your selection-area visible: +Last but not least, you'll need to add some basic styles to make your selection-area visible: ```css .selection-area { @@ -66,9 +70,9 @@ Last but not least you'll need to add some basic styles to make your selection-a } ``` -Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). This however can cause problems with the actual -selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). If you don't care about -text-selection, add the following to the container where all your selectables are located: +Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). +This, however, can cause problems with the actual selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). +If you don't care about text-selection, add the following to the container where all your selectables are located: ```css .container { diff --git a/packages/react/src/SelectionArea.tsx b/packages/react/src/SelectionArea.tsx index c2ec7da..203f9cf 100644 --- a/packages/react/src/SelectionArea.tsx +++ b/packages/react/src/SelectionArea.tsx @@ -1,9 +1,9 @@ /* eslint-disable no-use-before-define */ import VanillaSelectionArea from '@viselect/vanilla'; -import {SelectionEvents, SelectionOptions} from '@viselect/vanilla'; +import {SelectionEvents, PartialSelectionOptions} from '@viselect/vanilla'; import React, {useEffect, createContext, useContext, useRef, useState} from 'react'; -export interface SelectionAreaProps extends Partial, React.HTMLAttributes { +export interface SelectionAreaProps extends PartialSelectionOptions, React.HTMLAttributes { id?: string; className?: string; onBeforeStart?: SelectionEvents['beforestart']; diff --git a/packages/vanilla/README.md b/packages/vanilla/README.md index 4e83a4e..ce9ff73 100644 --- a/packages/vanilla/README.md +++ b/packages/vanilla/README.md @@ -70,7 +70,7 @@ import SelectionArea from "https://cdn.jsdelivr.net/npm/@viselect/vanilla/dist/v ### Getting started -Last but not least you'll need to add some basic styles to make your selection-area visible: +Last but not least, you'll need to add some basic styles to make your selection-area visible: ```css .selection-area { @@ -80,9 +80,9 @@ Last but not least you'll need to add some basic styles to make your selection-a } ``` -Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). This however can cause problems with the actual -selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). If you don't care about -text-selection, add the following to the container where all your selectables are located: +Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). +This, however, can cause problems with the actual selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). +If you don't care about text-selection, add the following to the container where all your selectables are located: ```css .container { @@ -268,7 +268,7 @@ Every event comes with the following properties: ```typescript { selection: SelectionArea // Current instance - event: TouchEvent | MouseEvent | null // TouchEvent, MouseEvent or `null` if triggered manually + event: TouchEvent | MouseEvent | null // TouchEvent, MouseEvent, or `null` if triggered manually store: { touched: Element[] // Touched elements selected: Element[] // Elements from the currently active selection (each click, drag counts as a single "selection") diff --git a/packages/vue/README.md b/packages/vue/README.md index a3a3030..7ac0799 100644 --- a/packages/vue/README.md +++ b/packages/vue/README.md @@ -45,6 +45,10 @@
+> [!NOTE] +> This is merely a convenience wrapper around [@viselect/vanilla](https://github.com/simonwep/selection/tree/master/packages/vanilla). +> The core API is fairly simple, if you want to have full control over it, you should roll out your own wrapper in your app. + ### Installation Install using your package manager of choice: @@ -53,7 +57,7 @@ Install using your package manager of choice: npm install @viselect/vue ``` -Last but not least you'll need to add some basic styles to make your selection-area visible: +Last but not least, you'll need to add some basic styles to make your selection-area visible: ```css .selection-area { @@ -63,9 +67,9 @@ Last but not least you'll need to add some basic styles to make your selection-a } ``` -Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). This however can cause problems with the actual -selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). If you don't care about -text-selection, add the following to the container where all your selectables are located: +Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of `v2.0.3`). +This, however, can cause problems with the actual selection ("introduced" by [#99](https://github.com/Simonwep/selection/pull/99), reported in [#103](https://github.com/Simonwep/selection/issues/103)). +If you don't care about text-selection, add the following to the container where all your selectables are located: ```css .container { @@ -75,7 +79,7 @@ text-selection, add the following to the container where all your selectables ar ### Usage -> Events are handled using props because you cannot return a value in events synchronously. +> Events are handled using props because you can’t return a value in events synchronously. ```vue ``` diff --git a/packages/vue/src/SelectionArea.vue b/packages/vue/src/SelectionArea.vue index 402a4fc..d448fae 100644 --- a/packages/vue/src/SelectionArea.vue +++ b/packages/vue/src/SelectionArea.vue @@ -5,7 +5,7 @@