@payfit/unity-components 3.4.8 → 3.4.10

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.
@@ -4,8 +4,9 @@ import { tabsVariant } from './Tabs.variant.js';
4
4
  interface TabsContextValue {
5
5
  variant: VariantProps<typeof tabsVariant>['variant'];
6
6
  scrollable: boolean;
7
+ layout: NonNullable<VariantProps<typeof tabsVariant>['layout']>;
7
8
  }
8
9
  export declare const TabsContext: import('react').Context<TabsContextValue>;
9
- export declare function TabsProvider({ children, variant, scrollable, }: PropsWithChildren<TabsContextValue>): import('react/jsx-runtime').JSX.Element;
10
+ export declare function TabsProvider({ children, variant, scrollable, layout, }: PropsWithChildren<TabsContextValue>): import('react/jsx-runtime').JSX.Element;
10
11
  export declare function useTabsContext(): TabsContextValue;
11
12
  export {};
@@ -3,13 +3,15 @@ import { jsx as n } from "react/jsx-runtime";
3
3
  //#region src/core/components/tabs/Tabs.context.tsx
4
4
  var r = e({
5
5
  variant: "primary",
6
- scrollable: !1
6
+ scrollable: !1,
7
+ layout: "compact"
7
8
  });
8
- function i({ children: e, variant: t, scrollable: i }) {
9
+ function i({ children: e, variant: t, scrollable: i, layout: a }) {
9
10
  return /* @__PURE__ */ n(r.Provider, {
10
11
  value: {
11
12
  variant: t,
12
- scrollable: i
13
+ scrollable: i,
14
+ layout: a
13
15
  },
14
16
  children: e
15
17
  });
@@ -1,9 +1,18 @@
1
1
  import { VariantProps } from '@payfit/unity-themes';
2
2
  import { TabsProps as AriaTabsProps } from 'react-aria-components/Tabs';
3
3
  import { tabsVariant } from './Tabs.variant.js';
4
+ type TabsLayout = NonNullable<VariantProps<typeof tabsVariant>['layout']>;
4
5
  export interface TabsProps extends Omit<AriaTabsProps, 'isDisabled' | 'orientation' | 'className' | 'style' | 'disabledKeys' | 'keyboardActivation' | 'slot'>, VariantProps<typeof tabsVariant> {
5
6
  /** set to true to make the tabs scrollable */
6
7
  scrollable?: boolean;
8
+ /**
9
+ * Controls how tabs use the available width.
10
+ * @default 'compact'
11
+ * @remarks
12
+ * - `compact` sizes each tab to its content.
13
+ * - `full` distributes the available tab-list width evenly across tabs.
14
+ */
15
+ layout?: TabsLayout;
7
16
  }
8
17
  /**
9
18
  * Use these tabs when switching between sections without changing the URL.
@@ -45,6 +54,15 @@ export interface TabsProps extends Omit<AriaTabsProps, 'isDisabled' | 'orientati
45
54
  * </TabPanels>
46
55
  * </Tabs>
47
56
  * ```
57
+ * @example Full-width layout
58
+ * ```tsx
59
+ * <Tabs layout="full">
60
+ * <TabList aria-label="Account">
61
+ * <RawTab id="profile">Profile</RawTab>
62
+ * <RawTab id="settings">Settings</RawTab>
63
+ * </TabList>
64
+ * </Tabs>
65
+ * ```
48
66
  */
49
67
  declare const Tabs: import('react').ForwardRefExoticComponent<TabsProps & import('react').RefAttributes<HTMLDivElement>>;
50
68
  export { Tabs };
@@ -4,19 +4,21 @@ import { forwardRef as n } from "react";
4
4
  import { jsx as r } from "react/jsx-runtime";
5
5
  import { Tabs as i } from "react-aria-components/Tabs";
6
6
  //#region src/core/components/tabs/Tabs.tsx
7
- var a = n(({ children: n, variant: a, scrollable: o = !1, ...s }, c) => {
8
- let { base: l } = t({
7
+ var a = n(({ children: n, variant: a, scrollable: o = !1, layout: s = "compact", ...c }, l) => {
8
+ let { base: u } = t({
9
9
  variant: a,
10
- scrollable: o
10
+ scrollable: o,
11
+ layout: s
11
12
  });
12
13
  return /* @__PURE__ */ r(e, {
13
14
  variant: a,
14
15
  scrollable: o,
16
+ layout: s,
15
17
  children: /* @__PURE__ */ r(i, {
16
18
  "data-dd-privacy": "allow",
17
- ref: c,
18
- className: l(),
19
- ...s,
19
+ ref: l,
20
+ className: u(),
21
+ ...c,
20
22
  children: n
21
23
  })
22
24
  });
@@ -16,6 +16,13 @@ export declare const tabsVariant: import('tailwind-variants').TVReturnType<{
16
16
  scroller: string;
17
17
  };
18
18
  };
19
+ layout: {
20
+ compact: {};
21
+ full: {
22
+ tabList: string;
23
+ tab: string;
24
+ };
25
+ };
19
26
  }, {
20
27
  base: string;
21
28
  tabList: string;
@@ -39,6 +46,13 @@ export declare const tabsVariant: import('tailwind-variants').TVReturnType<{
39
46
  scroller: string;
40
47
  };
41
48
  };
49
+ layout: {
50
+ compact: {};
51
+ full: {
52
+ tabList: string;
53
+ tab: string;
54
+ };
55
+ };
42
56
  }, {
43
57
  base: string;
44
58
  tabList: string;
@@ -62,6 +76,13 @@ export declare const tabsVariant: import('tailwind-variants').TVReturnType<{
62
76
  scroller: string;
63
77
  };
64
78
  };
79
+ layout: {
80
+ compact: {};
81
+ full: {
82
+ tabList: string;
83
+ tab: string;
84
+ };
85
+ };
65
86
  }, {
66
87
  base: string;
67
88
  tabList: string;
@@ -25,11 +25,19 @@ var t = e({
25
25
  base: "",
26
26
  scroller: ""
27
27
  }
28
+ },
29
+ layout: {
30
+ compact: {},
31
+ full: {
32
+ tabList: "uy:w-full",
33
+ tab: "uy:flex-1 uy:min-w-0"
34
+ }
28
35
  }
29
36
  },
30
37
  defaultVariants: {
31
38
  variant: "primary",
32
- scrollable: !1
39
+ scrollable: !1,
40
+ layout: "compact"
33
41
  }
34
42
  });
35
43
  //#endregion
@@ -5,15 +5,16 @@ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
5
  import { Tab as a } from "react-aria-components/Tabs";
6
6
  //#region src/core/components/tabs/parts/RawTab.tsx
7
7
  var o = n(({ children: n, suffix: o, id: s, ...c }, l) => {
8
- let { variant: u, scrollable: d } = e(), { tab: f } = t({
8
+ let { variant: u, scrollable: d, layout: f } = e(), { tab: p } = t({
9
9
  variant: u,
10
- scrollable: d
10
+ scrollable: d,
11
+ layout: f
11
12
  });
12
13
  return /* @__PURE__ */ i(a, {
13
14
  ...c,
14
15
  ref: l,
15
16
  id: s,
16
- className: f(),
17
+ className: p(),
17
18
  children: [n, o ? /* @__PURE__ */ r("span", { children: o }) : null]
18
19
  });
19
20
  });
@@ -7,21 +7,22 @@ import { useResizeObserver as l } from "usehooks-ts";
7
7
  import { TabList as u } from "react-aria-components/Tabs";
8
8
  //#region src/core/components/tabs/parts/TabList.tsx
9
9
  var d = r(function({ children: r, ...d }, f) {
10
- let p = a(null), [m, h] = o(!1), [g, _] = o(!1), { variant: v, scrollable: y } = e(), { tabList: b, scroller: x } = t({
10
+ let p = a(null), [m, h] = o(!1), [g, _] = o(!1), { variant: v, scrollable: y, layout: b } = e(), { tabList: x, scroller: S } = t({
11
11
  variant: v,
12
- scrollable: y
13
- }), S = i(() => {
12
+ scrollable: y,
13
+ layout: b
14
+ }), C = i(() => {
14
15
  if (!p.current) return;
15
16
  let { scrollLeft: e, scrollWidth: t, clientWidth: n } = p.current;
16
17
  h(e > 0), _(e + n < t);
17
18
  }, []);
18
19
  l({
19
20
  ref: p,
20
- onResize: S
21
+ onResize: C
21
22
  });
22
- let C = () => {
23
- S();
24
- }, w = () => {
23
+ let w = () => {
24
+ C();
25
+ }, T = () => {
25
26
  let e = p.current?.querySelectorAll("[role=tab]");
26
27
  if (!p.current || !e) return 0;
27
28
  let { scrollLeft: t } = p.current, n = Array.from(e);
@@ -30,7 +31,7 @@ var d = r(function({ children: r, ...d }, f) {
30
31
  if (r.offsetLeft < t) return -r.offsetWidth;
31
32
  }
32
33
  return 0;
33
- }, T = () => {
34
+ }, E = () => {
34
35
  let e = p.current?.querySelectorAll("[role=tab]");
35
36
  if (!p.current || !e) return 0;
36
37
  let { scrollLeft: t, clientWidth: n } = p.current, r = Array.from(e), i = t + n;
@@ -39,7 +40,12 @@ var d = r(function({ children: r, ...d }, f) {
39
40
  if (n > i || n < i) return t.offsetWidth;
40
41
  }
41
42
  return 0;
42
- };
43
+ }, D = /* @__PURE__ */ s(u, {
44
+ ...d,
45
+ ref: f,
46
+ className: x(),
47
+ children: r
48
+ });
43
49
  return y ? /* @__PURE__ */ c("div", {
44
50
  className: "uy:relative",
45
51
  children: [
@@ -48,38 +54,28 @@ var d = r(function({ children: r, ...d }, f) {
48
54
  onPress: () => {
49
55
  p.current?.scrollBy({
50
56
  behavior: "smooth",
51
- left: w()
57
+ left: T()
52
58
  });
53
59
  }
54
60
  }),
55
61
  /* @__PURE__ */ s("div", {
56
62
  ref: p,
57
63
  "data-testid": "scrollable-tab-list",
58
- className: x(),
59
- onScroll: C,
60
- children: /* @__PURE__ */ s(u, {
61
- ...d,
62
- ref: f,
63
- className: b(),
64
- children: r
65
- })
64
+ className: S(),
65
+ onScroll: w,
66
+ children: D
66
67
  }),
67
68
  g && /* @__PURE__ */ s(n, {
68
69
  direction: "right",
69
70
  onPress: () => {
70
71
  p.current?.scrollBy({
71
72
  behavior: "smooth",
72
- left: T()
73
+ left: E()
73
74
  });
74
75
  }
75
76
  })
76
77
  ]
77
- }) : /* @__PURE__ */ s(u, {
78
- ...d,
79
- ref: f,
80
- className: b(),
81
- children: r
82
- });
78
+ }) : D;
83
79
  });
84
80
  d.displayName = "TabList";
85
81
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/unity-components",
3
- "version": "3.4.8",
3
+ "version": "3.4.10",
4
4
  "module": "./dist/esm/index.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -103,7 +103,7 @@
103
103
  "@formatjs/intl": "4.1.12",
104
104
  "@internationalized/date": "3.12.4",
105
105
  "minimatch": "10.2.5",
106
- "@payfit/unity-illustrations": "3.4.8",
106
+ "@payfit/unity-illustrations": "3.4.10",
107
107
  "@radix-ui/react-avatar": "1.2.6",
108
108
  "@radix-ui/react-slot": "1.3.3",
109
109
  "@react-aria/interactions": "3.28.1",
@@ -132,8 +132,8 @@
132
132
  "zod": "4.6.5"
133
133
  },
134
134
  "peerDependencies": {
135
- "@payfit/unity-icons": "3.4.8",
136
- "@payfit/unity-themes": "3.4.8",
135
+ "@payfit/unity-icons": "3.4.10",
136
+ "@payfit/unity-themes": "3.4.10",
137
137
  "@storybook/react-vite": "^10",
138
138
  "@tanstack/react-query": "^5",
139
139
  "@tanstack/form-core": "1.33.5",
@@ -156,9 +156,9 @@
156
156
  "@payfit/storybook-addon-console-errors": "0.0.0-use.local",
157
157
  "@payfit/storybook-addon-datadog-rum": "0.0.0-use.local",
158
158
  "@payfit/storybook-config": "0.0.0-use.local",
159
- "@payfit/unity-icons": "3.4.8",
160
- "@payfit/unity-illustrations": "3.4.8",
161
- "@payfit/unity-themes": "3.4.8",
159
+ "@payfit/unity-icons": "3.4.10",
160
+ "@payfit/unity-illustrations": "3.4.10",
161
+ "@payfit/unity-themes": "3.4.10",
162
162
  "@payfit/vite-configs": "0.0.0-use.local",
163
163
  "@storybook/addon-a11y": "10.6.0",
164
164
  "@storybook/addon-designs": "11.1.4",