Skip to content

Commit a9460e9

Browse files
authored
fix(select-item): export class and style props (#1840)
Closes #1839
1 parent 8d5ef9c commit a9460e9

File tree

5 files changed

+59
-9
lines changed

5 files changed

+59
-9
lines changed

COMPONENT_INDEX.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,12 +3208,14 @@ None.
32083208

32093209
### Props
32103210

3211-
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
3212-
| :-------- | :------- | :--------------- | :------- | --------------------------------- | ------------------ | ----------------------------------- |
3213-
| value | No | <code>let</code> | No | <code>string &#124; number</code> | <code>""</code> | Specify the option value |
3214-
| text | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the option text |
3215-
| hidden | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the option |
3216-
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the option |
3211+
| Prop name | Required | Kind | Reactive | Type | Default value | Description |
3212+
| :-------- | :------- | :--------------- | :------- | --------------------------------- | ---------------------- | ----------------------------------------- |
3213+
| value | No | <code>let</code> | No | <code>string &#124; number</code> | <code>""</code> | Specify the option value |
3214+
| text | No | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the option text |
3215+
| hidden | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to hide the option |
3216+
| disabled | No | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to disable the option |
3217+
| class | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the class of the `option` element |
3218+
| style | No | <code>let</code> | No | <code>string</code> | <code>undefined</code> | Specify the style of the `option` element |
32173219

32183220
### Slots
32193221

docs/src/COMPONENT_API.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10452,6 +10452,28 @@
1045210452
"isRequired": false,
1045310453
"constant": false,
1045410454
"reactive": false
10455+
},
10456+
{
10457+
"name": "class",
10458+
"kind": "let",
10459+
"description": "Specify the class of the `option` element",
10460+
"type": "string",
10461+
"isFunction": false,
10462+
"isFunctionDeclaration": false,
10463+
"isRequired": false,
10464+
"constant": false,
10465+
"reactive": false
10466+
},
10467+
{
10468+
"name": "style",
10469+
"kind": "let",
10470+
"description": "Specify the style of the `option` element",
10471+
"type": "string",
10472+
"isFunction": false,
10473+
"isFunctionDeclaration": false,
10474+
"isRequired": false,
10475+
"constant": false,
10476+
"reactive": false
1045510477
}
1045610478
],
1045710479
"moduleExports": [],

src/Select/SelectItem.svelte

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
/** Set to `true` to disable the option */
1515
export let disabled = false;
1616
17+
let className = undefined;
18+
19+
/**
20+
* Specify the class of the `option` element
21+
* @type {string}
22+
*/
23+
export { className as class };
24+
25+
/**
26+
* Specify the style of the `option` element
27+
* @type {string}
28+
*/
29+
export let style = undefined;
30+
1731
import { getContext, onMount } from "svelte";
1832
1933
const id = "ccs-" + Math.random().toString(36);
@@ -38,8 +52,8 @@
3852
hidden="{hidden}"
3953
selected="{selected}"
4054
class:bx--select-option="{true}"
41-
class="{$$restProps.class}"
42-
style="{$$restProps.style}"
55+
class="{className}"
56+
style="{style}"
4357
>
4458
{text || value}
4559
</option>

tests/Select.test.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</script>
99

1010
<Select labelText="Carbon theme" selected="g10">
11-
<SelectItem value="white" text="White" />
11+
<SelectItem value="white" text="White" class="" style="" />
1212
<SelectItem value="g10" text="Gray 10" />
1313
<SelectItem value="g90" text="Gray 90" />
1414
<SelectItem value="g100" text="Gray 100" />

types/Select/SelectItem.svelte.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ export interface SelectItemProps {
2424
* @default false
2525
*/
2626
disabled?: boolean;
27+
28+
/**
29+
* Specify the class of the `option` element
30+
* @default undefined
31+
*/
32+
class?: string;
33+
34+
/**
35+
* Specify the style of the `option` element
36+
* @default undefined
37+
*/
38+
style?: string;
2739
}
2840

2941
export default class SelectItem extends SvelteComponentTyped<

0 commit comments

Comments
 (0)