Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/webpack-5.94.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultJanBeyer authored Oct 26, 2024
2 parents 3f45756 + 995e243 commit f89d592
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 48 deletions.
4 changes: 4 additions & 0 deletions DragSelect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.1.0

- Add `useLayers` option to enable/disable the `z-index` manipulation on drag/select of nodes. Thanks to [@digitalclubb](https://github.com/digitalclubb) for the contributing PR [#234](https://github.com/ThibaultJanBeyer/DragSelect/pull/234)

# 3.0.7

- Fix an issue with scrolling bottom if there is no area defined and the document.element is used
Expand Down
15 changes: 15 additions & 0 deletions DragSelect/__tests__/functional/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,19 @@ describe('Settings', () => {
cb = await selectItems(180, 120)
expect(cb?.sort()).toMatchObject(['one', 'two'])
})

it('useLayers swapping should work', async () => {
await page.goto(`${baseUrl}/settings.html`)
await page.evaluate(() =>
ds.setSettings({
draggability: true,
immediateDrag: true,
useLayers: false,
})
)
await moveSelect(page, 140, 85)
expect(
await page.evaluate(() => document.querySelector('#two').style.zIndex)
).toBe('')
})
})
4 changes: 2 additions & 2 deletions DragSelect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dragselect",
"version": "3.0.7",
"version": "3.1.0",
"description": "Easy JavaScript library for selecting and moving elements. With no dependencies. Drag-Select & Drag-And-Drop.",
"main": "./dist/DragSelect.js",
"module": "./dist/DragSelect.esm.js",
Expand Down Expand Up @@ -52,7 +52,7 @@
"minami": "^1.2.3",
"prettier": "^3.0.3",
"puppeteer": "21.3.1",
"rollup": "^3.29.2",
"rollup": "^3.29.5",
"rollup-plugin-dts": "^6.0.2",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^29.1.1",
Expand Down
1 change: 1 addition & 0 deletions DragSelect/src/methods/hydrateSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,5 @@ export const hydrateSettings = <E extends DSInputElement>(settings: Settings<E>,
withFallback,
'ds-dropzone-inside'
),
...hydrateHelper('useLayers', settings.useLayers, withFallback, true),
} as Required<Settings<E>>)
14 changes: 8 additions & 6 deletions DragSelect/src/modules/Drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ export default class Drag<E extends DSInputElement> {
}

private handleZIndex = (add: boolean) => {
this._elements.forEach(
(element) =>
(element.style.zIndex = `${
(parseInt(element.style.zIndex) || 0) + (add ? 9999 : -9998)
}`)
)
if (this.Settings.useLayers) {
this._elements.forEach(
(element) =>
(element.style.zIndex = `${
(parseInt(element.style.zIndex) || 0) + (add ? 9999 : -9998)
}`)
)
}
}

private moveElements = (posDirection: Vect2) => {
Expand Down
4 changes: 2 additions & 2 deletions DragSelect/src/modules/SelectedSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class SelectedSet<E extends DSInputElement> extends Set<E> {
this.PS.publish('Selected:added:pre', publishData)
super.add(element)
element.classList.add(this.Settings.selectedClass)
element.style.zIndex = `${(parseInt(element.style.zIndex) || 0) + 1}`
if (this.Settings.useLayers) element.style.zIndex = `${(parseInt(element.style.zIndex) || 0) + 1}`
this.PS.publish('Selected:added', publishData)
return this
}
Expand All @@ -51,7 +51,7 @@ export default class SelectedSet<E extends DSInputElement> extends Set<E> {
this.PS.publish('Selected:removed:pre', publishData)
const deleted = super.delete(element)
element.classList.remove(this.Settings.selectedClass)
element.style.zIndex = `${(parseInt(element.style.zIndex) || 0) - 1}`
if (this.Settings.useLayers) element.style.zIndex = `${(parseInt(element.style.zIndex) || 0) - 1}`
this.PS.publish('Selected:removed', publishData)
return deleted
}
Expand Down
2 changes: 2 additions & 0 deletions DragSelect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export type Settings<E extends DSInputElement> = {
dropZoneTargetClass?: string
/** [=ds-dropzone-inside] on dropZone that has elements inside after any drop */
dropZoneInsideClass?: string
/** [=true] Whether to use z-index when selecting and dragging an item */
useLayers?: boolean
}

export type DSCallbackObject<E extends DSInputElement> = Readonly<
Expand Down
2 changes: 2 additions & 0 deletions www/docs/API/Settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ds = new DragSelect({
| `keyboardDrag` | boolean | true |Whether or not the user can drag with the keyboard (Accessibility).
| `dragKeys` | { up:string[], down:string[], left:string[], right:string[] } | { up:['ArrowUp'], down: ['ArrowDown'], left: ['ArrowLeft'], right: ['ArrowRight'] } |The keys available to drag element using the keyboard. Any key value is possible ([see MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)).
| `keyboardDragSpeed` | number | 10 | The speed at which elements are dragged using the keyboard. In pixels per keyDown.
| `useLayers` | boolean | true | Whether to apply z-index when dragging and once dragged.

## Dropping
| property | type | default | description
Expand Down Expand Up @@ -113,5 +114,6 @@ new DragSelect({
refreshMemoryRate: 80,
usePointerEvents: false,
zoom: 1,
useLayers: true,
});
```
76 changes: 38 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3765,21 +3765,21 @@ binary-extensions@^2.0.0:
resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

[email protected].2:
version "1.20.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd"
integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==
[email protected].1:
version "1.20.1"
resolved "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz"
integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==
dependencies:
bytes "3.1.2"
content-type "~1.0.5"
content-type "~1.0.4"
debug "2.6.9"
depd "2.0.0"
destroy "1.2.0"
http-errors "2.0.0"
iconv-lite "0.4.24"
on-finished "2.4.1"
qs "6.11.0"
raw-body "2.5.2"
raw-body "2.5.1"
type-is "~1.6.18"
unpipe "1.0.0"

Expand Down Expand Up @@ -3854,11 +3854,11 @@ brace@^0.11.0, brace@^0.11.1:
integrity sha512-Fc8Ne62jJlKHiG/ajlonC4Sd66Pq68fFwK4ihJGNZpGqboc324SQk+lRvMzpPRuJOmfrJefdG8/7JdWX4bzJ2Q==

braces@^3.0.2, braces@~3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
version "3.0.2"
resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
dependencies:
fill-range "^7.1.1"
fill-range "^7.0.1"

browserslist@^4.0.0, browserslist@^4.18.1, browserslist@^4.21.10, browserslist@^4.21.4, browserslist@^4.21.9:
version "4.21.11"
Expand Down Expand Up @@ -4447,7 +4447,7 @@ [email protected]:
dependencies:
safe-buffer "5.2.1"

content-type@~1.0.4, content-type@~1.0.5:
content-type@~1.0.4:
version "1.0.5"
resolved "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz"
integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==
Expand All @@ -4467,10 +4467,10 @@ [email protected]:
resolved "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz"
integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==

cookie@0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051"
integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==
cookie@0.5.0:
version "0.5.0"
resolved "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz"
integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==

copy-text-to-clipboard@^3.0.1:
version "3.2.0"
Expand Down Expand Up @@ -5728,16 +5728,16 @@ expect@^29.0.0, expect@^29.7.0:
jest-util "^29.7.0"

express@^4.17.3:
version "4.19.2"
resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465"
integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==
version "4.18.2"
resolved "https://registry.npmjs.org/express/-/express-4.18.2.tgz"
integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==
dependencies:
accepts "~1.3.8"
array-flatten "1.1.1"
body-parser "1.20.2"
body-parser "1.20.1"
content-disposition "0.5.4"
content-type "~1.0.4"
cookie "0.6.0"
cookie "0.5.0"
cookie-signature "1.0.6"
debug "2.6.9"
depd "2.0.0"
Expand Down Expand Up @@ -5910,10 +5910,10 @@ filesize@^8.0.6:
resolved "https://registry.npmjs.org/filesize/-/filesize-8.0.7.tgz"
integrity sha512-pjmC+bkIF8XI7fWaH8KxHcZL3DPybs1roSKP4rKDvy20tAWwIObE4+JIseG2byfGKhud5ZnM4YSGKBz7Sh0ndQ==

fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
dependencies:
to-regex-range "^5.0.1"

Expand Down Expand Up @@ -6009,9 +6009,9 @@ flux@^4.0.1:
fbjs "^3.0.1"

follow-redirects@^1.0.0, follow-redirects@^1.14.7, follow-redirects@^1.14.9:
version "1.15.6"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==
version "1.15.3"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz"
integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==

for-each@^0.3.3:
version "0.3.3"
Expand Down Expand Up @@ -9808,10 +9808,10 @@ range-parser@^1.2.1, range-parser@~1.2.1:
resolved "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz"
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==

[email protected].2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a"
integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==
[email protected].1:
version "2.5.1"
resolved "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz"
integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==
dependencies:
bytes "3.1.2"
http-errors "2.0.0"
Expand Down Expand Up @@ -10445,10 +10445,10 @@ rollup-plugin-terser@^7.0.2:
serialize-javascript "^4.0.0"
terser "^5.0.0"

rollup@^3.1.0, rollup@^3.29.2:
version "3.29.3"
resolved "https://registry.npmjs.org/rollup/-/rollup-3.29.3.tgz"
integrity sha512-T7du6Hum8jOkSWetjRgbwpM6Sy0nECYrYRSmZjayFcOddtKJWU4d17AC3HNUk7HRuqy4p+G7aEZclSHytqUmEg==
rollup@^3.1.0, rollup@^3.29.5:
version "3.29.5"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54"
integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==
optionalDependencies:
fsevents "~2.3.2"

Expand Down Expand Up @@ -12119,9 +12119,9 @@ webpack-bundle-analyzer@^4.5.0:
ws "^7.3.1"

webpack-dev-middleware@^5.3.1:
version "5.3.4"
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.4.tgz#eb7b39281cbce10e104eb2b8bf2b63fce49a3517"
integrity sha512-BVdTqhhs+0IfoeAf7EoH5WE+exCmqGerHfDM0IL096Px60Tq2Mn9MAbnaGUe6HiMa41KMCYF19gyzZmBcq/o4Q==
version "5.3.3"
resolved "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz"
integrity sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==
dependencies:
colorette "^2.0.10"
memfs "^3.4.3"
Expand Down

0 comments on commit f89d592

Please sign in to comment.