= ({
(hasBubble && !isMobile && iconPosition === 'horizontal' && !accordion) ||
(hasBubble && isVertical && !accordion)
- const TagType = item.href === undefined || item.href === '' ? 'button' : 'a'
- const attrs =
- TagType === 'button'
- ? { type: 'button' }
- : {
- href: item.href,
- target: item.target,
- }
+ const isTabButton = item.href === undefined || item.href === ''
+ const TagType = isTabButton ? 'button' : 'a'
+
+ const attrs = isTabButton
+ ? {
+ 'type': 'button',
+ 'role': 'tab',
+ 'tabindex': item.active ? '0' : '-1',
+ 'aria-controls': item.tabPanelID,
+ 'aria-disabled': `${item.disabled}`,
+ 'aria-label': item.label,
+ }
+ : {
+ href: item.href,
+ target: item.target,
+ }
return (
= ({
data-value={item.value}
data-index={item.index}
data-testid="bal-tabs-item"
- aria-selected={item.active ? 'true' : 'false'}
- aria-disabled={`${item.disabled}`}
- aria-label={item.label}
- aria-controls={item.tabPanelID}
+ aria-selected={!isTabButton ? undefined : item.active ? 'true' : 'false'}
{...attrs}
onClick={(ev: MouseEvent) => onSelectTab(ev, item)}
>
@@ -137,5 +142,3 @@ export const TabButton: FunctionalComponent = ({
)
}
-
-let TabButtonIds = 0
diff --git a/packages/core/src/components/bal-tabs/components/tab-nav.tsx b/packages/core/src/components/bal-tabs/components/tab-nav.tsx
index c88dc39138..6f01aeee58 100644
--- a/packages/core/src/components/bal-tabs/components/tab-nav.tsx
+++ b/packages/core/src/components/bal-tabs/components/tab-nav.tsx
@@ -21,6 +21,7 @@ export interface TabNavProps {
animated: boolean
spaceless: boolean
expanded: boolean
+ isLinkList: boolean
verticalColSize: BalProps.BalTabsColSize
iconPosition: BalProps.BalTabsIconPosition
context?: BalProps.BalTabsContext
@@ -36,6 +37,7 @@ export const TabNav: FunctionalComponent
= ({
isMobile,
isTouch,
lineActive,
+ isLinkList,
border,
accordion,
isAccordionOpen,
@@ -76,7 +78,6 @@ export const TabNav: FunctionalComponent = ({
return (
= ({
class={{
...bemEl.element('carousel').class(),
}}
+ htmlRole={'tablist'}
fullHeight={isFullHeight}
border={border}
inverted={inverted}
@@ -105,6 +107,7 @@ export const TabNav: FunctionalComponent = ({
{tabs.map((tab, index) => (
- a11y
-
-
- Content of Tab A
- Content of Tab B
- Content of Tab C
- Content of Tab D
- Content of Tab linkBasic
+
+
+
+ Focus me
+ Content of Tab A
+
+ Focus me
+ Content of Tab B
+
+ Focus me
+ Content of Tab D
- Content of Tab A
Vertical
-
+
- Content of Tab A
- Content of Tab B
- Content of Tab C
- Content of Tab D
+
+ Focus me
+ Content of Tab A
+
+ Focus me
+ Content of Tab B
+
+ Focus me
+ Content of Tab C
+
+ Focus me
+ Content of Tab D
+
+
+
+ Links
+
+
+ Mixed
+
+
+
+ Focus me
+ Content of Tab A
+
+
+ Focus me
+ Content of Tab D
diff --git a/packages/core/src/utils/date/date.spec.ts b/packages/core/src/utils/date/date.spec.ts
index 6cb2a72d99..9fdc1d8d40 100644
--- a/packages/core/src/utils/date/date.spec.ts
+++ b/packages/core/src/utils/date/date.spec.ts
@@ -76,7 +76,6 @@ describe('balDate', () => {
const year = new Date().getFullYear()
const cutoff = year + 10
const cutoffTwoDigits = cutoff % 100
- console.log('cutoff', cutoff)
expect(BalDate.fromAnyFormat(`1.1.${cutoffTwoDigits}`).toISODate()).toStrictEqual(`20${cutoffTwoDigits}-01-01`)
expect(BalDate.fromAnyFormat(`1.1.${cutoffTwoDigits - 1}`).toISODate()).toStrictEqual(
`20${cutoffTwoDigits - 1}-01-01`,
diff --git a/packages/core/src/utils/string.spec.ts b/packages/core/src/utils/string.spec.ts
new file mode 100644
index 0000000000..9906d911fe
--- /dev/null
+++ b/packages/core/src/utils/string.spec.ts
@@ -0,0 +1,25 @@
+import { toKebabCase } from './string'
+
+describe('string', () => {
+ describe('toKebabCase', () => {
+ test('should format non string values correctly', () => {
+ expect(toKebabCase('')).toBe('')
+ expect(toKebabCase(undefined)).toBe('')
+ expect(toKebabCase(null)).toBe('')
+ expect(toKebabCase([])).toBe('')
+ expect(toKebabCase({})).toBe('')
+ expect(toKebabCase(7)).toBe('')
+ expect(toKebabCase(78)).toBe('')
+ expect(toKebabCase(true)).toBe('')
+ expect(toKebabCase(false)).toBe('')
+ })
+ test('should format string values correctly', () => {
+ expect(toKebabCase('HelloWorld')).toBe('hello-world')
+ expect(toKebabCase('Hello4World')).toBe('hello-4-world')
+ expect(toKebabCase('Hello44World')).toBe('hello-44-world')
+ expect(toKebabCase('4World')).toBe('4-world')
+ expect(toKebabCase('4World4')).toBe('4-world-4')
+ expect(toKebabCase('World')).toBe('world')
+ })
+ })
+})
diff --git a/packages/core/src/utils/string.ts b/packages/core/src/utils/string.ts
new file mode 100644
index 0000000000..7cd0a6036c
--- /dev/null
+++ b/packages/core/src/utils/string.ts
@@ -0,0 +1,10 @@
+export const toKebabCase = (string: unknown) => {
+ if (typeof string === 'string') {
+ return string
+ .replace(/([a-z])([0-9])/g, '$1-$2')
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
+ .replace(/[\s_]+/g, '-')
+ .toLowerCase()
+ }
+ return ''
+}