@teipublisher/pb-components 1.36.3 → 1.37.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 +15 -0
- 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/select.json +22 -16
- package/dist/pb-components-bundle.js +187 -187
- package/dist/pb-elements.json +162 -7
- package/package.json +2 -1
- package/pb-elements.json +162 -7
- package/src/pb-combo-box.js +154 -0
- package/src/pb-components.js +1 -0
- package/src/pb-page.js +9 -0
- package/src/pb-popover.js +1 -1
package/dist/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",
|
|
@@ -7390,6 +7545,9 @@
|
|
|
7390
7545
|
{
|
|
7391
7546
|
"name": "pb-toggle",
|
|
7392
7547
|
"description": "when received, dispatch state changes to the elements on the page (see `pb-toggle-feature`, `pb-select-feature`)"
|
|
7548
|
+
},
|
|
7549
|
+
{
|
|
7550
|
+
"name": "pb-page-loaded"
|
|
7393
7551
|
}
|
|
7394
7552
|
],
|
|
7395
7553
|
"slots": [
|
|
@@ -7773,7 +7931,8 @@
|
|
|
7773
7931
|
},
|
|
7774
7932
|
{
|
|
7775
7933
|
"name": "popup-class",
|
|
7776
|
-
"
|
|
7934
|
+
"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.",
|
|
7935
|
+
"type": "String"
|
|
7777
7936
|
},
|
|
7778
7937
|
{
|
|
7779
7938
|
"name": "subscribe",
|
|
@@ -7808,11 +7967,6 @@
|
|
|
7808
7967
|
}
|
|
7809
7968
|
],
|
|
7810
7969
|
"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
7970
|
{
|
|
7817
7971
|
"name": "remote",
|
|
7818
7972
|
"attribute": "remote",
|
|
@@ -7863,7 +8017,8 @@
|
|
|
7863
8017
|
{
|
|
7864
8018
|
"name": "popupClass",
|
|
7865
8019
|
"attribute": "popup-class",
|
|
7866
|
-
"
|
|
8020
|
+
"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.",
|
|
8021
|
+
"type": "String"
|
|
7867
8022
|
},
|
|
7868
8023
|
{
|
|
7869
8024
|
"name": "subscribe",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teipublisher/pb-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.0",
|
|
4
4
|
"description": "Collection of webcomponents underlying TEI Publisher",
|
|
5
5
|
"repository": "https://github.com/eeditiones/tei-publisher-components.git",
|
|
6
6
|
"main": "index.html",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"openseadragon": "^2.4.2",
|
|
84
84
|
"prismjs": "^1.21.0",
|
|
85
85
|
"tippy.js": "^6.2.7",
|
|
86
|
+
"tom-select": "^2.0.2",
|
|
86
87
|
"uniqolor": "^1.0.1",
|
|
87
88
|
"web-animations-js": "^2.3.2"
|
|
88
89
|
},
|
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",
|
|
@@ -7390,6 +7545,9 @@
|
|
|
7390
7545
|
{
|
|
7391
7546
|
"name": "pb-toggle",
|
|
7392
7547
|
"description": "when received, dispatch state changes to the elements on the page (see `pb-toggle-feature`, `pb-select-feature`)"
|
|
7548
|
+
},
|
|
7549
|
+
{
|
|
7550
|
+
"name": "pb-page-loaded"
|
|
7393
7551
|
}
|
|
7394
7552
|
],
|
|
7395
7553
|
"slots": [
|
|
@@ -7773,7 +7931,8 @@
|
|
|
7773
7931
|
},
|
|
7774
7932
|
{
|
|
7775
7933
|
"name": "popup-class",
|
|
7776
|
-
"
|
|
7934
|
+
"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.",
|
|
7935
|
+
"type": "String"
|
|
7777
7936
|
},
|
|
7778
7937
|
{
|
|
7779
7938
|
"name": "subscribe",
|
|
@@ -7808,11 +7967,6 @@
|
|
|
7808
7967
|
}
|
|
7809
7968
|
],
|
|
7810
7969
|
"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
7970
|
{
|
|
7817
7971
|
"name": "remote",
|
|
7818
7972
|
"attribute": "remote",
|
|
@@ -7863,7 +8017,8 @@
|
|
|
7863
8017
|
{
|
|
7864
8018
|
"name": "popupClass",
|
|
7865
8019
|
"attribute": "popup-class",
|
|
7866
|
-
"
|
|
8020
|
+
"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.",
|
|
8021
|
+
"type": "String"
|
|
7867
8022
|
},
|
|
7868
8023
|
{
|
|
7869
8024
|
"name": "subscribe",
|
|
@@ -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-page.js
CHANGED
|
@@ -229,6 +229,15 @@ class PbPage extends pbMixin(LitElement) {
|
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
const slot = this.shadowRoot.querySelector('slot');
|
|
233
|
+
slot.addEventListener('slotchange', () => {
|
|
234
|
+
const ev = new CustomEvent('pb-page-loaded', {
|
|
235
|
+
bubbles: true,
|
|
236
|
+
composed: true
|
|
237
|
+
});
|
|
238
|
+
this.dispatchEvent(ev);
|
|
239
|
+
}, { once: true });
|
|
240
|
+
|
|
232
241
|
const defaultLocales = resolveURL('../i18n/') + '{{ns}}/{{lng}}.json';
|
|
233
242
|
console.log('<pb-page> Loading locales. common: %s; additional: %s; namespaces: %o',
|
|
234
243
|
defaultLocales, this.locales, this._localeFallbacks);
|
package/src/pb-popover.js
CHANGED
|
@@ -74,7 +74,7 @@ export function loadTippyStyles(root, theme) {
|
|
|
74
74
|
* unless defined otherwise; clicking anywhere on the page will close the popup.
|
|
75
75
|
* @prop {"click" | "mouseenter" | "focus" | "focusin"} trigger - Defines one or more actions (space separated) which should cause
|
|
76
76
|
* the popover to show. If property `persistent` is set, `trigger` will by default be set to `click`.
|
|
77
|
-
* @prop {String}
|
|
77
|
+
* @prop {String} popupClass - Additional class names which will be added to the popup element.
|
|
78
78
|
* Use this to apply a specific style to certain popovers, but not others.
|
|
79
79
|
* @prop {String} remote - An optional URL to asynchronously load the popover's content from. Content will
|
|
80
80
|
* be loaded after the popover is displayed. The downloaded HTML content will replace the text set via the alternate slot.
|