@app-studio/web 0.8.64 → 0.8.65
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/components/Tabs/Tabs/Tabs.props.d.ts +37 -7
- package/dist/components/Tabs/Tabs/Tabs.state.d.ts +9 -5
- package/dist/components/Tabs/Tabs/Tabs.view.d.ts +5 -2
- package/dist/components/Text/Text/Text.props.d.ts +1 -1
- package/dist/web.cjs.development.js +124 -67
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +124 -67
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +124 -67
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -7641,90 +7641,147 @@
|
|
|
7641
7641
|
Table.Container = TableContainer;
|
|
7642
7642
|
Table.Template = TableView;
|
|
7643
7643
|
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7644
|
+
/**
|
|
7645
|
+
* Custom hook to manage the state of the active tab.
|
|
7646
|
+
* @param propTabs - The array of tab objects provided as props.
|
|
7647
|
+
* @param initialTabValue - The optional title of the tab to be initially active.
|
|
7648
|
+
* @returns An object containing the current activeTab and a function to update it.
|
|
7649
|
+
*/
|
|
7650
|
+
var useTabsState = (propTabs, initialTabValue) => {
|
|
7651
|
+
// Find the initial tab based on initialTabValue, or default to the first tab.
|
|
7652
|
+
// Ensure propTabs is not empty before accessing index 0.
|
|
7653
|
+
var findInitialTab = () => {
|
|
7654
|
+
if (!propTabs || propTabs.length === 0) {
|
|
7655
|
+
return undefined; // No tabs, no initial active tab
|
|
7656
|
+
}
|
|
7657
|
+
if (initialTabValue !== undefined) {
|
|
7658
|
+
var foundTab = propTabs.find(tab => tab.title === initialTabValue);
|
|
7659
|
+
if (foundTab) {
|
|
7660
|
+
return foundTab;
|
|
7661
|
+
}
|
|
7662
|
+
// Warn if initialTabValue is provided but not found
|
|
7663
|
+
console.warn("Tabs: initialTabValue \"" + initialTabValue + "\" not found in tabs. Defaulting to the first tab.");
|
|
7664
|
+
}
|
|
7665
|
+
return propTabs[0]; // Default to the first tab
|
|
7666
|
+
};
|
|
7667
|
+
var [activeTab, setActiveTab] = React.useState(findInitialTab);
|
|
7668
|
+
// Effect to update the active tab if the initialTabValue prop changes
|
|
7669
|
+
// or if the tabs array changes and the current active tab is no longer valid.
|
|
7670
|
+
React.useEffect(() => {
|
|
7671
|
+
var newInitialTab = findInitialTab();
|
|
7672
|
+
// Update only if the calculated initial tab is different from the current active tab
|
|
7673
|
+
// or if the current active tab is no longer in the list (and there are tabs)
|
|
7674
|
+
var currentActiveTabStillValid = activeTab && propTabs.some(t => t.title === activeTab.title);
|
|
7675
|
+
if (newInitialTab && (!currentActiveTabStillValid || initialTabValue !== undefined && (activeTab == null ? void 0 : activeTab.title) !== initialTabValue)) {
|
|
7676
|
+
setActiveTab(newInitialTab);
|
|
7677
|
+
} else if (!newInitialTab && activeTab) {
|
|
7678
|
+
// Handle case where all tabs are removed
|
|
7679
|
+
setActiveTab(undefined);
|
|
7680
|
+
}
|
|
7681
|
+
}, [propTabs, initialTabValue]); // Rerun when tabs or initial title changes
|
|
7648
7682
|
return {
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
tabsState,
|
|
7652
|
-
setTabsState
|
|
7683
|
+
activeTab,
|
|
7684
|
+
setActiveTab
|
|
7653
7685
|
};
|
|
7654
7686
|
};
|
|
7655
7687
|
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7688
|
+
/**
|
|
7689
|
+
* The presentation component for Tabs. Renders the UI based on props.
|
|
7690
|
+
*/
|
|
7691
|
+
var TabsView = _ref => {
|
|
7692
|
+
var {
|
|
7693
|
+
tabs = [],
|
|
7694
|
+
// Default to empty array
|
|
7695
|
+
activeTab,
|
|
7696
|
+
handleTabClick,
|
|
7697
|
+
styles = {},
|
|
7698
|
+
// Default to empty object
|
|
7666
7699
|
renderTab,
|
|
7667
7700
|
renderContent
|
|
7668
|
-
} =
|
|
7669
|
-
//
|
|
7670
|
-
|
|
7671
|
-
//
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
//
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7701
|
+
} = _ref;
|
|
7702
|
+
// If there's no active tab (e.g., tabs array is empty), render nothing or a placeholder
|
|
7703
|
+
if (!activeTab) {
|
|
7704
|
+
// Optionally render a placeholder when no tabs are active/available
|
|
7705
|
+
// return <View {...styles.container}><Text>No tabs available.</Text></View>;
|
|
7706
|
+
return null; // Or simply render nothing
|
|
7707
|
+
}
|
|
7708
|
+
return (
|
|
7709
|
+
/*#__PURE__*/
|
|
7710
|
+
// Use Vertical layout for overall structure (tabs header above content)
|
|
7711
|
+
React__default.createElement(Vertical, Object.assign({
|
|
7712
|
+
width: "100%",
|
|
7713
|
+
height: '100%'
|
|
7714
|
+
}, styles.container), /*#__PURE__*/React__default.createElement(Horizontal, Object.assign({}, styles.headerTabs), tabs.map(tab => {
|
|
7715
|
+
// Determine if the current tab in the loop is the active one
|
|
7716
|
+
var isActive = tab.title === activeTab.title;
|
|
7717
|
+
// Prepare the onClick handler for this specific tab
|
|
7718
|
+
var onClick = () => handleTabClick(tab);
|
|
7719
|
+
// Use the custom renderTab function if provided
|
|
7720
|
+
if (renderTab) {
|
|
7721
|
+
return renderTab(tab, isActive, onClick);
|
|
7722
|
+
}
|
|
7723
|
+
// Default rendering for a tab button
|
|
7724
|
+
return /*#__PURE__*/React__default.createElement(Button, Object.assign({
|
|
7725
|
+
key: tab.title,
|
|
7726
|
+
onClick: onClick,
|
|
7727
|
+
borderBottomLeftRadius: 0,
|
|
7728
|
+
borderBottomRightRadius: 0
|
|
7729
|
+
}, styles.tab, isActive ? styles.activeTab : {}, {
|
|
7730
|
+
// Example: Set variant based on active state (can be overridden by styles)
|
|
7731
|
+
variant: isActive ? 'filled' : 'ghost',
|
|
7732
|
+
cursor: "pointer" // Ensure pointer cursor
|
|
7733
|
+
}), tab.icon, /*#__PURE__*/React__default.createElement(Text
|
|
7734
|
+
// Apply base title styles and merge activeText styles if this tab is active
|
|
7735
|
+
, Object.assign({}, styles.title, isActive ? styles.activeText : {}), tab.title));
|
|
7736
|
+
})), /*#__PURE__*/React__default.createElement(View, Object.assign({
|
|
7737
|
+
width: '100%',
|
|
7738
|
+
height: "100%"
|
|
7739
|
+
}, styles.content), renderContent ? renderContent(activeTab) :
|
|
7740
|
+
// Otherwise, render the content property from the active tab object
|
|
7741
|
+
activeTab.content))
|
|
7742
|
+
);
|
|
7706
7743
|
};
|
|
7707
7744
|
|
|
7745
|
+
/**
|
|
7746
|
+
* Tabs component allows users to navigate between different sections of content.
|
|
7747
|
+
* It manages the active tab state and renders the corresponding content.
|
|
7748
|
+
*/
|
|
7708
7749
|
var TabsComponent = _ref => {
|
|
7709
7750
|
var {
|
|
7710
7751
|
tabs,
|
|
7711
|
-
styles
|
|
7752
|
+
styles,
|
|
7753
|
+
initialTabValue,
|
|
7754
|
+
onTabChange,
|
|
7755
|
+
renderTab,
|
|
7756
|
+
renderContent
|
|
7712
7757
|
} = _ref;
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7758
|
+
// Use the custom hook to manage the active tab state
|
|
7759
|
+
var {
|
|
7760
|
+
activeTab,
|
|
7761
|
+
setActiveTab
|
|
7762
|
+
} = useTabsState(tabs, initialTabValue);
|
|
7763
|
+
// Handler function to change the active tab and trigger the callback
|
|
7764
|
+
var handleTabClick = tab => {
|
|
7765
|
+
// Only update state and call callback if the clicked tab is different from the current one
|
|
7766
|
+
if ((activeTab == null ? void 0 : activeTab.title) !== tab.title) {
|
|
7767
|
+
setActiveTab(tab);
|
|
7768
|
+
// Call the onTabChange callback if provided
|
|
7769
|
+
if (onTabChange) {
|
|
7770
|
+
onTabChange(tab);
|
|
7771
|
+
}
|
|
7772
|
+
}
|
|
7773
|
+
};
|
|
7774
|
+
// Render the presentation component with the necessary props
|
|
7719
7775
|
return /*#__PURE__*/React__default.createElement(TabsView, {
|
|
7720
7776
|
tabs: tabs,
|
|
7721
7777
|
styles: styles,
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7778
|
+
activeTab: activeTab,
|
|
7779
|
+
handleTabClick: handleTabClick,
|
|
7780
|
+
renderTab: renderTab,
|
|
7781
|
+
renderContent: renderContent
|
|
7726
7782
|
});
|
|
7727
7783
|
};
|
|
7784
|
+
// Export the component wrapped in React.memo for performance optimization
|
|
7728
7785
|
var Tabs = /*#__PURE__*/React__default.memo(TabsComponent);
|
|
7729
7786
|
|
|
7730
7787
|
// Declares the useToggleState function which takes defaultToggled parameter to initialize the toggle state.
|