Skip to content

Commit

Permalink
Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
majidsajadi committed Aug 31, 2024
1 parent 4421826 commit 0b9f7af
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 88 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tapsioss/web-components",
"version": "0.0.0-alpha-3",
"version": "0.0.0-alpha-4",
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
Expand Down
4 changes: 2 additions & 2 deletions src/bottom-sheet/bottom-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ export class BottomSheet extends LitElement {
}
}
};

private handleDismiss = (): void => {
this.disappear = true;

this.dispatchEvent(
new CustomEvent('close', {
bubbles: true,
Expand Down
2 changes: 1 addition & 1 deletion src/bottom-sheet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import styles from './bottom-sheet.style';
* @cssprop [--tap-bottom-sheet-header-padding=12px]
* @cssprop [--tap-bottom-sheet-background=--tap-sys-color-surface-primary]
* @cssprop [--tap-bottom-sheet-content-overflow-y=scroll]
*
*
* @fires close - Fires when the bottom sheet closes.
*/
@customElement('tap-bottom-sheet')
Expand Down
26 changes: 13 additions & 13 deletions src/radio-group/radio-group.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ interface ArgTypes {

const Template: Story<ArgTypes> = ({ value, direction }: ArgTypes) => html`
<tap-radio-group value="${value}" direction="${direction}">
<tap-row>
<div slot="leading"><tap-radio value="1"></tap-radio></div>
<div slot="content">
<span>Label for Option 1</span>
</div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="2"></tap-radio>
<span>Label for Option 2</span>
</div>
</tap-row>
<tap-row>
<div slot="leading"><tap-radio value="1"></tap-radio></div>
<div slot="content">
<span>Label for Option 1</span>
</div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="2"></tap-radio>
<span>Label for Option 2</span>
</div>
</tap-row>
<tap-radio value="3"></tap-radio>
<tap-radio value="4"></tap-radio>
</tap-radio-group>
Expand Down
140 changes: 72 additions & 68 deletions src/radio-group/radio-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,88 +5,92 @@ import { expect, fixture, html } from '@open-wc/testing';
import { RadioGroup } from './radio-group.js';

describe('tap-radio-group component', () => {
const value = '2';
it('should select the correct radio button based on the initial value', async () => {
const element = await fixture<RadioGroup>(html`
const value = '2';
it('should select the correct radio button based on the initial value', async () => {
const element = await fixture<RadioGroup>(html`
<tap-radio-group value=${value}>
<tap-radio value="1"></tap-radio>
<tap-radio value="2"></tap-radio>
<tap-radio value="3"></tap-radio>
</tap-radio-group>
`);

const radios = element.radios;
const radios = element.radios;

expect(radios.length).to.equal(3);
expect(radios.find(radio => radio.value === value)?.checked).to.be.true;
});
expect(radios.length).to.equal(3);
expect(radios.find((radio) => radio.value === value)?.checked).to.be.true;
});

it('should select a radio button when a nested element is passed', async () => {
const rootElement = await fixture<RadioGroup>(html`
<tap-radio-group value="2">
<div>
<tap-radio value="1"></tap-radio>
</div>
<div>
<tap-radio value="2"></tap-radio>
</div>
<div>
<tap-radio value="3"></tap-radio>
</div>
</tap-radio-group>
`);
it('should select a radio button when a nested element is passed', async () => {
const rootElement = await fixture<RadioGroup>(html`
<tap-radio-group value="2">
<div>
<tap-radio value="1"></tap-radio>
</div>
<div>
<tap-radio value="2"></tap-radio>
</div>
<div>
<tap-radio value="3"></tap-radio>
</div>
</tap-radio-group>
`);

const slot = rootElement.shadowRoot?.querySelector('slot');
const elements = slot!.assignedElements({ flatten: true });
const slot = rootElement.shadowRoot?.querySelector('slot');
const elements = slot!.assignedElements({ flatten: true });

// TODO: use the element.radios
const radios = elements.flatMap(element => {
if (element.nodeType === Node.ELEMENT_NODE) {
const el = element as HTMLElement;
const foundRadios = Array.from(el.querySelectorAll('tap-radio'));
return foundRadios;
}
return [];
});
expect(radios.length).to.equal(3);
expect(radios.find(radio => radio.value === value)?.value).to.equal(value);
// TODO: use the element.radios
const radios = elements.flatMap((element) => {
if (element.nodeType === Node.ELEMENT_NODE) {
const el = element as HTMLElement;
const foundRadios = Array.from(el.querySelectorAll('tap-radio'));
return foundRadios;
}
return [];
});
expect(radios.length).to.equal(3);
expect(radios.find((radio) => radio.value === value)?.value).to.equal(
value,
);
});

it('should handle radio buttons nested inside other elements', async () => {
const rootElement = await fixture<RadioGroup>(html`
<tap-radio-group value=${value}>
<tap-row>
<div slot="leading"><tap-radio value="1"></tap-radio></div>
<div slot="content"><span>Label 1</span></div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="2"></tap-radio>
<span>Label 2</span>
</div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="3"></tap-radio>
<span>Label 3</span>
</div>
</tap-row>
</tap-radio-group>
`);
it('should handle radio buttons nested inside other elements', async () => {
const rootElement = await fixture<RadioGroup>(html`
<tap-radio-group value=${value}>
<tap-row>
<div slot="leading"><tap-radio value="1"></tap-radio></div>
<div slot="content"><span>Label 1</span></div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="2"></tap-radio>
<span>Label 2</span>
</div>
</tap-row>
<tap-row>
<div slot="content">
<tap-radio value="3"></tap-radio>
<span>Label 3</span>
</div>
</tap-row>
</tap-radio-group>
`);

const slot = rootElement.shadowRoot?.querySelector('slot');
const elements = slot!.assignedElements({ flatten: true });
const slot = rootElement.shadowRoot?.querySelector('slot');
const elements = slot!.assignedElements({ flatten: true });

// TODO: use the element.radios
const radios = elements.flatMap(element => {
if (element.nodeType === Node.ELEMENT_NODE) {
const el = element as HTMLElement;
const foundRadios = Array.from(el.querySelectorAll('tap-radio'));
return foundRadios;
}
return [];
});
expect(radios.length).to.equal(3);
expect(radios.find(radio => radio.value === value)?.value).to.equal(value);
// TODO: use the element.radios
const radios = elements.flatMap((element) => {
if (element.nodeType === Node.ELEMENT_NODE) {
const el = element as HTMLElement;
const foundRadios = Array.from(el.querySelectorAll('tap-radio'));
return foundRadios;
}
return [];
});
expect(radios.length).to.equal(3);
expect(radios.find((radio) => radio.value === value)?.value).to.equal(
value,
);
});
});
2 changes: 1 addition & 1 deletion src/radio-group/radio-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class RadioGroup extends LitElement {
radios.push(node);
} else if (node instanceof HTMLElement) {
radios = radios.concat(
findRadios(Array.from(node.querySelectorAll('tap-radio')))
findRadios(Array.from(node.querySelectorAll('tap-radio'))),
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/toast/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class Toast extends LitElement {

@property({ type: Boolean, attribute: 'show-dismiss-button' })
showDismissButton? = false;

@property({ reflect: true })
variant?: 'success' | 'error' | 'info' | 'warning' | 'inverse' = 'inverse';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export function redispatchEvent(element: Element, event: Event) {
}

return dispatched;
}
}

0 comments on commit 0b9f7af

Please sign in to comment.