mithril-materialized 2.0.0-beta.6 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +10 -16
- package/dist/index.js +10 -16
- package/dist/index.umd.js +10 -16
- package/dist/tabs.d.ts +0 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4379,13 +4379,9 @@ const Switch = () => {
|
|
|
4379
4379
|
/** CSS-only Tabs component - no MaterializeCSS dependencies */
|
|
4380
4380
|
const Tabs = () => {
|
|
4381
4381
|
const toAnchored = () => {
|
|
4382
|
-
let activeTabFound = false;
|
|
4383
4382
|
return (tab) => {
|
|
4384
|
-
const active = activeTabFound ? false : tab.active;
|
|
4385
|
-
if (active)
|
|
4386
|
-
activeTabFound = true;
|
|
4387
4383
|
const tabId = createId(tab.title, tab.id);
|
|
4388
|
-
return Object.assign(Object.assign({}, tab), {
|
|
4384
|
+
return Object.assign(Object.assign({}, tab), { tabId, anchorId: `anchor-${tabId}` });
|
|
4389
4385
|
};
|
|
4390
4386
|
};
|
|
4391
4387
|
const state = {
|
|
@@ -4396,7 +4392,9 @@ const Tabs = () => {
|
|
|
4396
4392
|
indicatorStyle: {
|
|
4397
4393
|
left: '0px',
|
|
4398
4394
|
width: '0px',
|
|
4399
|
-
}
|
|
4395
|
+
},
|
|
4396
|
+
lastIndicatorUpdate: '',
|
|
4397
|
+
};
|
|
4400
4398
|
const createId = (title, id) => (id ? id : title.replace(/ /g, '').toLowerCase());
|
|
4401
4399
|
const updateIndicator = () => {
|
|
4402
4400
|
const tabElement = document.getElementById(state.activeTabId);
|
|
@@ -4418,6 +4416,7 @@ const Tabs = () => {
|
|
|
4418
4416
|
}
|
|
4419
4417
|
};
|
|
4420
4418
|
const handleTabClick = (tabId, tabElement, attrs) => {
|
|
4419
|
+
console.log({ state, tabId });
|
|
4421
4420
|
if (state.activeTabId === tabId)
|
|
4422
4421
|
return;
|
|
4423
4422
|
state.activeTabId = tabId;
|
|
@@ -4477,20 +4476,15 @@ const Tabs = () => {
|
|
|
4477
4476
|
const selectedTab = selectedTabId ? anchoredTabs.find((a) => a.tabId === selectedTabId) : undefined;
|
|
4478
4477
|
if (selectedTab) {
|
|
4479
4478
|
state.activeTabId = selectedTab.tabId;
|
|
4480
|
-
selectedTab.active = true;
|
|
4481
4479
|
return selectedTab;
|
|
4482
4480
|
}
|
|
4483
|
-
const
|
|
4484
|
-
if (
|
|
4485
|
-
|
|
4486
|
-
state.activeTabId = activeTab.tabId;
|
|
4487
|
-
return activeTab;
|
|
4488
|
-
}
|
|
4481
|
+
const curTab = state.activeTabId && anchoredTabs.find((a) => a.tabId === state.activeTabId);
|
|
4482
|
+
if (curTab)
|
|
4483
|
+
return curTab;
|
|
4489
4484
|
// Default to first non-disabled tab
|
|
4490
|
-
const firstAvailableTab = anchoredTabs.find((
|
|
4485
|
+
const firstAvailableTab = anchoredTabs.find((a) => !a.disabled && !a.href);
|
|
4491
4486
|
if (firstAvailableTab) {
|
|
4492
4487
|
state.activeTabId = firstAvailableTab.tabId;
|
|
4493
|
-
firstAvailableTab.active = true;
|
|
4494
4488
|
return firstAvailableTab;
|
|
4495
4489
|
}
|
|
4496
4490
|
return undefined;
|
|
@@ -4529,7 +4523,7 @@ const Tabs = () => {
|
|
|
4529
4523
|
disabled,
|
|
4530
4524
|
}, m('a', {
|
|
4531
4525
|
id: anchorId,
|
|
4532
|
-
className: tab.
|
|
4526
|
+
className: tab.tabId === state.activeTabId ? 'active' : undefined,
|
|
4533
4527
|
target,
|
|
4534
4528
|
href: href || `#${anchorId}`,
|
|
4535
4529
|
onclick: disabled || href
|
package/dist/index.js
CHANGED
|
@@ -4381,13 +4381,9 @@ const Switch = () => {
|
|
|
4381
4381
|
/** CSS-only Tabs component - no MaterializeCSS dependencies */
|
|
4382
4382
|
const Tabs = () => {
|
|
4383
4383
|
const toAnchored = () => {
|
|
4384
|
-
let activeTabFound = false;
|
|
4385
4384
|
return (tab) => {
|
|
4386
|
-
const active = activeTabFound ? false : tab.active;
|
|
4387
|
-
if (active)
|
|
4388
|
-
activeTabFound = true;
|
|
4389
4385
|
const tabId = createId(tab.title, tab.id);
|
|
4390
|
-
return Object.assign(Object.assign({}, tab), {
|
|
4386
|
+
return Object.assign(Object.assign({}, tab), { tabId, anchorId: `anchor-${tabId}` });
|
|
4391
4387
|
};
|
|
4392
4388
|
};
|
|
4393
4389
|
const state = {
|
|
@@ -4398,7 +4394,9 @@ const Tabs = () => {
|
|
|
4398
4394
|
indicatorStyle: {
|
|
4399
4395
|
left: '0px',
|
|
4400
4396
|
width: '0px',
|
|
4401
|
-
}
|
|
4397
|
+
},
|
|
4398
|
+
lastIndicatorUpdate: '',
|
|
4399
|
+
};
|
|
4402
4400
|
const createId = (title, id) => (id ? id : title.replace(/ /g, '').toLowerCase());
|
|
4403
4401
|
const updateIndicator = () => {
|
|
4404
4402
|
const tabElement = document.getElementById(state.activeTabId);
|
|
@@ -4420,6 +4418,7 @@ const Tabs = () => {
|
|
|
4420
4418
|
}
|
|
4421
4419
|
};
|
|
4422
4420
|
const handleTabClick = (tabId, tabElement, attrs) => {
|
|
4421
|
+
console.log({ state, tabId });
|
|
4423
4422
|
if (state.activeTabId === tabId)
|
|
4424
4423
|
return;
|
|
4425
4424
|
state.activeTabId = tabId;
|
|
@@ -4479,20 +4478,15 @@ const Tabs = () => {
|
|
|
4479
4478
|
const selectedTab = selectedTabId ? anchoredTabs.find((a) => a.tabId === selectedTabId) : undefined;
|
|
4480
4479
|
if (selectedTab) {
|
|
4481
4480
|
state.activeTabId = selectedTab.tabId;
|
|
4482
|
-
selectedTab.active = true;
|
|
4483
4481
|
return selectedTab;
|
|
4484
4482
|
}
|
|
4485
|
-
const
|
|
4486
|
-
if (
|
|
4487
|
-
|
|
4488
|
-
state.activeTabId = activeTab.tabId;
|
|
4489
|
-
return activeTab;
|
|
4490
|
-
}
|
|
4483
|
+
const curTab = state.activeTabId && anchoredTabs.find((a) => a.tabId === state.activeTabId);
|
|
4484
|
+
if (curTab)
|
|
4485
|
+
return curTab;
|
|
4491
4486
|
// Default to first non-disabled tab
|
|
4492
|
-
const firstAvailableTab = anchoredTabs.find((
|
|
4487
|
+
const firstAvailableTab = anchoredTabs.find((a) => !a.disabled && !a.href);
|
|
4493
4488
|
if (firstAvailableTab) {
|
|
4494
4489
|
state.activeTabId = firstAvailableTab.tabId;
|
|
4495
|
-
firstAvailableTab.active = true;
|
|
4496
4490
|
return firstAvailableTab;
|
|
4497
4491
|
}
|
|
4498
4492
|
return undefined;
|
|
@@ -4531,7 +4525,7 @@ const Tabs = () => {
|
|
|
4531
4525
|
disabled,
|
|
4532
4526
|
}, m('a', {
|
|
4533
4527
|
id: anchorId,
|
|
4534
|
-
className: tab.
|
|
4528
|
+
className: tab.tabId === state.activeTabId ? 'active' : undefined,
|
|
4535
4529
|
target,
|
|
4536
4530
|
href: href || `#${anchorId}`,
|
|
4537
4531
|
onclick: disabled || href
|
package/dist/index.umd.js
CHANGED
|
@@ -4383,13 +4383,9 @@
|
|
|
4383
4383
|
/** CSS-only Tabs component - no MaterializeCSS dependencies */
|
|
4384
4384
|
const Tabs = () => {
|
|
4385
4385
|
const toAnchored = () => {
|
|
4386
|
-
let activeTabFound = false;
|
|
4387
4386
|
return (tab) => {
|
|
4388
|
-
const active = activeTabFound ? false : tab.active;
|
|
4389
|
-
if (active)
|
|
4390
|
-
activeTabFound = true;
|
|
4391
4387
|
const tabId = createId(tab.title, tab.id);
|
|
4392
|
-
return Object.assign(Object.assign({}, tab), {
|
|
4388
|
+
return Object.assign(Object.assign({}, tab), { tabId, anchorId: `anchor-${tabId}` });
|
|
4393
4389
|
};
|
|
4394
4390
|
};
|
|
4395
4391
|
const state = {
|
|
@@ -4400,7 +4396,9 @@
|
|
|
4400
4396
|
indicatorStyle: {
|
|
4401
4397
|
left: '0px',
|
|
4402
4398
|
width: '0px',
|
|
4403
|
-
}
|
|
4399
|
+
},
|
|
4400
|
+
lastIndicatorUpdate: '',
|
|
4401
|
+
};
|
|
4404
4402
|
const createId = (title, id) => (id ? id : title.replace(/ /g, '').toLowerCase());
|
|
4405
4403
|
const updateIndicator = () => {
|
|
4406
4404
|
const tabElement = document.getElementById(state.activeTabId);
|
|
@@ -4422,6 +4420,7 @@
|
|
|
4422
4420
|
}
|
|
4423
4421
|
};
|
|
4424
4422
|
const handleTabClick = (tabId, tabElement, attrs) => {
|
|
4423
|
+
console.log({ state, tabId });
|
|
4425
4424
|
if (state.activeTabId === tabId)
|
|
4426
4425
|
return;
|
|
4427
4426
|
state.activeTabId = tabId;
|
|
@@ -4481,20 +4480,15 @@
|
|
|
4481
4480
|
const selectedTab = selectedTabId ? anchoredTabs.find((a) => a.tabId === selectedTabId) : undefined;
|
|
4482
4481
|
if (selectedTab) {
|
|
4483
4482
|
state.activeTabId = selectedTab.tabId;
|
|
4484
|
-
selectedTab.active = true;
|
|
4485
4483
|
return selectedTab;
|
|
4486
4484
|
}
|
|
4487
|
-
const
|
|
4488
|
-
if (
|
|
4489
|
-
|
|
4490
|
-
state.activeTabId = activeTab.tabId;
|
|
4491
|
-
return activeTab;
|
|
4492
|
-
}
|
|
4485
|
+
const curTab = state.activeTabId && anchoredTabs.find((a) => a.tabId === state.activeTabId);
|
|
4486
|
+
if (curTab)
|
|
4487
|
+
return curTab;
|
|
4493
4488
|
// Default to first non-disabled tab
|
|
4494
|
-
const firstAvailableTab = anchoredTabs.find((
|
|
4489
|
+
const firstAvailableTab = anchoredTabs.find((a) => !a.disabled && !a.href);
|
|
4495
4490
|
if (firstAvailableTab) {
|
|
4496
4491
|
state.activeTabId = firstAvailableTab.tabId;
|
|
4497
|
-
firstAvailableTab.active = true;
|
|
4498
4492
|
return firstAvailableTab;
|
|
4499
4493
|
}
|
|
4500
4494
|
return undefined;
|
|
@@ -4533,7 +4527,7 @@
|
|
|
4533
4527
|
disabled,
|
|
4534
4528
|
}, m('a', {
|
|
4535
4529
|
id: anchorId,
|
|
4536
|
-
className: tab.
|
|
4530
|
+
className: tab.tabId === state.activeTabId ? 'active' : undefined,
|
|
4537
4531
|
target,
|
|
4538
4532
|
href: href || `#${anchorId}`,
|
|
4539
4533
|
onclick: disabled || href
|
package/dist/tabs.d.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface TabItem {
|
|
|
14
14
|
vnode?: Vnode<any, any>;
|
|
15
15
|
/** ID of the tab element. Default the title in lowercase */
|
|
16
16
|
id?: string;
|
|
17
|
-
/** If the tab should be active */
|
|
18
|
-
active?: boolean;
|
|
19
17
|
/** If the tab should be disabled */
|
|
20
18
|
disabled?: boolean;
|
|
21
19
|
/** CSS class for the tab (li), default `.tab.col.s3` */
|