@codella-software/react 2.0.1 → 2.1.0

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useState, useEffect, useMemo, createContext, useContext, useCallback } from "react";
2
2
  import { TableBuilder } from "@codella/core";
3
- import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { jsx } from "react/jsx-runtime";
4
4
  import { fromEvent, Observable as Observable$1, of, EMPTY, Subject as Subject$1, BehaviorSubject, timer } from "rxjs";
5
5
  import { takeUntil, map, filter, tap, take, distinctUntilChanged } from "rxjs/operators";
6
6
  function useFiltersAndSort(options) {
@@ -1981,128 +1981,9 @@ function useSetActiveTab() {
1981
1981
  previousTab: () => service.previousTab()
1982
1982
  };
1983
1983
  }
1984
- function ResponsiveTabs({
1985
- className = "",
1986
- tabClassName = "",
1987
- activeTabClassName = "",
1988
- selectClassName = "",
1989
- breakpoint = 768,
1990
- showBadges = true,
1991
- icon = true
1992
- }) {
1993
- const [isMobile, setIsMobile] = useState(false);
1994
- const activeTab = useActiveTab();
1995
- const tabs = useTabs();
1996
- const { setActiveTab } = useSetActiveTab();
1997
- useEffect(() => {
1998
- const handleResize = () => {
1999
- setIsMobile(window.innerWidth < breakpoint);
2000
- };
2001
- handleResize();
2002
- window.addEventListener("resize", handleResize);
2003
- return () => {
2004
- window.removeEventListener("resize", handleResize);
2005
- };
2006
- }, [breakpoint]);
2007
- if (!activeTab) {
2008
- return null;
2009
- }
2010
- return isMobile ? /* @__PURE__ */ jsx(
2011
- TabsSelect,
2012
- {
2013
- tabs,
2014
- activeTabId: activeTab.id,
2015
- onTabChange: setActiveTab,
2016
- className: selectClassName
2017
- }
2018
- ) : /* @__PURE__ */ jsx(
2019
- TabsList,
2020
- {
2021
- tabs,
2022
- activeTabId: activeTab.id,
2023
- onTabChange: setActiveTab,
2024
- className,
2025
- tabClassName,
2026
- activeTabClassName,
2027
- showBadges,
2028
- icon
2029
- }
2030
- );
2031
- }
2032
- function TabsList({
2033
- tabs,
2034
- activeTabId,
2035
- onTabChange,
2036
- className = "",
2037
- tabClassName = "",
2038
- activeTabClassName = "",
2039
- showBadges = true,
2040
- icon = true
2041
- }) {
2042
- return /* @__PURE__ */ jsx(
2043
- "div",
2044
- {
2045
- role: "tablist",
2046
- className: `flex border-b border-gray-200 ${className}`,
2047
- "aria-label": "Tabs",
2048
- children: tabs.map((tab) => /* @__PURE__ */ jsx(
2049
- "button",
2050
- {
2051
- role: "tab",
2052
- "aria-selected": tab.id === activeTabId,
2053
- "aria-controls": `tabpanel-${tab.id}`,
2054
- id: `tab-${tab.id}`,
2055
- onClick: () => !tab.disabled && onTabChange(tab.id),
2056
- disabled: tab.disabled,
2057
- className: `
2058
- relative px-4 py-2 text-sm font-medium transition-colors
2059
- ${tab.disabled ? "text-gray-400 cursor-not-allowed" : "text-gray-700 hover:text-gray-900"}
2060
- ${tab.id === activeTabId ? `text-blue-600 border-b-2 border-blue-600 ${activeTabClassName}` : ""}
2061
- ${tabClassName}
2062
- `,
2063
- children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
2064
- icon && tab.icon && /* @__PURE__ */ jsx("span", { className: "text-lg", children: tab.icon }),
2065
- /* @__PURE__ */ jsx("span", { children: tab.label }),
2066
- showBadges && tab.badge && /* @__PURE__ */ jsx("span", { className: "ml-1 inline-flex items-center justify-center px-2 py-1 text-xs font-semibold leading-none text-white transform translate-y-px bg-red-600 rounded-full", children: tab.badge })
2067
- ] })
2068
- },
2069
- tab.id
2070
- ))
2071
- }
2072
- );
2073
- }
2074
- function TabsSelect({
2075
- tabs,
2076
- activeTabId,
2077
- onTabChange,
2078
- className = ""
2079
- }) {
2080
- tabs.find((t) => t.id === activeTabId);
2081
- return /* @__PURE__ */ jsx("div", { className: `w-full ${className}`, children: /* @__PURE__ */ jsx(
2082
- "select",
2083
- {
2084
- value: activeTabId,
2085
- onChange: (e) => onTabChange(e.target.value),
2086
- "aria-label": "Select a tab",
2087
- className: `
2088
- w-full px-3 py-2 text-sm font-medium border border-gray-300 rounded-md
2089
- bg-white text-gray-900 hover:border-gray-400 focus:outline-none focus:ring-2
2090
- focus:ring-blue-500 focus:ring-offset-0
2091
- `,
2092
- children: tabs.map((tab) => /* @__PURE__ */ jsxs("option", { value: tab.id, disabled: tab.disabled, children: [
2093
- tab.label,
2094
- " ",
2095
- tab.badge ? `(${tab.badge})` : ""
2096
- ] }, tab.id))
2097
- }
2098
- ) });
2099
- }
2100
1984
  export {
2101
1985
  LiveUpdateProvider,
2102
- ResponsiveTabs,
2103
- TabsList,
2104
1986
  TabsProvider,
2105
- TabsSelect,
2106
1987
  useActiveTab,
2107
1988
  useFiltersAndSort,
2108
1989
  useFormBuilder,