diff --git a/HISTORY.md b/HISTORY.md index b3104acc..08f2efbf 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +# v4.8.0 + +- Added a new property to make the number of selected values used in the trigger label variable. +- The new property is `display-value-count` and its default value is `1`, which is the current default behaviour. + # v4.7.10 - Added read-only and disabled-viewable properties to px-dropdown. diff --git a/bower.json b/bower.json index a5017f4d..2ff665be 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "px-dropdown", - "version": "4.7.10", + "version": "4.8.0", "main": [ "px-dropdown.html" ], diff --git a/demo/simple_demo.html b/demo/simple_demo.html index aa67216b..a739fa96 100644 --- a/demo/simple_demo.html +++ b/demo/simple_demo.html @@ -14,7 +14,7 @@ limitations under the License. --> - + @@ -91,7 +91,9 @@ hoist read-only container-type="bar" - selected-values='["2","5"]' + display-value-count="3" + select-by="key" + selected-values='["1","2","3"]' items='[{"key":"1","val":"iPhone"},{"key":"2","val":"Android"},{"key":"3","val":"Blackberry"},{"key":"4","val":"Windows Windows Windows Windows Windows Windows Windows Phone"},{"key":"5","val":"Flip Phone","disabled":true}]' multi> @@ -135,16 +137,4 @@ - - diff --git a/package-lock.json b/package-lock.json index 69896219..5007ed02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "px-dropdown", - "version": "4.7.10", + "version": "4.7.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3408e102..0139524f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "px-dropdown", "author": "General Electric", "description": "A Predix UI Dropdown component", - "version": "4.7.10", + "version": "4.8.0", "extName": null, "repository": { "type": "git", diff --git a/px-dropdown-api.json b/px-dropdown-api.json index 2137259d..44145921 100644 --- a/px-dropdown-api.json +++ b/px-dropdown-api.json @@ -2337,15 +2337,15 @@ }, { "name": "_handleSelection", - "description": "Handles the selection event from iron-selector to update\nthe label displayed inside the dropdown.", + "description": "Handles the selection event from iron-selector to update\nthe label displayed inside the dropdown. Use the displayValueCount property to define how many values\nare displayed in the trigger value of multiple select lists", "privacy": "protected", "sourceRange": { "start": { - "line": 587, + "line": 588, "column": 4 }, "end": { - "line": 614, + "line": 617, "column": 5 } }, @@ -2362,11 +2362,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 619, + "line": 622, "column": 4 }, "end": { - "line": 645, + "line": 650, "column": 5 } }, @@ -2383,11 +2383,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 649, + "line": 654, "column": 4 }, "end": { - "line": 651, + "line": 656, "column": 5 } }, @@ -2400,11 +2400,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 656, + "line": 661, "column": 4 }, "end": { - "line": 666, + "line": 671, "column": 5 } }, @@ -2417,11 +2417,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 670, + "line": 675, "column": 4 }, "end": { - "line": 677, + "line": 682, "column": 5 } }, @@ -2447,11 +2447,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 681, + "line": 686, "column": 4 }, "end": { - "line": 686, + "line": 691, "column": 5 } }, @@ -2471,11 +2471,11 @@ "privacy": "private", "sourceRange": { "start": { - "line": 692, + "line": 697, "column": 4 }, "end": { - "line": 695, + "line": 700, "column": 5 } }, @@ -2488,11 +2488,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 700, + "line": 705, "column": 4 }, "end": { - "line": 724, + "line": 729, "column": 5 } }, @@ -2512,11 +2512,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 728, + "line": 733, "column": 4 }, "end": { - "line": 736, + "line": 741, "column": 5 } }, @@ -2529,11 +2529,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 740, + "line": 745, "column": 4 }, "end": { - "line": 746, + "line": 751, "column": 5 } }, @@ -2546,11 +2546,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 750, + "line": 755, "column": 4 }, "end": { - "line": 758, + "line": 763, "column": 5 } }, @@ -2570,11 +2570,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 762, + "line": 767, "column": 4 }, "end": { - "line": 847, + "line": 852, "column": 5 } }, @@ -2591,11 +2591,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 851, + "line": 856, "column": 4 }, "end": { - "line": 859, + "line": 864, "column": 5 } }, @@ -2612,11 +2612,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 863, + "line": 868, "column": 4 }, "end": { - "line": 865, + "line": 870, "column": 5 } }, @@ -2633,11 +2633,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 869, + "line": 874, "column": 4 }, "end": { - "line": 871, + "line": 876, "column": 5 } }, @@ -2663,11 +2663,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 875, + "line": 880, "column": 4 }, "end": { - "line": 877, + "line": 882, "column": 5 } }, @@ -2684,11 +2684,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 881, + "line": 886, "column": 4 }, "end": { - "line": 883, + "line": 888, "column": 5 } }, @@ -2711,11 +2711,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 884, + "line": 889, "column": 4 }, "end": { - "line": 886, + "line": 891, "column": 5 } }, @@ -2735,11 +2735,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 887, + "line": 892, "column": 4 }, "end": { - "line": 889, + "line": 894, "column": 5 } }, @@ -2759,11 +2759,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 890, + "line": 895, "column": 4 }, "end": { - "line": 892, + "line": 897, "column": 5 } }, @@ -2783,11 +2783,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 893, + "line": 898, "column": 4 }, "end": { - "line": 895, + "line": 900, "column": 5 } }, @@ -2811,7 +2811,7 @@ "column": 10 }, "end": { - "line": 896, + "line": 901, "column": 3 } }, @@ -3597,11 +3597,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 193, + "line": 194, "column": 6 }, "end": { - "line": 197, + "line": 198, "column": 7 } }, @@ -3619,11 +3619,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 201, + "line": 202, "column": 6 }, "end": { - "line": 204, + "line": 205, "column": 7 } }, @@ -3639,11 +3639,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 209, + "line": 210, "column": 6 }, "end": { - "line": 211, + "line": 212, "column": 7 } }, @@ -3658,11 +3658,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 216, + "line": 217, "column": 6 }, "end": { - "line": 219, + "line": 220, "column": 7 } }, @@ -3678,11 +3678,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 225, + "line": 226, "column": 6 }, "end": { - "line": 230, + "line": 231, "column": 7 } }, @@ -3694,6 +3694,28 @@ }, "defaultValue": "\"Select\"" }, + { + "name": "displayValueCount", + "type": "number", + "description": "The number of values to display as a comma separated string on multi select lists. \nSelections greater then this number will display as \"N Selected\"", + "privacy": "public", + "sourceRange": { + "start": { + "line": 236, + "column": 6 + }, + "end": { + "line": 240, + "column": 7 + } + }, + "metadata": { + "polymer": { + "observer": "\"_resetMinWidth\"" + } + }, + "defaultValue": "1" + }, { "name": "disableClear", "type": "boolean", @@ -3701,11 +3723,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 239, + "line": 249, "column": 6 }, "end": { - "line": 242, + "line": 252, "column": 7 } }, @@ -3721,11 +3743,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 246, + "line": 256, "column": 6 }, "end": { - "line": 249, + "line": 259, "column": 7 } }, @@ -3741,11 +3763,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 255, + "line": 265, "column": 6 }, "end": { - "line": 258, + "line": 268, "column": 7 } }, @@ -3761,11 +3783,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 264, + "line": 274, "column": 6 }, "end": { - "line": 267, + "line": 277, "column": 7 } }, @@ -3781,11 +3803,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 272, + "line": 282, "column": 6 }, "end": { - "line": 274, + "line": 284, "column": 7 } }, @@ -3800,11 +3822,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 289, + "line": 299, "column": 6 }, "end": { - "line": 295, + "line": 305, "column": 7 } }, @@ -3822,11 +3844,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 301, + "line": 311, "column": 6 }, "end": { - "line": 304, + "line": 314, "column": 7 } }, @@ -3842,11 +3864,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 309, + "line": 319, "column": 6 }, "end": { - "line": 312, + "line": 322, "column": 7 } }, @@ -3862,11 +3884,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 317, + "line": 327, "column": 6 }, "end": { - "line": 321, + "line": 331, "column": 7 } }, @@ -3884,11 +3906,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 326, + "line": 336, "column": 6 }, "end": { - "line": 329, + "line": 339, "column": 7 } }, @@ -3905,11 +3927,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 333, + "line": 343, "column": 6 }, "end": { - "line": 339, + "line": 349, "column": 7 } }, @@ -3927,11 +3949,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 345, + "line": 355, "column": 6 }, "end": { - "line": 348, + "line": 358, "column": 7 } }, @@ -3947,11 +3969,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 353, + "line": 363, "column": 6 }, "end": { - "line": 356, + "line": 366, "column": 7 } }, @@ -3967,11 +3989,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 360, + "line": 370, "column": 6 }, "end": { - "line": 363, + "line": 373, "column": 7 } }, @@ -3987,11 +4009,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 367, + "line": 377, "column": 6 }, "end": { - "line": 370, + "line": 380, "column": 7 } }, @@ -4007,11 +4029,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 375, + "line": 385, "column": 6 }, "end": { - "line": 378, + "line": 388, "column": 7 } }, @@ -4027,11 +4049,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 383, + "line": 393, "column": 6 }, "end": { - "line": 386, + "line": 396, "column": 7 } }, @@ -4047,11 +4069,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 392, + "line": 402, "column": 6 }, "end": { - "line": 394, + "line": 404, "column": 7 } }, @@ -4066,11 +4088,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 400, + "line": 410, "column": 6 }, "end": { - "line": 403, + "line": 413, "column": 7 } }, @@ -4086,11 +4108,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 411, + "line": 421, "column": 6 }, "end": { - "line": 414, + "line": 424, "column": 7 } }, @@ -4106,11 +4128,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 419, + "line": 429, "column": 6 }, "end": { - "line": 422, + "line": 432, "column": 7 } }, @@ -4126,11 +4148,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 427, + "line": 437, "column": 6 }, "end": { - "line": 430, + "line": 440, "column": 7 } }, @@ -4146,11 +4168,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 436, + "line": 446, "column": 6 }, "end": { - "line": 439, + "line": 449, "column": 7 } }, @@ -4166,11 +4188,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 445, + "line": 455, "column": 6 }, "end": { - "line": 448, + "line": 458, "column": 7 } }, @@ -4186,11 +4208,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 455, + "line": 465, "column": 6 }, "end": { - "line": 458, + "line": 468, "column": 7 } }, @@ -4206,11 +4228,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 465, + "line": 475, "column": 6 }, "end": { - "line": 468, + "line": 478, "column": 7 } }, @@ -4226,11 +4248,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 473, + "line": 483, "column": 6 }, "end": { - "line": 476, + "line": 486, "column": 7 } }, @@ -4245,11 +4267,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 480, + "line": 490, "column": 6 }, "end": { - "line": 483, + "line": 493, "column": 7 } }, @@ -4265,11 +4287,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 488, + "line": 498, "column": 6 }, "end": { - "line": 491, + "line": 501, "column": 7 } }, @@ -4285,11 +4307,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 499, + "line": 509, "column": 6 }, "end": { - "line": 502, + "line": 512, "column": 7 } }, @@ -4305,11 +4327,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 503, + "line": 513, "column": 6 }, "end": { - "line": 506, + "line": 516, "column": 7 } }, @@ -4325,11 +4347,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 511, + "line": 521, "column": 6 }, "end": { - "line": 522, + "line": 532, "column": 7 } }, @@ -4345,11 +4367,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 526, + "line": 536, "column": 6 }, "end": { - "line": 531, + "line": 541, "column": 7 } }, @@ -4364,11 +4386,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 536, + "line": 546, "column": 6 }, "end": { - "line": 538, + "line": 548, "column": 7 } }, @@ -4383,11 +4405,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 543, + "line": 553, "column": 6 }, "end": { - "line": 546, + "line": 556, "column": 7 } }, @@ -4403,11 +4425,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 550, + "line": 560, "column": 6 }, "end": { - "line": 553, + "line": 563, "column": 7 } }, @@ -4424,11 +4446,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 555, + "line": 565, "column": 4 }, "end": { - "line": 567, + "line": 577, "column": 5 } }, @@ -4441,11 +4463,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 568, + "line": 578, "column": 4 }, "end": { - "line": 576, + "line": 586, "column": 5 } }, @@ -4458,11 +4480,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 577, + "line": 587, "column": 4 }, "end": { - "line": 579, + "line": 589, "column": 5 } }, @@ -4718,11 +4740,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 580, + "line": 590, "column": 4 }, "end": { - "line": 582, + "line": 592, "column": 5 } }, @@ -4735,11 +4757,11 @@ "privacy": "public", "sourceRange": { "start": { - "line": 587, + "line": 597, "column": 4 }, "end": { - "line": 592, + "line": 602, "column": 5 } }, @@ -4752,11 +4774,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 601, + "line": 611, "column": 4 }, "end": { - "line": 616, + "line": 626, "column": 5 } }, @@ -4773,11 +4795,11 @@ "privacy": "protected", "sourceRange": { "start": { - "line": 620, + "line": 630, "column": 4 }, "end": { - "line": 626, + "line": 636, "column": 5 } }, @@ -4795,11 +4817,11 @@ "metadata": {}, "sourceRange": { "start": { - "line": 180, + "line": 181, "column": 10 }, "end": { - "line": 639, + "line": 649, "column": 3 } }, @@ -4829,11 +4851,11 @@ "description": "A flag which reflects if the dropdown trigger has been clicked or not.", "sourceRange": { "start": { - "line": 193, + "line": 194, "column": 6 }, "end": { - "line": 197, + "line": 198, "column": 7 } }, @@ -4845,11 +4867,11 @@ "description": "Whether or not to hide the chevron icon from the dropdown.", "sourceRange": { "start": { - "line": 201, + "line": 202, "column": 6 }, "end": { - "line": 204, + "line": 205, "column": 7 } }, @@ -4861,11 +4883,11 @@ "description": "A CSS selector which specifies the bounding target the dropdown will be\ndisplayed within. Defaults to `window`.", "sourceRange": { "start": { - "line": 209, + "line": 210, "column": 6 }, "end": { - "line": 211, + "line": 212, "column": 7 } }, @@ -4877,11 +4899,11 @@ "description": "Whether the dropdown will close when a user clicks\noutside of it. Set to true to prevent dropdown from closing.", "sourceRange": { "start": { - "line": 216, + "line": 217, "column": 6 }, "end": { - "line": 219, + "line": 220, "column": 7 } }, @@ -4893,27 +4915,43 @@ "description": "The placeholder text to display in the dropdown. If the\nselected value(s) are cleared out, the displayValue will be\nreplaced in the dropdown.", "sourceRange": { "start": { - "line": 225, + "line": 226, "column": 6 }, "end": { - "line": 230, + "line": 231, "column": 7 } }, "metadata": {}, "type": "string" }, + { + "name": "display-value-count", + "description": "The number of values to display as a comma separated string on multi select lists. \nSelections greater then this number will display as \"N Selected\"", + "sourceRange": { + "start": { + "line": 236, + "column": 6 + }, + "end": { + "line": 240, + "column": 7 + } + }, + "metadata": {}, + "type": "number" + }, { "name": "disable-clear", "description": "If set to true, users are unable to clear out the dropdown\nonce a selection has been made. Useful for required single-select\ndropdowns where an empty state would be undesirable. Not recommended\nfor multi-select dropdowns, as it means the user will simply lose the ability\nto quickly deselect all checked options (there is currently no mechanism\nwhich requires a user to select at least one option).", "sourceRange": { "start": { - "line": 239, + "line": 249, "column": 6 }, "end": { - "line": 242, + "line": 252, "column": 7 } }, @@ -4925,11 +4963,11 @@ "description": "If set to true, users can still open the dropdown but can not click on items", "sourceRange": { "start": { - "line": 246, + "line": 256, "column": 6 }, "end": { - "line": 249, + "line": 259, "column": 7 } }, @@ -4941,11 +4979,11 @@ "description": "If set to true, users can still open the dropdown and click on items,\nbut they will not be selected. Use this property in use cases where\nthe dropdown is used as a menu instead of a form input.", "sourceRange": { "start": { - "line": 255, + "line": 265, "column": 6 }, "end": { - "line": 258, + "line": 268, "column": 7 } }, @@ -4957,11 +4995,11 @@ "description": "By default, dropdown items longer than the max-width of the dropdown\nwill be truncated, with the full string available on hover tooltip.\nIf this property is set, items will not be truncated, but will wrap instead.", "sourceRange": { "start": { - "line": 264, + "line": 274, "column": 6 }, "end": { - "line": 267, + "line": 277, "column": 7 } }, @@ -4973,11 +5011,11 @@ "description": "An array that contains the list of items which show up in the dropdown.\nEach item can either be a simple string, or an object consisting of:\n* 'key' - a unique identifier (number or string)\n* 'val' - the actual text that is displayed\n* 'disabled' - whether the item should be disabled completely - can't be selected nor used as a menu option (optional)\n* 'disableSelect` - whether the item should be disabled for selection, but can still be used as a menu option (optional)\n* 'selected' - whether the item should be selected at instantiation (optional)\n* 'icon' - an icon name from the px-icon-set to display next to the item (optional)\n* 'color' - the color to use for the icon - if not specified, the default text colors will be used (optional)\n\nNote: if you specify more than one item as `selected`, but `multi` is not enabled,\nonly the *first* selected item will be chosen. See also `clearSelectionsOnChange`.", "sourceRange": { "start": { - "line": 289, + "line": 299, "column": 6 }, "end": { - "line": 295, + "line": 305, "column": 7 } }, @@ -4989,11 +5027,11 @@ "description": "If set to true, multiple values can be selected in the dropdown.\nSelected values are reflected in the `selectedValues` property.\nIf set to false, a single selected value is reflected in `selected`.", "sourceRange": { "start": { - "line": 301, + "line": 311, "column": 6 }, "end": { - "line": 304, + "line": 314, "column": 7 } }, @@ -5005,11 +5043,11 @@ "description": "Which property of each dropdown item will be used to get/set\nthe selected items - should be one of \"key\" or \"val\".", "sourceRange": { "start": { - "line": 309, + "line": 319, "column": 6 }, "end": { - "line": 312, + "line": 322, "column": 7 } }, @@ -5021,11 +5059,11 @@ "description": "Gets or sets the selected item when `multi` is false.\nWill either be a single key or value based on `selectBy`.", "sourceRange": { "start": { - "line": 317, + "line": 327, "column": 6 }, "end": { - "line": 321, + "line": 331, "column": 7 } }, @@ -5037,11 +5075,11 @@ "description": "Gets or sets the selected items when `multi` is true.\nWill either be an array of keys or values based on `selectBy`.", "sourceRange": { "start": { - "line": 326, + "line": 336, "column": 6 }, "end": { - "line": 329, + "line": 339, "column": 7 } }, @@ -5053,11 +5091,11 @@ "description": "A read-only array of the selected `
` elements in the dropdown.", "sourceRange": { "start": { - "line": 333, + "line": 343, "column": 6 }, "end": { - "line": 339, + "line": 349, "column": 7 } }, @@ -5069,11 +5107,11 @@ "description": "By default, the dropdown will constrain scrolling on the page to\nitself when opened. Set to true in order to allow scrolling of\nthe page while the dropdown is open.", "sourceRange": { "start": { - "line": 345, + "line": 355, "column": 6 }, "end": { - "line": 348, + "line": 358, "column": 7 } }, @@ -5085,11 +5123,11 @@ "description": "Style for the button that invokes the dropdown.\nOne of 'default','bare','bare--primary', 'tertiary', or 'icon'.", "sourceRange": { "start": { - "line": 353, + "line": 363, "column": 6 }, "end": { - "line": 356, + "line": 366, "column": 7 } }, @@ -5101,11 +5139,11 @@ "description": "Whether the dropdown should be disabled and non-interactive.", "sourceRange": { "start": { - "line": 360, + "line": 370, "column": 6 }, "end": { - "line": 363, + "line": 373, "column": 7 } }, @@ -5117,11 +5155,11 @@ "description": "Whether the dropdown should be disabled and interactive.", "sourceRange": { "start": { - "line": 367, + "line": 377, "column": 6 }, "end": { - "line": 370, + "line": 380, "column": 7 } }, @@ -5133,11 +5171,11 @@ "description": "If true, the dropdown will include a search box, whereby the\ndropdown items can be filtered with a search term.", "sourceRange": { "start": { - "line": 375, + "line": 385, "column": 6 }, "end": { - "line": 378, + "line": 388, "column": 7 } }, @@ -5149,11 +5187,11 @@ "description": "The value of the search box, used for filtering the dropdown\nitems when searchMode is true.", "sourceRange": { "start": { - "line": 383, + "line": 393, "column": 6 }, "end": { - "line": 386, + "line": 396, "column": 7 } }, @@ -5165,11 +5203,11 @@ "description": "What to sort the dropdown items by - one of \"key\" or \"val\".\nBy default, the items will be displayed in the order they are\npassed into the component.", "sourceRange": { "start": { - "line": 392, + "line": 402, "column": 6 }, "end": { - "line": 394, + "line": 404, "column": 7 } }, @@ -5181,11 +5219,11 @@ "description": "If set to true, the display-value will always show up in the\ninvoking button of the dropdown. Useful in cases like the\npx-data-table, where \"Show/Hide Columns\" should always appear.", "sourceRange": { "start": { - "line": 400, + "line": 410, "column": 6 }, "end": { - "line": 403, + "line": 413, "column": 7 } }, @@ -5197,11 +5235,11 @@ "description": "If buttonStyle is set to 'icon' this property will dictate\nwhich icon will be displayed inside of the dropdown button.\nThe `displayValue`, selected values, and chevron will not be displayed.\nPerfect for icon-invoked menus. The value of this property should\nbe a valid px-icon name, e.g. 'px-utl:app-settings'", "sourceRange": { "start": { - "line": 411, + "line": 421, "column": 6 }, "end": { - "line": 414, + "line": 424, "column": 7 } }, @@ -5213,11 +5251,11 @@ "description": "Set this property if you would like the `selected` and `selectedValues`\nproperties to be cleared whenever mutations are made to the `items` array.", "sourceRange": { "start": { - "line": 419, + "line": 429, "column": 6 }, "end": { - "line": 422, + "line": 432, "column": 7 } }, @@ -5229,11 +5267,11 @@ "description": "The height of the trigger element, used for calculating offset distance\nfor the dropdown. Set this value if you use the `trigger` slot.", "sourceRange": { "start": { - "line": 427, + "line": 437, "column": 6 }, "end": { - "line": 430, + "line": 440, "column": 7 } }, @@ -5245,11 +5283,11 @@ "description": "By default, the dropdown menu will be flush against the trigger.\nEnable this property to show a caret between the two. Useful\nin iconic menus and used by the application/product switcher.", "sourceRange": { "start": { - "line": 436, + "line": 446, "column": 6 }, "end": { - "line": 439, + "line": 449, "column": 7 } }, @@ -5261,11 +5299,11 @@ "description": "By default the dropdown will attempt to automatically align itself\nvertically and horizontally based on the available space. Set this flag\nto turn off that automatic behavior and force a certain `verticalAlign` / `horizontalAlign`.", "sourceRange": { "start": { - "line": 445, + "line": 455, "column": 6 }, "end": { - "line": 448, + "line": 458, "column": 7 } }, @@ -5277,11 +5315,11 @@ "description": "Vertical alignment of the dropdown relative to the trigger.\nShould be one of `top` or `bottom` where `top` means that the dropdown\nand trigger are aligned at the top, so the dropdown will extend _below_ the trigger.\nOverridden by dynamic alignment, unless `disableDynamicAlign` is true.", "sourceRange": { "start": { - "line": 455, + "line": 465, "column": 6 }, "end": { - "line": 458, + "line": 468, "column": 7 } }, @@ -5293,11 +5331,11 @@ "description": "Horizontal alignment of the dropdown relative to the trigger.\nShould be one of `left` or `right` where `left` means that the dropdown\nand trigger are aligned on their left side, so the dropdown will extend _to the right_.\nOverridden by dynamic alignment, unless `disableDynamicAlign` is true.", "sourceRange": { "start": { - "line": 465, + "line": 475, "column": 6 }, "end": { - "line": 468, + "line": 478, "column": 7 } }, @@ -5309,11 +5347,11 @@ "description": "Whether to display the mobile version of the dropdown, which appears as a fullscreen modal.\nAutomatically detected based on the breakpoint specified in `mobileAt`.", "sourceRange": { "start": { - "line": 473, + "line": 483, "column": 6 }, "end": { - "line": 476, + "line": 486, "column": 7 } }, @@ -5325,11 +5363,11 @@ "description": "The breakpoint (in # of pixels) at which to display the mobile version of px-dropdown.", "sourceRange": { "start": { - "line": 480, + "line": 490, "column": 6 }, "end": { - "line": 483, + "line": 493, "column": 7 } }, @@ -5341,11 +5379,11 @@ "description": "By default, the mobile dropdown will show Apply/Clear buttons.\nSet this property to hide them.", "sourceRange": { "start": { - "line": 488, + "line": 498, "column": 6 }, "end": { - "line": 491, + "line": 501, "column": 7 } }, @@ -5357,11 +5395,11 @@ "description": "A valid IETF language tag as a string that `app-localize-behavior` will\nuse to localize this component.\n\nSee https://github.com/PolymerElements/app-localize-behavior for API\ndocumentation and more information.", "sourceRange": { "start": { - "line": 499, + "line": 509, "column": 6 }, "end": { - "line": 502, + "line": 512, "column": 7 } }, @@ -5373,11 +5411,11 @@ "description": "", "sourceRange": { "start": { - "line": 503, + "line": 513, "column": 6 }, "end": { - "line": 506, + "line": 516, "column": 7 } }, @@ -5389,11 +5427,11 @@ "description": "A dictionary of strings used within the component for AppLocalizeBehavior\nto use, based on the selected `language` property.", "sourceRange": { "start": { - "line": 511, + "line": 521, "column": 6 }, "end": { - "line": 522, + "line": 532, "column": 7 } }, @@ -5405,11 +5443,11 @@ "description": "Specifies if the dropdown content should get hoisted to a container in order to escape its current stacking context", "sourceRange": { "start": { - "line": 550, + "line": 560, "column": 6 }, "end": { - "line": 553, + "line": 563, "column": 7 } }, diff --git a/px-dropdown-content.html b/px-dropdown-content.html index 78ec90de..397b9a57 100644 --- a/px-dropdown-content.html +++ b/px-dropdown-content.html @@ -583,13 +583,16 @@ }, /** * Handles the selection event from iron-selector to update - * the label displayed inside the dropdown. + * the label displayed inside the dropdown. Use the displayValueCount property to define how many values + * are displayed in the trigger value of multiple select lists */ _handleSelection: function(evt) { - if(this.multi && this.selectedValues.length === 1 && !this.hideSelected) { - this.displayValueSelected = this.$.selector.selectedItems[0].innerText.trim(); + if(this.multi && this.$.selector.selectedItems.length > 0 && this.selectedValues.length <= this.displayValueCount && !this.hideSelected) { + this.displayValueSelected = this.$.selector.selectedItems.map(function(item) { + return item.val.trim(); + }).join(', '); } - else if(this.multi && this.selectedValues.length > 1 && !this.hideSelected) { + else if(this.multi && this.selectedValues.length > this.displayValueCount && !this.hideSelected) { this.displayValueSelected = this.selectedValues.length + ' ' + this.localize('selected'); } else if(!this.hideSelected) { @@ -618,10 +621,12 @@ * the label displayed inside the dropdown. */ _handleDeselection: function(evt) { - if(this.multi && this.$.selector.selectedItems.length === 1 && !this.hideSelected) { - this.displayValueSelected = this.$.selector.selectedItems[0].innerText.trim(); + if(this.multi && this.$.selector.selectedItems.length > 0 && this.$.selector.selectedItems.length <= this.displayValueCount && !this.hideSelected) { + this.displayValueSelected = this.$.selector.selectedItems.map(function(item) { + return item.val.trim(); + }).join(', '); } - else if(this.multi && this.selectedValues.length > 1 && !this.hideSelected) { + else if(this.multi && this.selectedValues.length > this.displayValueCount && !this.hideSelected) { this.displayValueSelected = this.selectedValues.length + ' ' + this.localize('selected'); } else { diff --git a/px-dropdown.html b/px-dropdown.html index ccfed118..58d9527e 100644 --- a/px-dropdown.html +++ b/px-dropdown.html @@ -145,6 +145,7 @@ opened="{{opened}}" key-bindings-target="[[_keyBindingsTarget]]" display-value="[[displayValue]]" + display-value-count="[[displayValueCount]]" language="[[language]]" resources="[[resources]]" use-key-if-missing="[[useKeyIfMissing]]" @@ -229,6 +230,15 @@ value: 'Select', observer: '_resetMinWidth' }, + /** + * The number of values to display as a comma separated string on multi select lists. + * Selections greater then this number will display as "N Selected" + */ + displayValueCount: { + type: Number, + value: 1, + observer: '_resetMinWidth' + }, /** * If set to true, users are unable to clear out the dropdown * once a selection has been made. Useful for required single-select diff --git a/test/px-dropdown-custom-tests.js b/test/px-dropdown-custom-tests.js index 9ef71a11..e7fbcfa3 100644 --- a/test/px-dropdown-custom-tests.js +++ b/test/px-dropdown-custom-tests.js @@ -50,7 +50,8 @@ describe("Custom Automation Tests for px-dropdown", function(done) { "A very long value to test that the trigger and content widths can be constrained" ); const triggerSize = px_dropdown_button.getBoundingClientRect(); - expect(triggerSize.width == 400).to.be.true; + + expect(Math.floor(triggerSize.width) == 400).to.be.true; done(); }); }; @@ -314,7 +315,54 @@ describe("Custom Automation Tests for sort feature px-dropdown", function(done) }); }); -describe("Custom Automation Tests for px-dropdown", function(done) { +describe("Custom Automation Tests for multiple display values feature px-dropdown", function(done) { + let px_dropdown; + let px_dropdown_button; + let dropdown_option; + + beforeEach(function(done) { + px_dropdown = fixture("dropdown-multi-select-values-fixture"); + flush(() => { + px_dropdown_button = px_dropdown.$.trigger.$.trigger; + done(); + }); + }); + + it("Trigger label is 'One, Two, Three' as section count is <= display-value-count", function(done) { + assert.equal( + px_dropdown._displayValueSelected, + "One, Two, Three", + "expected trigger value to be 'One, Two, Three'" + ); + done(); + }); + + it("Trigger label is '4 selected' as section count is > display-value-count", function(done) { + px_dropdown_content = px_dropdown.$.content.$.dropdown; + px_dropdown_button = px_dropdown.$.trigger.$.trigger; + dropdown_option = Polymer.dom(px_dropdown.$.content.root).querySelectorAll( + ".dropdown-option" + )[3]; + + var item_click = function(e) { + assert.equal( + px_dropdown._displayValueSelected, + "4 selected", + "expected trigger value to be '4 selected'" + ); + done(); + }; + px_dropdown_button.click(); + px_dropdown.addEventListener("px-dropdown-selection-changed", item_click); + dropdown_option.click(); + px_dropdown.removeEventListener( + "px-dropdown-selection-changed", + item_click + ); + }); +}); + +describe("Close with esc key tests for px-dropdown", function(done) { let px_dropdown; let px_dropdown_content; let px_dropdown_button; diff --git a/test/px-dropdown-test-fixture.html b/test/px-dropdown-test-fixture.html index a2f9dce9..055814da 100644 --- a/test/px-dropdown-test-fixture.html +++ b/test/px-dropdown-test-fixture.html @@ -51,10 +51,10 @@ - + @@ -64,6 +64,13 @@ + + + +