@mwater/visualization 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/MWaterContextComponent.d.ts +1 -1
- package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
- package/lib/MWaterGlobalFiltersComponent.js +11 -20
- package/lib/MWaterLoaderComponent.d.ts +4 -13
- package/lib/MWaterLoaderComponent.js +2 -11
- package/lib/UndoStack.d.ts +2 -1
- package/lib/UndoStack.js +12 -6
- package/lib/dashboards/DashboardComponent.js +5 -4
- package/lib/dashboards/DashboardDesign.d.ts +1 -1
- package/lib/dashboards/ServerDashboardDataSource.js +0 -10
- package/lib/dashboards/SettingsModalComponent.js +1 -1
- package/lib/datagrids/DatagridComponent.js +22 -2
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
- package/lib/datagrids/DatagridDesignerComponent.js +108 -120
- package/lib/datagrids/DatagridViewComponent.js +3 -2
- package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
- package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
- package/lib/index.css +45 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +2 -3
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
- package/lib/maps/BufferLayer.js +12 -0
- package/lib/maps/BufferLayerDesign.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayer.js +12 -0
- package/lib/maps/ChoroplethLayerDesign.d.ts +5 -2
- package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -32
- package/lib/maps/ChoroplethLayerDesigner.js +58 -89
- package/lib/maps/DirectMapDataSource.js +0 -10
- package/lib/maps/EditHoverOver.d.ts +4 -3
- package/lib/maps/EditHoverOver.js +3 -3
- package/lib/maps/HoverContent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +10 -19
- package/lib/maps/MapComponent.js +0 -1
- package/lib/maps/MapUtils.js +10 -1
- package/lib/maps/MarkersLayer.js +18 -2
- package/lib/maps/MarkersLayerDesign.d.ts +1 -1
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +12 -41
- package/lib/maps/MarkersLayerDesignerComponent.js +81 -111
- package/lib/maps/ServerMapDataSource.js +0 -10
- package/lib/maps/VectorMapViewComponent.js +1 -9
- package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
- package/lib/maps/symbols/font-awesome/ban.png +0 -0
- package/lib/maps/symbols/font-awesome/beer.png +0 -0
- package/lib/maps/symbols/font-awesome/bell.png +0 -0
- package/lib/maps/symbols/font-awesome/bolt.png +0 -0
- package/lib/maps/symbols/font-awesome/building.png +0 -0
- package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
- package/lib/maps/symbols/font-awesome/bus.png +0 -0
- package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
- package/lib/maps/symbols/font-awesome/certificate.png +0 -0
- package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/check.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud.png +0 -0
- package/lib/maps/symbols/font-awesome/comment.png +0 -0
- package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/lib/maps/symbols/font-awesome/female.png +0 -0
- package/lib/maps/symbols/font-awesome/file.png +0 -0
- package/lib/maps/symbols/font-awesome/flag.png +0 -0
- package/lib/maps/symbols/font-awesome/flask.png +0 -0
- package/lib/maps/symbols/font-awesome/h-square.png +0 -0
- package/lib/maps/symbols/font-awesome/home.png +0 -0
- package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/male.png +0 -0
- package/lib/maps/symbols/font-awesome/medkit.png +0 -0
- package/lib/maps/symbols/font-awesome/mobile.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
- package/lib/maps/symbols/font-awesome/plus.png +0 -0
- package/lib/maps/symbols/font-awesome/square.png +0 -0
- package/lib/maps/symbols/font-awesome/star.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/lib/maps/symbols/font-awesome/ticket.png +0 -0
- package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/times.png +0 -0
- package/lib/maps/symbols/font-awesome/tint.png +0 -0
- package/lib/maps/symbols/font-awesome/tree.png +0 -0
- package/lib/maps/symbols/font-awesome/university.png +0 -0
- package/lib/maps/symbols/font-awesome/usd.png +0 -0
- package/lib/maps/symbols/font-awesome/user.png +0 -0
- package/lib/maps/symbols/font-awesome/users.png +0 -0
- package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/lib/maps/symbols/sdf-ize.sh +93 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +20 -36
- package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +4 -2
- package/lib/mwater_table_selection/IndicatorsListComponent.js +103 -34
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +26 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +237 -51
- package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +2 -2
- package/lib/mwater_table_selection/MWaterTableSelectComponent.js +9 -4
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
- package/lib/quickfilter/QuickfiltersComponent.js +53 -110
- package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
- package/lib/quickfilter/TextLiteralComponent.js +85 -82
- package/lib/widgets/MapWidget.js +4 -2
- package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
- package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
- package/package.json +2 -3
- package/src/MWaterContextComponent.tsx +1 -1
- package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
- package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +17 -18
- package/src/UndoStack.ts +14 -6
- package/src/dashboards/DashboardComponent.tsx +5 -4
- package/src/dashboards/DashboardDesign.ts +1 -1
- package/src/dashboards/ServerDashboardDataSource.ts +0 -12
- package/src/dashboards/SettingsModalComponent.tsx +1 -1
- package/src/datagrids/DatagridComponent.tsx +30 -2
- package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
- package/src/datagrids/DatagridViewComponent.tsx +3 -2
- package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
- package/src/index.css +45 -2
- package/src/index.ts +5 -11
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
- package/src/maps/BufferLayer.ts +14 -1
- package/src/maps/BufferLayerDesign.ts +1 -1
- package/src/maps/BufferLayerDesignerComponent.tsx +2 -1
- package/src/maps/ChoroplethLayer.ts +20 -7
- package/src/maps/ChoroplethLayerDesign.ts +5 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +169 -165
- package/src/maps/DirectMapDataSource.ts +0 -12
- package/src/maps/EditHoverOver.tsx +9 -5
- package/src/maps/HoverContent.tsx +1 -1
- package/src/maps/LeafletMapComponent.tsx +10 -19
- package/src/maps/MapComponent.ts +0 -1
- package/src/maps/MapUtils.ts +13 -1
- package/src/maps/MarkersLayer.ts +22 -5
- package/src/maps/MarkersLayerDesign.ts +1 -1
- package/src/maps/MarkersLayerDesignerComponent.tsx +360 -0
- package/src/maps/ServerMapDataSource.ts +0 -12
- package/src/maps/VectorMapViewComponent.tsx +2 -13
- package/src/maps/symbols/font-awesome/asterisk.png +0 -0
- package/src/maps/symbols/font-awesome/ban.png +0 -0
- package/src/maps/symbols/font-awesome/beer.png +0 -0
- package/src/maps/symbols/font-awesome/bell.png +0 -0
- package/src/maps/symbols/font-awesome/bolt.png +0 -0
- package/src/maps/symbols/font-awesome/building.png +0 -0
- package/src/maps/symbols/font-awesome/bullseye.png +0 -0
- package/src/maps/symbols/font-awesome/bus.png +0 -0
- package/src/maps/symbols/font-awesome/caret-up.png +0 -0
- package/src/maps/symbols/font-awesome/certificate.png +0 -0
- package/src/maps/symbols/font-awesome/check-circle.png +0 -0
- package/src/maps/symbols/font-awesome/check.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/symbols/font-awesome/cloud.png +0 -0
- package/src/maps/symbols/font-awesome/comment.png +0 -0
- package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/src/maps/symbols/font-awesome/female.png +0 -0
- package/src/maps/symbols/font-awesome/file.png +0 -0
- package/src/maps/symbols/font-awesome/flag.png +0 -0
- package/src/maps/symbols/font-awesome/flask.png +0 -0
- package/src/maps/symbols/font-awesome/h-square.png +0 -0
- package/src/maps/symbols/font-awesome/home.png +0 -0
- package/src/maps/symbols/font-awesome/info-circle.png +0 -0
- package/src/maps/symbols/font-awesome/male.png +0 -0
- package/src/maps/symbols/font-awesome/medkit.png +0 -0
- package/src/maps/symbols/font-awesome/mobile.png +0 -0
- package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/src/maps/symbols/font-awesome/plus-square.png +0 -0
- package/src/maps/symbols/font-awesome/plus.png +0 -0
- package/src/maps/symbols/font-awesome/square.png +0 -0
- package/src/maps/symbols/font-awesome/star.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/src/maps/symbols/font-awesome/ticket.png +0 -0
- package/src/maps/symbols/font-awesome/times-circle.png +0 -0
- package/src/maps/symbols/font-awesome/times.png +0 -0
- package/src/maps/symbols/font-awesome/tint.png +0 -0
- package/src/maps/symbols/font-awesome/tree.png +0 -0
- package/src/maps/symbols/font-awesome/university.png +0 -0
- package/src/maps/symbols/font-awesome/usd.png +0 -0
- package/src/maps/symbols/font-awesome/user.png +0 -0
- package/src/maps/symbols/font-awesome/users.png +0 -0
- package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/src/maps/symbols/sdf-ize.sh +93 -0
- package/src/maps/vectorMaps.tsx +20 -44
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +165 -37
- package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +373 -37
- package/src/mwater_table_selection/MWaterTableSelectComponent.tsx +12 -8
- package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
- package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
- package/src/quickfilter/TextLiteralComponent.tsx +197 -0
- package/src/widgets/MapWidget.tsx +9 -1
- package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
- package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
- package/test/UndoStackTests.ts +52 -1
- package/.storybook/config.js +0 -7
- package/.storybook/head.html +0 -3
- package/.storybook/webpack.config.js +0 -15
- package/src/maps/BingLayer.ts +0 -146
- package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
- package/src/quickfilter/TextLiteralComponent.ts +0 -165
- package/stories/UpdateableComponent.js +0 -29
- package/stories/consoles.js +0 -202
- package/stories/dashboards.js +0 -217
- package/stories/datagridDesign.js +0 -114
- package/stories/datagrids.js +0 -69
- package/stories/dates.js +0 -80
- package/stories/exprcomponent.js +0 -43
- package/stories/index.js +0 -18
- package/stories/leaflet.js +0 -59
- package/stories/maps.js +0 -24
- package/stories/pivotChart.js +0 -235
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import PropTypes from "prop-types"
|
|
2
2
|
import _ from "lodash"
|
|
3
3
|
import React from "react"
|
|
4
|
-
const R = React.createElement
|
|
5
4
|
|
|
6
|
-
import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
5
|
+
import { DataSource, ExprUtils, ExprValidator, Schema } from "@mwater/expressions"
|
|
7
6
|
import { ExprComponent } from "@mwater/expressions-ui"
|
|
8
7
|
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
9
8
|
import { getFormatOptions } from "../../valueFormatter"
|
|
@@ -20,6 +19,7 @@ export interface ExprItemEditorComponentProps {
|
|
|
20
19
|
exprItem: HtmlItemExpr
|
|
21
20
|
/** Called with expr item */
|
|
22
21
|
onChange: (exprItem: HtmlItemExpr) => void
|
|
22
|
+
/** Optional table that will be filtered to have a single row present. Widget designer should optionally account for this */
|
|
23
23
|
singleRowTable?: string
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -80,85 +80,91 @@ export default class ExprItemEditorComponent extends React.Component<
|
|
|
80
80
|
return null
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_.map(formats, (format) => R("option", { key: format.value, value: format.value }, format.label))
|
|
97
|
-
)
|
|
83
|
+
return (
|
|
84
|
+
<div className="mb-3">
|
|
85
|
+
<label className="text-muted">{T`Format`}</label>
|
|
86
|
+
{": "}
|
|
87
|
+
<select
|
|
88
|
+
value={this.props.exprItem.format != null ? this.props.exprItem.format : getDefaultFormat(exprType)}
|
|
89
|
+
className="form-select"
|
|
90
|
+
style={{ width: "auto", display: "inline-block" }}
|
|
91
|
+
onChange={this.handleFormatChange}
|
|
92
|
+
>
|
|
93
|
+
{_.map(formats, (format) => <option key={format.value} value={format.value}>{format.label}</option>)}
|
|
94
|
+
</select>
|
|
95
|
+
</div>
|
|
98
96
|
)
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
render() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
100
|
+
const exprValidator = new ExprValidator(this.props.schema)
|
|
101
|
+
const error = exprValidator.validateExpr(this.props.exprItem.expr, {
|
|
102
|
+
table: this.state.table,
|
|
103
|
+
aggrStatuses: ["individual", "literal", "aggregate"]
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div style={{ paddingBottom: 200 }}>
|
|
108
|
+
<div className="mb-3">
|
|
109
|
+
<label className="text-muted"><i className="fa fa-database" /> {T`Data Source`}</label>
|
|
110
|
+
{": "}
|
|
111
|
+
<TableSelectComponent
|
|
112
|
+
schema={this.props.schema}
|
|
113
|
+
value={this.state.table}
|
|
114
|
+
onChange={this.handleTableChange}
|
|
115
|
+
/>
|
|
116
|
+
<br />
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{this.state.table
|
|
120
|
+
? (
|
|
121
|
+
<div className="mb-3">
|
|
122
|
+
<label className="text-muted">{T`Field`}</label>
|
|
123
|
+
{": "}
|
|
124
|
+
<ExprComponent
|
|
125
|
+
schema={this.props.schema}
|
|
126
|
+
dataSource={this.props.dataSource}
|
|
127
|
+
table={this.state.table}
|
|
128
|
+
types={["text", "number", "enum", "date", "datetime", "boolean", "enumset", "geometry"]}
|
|
129
|
+
value={this.props.exprItem.expr}
|
|
130
|
+
aggrStatuses={["individual", "literal", "aggregate"]}
|
|
131
|
+
onChange={this.handleExprChange}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
: undefined}
|
|
136
|
+
|
|
137
|
+
{error ? <div className="alert alert-danger">
|
|
138
|
+
<i className="fa fa-exclamation-circle" /> {error}
|
|
139
|
+
</div> : undefined}
|
|
140
|
+
|
|
141
|
+
{this.state.table && this.props.exprItem.expr
|
|
142
|
+
? (
|
|
143
|
+
<div className="mb-3">
|
|
144
|
+
<Checkbox
|
|
145
|
+
key="includeLabel"
|
|
146
|
+
value={this.props.exprItem.includeLabel}
|
|
147
|
+
onChange={this.handleIncludeLabelChange}
|
|
148
|
+
>
|
|
149
|
+
{T`Include Label`}
|
|
150
|
+
</Checkbox>
|
|
151
|
+
|
|
152
|
+
{this.props.exprItem.includeLabel
|
|
153
|
+
? <input
|
|
154
|
+
key="labelText"
|
|
155
|
+
className="form-control"
|
|
156
|
+
type="text"
|
|
157
|
+
value={this.props.exprItem.labelText || ""}
|
|
158
|
+
onChange={this.handleLabelTextChange}
|
|
159
|
+
placeholder={new ExprUtils(this.props.schema).summarizeExpr(this.props.exprItem.expr) + ": "}
|
|
160
|
+
/>
|
|
161
|
+
: undefined}
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
: undefined}
|
|
165
|
+
|
|
166
|
+
{this.renderFormat()}
|
|
167
|
+
</div>
|
|
162
168
|
)
|
|
163
169
|
}
|
|
164
170
|
}
|
|
@@ -9,6 +9,7 @@ export interface ExprUpdateModalComponentProps {
|
|
|
9
9
|
schema: Schema
|
|
10
10
|
/** Data source to use to get values */
|
|
11
11
|
dataSource: DataSource
|
|
12
|
+
/** Optional table that will be filtered to have a single row present. Widget designer should optionally account for this */
|
|
12
13
|
singleRowTable?: string
|
|
13
14
|
}
|
|
14
15
|
|
package/test/UndoStackTests.ts
CHANGED
|
@@ -58,7 +58,7 @@ describe("UndoStack", function () {
|
|
|
58
58
|
return assert.equal(us.getValue(), this.b)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
it("pushing new value clears redo stack", function () {
|
|
62
62
|
let us = this.undoStack.push(this.a)
|
|
63
63
|
us = us.push(this.b)
|
|
64
64
|
us = us.undo()
|
|
@@ -70,4 +70,55 @@ describe("UndoStack", function () {
|
|
|
70
70
|
us = us.push(this.c)
|
|
71
71
|
return assert.isFalse(us.canRedo())
|
|
72
72
|
})
|
|
73
|
+
|
|
74
|
+
it("limits stack depth when maxDepth is set", function () {
|
|
75
|
+
let us = new UndoStack(undefined, undefined, 3)
|
|
76
|
+
us = us.push({ x: 1 })
|
|
77
|
+
us = us.push({ x: 2 })
|
|
78
|
+
us = us.push({ x: 3 })
|
|
79
|
+
us = us.push({ x: 4 })
|
|
80
|
+
|
|
81
|
+
// Should only keep last 3 values
|
|
82
|
+
assert.equal(us.undoStack.length, 3)
|
|
83
|
+
assert.equal(us.getValue().x, 4)
|
|
84
|
+
|
|
85
|
+
// Can undo twice (3 values means 2 undo operations)
|
|
86
|
+
assert.isTrue(us.canUndo())
|
|
87
|
+
us = us.undo()
|
|
88
|
+
assert.equal(us.getValue().x, 3)
|
|
89
|
+
assert.isTrue(us.canUndo())
|
|
90
|
+
us = us.undo()
|
|
91
|
+
assert.equal(us.getValue().x, 2)
|
|
92
|
+
|
|
93
|
+
// Cannot undo anymore (only 1 value left)
|
|
94
|
+
return assert.isFalse(us.canUndo())
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it("preserves maxDepth through undo and redo operations", function () {
|
|
98
|
+
let us = new UndoStack(undefined, undefined, 5)
|
|
99
|
+
us = us.push({ x: 1 })
|
|
100
|
+
us = us.push({ x: 2 })
|
|
101
|
+
|
|
102
|
+
us = us.undo()
|
|
103
|
+
assert.equal(us.maxDepth, 5)
|
|
104
|
+
|
|
105
|
+
us = us.redo()
|
|
106
|
+
assert.equal(us.maxDepth, 5)
|
|
107
|
+
|
|
108
|
+
us = us.push({ x: 3 })
|
|
109
|
+
return assert.equal(us.maxDepth, 5)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return it("works without maxDepth (unlimited)", function () {
|
|
113
|
+
let us = new UndoStack()
|
|
114
|
+
|
|
115
|
+
// Push many values
|
|
116
|
+
for (let i = 0; i < 100; i++) {
|
|
117
|
+
us = us.push({ x: i })
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Should keep all values
|
|
121
|
+
assert.equal(us.undoStack.length, 100)
|
|
122
|
+
return assert.equal(us.getValue().x, 99)
|
|
123
|
+
})
|
|
73
124
|
})
|
package/.storybook/config.js
DELETED
package/.storybook/head.html
DELETED
package/src/maps/BingLayer.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (c) 2011-2014, Pavel Shramov, Bruno Bergot
|
|
3
|
-
All rights reserved.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without modification, are
|
|
6
|
-
permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
9
|
-
conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
12
|
-
of conditions and the following disclaimer in the documentation and/or other materials
|
|
13
|
-
provided with the distribution.
|
|
14
|
-
|
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
16
|
-
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
17
|
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
18
|
-
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
19
|
-
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
-
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
21
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
22
|
-
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
23
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import L from "leaflet"
|
|
27
|
-
|
|
28
|
-
module.exports = L.TileLayer.extend({
|
|
29
|
-
options: {
|
|
30
|
-
subdomains: [0, 1, 2, 3],
|
|
31
|
-
type: "Aerial",
|
|
32
|
-
attribution: "Bing",
|
|
33
|
-
culture: "",
|
|
34
|
-
maxZoom: 21,
|
|
35
|
-
maxNativeZoom: 19
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
initialize: function (key: any, options: any) {
|
|
39
|
-
L.Util.setOptions(this, options)
|
|
40
|
-
|
|
41
|
-
this._key = key
|
|
42
|
-
this._url = null
|
|
43
|
-
this.meta = {}
|
|
44
|
-
this.loadMetadata()
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
tile2quad: function (x: any, y: any, z: any) {
|
|
48
|
-
var quad = ""
|
|
49
|
-
for (var i = z; i > 0; i--) {
|
|
50
|
-
var digit = 0
|
|
51
|
-
var mask = 1 << (i - 1)
|
|
52
|
-
if ((x & mask) !== 0) digit += 1
|
|
53
|
-
if ((y & mask) !== 0) digit += 2
|
|
54
|
-
quad = quad + digit
|
|
55
|
-
}
|
|
56
|
-
return quad
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
getTileUrl: function (p: any, z: any) {
|
|
60
|
-
var zoom = this._getZoomForUrl()
|
|
61
|
-
var subdomains = this.options.subdomains,
|
|
62
|
-
s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)]
|
|
63
|
-
return this._url
|
|
64
|
-
.replace("{subdomain}", s)
|
|
65
|
-
.replace("{quadkey}", this.tile2quad(p.x, p.y, zoom))
|
|
66
|
-
.replace("{culture}", this.options.culture)
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
loadMetadata: function () {
|
|
70
|
-
var _this = this
|
|
71
|
-
var url = `https://dev.virtualearth.net/REST/v1/Imagery/Metadata/${this.options.type}?include=ImageryProviders&key=${this._key}&UriScheme=https`
|
|
72
|
-
|
|
73
|
-
fetch(url)
|
|
74
|
-
.then(response => response.json())
|
|
75
|
-
.then(meta => {
|
|
76
|
-
_this.meta = meta
|
|
77
|
-
if (meta.errorDetails) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
_this.initMetadata()
|
|
81
|
-
})
|
|
82
|
-
.catch(error => console.error('Error loading Bing Maps metadata:', error))
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
initMetadata: function () {
|
|
86
|
-
var r = this.meta.resourceSets[0].resources[0]
|
|
87
|
-
if (!r) {
|
|
88
|
-
console.error("Error loading Bing Maps metadata")
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
this.options.subdomains = r.imageUrlSubdomains
|
|
92
|
-
this._url = r.imageUrl
|
|
93
|
-
this._providers = []
|
|
94
|
-
if (r.imageryProviders) {
|
|
95
|
-
for (var i = 0; i < r.imageryProviders.length; i++) {
|
|
96
|
-
var p = r.imageryProviders[i]
|
|
97
|
-
for (var j = 0; j < p.coverageAreas.length; j++) {
|
|
98
|
-
var c = p.coverageAreas[j]
|
|
99
|
-
var coverage: any = { zoomMin: c.zoomMin, zoomMax: c.zoomMax, active: false }
|
|
100
|
-
var bounds = new L.LatLngBounds(
|
|
101
|
-
new L.LatLng(c.bbox[0] + 0.01, c.bbox[1] + 0.01),
|
|
102
|
-
new L.LatLng(c.bbox[2] - 0.01, c.bbox[3] - 0.01)
|
|
103
|
-
)
|
|
104
|
-
coverage.bounds = bounds
|
|
105
|
-
coverage.attrib = p.attribution
|
|
106
|
-
this._providers.push(coverage)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
this._update()
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
_update: function () {
|
|
114
|
-
if (this._url === null || !this._map) return
|
|
115
|
-
this._update_attribution()
|
|
116
|
-
;(L.TileLayer.prototype as any)._update.apply(this, [])
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
_update_attribution: function () {
|
|
120
|
-
var bounds = this._map.getBounds()
|
|
121
|
-
var zoom = this._map.getZoom()
|
|
122
|
-
for (var i = 0; i < this._providers.length; i++) {
|
|
123
|
-
var p = this._providers[i]
|
|
124
|
-
if (zoom <= p.zoomMax && zoom >= p.zoomMin && bounds.intersects(p.bounds)) {
|
|
125
|
-
if (!p.active && this._map.attributionControl) this._map.attributionControl.addAttribution(p.attrib)
|
|
126
|
-
p.active = true
|
|
127
|
-
} else {
|
|
128
|
-
if (p.active && this._map.attributionControl) this._map.attributionControl.removeAttribution(p.attrib)
|
|
129
|
-
p.active = false
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
onRemove: function (map: any) {
|
|
135
|
-
if (this._providers) {
|
|
136
|
-
for (var i = 0; i < this._providers.length; i++) {
|
|
137
|
-
var p = this._providers[i]
|
|
138
|
-
if (p.active && this._map.attributionControl) {
|
|
139
|
-
this._map.attributionControl.removeAttribution(p.attrib)
|
|
140
|
-
p.active = false
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
L.TileLayer.prototype.onRemove.apply(this, [map])
|
|
145
|
-
}
|
|
146
|
-
})
|