feat(multi-select): add hideLabel prop

This commit is contained in:
metonym 2021-10-14 15:36:26 -07:00
commit b2812a1853
6 changed files with 31 additions and 2 deletions

View file

@ -2434,6 +2434,7 @@ export interface MultiSelectItem {
| warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text | | warnText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the warning state text |
| helperText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the helper text | | helperText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the helper text |
| label | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the list box label | | label | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the list box label |
| hideLabel | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to visually hide the label text |
| id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component | | id | <code>let</code> | No | <code>string</code> | <code>"ccs-" + Math.random().toString(36)</code> | Set an id for the list box component |
| name | <code>let</code> | No | <code>string</code> | -- | Specify a name attribute for the select | | name | <code>let</code> | No | <code>string</code> | -- | Specify a name attribute for the select |

View file

@ -6569,6 +6569,17 @@
"constant": false, "constant": false,
"reactive": false "reactive": false
}, },
{
"name": "hideLabel",
"kind": "let",
"description": "Set to `true` to visually hide the label text",
"type": "boolean",
"value": "false",
"isFunction": false,
"isFunctionDeclaration": false,
"constant": false,
"reactive": false
},
{ {
"name": "id", "name": "id",
"kind": "let", "kind": "let",

View file

@ -71,6 +71,14 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
{id: "2", text: "Fax"}]}" {id: "2", text: "Fax"}]}"
/> />
### Hidden label
<MultiSelect titleText="Contact" label="Select contact methods..." hideLabel
items="{[{id: "0", text: "Slack"},
{id: "1", text: "Email"},
{id: "2", text: "Fax"}]}"
/>
### Light variant ### Light variant
<MultiSelect light titleText="Contact" label="Select contact methods..." <MultiSelect light titleText="Contact" label="Select contact methods..."
@ -103,8 +111,6 @@ Set `direction` to `"top"` for the dropdown menu to appear above the input.
{id: "2", text: "Fax"}]}" {id: "2", text: "Fax"}]}"
/> />
### Invalid state ### Invalid state
<MultiSelect invalid invalidText="A contact method is required" titleText="Contact" label="Select contact methods..." <MultiSelect invalid invalidText="A contact method is required" titleText="Contact" label="Select contact methods..."

View file

@ -116,6 +116,9 @@
/** Specify the list box label */ /** Specify the list box label */
export let label = ""; export let label = "";
/** Set to `true` to visually hide the label text */
export let hideLabel = false;
/** Set an id for the list box component */ /** Set an id for the list box component */
export let id = "ccs-" + Math.random().toString(36); export let id = "ccs-" + Math.random().toString(36);
@ -259,6 +262,7 @@
for="{id}" for="{id}"
class:bx--label="{true}" class:bx--label="{true}"
class:bx--label--disabled="{disabled}" class:bx--label--disabled="{disabled}"
class:bx--visually-hidden="{hideLabel}"
> >
{titleText} {titleText}
</label> </label>

View file

@ -6,6 +6,7 @@
direction="top" direction="top"
titleText="Contact" titleText="Contact"
label="Select contact methods..." label="Select contact methods..."
hideLabel
items="{[ items="{[
{ id: '0', text: 'Slack' }, { id: '0', text: 'Slack' },
{ id: '1', text: 'Email' }, { id: '1', text: 'Email' },

View file

@ -164,6 +164,12 @@ export interface MultiSelectProps
*/ */
label?: string; label?: string;
/**
* Set to `true` to visually hide the label text
* @default false
*/
hideLabel?: boolean;
/** /**
* Set an id for the list box component * Set an id for the list box component
* @default "ccs-" + Math.random().toString(36) * @default "ccs-" + Math.random().toString(36)