Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
94dbec2
Incrementally update
tristen Mar 4, 2025
0e08763
Lose extensions on imports
tristen Mar 4, 2025
f81f483
Declare class
tristen Mar 4, 2025
60e274d
More conversion
tristen Mar 4, 2025
f8166b3
Move all source .js to .ts
tristen Mar 4, 2025
88f9cb1
Format everything
tristen Mar 4, 2025
6c95cc9
Fix bad reference to getFeaturesAt
tristen Mar 4, 2025
2098903
More TypeScript setup
tristen Mar 4, 2025
dd83eed
Convet more to TypeScript
tristen Mar 4, 2025
8cdbaf0
Tackle smaller libs
tristen Mar 4, 2025
0a746b8
Move feature_types to classes
tristen Mar 5, 2025
f7cc701
Start over again with @types/mapbox-gl-draw
tristen Mar 6, 2025
711f71c
Reformatting wave
tristen Mar 6, 2025
045467d
More typing
tristen Mar 6, 2025
5b71f7b
Simple typings for common selectors
tristen Mar 6, 2025
bf78fe6
More typings
tristen Mar 6, 2025
e1cc500
More type safety, nest properties in mode objects
tristen Mar 13, 2025
c865b76
More
tristen Mar 13, 2025
2923db4
More
tristen Mar 13, 2025
2f8abc0
Drop unused method
tristen Mar 13, 2025
9506e08
Bad typing for QRF
tristen Mar 13, 2025
7a00968
Add argument signatures to mode interface and do not recast
tristen Mar 13, 2025
1b4c52e
Walk back
tristen Mar 13, 2025
2792160
Reduce the scope of this PR by skipping bench stuff
tristen Mar 14, 2025
2e24ed1
Reduce scope further
tristen Mar 14, 2025
d23d156
Bad conditional
tristen Mar 14, 2025
05cf584
Walk back on eslint stuff
tristen Mar 14, 2025
3b48ac1
eslint changes
tristen Mar 14, 2025
1c2bc4c
Consistify direct select with object+property of other modes
tristen Mar 14, 2025
64cd9df
Mode state interface
tristen Mar 14, 2025
dd3b5d2
More typings for direct_select
tristen Mar 15, 2025
06ebad2
Organize, use ModeCTX directly
tristen Mar 15, 2025
5daaa4a
Simplify
tristen Mar 15, 2025
c6ec967
String is also accepted
tristen Mar 15, 2025
341d3ac
Fixes to store
tristen Mar 16, 2025
aa98282
More on store
tristen Mar 16, 2025
34798cf
Work on api
tristen Mar 16, 2025
fe4d933
More typing
tristen Mar 16, 2025
4755a90
Finish api
tristen Mar 16, 2025
7276daa
Add ts-node loader and drop js extensions in test files
tristen Mar 16, 2025
8560abb
Convert the rest of lib to named exports
tristen Mar 16, 2025
77877c4
Move test files to typescript
tristen Mar 16, 2025
cebd5ab
Simplify
tristen Mar 16, 2025
11fc1c4
Some type coersion for tests
tristen Mar 17, 2025
b32aad7
More typings for tests
tristen Mar 17, 2025
9b0ca09
More types more coercing for mocks
tristen Mar 17, 2025
a1e18d9
More typings for tests
tristen Mar 17, 2025
7f1f5c5
Do some spy mocking
tristen Mar 17, 2025
195b056
More spy coersion
tristen Mar 17, 2025
ac8d989
Finish up the pass on tsc errors in tests
tristen Mar 17, 2025
041405c
tsx is better?
tristen Mar 17, 2025
845a741
Fixes to TypeScript for tests
tristen Mar 17, 2025
31a7035
Lint fixes suspiciously light
tristen Mar 17, 2025
b54417b
Bad typo
tristen Mar 17, 2025
7257289
Need to confirm undefined here
tristen Mar 17, 2025
57a7828
Merge branch 'main' into tsc
tristen Mar 17, 2025
37b1e97
Not a major version bump
tristen Mar 17, 2025
bd51259
Fix rollup
tristen Mar 17, 2025
dde51f2
Drop `export` where it is not necessary
tristen Mar 17, 2025
d180d1f
Remove overriding method
tristen Mar 18, 2025
326426e
Merge branch 'main' into tsc
tristen Mar 18, 2025
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
10 changes: 1 addition & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"extends": [
"mourner",
"plugin:import/recommended"
],
"parser": "espree",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
},
"parser": "@typescript-eslint/parser",
"plugins": [
"import"
],
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dist/mapbox-gl-draw-unminified.js.map
dist/bench.js
dist/bench.js.map
coverage/
.nyc_output/
debug/access_token_generated.js
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm test
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.css' type='text/css' />
```

### Typescript

Typescript definition files are available as part of the [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mapbox__mapbox-gl-draw) package.

```
npm install @types/mapbox__mapbox-gl-draw
```

### Example usage

```js
Expand Down
52 changes: 28 additions & 24 deletions dist/mapbox-gl-draw.css
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@

/* Override default control style */
.mapbox-gl-draw_ctrl-bottom-left,
.mapbox-gl-draw_ctrl-top-left {
margin-left:0;
border-radius:0 4px 4px 0;
margin-left: 0;
border-radius: 0 4px 4px 0;
}
.mapbox-gl-draw_ctrl-top-right,
.mapbox-gl-draw_ctrl-bottom-right {
margin-right:0;
border-radius:4px 0 0 4px;
margin-right: 0;
border-radius: 4px 0 0 4px;
}

.mapbox-gl-draw_ctrl-draw-btn {
border-color:rgba(0,0,0,0.9);
color:rgba(255,255,255,0.5);
width:30px;
height:30px;
border-color: rgba(0, 0, 0, 0.9);
color: rgba(255, 255, 255, 0.5);
width: 30px;
height: 30px;
}

.mapbox-gl-draw_ctrl-draw-btn.active,
.mapbox-gl-draw_ctrl-draw-btn.active:hover {
background-color:rgb(0 0 0/5%);
background-color: rgb(0 0 0/5%);
}
.mapbox-gl-draw_ctrl-draw-btn {
background-repeat: no-repeat;
Expand Down Expand Up @@ -55,34 +54,39 @@
.mapboxgl-map.mouse-add .mapboxgl-canvas-container.mapboxgl-interactive {
cursor: crosshair;
}
.mapboxgl-map.mouse-move.mode-direct_select .mapboxgl-canvas-container.mapboxgl-interactive {
.mapboxgl-map.mouse-move.mode-direct_select
.mapboxgl-canvas-container.mapboxgl-interactive {
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
.mapboxgl-map.mode-direct_select.feature-vertex.mouse-move .mapboxgl-canvas-container.mapboxgl-interactive {
.mapboxgl-map.mode-direct_select.feature-vertex.mouse-move
.mapboxgl-canvas-container.mapboxgl-interactive {
cursor: move;
}
.mapboxgl-map.mode-direct_select.feature-midpoint.mouse-pointer .mapboxgl-canvas-container.mapboxgl-interactive {
.mapboxgl-map.mode-direct_select.feature-midpoint.mouse-pointer
.mapboxgl-canvas-container.mapboxgl-interactive {
cursor: cell;
}
.mapboxgl-map.mode-direct_select.feature-feature.mouse-move .mapboxgl-canvas-container.mapboxgl-interactive {
.mapboxgl-map.mode-direct_select.feature-feature.mouse-move
.mapboxgl-canvas-container.mapboxgl-interactive {
cursor: move;
}
.mapboxgl-map.mode-static.mouse-pointer .mapboxgl-canvas-container.mapboxgl-interactive {
.mapboxgl-map.mode-static.mouse-pointer
.mapboxgl-canvas-container.mapboxgl-interactive {
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}

.mapbox-gl-draw_boxselect {
pointer-events: none;
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
background: rgba(0,0,0,.1);
border: 2px dotted #fff;
opacity: 0.5;
pointer-events: none;
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
background: rgba(0, 0, 0, 0.1);
border: 2px dotted #fff;
opacity: 0.5;
}
36 changes: 0 additions & 36 deletions index.js

This file was deleted.

38 changes: 38 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { spy } from 'sinon';
import runSetup from './src/setup';
import { configureOptions } from './src/options';
import setupAPI from './src/api';
import * as modes from './src/modes/index';
import * as Constants from './src/constants';
import * as lib from './src/lib/index';
import type { DrawOptions, Draw } from './src/types/types';

const setupDraw = (options: DrawOptions, api: Draw) => {
options = configureOptions(options);

const ctx = {
options
} as spy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have this test-related cast here?


api = setupAPI(ctx, api);
ctx.api = api;

const setup = runSetup(ctx);

api.onAdd = setup.onAdd;
api.onRemove = setup.onRemove;
api.types = Constants.types;
api.options = options;

return api;
};

function MapboxDraw(options?: DrawOptions) {
setupDraw(options, this);
}

MapboxDraw.modes = modes;
MapboxDraw.constants = Constants;
MapboxDraw.lib = lib;

export default MapboxDraw;
Loading