@teipublisher/pb-components 1.36.2 → 1.38.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/CHANGELOG.md +29 -0
- package/Dockerfile +1 -1
- package/css/tom-select/tom-select.bootstrap4.min.css +2 -0
- package/css/tom-select/tom-select.bootstrap5.min.css +2 -0
- package/css/tom-select/tom-select.default.min.css +2 -0
- package/css/tom-select/tom-select.min.css +2 -0
- package/dist/demo/demos.json +3 -0
- package/dist/demo/pb-combo-box.html +102 -0
- package/dist/demo/pb-leaflet-map.html +4 -0
- package/dist/demo/select.json +22 -16
- package/dist/pb-components-bundle.js +182 -182
- package/dist/pb-elements.json +283 -9
- package/dist/pb-leaflet-map.js +3 -3
- package/package.json +2 -1
- package/pb-elements.json +283 -9
- package/src/pb-combo-box.js +154 -0
- package/src/pb-components.js +1 -0
- package/src/pb-geolocation.js +3 -2
- package/src/pb-leaflet-map.js +40 -4
- package/src/pb-map-icon.js +101 -0
- package/src/pb-page.js +9 -0
- package/src/pb-popover.js +1 -1
- package/src/pb-timeline.js +22 -11
package/pb-elements.json
CHANGED
|
@@ -2285,6 +2285,161 @@
|
|
|
2285
2285
|
}
|
|
2286
2286
|
]
|
|
2287
2287
|
},
|
|
2288
|
+
{
|
|
2289
|
+
"name": "pb-combo-box",
|
|
2290
|
+
"path": "./src/pb-combo-box.js",
|
|
2291
|
+
"description": "Provides a combo box, i.e. a combination of an input with a dropdown.\nItems to select from may be obtained from a remote data source.\n\nThe form control to be used (either a select or input) should be passed \nin the content of the element. If no control is provided, a simple `<input>`\nwill be created.",
|
|
2292
|
+
"attributes": [
|
|
2293
|
+
{
|
|
2294
|
+
"name": "source",
|
|
2295
|
+
"description": "A remote data source to use. The component will pass the text entered by the user\nin parameter `query`. It expects a JSON array of objects with each object describing\none item:\n\n```json\n{\n \"text\": \"Text to show as label\",\n \"value\": \"value-to-use\"\n}\n```",
|
|
2296
|
+
"type": "string"
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
"name": "close-after-select",
|
|
2300
|
+
"description": "Automatically close the dropdown once the user made a selection",
|
|
2301
|
+
"type": "boolean",
|
|
2302
|
+
"default": "false"
|
|
2303
|
+
},
|
|
2304
|
+
{
|
|
2305
|
+
"name": "preload",
|
|
2306
|
+
"description": "Preload all items from the remote data source at startup",
|
|
2307
|
+
"type": "boolean",
|
|
2308
|
+
"default": "false"
|
|
2309
|
+
},
|
|
2310
|
+
{
|
|
2311
|
+
"name": "on-blur",
|
|
2312
|
+
"description": "Name of the event to be emitted when the user leaves the form control",
|
|
2313
|
+
"type": "string",
|
|
2314
|
+
"default": "\"pb-combo-box-blur\""
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
"name": "on-change",
|
|
2318
|
+
"description": "Name of the event to be emitted when the value of the form control has changed",
|
|
2319
|
+
"type": "string",
|
|
2320
|
+
"default": "\"pb-combo-box-change\""
|
|
2321
|
+
},
|
|
2322
|
+
{
|
|
2323
|
+
"name": "subscribe",
|
|
2324
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
2325
|
+
"type": "string"
|
|
2326
|
+
},
|
|
2327
|
+
{
|
|
2328
|
+
"name": "subscribe-config",
|
|
2329
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
2330
|
+
"type": "object"
|
|
2331
|
+
},
|
|
2332
|
+
{
|
|
2333
|
+
"name": "emit",
|
|
2334
|
+
"description": "The name of the channel to send events to.",
|
|
2335
|
+
"type": "string"
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
"name": "emit-config",
|
|
2339
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
2340
|
+
"type": "object"
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
"name": "wait-for",
|
|
2344
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
2345
|
+
"type": "string"
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
"name": "disabled",
|
|
2349
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
2350
|
+
"type": "boolean",
|
|
2351
|
+
"default": "false"
|
|
2352
|
+
}
|
|
2353
|
+
],
|
|
2354
|
+
"properties": [
|
|
2355
|
+
{
|
|
2356
|
+
"name": "renderItem",
|
|
2357
|
+
"description": "Set a javascript function to be called whenever an item\nneeds to be rendered. The function will be passed the data\nobject of the current item as argument.",
|
|
2358
|
+
"type": "Function"
|
|
2359
|
+
},
|
|
2360
|
+
{
|
|
2361
|
+
"name": "theme",
|
|
2362
|
+
"type": "string",
|
|
2363
|
+
"default": "\"default\""
|
|
2364
|
+
},
|
|
2365
|
+
{
|
|
2366
|
+
"name": "source",
|
|
2367
|
+
"attribute": "source",
|
|
2368
|
+
"description": "A remote data source to use. The component will pass the text entered by the user\nin parameter `query`. It expects a JSON array of objects with each object describing\none item:\n\n```json\n{\n \"text\": \"Text to show as label\",\n \"value\": \"value-to-use\"\n}\n```",
|
|
2369
|
+
"type": "string"
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
"name": "closeAfterSelect",
|
|
2373
|
+
"attribute": "close-after-select",
|
|
2374
|
+
"description": "Automatically close the dropdown once the user made a selection",
|
|
2375
|
+
"type": "boolean",
|
|
2376
|
+
"default": "false"
|
|
2377
|
+
},
|
|
2378
|
+
{
|
|
2379
|
+
"name": "preload",
|
|
2380
|
+
"attribute": "preload",
|
|
2381
|
+
"description": "Preload all items from the remote data source at startup",
|
|
2382
|
+
"type": "boolean",
|
|
2383
|
+
"default": "false"
|
|
2384
|
+
},
|
|
2385
|
+
{
|
|
2386
|
+
"name": "renderFunction",
|
|
2387
|
+
"type": "object",
|
|
2388
|
+
"default": "\"renderDefault\""
|
|
2389
|
+
},
|
|
2390
|
+
{
|
|
2391
|
+
"name": "onBlur",
|
|
2392
|
+
"attribute": "on-blur",
|
|
2393
|
+
"description": "Name of the event to be emitted when the user leaves the form control",
|
|
2394
|
+
"type": "string",
|
|
2395
|
+
"default": "\"pb-combo-box-blur\""
|
|
2396
|
+
},
|
|
2397
|
+
{
|
|
2398
|
+
"name": "onChange",
|
|
2399
|
+
"attribute": "on-change",
|
|
2400
|
+
"description": "Name of the event to be emitted when the value of the form control has changed",
|
|
2401
|
+
"type": "string",
|
|
2402
|
+
"default": "\"pb-combo-box-change\""
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
"name": "subscribe",
|
|
2406
|
+
"attribute": "subscribe",
|
|
2407
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
2408
|
+
"type": "string"
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
"name": "subscribeConfig",
|
|
2412
|
+
"attribute": "subscribe-config",
|
|
2413
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
2414
|
+
"type": "object"
|
|
2415
|
+
},
|
|
2416
|
+
{
|
|
2417
|
+
"name": "emit",
|
|
2418
|
+
"attribute": "emit",
|
|
2419
|
+
"description": "The name of the channel to send events to.",
|
|
2420
|
+
"type": "string"
|
|
2421
|
+
},
|
|
2422
|
+
{
|
|
2423
|
+
"name": "emitConfig",
|
|
2424
|
+
"attribute": "emit-config",
|
|
2425
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
2426
|
+
"type": "object"
|
|
2427
|
+
},
|
|
2428
|
+
{
|
|
2429
|
+
"name": "waitFor",
|
|
2430
|
+
"attribute": "wait-for",
|
|
2431
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
2432
|
+
"type": "string"
|
|
2433
|
+
},
|
|
2434
|
+
{
|
|
2435
|
+
"name": "disabled",
|
|
2436
|
+
"attribute": "disabled",
|
|
2437
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
2438
|
+
"type": "boolean",
|
|
2439
|
+
"default": "false"
|
|
2440
|
+
}
|
|
2441
|
+
]
|
|
2442
|
+
},
|
|
2288
2443
|
{
|
|
2289
2444
|
"name": "pb-custom-form",
|
|
2290
2445
|
"path": "./src/pb-custom-form.js",
|
|
@@ -3803,7 +3958,7 @@
|
|
|
3803
3958
|
{
|
|
3804
3959
|
"name": "pb-geolocation",
|
|
3805
3960
|
"path": "./src/pb-geolocation.js",
|
|
3806
|
-
"description": "Represents a geo location. Extends `pb-highlight`, but sends an additional `pb-geolocation` event\non mouseover.\n\nFor `pb-leaflet-map` to show markers for `pb-geolocation` elements, make sure that map subscribes to the channel\ninto which `pb-geolocation`s emit and that map is loaded before the emitting component, e.g. `pb-view`, by specifying \n`wait-for` property",
|
|
3961
|
+
"description": "Represents a geo location. Extends `pb-highlight`, but sends an additional `pb-geolocation` event\non mouseover.\n\nFor `pb-leaflet-map` to show markers for `pb-geolocation` elements, make sure that map subscribes to the channel\ninto which `pb-geolocation`s emit and that map is loaded before the emitting component, e.g. `pb-view`, by specifying \n`wait-for` property.",
|
|
3807
3962
|
"attributes": [
|
|
3808
3963
|
{
|
|
3809
3964
|
"name": "longitude",
|
|
@@ -4609,7 +4764,7 @@
|
|
|
4609
4764
|
{
|
|
4610
4765
|
"name": "pb-leaflet-map",
|
|
4611
4766
|
"path": "./src/pb-leaflet-map.js",
|
|
4612
|
-
"description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map
|
|
4767
|
+
"description": "A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.\n\nThe map layers displayed can be configured via nested `pb-map-layer` (see docs) elements,\nicons via `pb-map-icon`.",
|
|
4613
4768
|
"attributes": [
|
|
4614
4769
|
{
|
|
4615
4770
|
"name": "latitude",
|
|
@@ -5582,6 +5737,114 @@
|
|
|
5582
5737
|
}
|
|
5583
5738
|
]
|
|
5584
5739
|
},
|
|
5740
|
+
{
|
|
5741
|
+
"name": "pb-map-icon",
|
|
5742
|
+
"path": "./src/pb-map-icon.js",
|
|
5743
|
+
"description": "Configure a map icon type to be used for markers. \nShould be nested inside `pb-leaflet-map`.",
|
|
5744
|
+
"attributes": [
|
|
5745
|
+
{
|
|
5746
|
+
"name": "icon-size",
|
|
5747
|
+
"description": "Size of the icon as comma-separated string, i.e. 'height, width'.",
|
|
5748
|
+
"type": "array"
|
|
5749
|
+
},
|
|
5750
|
+
{
|
|
5751
|
+
"name": "icon-anchor",
|
|
5752
|
+
"description": "Anchor position of the icon as comma-separated string, i.e. 'height, width'.",
|
|
5753
|
+
"type": "array"
|
|
5754
|
+
},
|
|
5755
|
+
{
|
|
5756
|
+
"name": "shadow-url",
|
|
5757
|
+
"description": "The URL to load the shadow icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.",
|
|
5758
|
+
"type": "string"
|
|
5759
|
+
},
|
|
5760
|
+
{
|
|
5761
|
+
"name": "shadow-size",
|
|
5762
|
+
"description": "Size of the shadow icon as comma-separated string, i.e. 'height, width'.",
|
|
5763
|
+
"type": "array"
|
|
5764
|
+
},
|
|
5765
|
+
{
|
|
5766
|
+
"name": "shadow-anchor",
|
|
5767
|
+
"description": "Anchor position of the shadow icon as comma-separated string, i.e. 'height, width'.",
|
|
5768
|
+
"type": "array"
|
|
5769
|
+
},
|
|
5770
|
+
{
|
|
5771
|
+
"name": "popup-anchor",
|
|
5772
|
+
"description": "Anchor position of the popup as comma-separated string, i.e. 'height, width'.",
|
|
5773
|
+
"type": "array"
|
|
5774
|
+
},
|
|
5775
|
+
{
|
|
5776
|
+
"name": "name",
|
|
5777
|
+
"description": "Name of the icon. Set to 'active' to configure the icon used for\nplaces which were target of a previous `pb-geolocation` event (i.e. are currently 'active').",
|
|
5778
|
+
"type": "string",
|
|
5779
|
+
"default": "\"default\""
|
|
5780
|
+
},
|
|
5781
|
+
{
|
|
5782
|
+
"name": "icon-url",
|
|
5783
|
+
"description": "The URL to load the icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.",
|
|
5784
|
+
"type": "string"
|
|
5785
|
+
}
|
|
5786
|
+
],
|
|
5787
|
+
"properties": [
|
|
5788
|
+
{
|
|
5789
|
+
"name": "iconSize",
|
|
5790
|
+
"attribute": "icon-size",
|
|
5791
|
+
"description": "Size of the icon as comma-separated string, i.e. 'height, width'.",
|
|
5792
|
+
"type": "array"
|
|
5793
|
+
},
|
|
5794
|
+
{
|
|
5795
|
+
"name": "iconAnchor",
|
|
5796
|
+
"attribute": "icon-anchor",
|
|
5797
|
+
"description": "Anchor position of the icon as comma-separated string, i.e. 'height, width'.",
|
|
5798
|
+
"type": "array"
|
|
5799
|
+
},
|
|
5800
|
+
{
|
|
5801
|
+
"name": "shadowUrl",
|
|
5802
|
+
"attribute": "shadow-url",
|
|
5803
|
+
"description": "The URL to load the shadow icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.",
|
|
5804
|
+
"type": "string"
|
|
5805
|
+
},
|
|
5806
|
+
{
|
|
5807
|
+
"name": "shadowSize",
|
|
5808
|
+
"attribute": "shadow-size",
|
|
5809
|
+
"description": "Size of the shadow icon as comma-separated string, i.e. 'height, width'.",
|
|
5810
|
+
"type": "array"
|
|
5811
|
+
},
|
|
5812
|
+
{
|
|
5813
|
+
"name": "shadowAnchor",
|
|
5814
|
+
"attribute": "shadow-anchor",
|
|
5815
|
+
"description": "Anchor position of the shadow icon as comma-separated string, i.e. 'height, width'.",
|
|
5816
|
+
"type": "array"
|
|
5817
|
+
},
|
|
5818
|
+
{
|
|
5819
|
+
"name": "popupAncor",
|
|
5820
|
+
"attribute": "popup-anchor",
|
|
5821
|
+
"description": "Anchor position of the popup as comma-separated string, i.e. 'height, width'.",
|
|
5822
|
+
"type": "array"
|
|
5823
|
+
},
|
|
5824
|
+
{
|
|
5825
|
+
"name": "options",
|
|
5826
|
+
"type": "object"
|
|
5827
|
+
},
|
|
5828
|
+
{
|
|
5829
|
+
"name": "name",
|
|
5830
|
+
"attribute": "name",
|
|
5831
|
+
"description": "Name of the icon. Set to 'active' to configure the icon used for\nplaces which were target of a previous `pb-geolocation` event (i.e. are currently 'active').",
|
|
5832
|
+
"type": "string",
|
|
5833
|
+
"default": "\"default\""
|
|
5834
|
+
},
|
|
5835
|
+
{
|
|
5836
|
+
"name": "type",
|
|
5837
|
+
"type": "string",
|
|
5838
|
+
"default": "\"image\""
|
|
5839
|
+
},
|
|
5840
|
+
{
|
|
5841
|
+
"name": "iconUrl",
|
|
5842
|
+
"attribute": "icon-url",
|
|
5843
|
+
"description": "The URL to load the icon from. Should be relative to the path set via the `imagesPath` property on `pb-leaflet-map`.",
|
|
5844
|
+
"type": "string"
|
|
5845
|
+
}
|
|
5846
|
+
]
|
|
5847
|
+
},
|
|
5585
5848
|
{
|
|
5586
5849
|
"name": "pb-map-layer",
|
|
5587
5850
|
"path": "./src/pb-map-layer.js",
|
|
@@ -7390,6 +7653,9 @@
|
|
|
7390
7653
|
{
|
|
7391
7654
|
"name": "pb-toggle",
|
|
7392
7655
|
"description": "when received, dispatch state changes to the elements on the page (see `pb-toggle-feature`, `pb-select-feature`)"
|
|
7656
|
+
},
|
|
7657
|
+
{
|
|
7658
|
+
"name": "pb-page-loaded"
|
|
7393
7659
|
}
|
|
7394
7660
|
],
|
|
7395
7661
|
"slots": [
|
|
@@ -7773,7 +8039,8 @@
|
|
|
7773
8039
|
},
|
|
7774
8040
|
{
|
|
7775
8041
|
"name": "popup-class",
|
|
7776
|
-
"
|
|
8042
|
+
"description": "Additional class names which will be added to the popup element.\nUse this to apply a specific style to certain popovers, but not others.",
|
|
8043
|
+
"type": "String"
|
|
7777
8044
|
},
|
|
7778
8045
|
{
|
|
7779
8046
|
"name": "subscribe",
|
|
@@ -7808,11 +8075,6 @@
|
|
|
7808
8075
|
}
|
|
7809
8076
|
],
|
|
7810
8077
|
"properties": [
|
|
7811
|
-
{
|
|
7812
|
-
"name": "poupClass",
|
|
7813
|
-
"description": "Additional class names which will be added to the popup element.\nUse this to apply a specific style to certain popovers, but not others.",
|
|
7814
|
-
"type": "String"
|
|
7815
|
-
},
|
|
7816
8078
|
{
|
|
7817
8079
|
"name": "remote",
|
|
7818
8080
|
"attribute": "remote",
|
|
@@ -7863,7 +8125,8 @@
|
|
|
7863
8125
|
{
|
|
7864
8126
|
"name": "popupClass",
|
|
7865
8127
|
"attribute": "popup-class",
|
|
7866
|
-
"
|
|
8128
|
+
"description": "Additional class names which will be added to the popup element.\nUse this to apply a specific style to certain popovers, but not others.",
|
|
8129
|
+
"type": "String"
|
|
7867
8130
|
},
|
|
7868
8131
|
{
|
|
7869
8132
|
"name": "subscribe",
|
|
@@ -9576,6 +9839,11 @@
|
|
|
9576
9839
|
"type": "array",
|
|
9577
9840
|
"default": "[\"D\",\"W\",\"M\",\"Y\",\"5Y\",\"10Y\"]"
|
|
9578
9841
|
},
|
|
9842
|
+
{
|
|
9843
|
+
"name": "max-interval",
|
|
9844
|
+
"type": "number",
|
|
9845
|
+
"default": "60"
|
|
9846
|
+
},
|
|
9579
9847
|
{
|
|
9580
9848
|
"name": "url",
|
|
9581
9849
|
"description": "Endpoint to load timeline data from. Expects response to be an\nobject with key value pairs for (date, hits).\n\nWill be reloaded whenever 'start-date' or 'end-date' attributes change.",
|
|
@@ -9672,6 +9940,12 @@
|
|
|
9672
9940
|
"type": "array",
|
|
9673
9941
|
"default": "[\"D\",\"W\",\"M\",\"Y\",\"5Y\",\"10Y\"]"
|
|
9674
9942
|
},
|
|
9943
|
+
{
|
|
9944
|
+
"name": "maxInterval",
|
|
9945
|
+
"attribute": "max-interval",
|
|
9946
|
+
"type": "number",
|
|
9947
|
+
"default": "60"
|
|
9948
|
+
},
|
|
9675
9949
|
{
|
|
9676
9950
|
"name": "url",
|
|
9677
9951
|
"attribute": "url",
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { LitElement } from 'lit-element';
|
|
2
|
+
import TomSelect from "tom-select";
|
|
3
|
+
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { resolveURL } from './utils.js';
|
|
5
|
+
|
|
6
|
+
function importTheme(theme) {
|
|
7
|
+
if (document.getElementById('__pb-multi-select-css')) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const themes = resolveURL('../css/tom-select');
|
|
11
|
+
const link = document.createElement('link');
|
|
12
|
+
link.id = '__pb-multi-select-css';
|
|
13
|
+
link.href = `${themes}/tom-select.${theme}.min.css`;
|
|
14
|
+
link.rel = 'stylesheet';
|
|
15
|
+
document.head.appendChild(link);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const renderDefault = (data) =>
|
|
19
|
+
data ? `<div>${data.text}</div>` : '';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Provides a combo box, i.e. a combination of an input with a dropdown.
|
|
23
|
+
* Items to select from may be obtained from a remote data source.
|
|
24
|
+
*
|
|
25
|
+
* The form control to be used (either a select or input) should be passed
|
|
26
|
+
* in the content of the element. If no control is provided, a simple `<input>`
|
|
27
|
+
* will be created.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
export class PbComboBox extends pbMixin(LitElement) {
|
|
31
|
+
static get properties() {
|
|
32
|
+
return {
|
|
33
|
+
...super.properties,
|
|
34
|
+
/**
|
|
35
|
+
* A remote data source to use. The component will pass the text entered by the user
|
|
36
|
+
* in parameter `query`. It expects a JSON array of objects with each object describing
|
|
37
|
+
* one item:
|
|
38
|
+
*
|
|
39
|
+
* ```json
|
|
40
|
+
* {
|
|
41
|
+
* "text": "Text to show as label",
|
|
42
|
+
* "value": "value-to-use"
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
source: {
|
|
47
|
+
type: String
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Automatically close the dropdown once the user made a selection
|
|
51
|
+
*/
|
|
52
|
+
closeAfterSelect: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
attribute: 'close-after-select'
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Preload all items from the remote data source at startup
|
|
58
|
+
*/
|
|
59
|
+
preload: {
|
|
60
|
+
type: Boolean
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Name of the event to be emitted when the user leaves the form control
|
|
64
|
+
*/
|
|
65
|
+
onBlur: {
|
|
66
|
+
type: String,
|
|
67
|
+
attribute: 'on-blur'
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Name of the event to be emitted when the value of the form control has changed
|
|
71
|
+
*/
|
|
72
|
+
onChange: {
|
|
73
|
+
type: String,
|
|
74
|
+
attribute: 'on-change'
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Set a javascript function to be called whenever an item
|
|
81
|
+
* needs to be rendered. The function will be passed the data
|
|
82
|
+
* object of the current item as argument.
|
|
83
|
+
*
|
|
84
|
+
* @param {Function} callbackFunction
|
|
85
|
+
*/
|
|
86
|
+
set renderItem(callbackFunction) {
|
|
87
|
+
this.renderFunction = callbackFunction;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
constructor() {
|
|
91
|
+
super();
|
|
92
|
+
this.theme = 'default';
|
|
93
|
+
this.source = null;
|
|
94
|
+
this.closeAfterSelect = false;
|
|
95
|
+
this.preload = false;
|
|
96
|
+
this.renderFunction = renderDefault;
|
|
97
|
+
this.onBlur = 'pb-combo-box-blur';
|
|
98
|
+
this.onChange = 'pb-combo-box-change';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
connectedCallback() {
|
|
102
|
+
super.connectedCallback();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
firstUpdated() {
|
|
106
|
+
importTheme(this.theme);
|
|
107
|
+
|
|
108
|
+
let input = this.querySelector('select,input');
|
|
109
|
+
|
|
110
|
+
if (!input) {
|
|
111
|
+
// create input if none was passed
|
|
112
|
+
input = document.createElement('input');
|
|
113
|
+
this.appendChild(input);
|
|
114
|
+
}
|
|
115
|
+
input.autocomplete = false;
|
|
116
|
+
|
|
117
|
+
PbComboBox.waitOnce('pb-page-ready', () => {
|
|
118
|
+
const options = {};
|
|
119
|
+
if (this.source) {
|
|
120
|
+
const url = this.toAbsoluteURL(this.source);
|
|
121
|
+
options.labelField = 'text';
|
|
122
|
+
options.valueField = 'value';
|
|
123
|
+
options.searchField = ['text', 'value'];
|
|
124
|
+
options.preload = this.preload;
|
|
125
|
+
options.load = (query, callback) => {
|
|
126
|
+
fetch(`${url}?query=${encodeURIComponent(query)}`, {
|
|
127
|
+
method: 'GET',
|
|
128
|
+
mode: 'cors',
|
|
129
|
+
credentials: 'same-origin'
|
|
130
|
+
})
|
|
131
|
+
.then(response => response.json())
|
|
132
|
+
.then(json => {
|
|
133
|
+
callback(json);
|
|
134
|
+
}).catch(()=>{
|
|
135
|
+
callback();
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
options.render = {
|
|
139
|
+
option: this.renderFunction,
|
|
140
|
+
item: this.renderFunction
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
options.closeAfterSelect = this.closeAfterSelect;
|
|
144
|
+
options.onBlur = () => this.emitTo(this.onBlur);
|
|
145
|
+
options.onChange = () => this.emitTo(this.onChange);
|
|
146
|
+
this._select = new TomSelect(input, options);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
createRenderRoot() {
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
customElements.define('pb-combo-box', PbComboBox);
|
package/src/pb-components.js
CHANGED
package/src/pb-geolocation.js
CHANGED
|
@@ -8,7 +8,7 @@ import { PbHighlight } from "./pb-highlight.js";
|
|
|
8
8
|
*
|
|
9
9
|
* For `pb-leaflet-map` to show markers for `pb-geolocation` elements, make sure that map subscribes to the channel
|
|
10
10
|
* into which `pb-geolocation`s emit and that map is loaded before the emitting component, e.g. `pb-view`, by specifying
|
|
11
|
-
* `wait-for` property
|
|
11
|
+
* `wait-for` property.
|
|
12
12
|
*
|
|
13
13
|
* @slot - default unnamed slot for content. May also contain an option `<template>` element for content to be shown in a popup
|
|
14
14
|
* @fires pb-geolocation - Sends geocoordinates
|
|
@@ -74,7 +74,8 @@ export class PbGeolocation extends PbHighlight {
|
|
|
74
74
|
label: this.label,
|
|
75
75
|
zoom: this.zoom,
|
|
76
76
|
popup: this.popup,
|
|
77
|
-
element: this
|
|
77
|
+
element: this,
|
|
78
|
+
event: this.event
|
|
78
79
|
})
|
|
79
80
|
);
|
|
80
81
|
}
|
package/src/pb-leaflet-map.js
CHANGED
|
@@ -3,9 +3,13 @@ import "@lrnwebcomponents/es-global-bridge";
|
|
|
3
3
|
import { pbMixin } from './pb-mixin.js';
|
|
4
4
|
import { resolveURL } from './utils.js';
|
|
5
5
|
import './pb-map-layer.js';
|
|
6
|
+
import './pb-map-icon.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A wrapper component for [leaflet](https://leafletjs.com/) displaying a map.
|
|
10
|
+
*
|
|
11
|
+
* The map layers displayed can be configured via nested `pb-map-layer` (see docs) elements,
|
|
12
|
+
* icons via `pb-map-icon`.
|
|
9
13
|
*
|
|
10
14
|
* @slot - may contain a series of `pb-map-layer` configurations
|
|
11
15
|
* @fires pb-leaflet-marker-click - Fires event to be processed by the map upon click
|
|
@@ -113,12 +117,14 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
113
117
|
this.cluster = false;
|
|
114
118
|
this.fitMarkers = false;
|
|
115
119
|
this.disableClusteringAt = null;
|
|
120
|
+
this._icons = {};
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
connectedCallback() {
|
|
119
124
|
super.connectedCallback();
|
|
120
125
|
|
|
121
126
|
this._layers = this.querySelectorAll('pb-map-layer');
|
|
127
|
+
this._markers = this.querySelectorAll('pb-map-icon');
|
|
122
128
|
|
|
123
129
|
/**
|
|
124
130
|
* Custom event which passes an array of pb-geolocation within event details
|
|
@@ -142,6 +148,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
142
148
|
this.emitTo('pb-leaflet-marker-click', loc);
|
|
143
149
|
});
|
|
144
150
|
marker.bindTooltip(loc.label);
|
|
151
|
+
this.setMarkerIcon(marker);
|
|
145
152
|
this._markerLayer.addLayer(marker);
|
|
146
153
|
});
|
|
147
154
|
this._fitBounds();
|
|
@@ -170,6 +177,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
170
177
|
marker.addEventListener('click', () => {
|
|
171
178
|
this.emitTo('pb-leaflet-marker-click', loc);
|
|
172
179
|
});
|
|
180
|
+
this.setMarkerIcon(marker);
|
|
173
181
|
});
|
|
174
182
|
this._fitBounds();
|
|
175
183
|
});
|
|
@@ -194,6 +202,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
194
202
|
if (ev.detail.popup) {
|
|
195
203
|
marker.bindPopup(ev.detail.popup);
|
|
196
204
|
}
|
|
205
|
+
this.setMarkerIcon(marker);
|
|
197
206
|
marker.addTo(this._markerLayer);
|
|
198
207
|
|
|
199
208
|
if (ev.detail.fitBounds) {
|
|
@@ -204,14 +213,22 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
204
213
|
} else {
|
|
205
214
|
console.log('<pb-leaflet-map> Marker already added to map');
|
|
206
215
|
}
|
|
216
|
+
|
|
207
217
|
if (this.toggle) {
|
|
208
218
|
this.disabled = false;
|
|
209
219
|
}
|
|
210
|
-
|
|
220
|
+
const activateMarker = ev.detail.event;
|
|
221
|
+
this._locationChanged(this.latitude, this.longitude, ev.detail.zoom, activateMarker);
|
|
211
222
|
}
|
|
212
223
|
});
|
|
213
224
|
}
|
|
214
225
|
|
|
226
|
+
setMarkerIcon(layer) {
|
|
227
|
+
if (this._icons && this._icons.default) {
|
|
228
|
+
layer.setIcon(this._icons.default);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
215
232
|
firstUpdated() {
|
|
216
233
|
if (!this.toggle) {
|
|
217
234
|
this.disabled = false;
|
|
@@ -274,6 +291,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
274
291
|
crs
|
|
275
292
|
});
|
|
276
293
|
this._configureLayers();
|
|
294
|
+
this._configureMarkers();
|
|
277
295
|
|
|
278
296
|
if (this.cluster) {
|
|
279
297
|
const options = {};
|
|
@@ -312,6 +330,19 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
312
330
|
}
|
|
313
331
|
}
|
|
314
332
|
|
|
333
|
+
_configureMarkers() {
|
|
334
|
+
if (this._markers.length === 0) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
this._icons = {};
|
|
339
|
+
this._markers.forEach(config => {
|
|
340
|
+
if (config.iconUrl) {
|
|
341
|
+
this._icons[config.name] = L.icon(config.options);
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
}
|
|
345
|
+
|
|
315
346
|
_configureLayers() {
|
|
316
347
|
if (this._layers.length === 0) {
|
|
317
348
|
// configure a default layer
|
|
@@ -379,7 +410,7 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
379
410
|
}
|
|
380
411
|
}
|
|
381
412
|
|
|
382
|
-
_locationChanged(lat, long, zoom) {
|
|
413
|
+
_locationChanged(lat, long, zoom, setActive) {
|
|
383
414
|
if (this._map) {
|
|
384
415
|
const coords = L.latLng([lat, long]);
|
|
385
416
|
this._markerLayer.eachLayer((layer) => {
|
|
@@ -395,6 +426,11 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
395
426
|
layer.openTooltip();
|
|
396
427
|
this._map.setView(coords, this.zoom);
|
|
397
428
|
}
|
|
429
|
+
if (setActive && this._icons && this._icons.active) {
|
|
430
|
+
layer.setIcon(this._icons.active);
|
|
431
|
+
}
|
|
432
|
+
} else if (this._icons && this._icons.default && layer.getIcon() !== this._icons.default) {
|
|
433
|
+
layer.setIcon(this._icons.default);
|
|
398
434
|
}
|
|
399
435
|
});
|
|
400
436
|
}
|
|
@@ -402,10 +438,10 @@ export class PbLeafletMap extends pbMixin(LitElement) {
|
|
|
402
438
|
|
|
403
439
|
_hasMarker(lat, long) {
|
|
404
440
|
const coords = L.latLng([lat, long]);
|
|
405
|
-
let found =
|
|
441
|
+
let found = null;
|
|
406
442
|
this._markerLayer.eachLayer((layer) => {
|
|
407
443
|
if (layer instanceof L.Marker && layer.getLatLng().equals(coords)) {
|
|
408
|
-
found =
|
|
444
|
+
found = layer;
|
|
409
445
|
}
|
|
410
446
|
});
|
|
411
447
|
return found;
|