Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(select-item): export class and style props #1840

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions COMPONENT_INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -3208,12 +3208,14 @@ None.

### Props

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

### Slots

Expand Down
22 changes: 22 additions & 0 deletions docs/src/COMPONENT_API.json
Original file line number Diff line number Diff line change
Expand Up @@ -10452,6 +10452,28 @@
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "class",
"kind": "let",
"description": "Specify the class of the `option` element",
"type": "string",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
},
{
"name": "style",
"kind": "let",
"description": "Specify the style of the `option` element",
"type": "string",
"isFunction": false,
"isFunctionDeclaration": false,
"isRequired": false,
"constant": false,
"reactive": false
}
],
"moduleExports": [],
Expand Down
18 changes: 16 additions & 2 deletions src/Select/SelectItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
/** Set to `true` to disable the option */
export let disabled = false;

let className = undefined;

/**
* Specify the class of the `option` element
* @type {string}
*/
export { className as class };

/**
* Specify the style of the `option` element
* @type {string}
*/
export let style = undefined;

import { getContext, onMount } from "svelte";

const id = "ccs-" + Math.random().toString(36);
Expand All @@ -38,8 +52,8 @@
hidden="{hidden}"
selected="{selected}"
class:bx--select-option="{true}"
class="{$$restProps.class}"
style="{$$restProps.style}"
class="{className}"
style="{style}"
>
{text || value}
</option>
2 changes: 1 addition & 1 deletion tests/Select.test.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</script>

<Select labelText="Carbon theme" selected="g10">
<SelectItem value="white" text="White" />
<SelectItem value="white" text="White" class="" style="" />
<SelectItem value="g10" text="Gray 10" />
<SelectItem value="g90" text="Gray 90" />
<SelectItem value="g100" text="Gray 100" />
Expand Down
12 changes: 12 additions & 0 deletions types/Select/SelectItem.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ export interface SelectItemProps {
* @default false
*/
disabled?: boolean;

/**
* Specify the class of the `option` element
* @default undefined
*/
class?: string;

/**
* Specify the style of the `option` element
* @default undefined
*/
style?: string;
}

export default class SelectItem extends SvelteComponentTyped<
Expand Down