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