@ogcio/design-system-react 1.12.4 → 1.14.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.
Files changed (123) hide show
  1. package/dist/accordion/accordion-item.js +1 -1
  2. package/dist/alert/alert.js +1 -1
  3. package/dist/autocomplete/autocomplete.d.ts +21 -3
  4. package/dist/autocomplete/autocomplete.js +212 -237
  5. package/dist/autocomplete/types.d.ts +29 -7
  6. package/dist/autocomplete/types.js +2 -1
  7. package/dist/autocomplete/use-autocomplete-controller.d.ts +12 -0
  8. package/dist/autocomplete/use-autocomplete-controller.js +169 -0
  9. package/dist/button/button.js +27 -22
  10. package/dist/button/helpers.d.ts +1 -1
  11. package/dist/button/helpers.js +14 -12
  12. package/dist/button/types.d.ts +1 -1
  13. package/dist/button-group/button-group.d.ts +1 -0
  14. package/dist/button-group/button-group.js +67 -60
  15. package/dist/card/card-next.js +28 -28
  16. package/dist/checkbox/checkbox.d.ts +7 -1
  17. package/dist/combo-box/dropdown-item.js +30 -30
  18. package/dist/data-grid/editable-table-cell.d.ts +3 -0
  19. package/dist/data-grid/editable-table-cell.js +73 -0
  20. package/dist/data-grid/tanstack/tanstack-helpers.d.ts +11 -0
  21. package/dist/data-grid/tanstack/tanstack-helpers.js +1799 -0
  22. package/dist/data-grid/types.d.ts +20 -0
  23. package/dist/data-grid/types.js +1 -0
  24. package/dist/drawer/drawer.content.js +6 -6
  25. package/dist/drawer/drawer.js +8 -8
  26. package/dist/error-text/error-text.js +1 -1
  27. package/dist/forms/form-field/form-field.js +4 -4
  28. package/dist/forms/form-field-with-tag/form-field-with-tag.js +1 -1
  29. package/dist/header/components/header-slot.js +38 -27
  30. package/dist/header/header.js +5 -5
  31. package/dist/heading/heading.js +1 -1
  32. package/dist/hint-text/hint-text.js +1 -1
  33. package/dist/hooks/use-aria-hider.d.ts +1 -0
  34. package/dist/hooks/use-aria-hider.js +20 -0
  35. package/dist/hooks/use-combined-refs.d.ts +5 -0
  36. package/dist/hooks/use-combined-refs.js +10 -0
  37. package/dist/hooks/use-focus-trap.d.ts +2 -0
  38. package/dist/hooks/use-focus-trap.js +678 -0
  39. package/dist/hooks/use-scroll-highlighted-item.d.ts +1 -0
  40. package/dist/hooks/use-scroll-highlighted-item.js +16 -0
  41. package/dist/icon/icon.js +46 -46
  42. package/dist/icon/icons.d.ts +2 -2
  43. package/dist/icon/icons.js +5 -1
  44. package/dist/icon/svgs/placeholder.js +2 -2
  45. package/dist/icon-button/icon-button.js +24 -22
  46. package/dist/index-2sRBqKFV.js +78 -0
  47. package/dist/{index-DNkhmzZp.js → index-CB-zPpNk.js} +44 -44
  48. package/dist/index.d.ts +9 -6
  49. package/dist/index.js +135 -130
  50. package/dist/input-checkbox/input-checkbox.d.ts +9 -2
  51. package/dist/input-checkbox/input-checkbox.js +65 -42
  52. package/dist/input-checkbox/types.d.ts +5 -0
  53. package/dist/input-checkbox-group/input-checkbox-group.js +22 -16
  54. package/dist/input-checkbox-group/types.d.ts +1 -0
  55. package/dist/input-radio/input-radio.js +15 -15
  56. package/dist/input-radio-group/input-radio-group.js +24 -17
  57. package/dist/input-radio-group/types.d.ts +1 -0
  58. package/dist/input-text/input-text.d.ts +22 -0
  59. package/dist/input-text/input-text.js +121 -100
  60. package/dist/input-text/type.d.ts +5 -0
  61. package/dist/label/label.js +1 -1
  62. package/dist/link/link.js +1 -1
  63. package/dist/list/list.js +3 -3
  64. package/dist/lodash-D1c5hFAM.js +3677 -0
  65. package/dist/modal/modal.content.js +1 -1
  66. package/dist/modal/modal.d.ts +8 -2
  67. package/dist/modal/modal.js +166 -131
  68. package/dist/popover/popover.d.ts +1 -1
  69. package/dist/popover/popover.js +534 -526
  70. package/dist/popover/types.d.ts +1 -0
  71. package/dist/popover/utilities.d.ts +2 -0
  72. package/dist/popover/utilities.js +16 -0
  73. package/dist/primitives/anchor.js +1 -1
  74. package/dist/primitives/button.d.ts +3 -0
  75. package/dist/primitives/button.js +9 -0
  76. package/dist/progress-bar/progress-bar.js +8 -8
  77. package/dist/progress-stepper/progress-stepper.js +12 -12
  78. package/dist/score-select/score-select.js +3 -3
  79. package/dist/select/select-menu.d.ts +2 -2
  80. package/dist/select/select-menu.js +113 -110
  81. package/dist/select/select-native.d.ts +5 -2
  82. package/dist/select/select-native.js +45 -15
  83. package/dist/select/select-next.d.ts +14 -2
  84. package/dist/select/select-next.js +190 -142
  85. package/dist/select/select-search.d.ts +3 -0
  86. package/dist/select/select-search.js +24 -0
  87. package/dist/select/select.d.ts +4 -2
  88. package/dist/select/select.js +3 -2
  89. package/dist/select/types.d.ts +25 -1
  90. package/dist/side-nav/side-nav.js +23 -23
  91. package/dist/spinner/spinner.js +1 -1
  92. package/dist/stack/stack.js +40 -49
  93. package/dist/styles.css +2 -3
  94. package/dist/table/index.d.ts +8 -0
  95. package/dist/table/index.js +19 -0
  96. package/dist/table/table-data.d.ts +16 -2
  97. package/dist/table/table-data.js +64 -17
  98. package/dist/table/table-header.d.ts +4 -1
  99. package/dist/table/table-header.js +58 -18
  100. package/dist/table/table-pagination.d.ts +8 -0
  101. package/dist/table/table-pagination.js +97 -0
  102. package/dist/table/table-row.js +7 -6
  103. package/dist/table/table.d.ts +4 -1
  104. package/dist/table/table.js +22 -15
  105. package/dist/tabs/scrollable-tab-list.d.ts +9 -0
  106. package/dist/tabs/scrollable-tab-list.js +84 -0
  107. package/dist/tabs/tab-item.d.ts +9 -15
  108. package/dist/tabs/tab-item.js +85 -38
  109. package/dist/tabs/tab-list.d.ts +2 -5
  110. package/dist/tabs/tab-list.js +83 -49
  111. package/dist/tabs/tab-panel.d.ts +2 -7
  112. package/dist/tabs/tab-panel.js +2 -5
  113. package/dist/tabs/tabs.d.ts +2 -7
  114. package/dist/tabs/tabs.js +24 -20
  115. package/dist/tabs/types.d.ts +64 -0
  116. package/dist/tabs/types.js +1 -0
  117. package/dist/text-input/text-input.d.ts +1 -0
  118. package/dist/textarea/textarea.d.ts +1 -2
  119. package/dist/textarea/textarea.js +60 -60
  120. package/dist/toast/ds-toast.js +1 -1
  121. package/dist/tooltip/tooltip.js +1 -1
  122. package/package.json +6 -6
  123. package/dist/index-ntYL1VRC.js +0 -64
@@ -0,0 +1,8 @@
1
+ export { Caption } from './caption.js';
2
+ export { TableBody } from './table-body.js';
3
+ export { TableData, TableCell } from './table-data.js';
4
+ export { TableFoot } from './table-foot.js';
5
+ export { TableHead } from './table-head.js';
6
+ export { TableHeader } from './table-header.js';
7
+ export { TableRow } from './table-row.js';
8
+ export { Table } from './table.js';
@@ -0,0 +1,19 @@
1
+ import { Caption as r } from "./caption.js";
2
+ import { TableBody as t } from "./table-body.js";
3
+ import { TableCell as p, TableData as b } from "./table-data.js";
4
+ import { TableFoot as m } from "./table-foot.js";
5
+ import { TableHead as T } from "./table-head.js";
6
+ import { TableHeader as C } from "./table-header.js";
7
+ import { TableRow as i } from "./table-row.js";
8
+ import { Table as w } from "./table.js";
9
+ export {
10
+ r as Caption,
11
+ w as Table,
12
+ t as TableBody,
13
+ p as TableCell,
14
+ b as TableData,
15
+ m as TableFoot,
16
+ T as TableHead,
17
+ C as TableHeader,
18
+ i as TableRow
19
+ };
@@ -1,8 +1,22 @@
1
- import { TdHTMLAttributes } from 'react';
1
+ import { TdHTMLAttributes, ReactNode } from 'react';
2
2
  import { TableAlign, VerticalAlign } from './table.js';
3
3
  interface TableDataProps extends TdHTMLAttributes<HTMLTableCellElement> {
4
4
  align?: TableAlign;
5
5
  valign?: VerticalAlign;
6
+ tableCellClassName?: string;
7
+ children: any;
6
8
  }
7
- export declare function TableData({ align, valign, className, children, ...props }: TableDataProps): import("react/jsx-runtime").JSX.Element;
9
+ type TableCellProps = {
10
+ children: ReactNode;
11
+ className?: string;
12
+ };
13
+ type TableExpandIconProps = {
14
+ expanded?: boolean;
15
+ onClick: any;
16
+ };
17
+ type TableDataSlotProps = Omit<TableDataProps, 'align' | 'valign'>;
18
+ export declare function TableData({ align, valign, className, children, tableCellClassName, ...props }: TableDataProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare const TableCell: ({ children, className }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const TableExpandIcon: ({ expanded, onClick, }: TableExpandIconProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const TableDataSlot: ({ children, className, ...props }: TableDataSlotProps) => import("react/jsx-runtime").JSX.Element;
8
22
  export {};
@@ -1,35 +1,82 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { cn as m } from "../cn.js";
3
- function c({
1
+ "use client";
2
+ import { jsx as n } from "react/jsx-runtime";
3
+ import { useRef as d, useState as g, useEffect as u } from "react";
4
+ import { cn as c } from "../cn.js";
5
+ import { IconButton as w } from "../icon-button/icon-button.js";
6
+ function C({
4
7
  align: t = "left",
5
8
  valign: e = "middle",
6
- className: i,
7
- children: l,
8
- ...n
9
+ className: r,
10
+ children: o,
11
+ tableCellClassName: i,
12
+ ...m
9
13
  }) {
10
- const g = {
14
+ const a = {
11
15
  left: "gi-text-left",
12
16
  center: "gi-text-center",
13
17
  right: "gi-text-right"
14
- }[t], o = {
18
+ }[t], s = {
15
19
  top: "gi-align-top",
16
20
  middle: "gi-align-middle",
17
21
  bottom: "gi-align-bottom"
18
- }[e];
19
- return /* @__PURE__ */ a(
22
+ }[e], l = d(null), [f, p] = g(!1);
23
+ return u(() => {
24
+ if (!l.current)
25
+ return;
26
+ const b = l.current.querySelectorAll("input, select, button");
27
+ p(b.length > 0);
28
+ }, []), /* @__PURE__ */ n(
20
29
  "td",
21
30
  {
22
- className: m(
23
- g,
24
- o,
31
+ ref: l,
32
+ className: c(
33
+ a,
34
+ s,
25
35
  "gi-table-td",
26
- i
36
+ r
27
37
  ),
28
- ...n,
29
- children: l
38
+ ...m,
39
+ children: f ? o : /* @__PURE__ */ n(x, { className: i, children: o })
30
40
  }
31
41
  );
32
42
  }
43
+ const x = ({ children: t, className: e }) => /* @__PURE__ */ n("div", { className: c("gi-table-data-cell", e), children: t }), E = ({
44
+ expanded: t,
45
+ onClick: e
46
+ }) => {
47
+ const [r, o] = g("md"), i = d(null);
48
+ return u(() => {
49
+ var l;
50
+ const a = (l = i.current) == null ? void 0 : l.closest(".gi-table"), s = a == null ? void 0 : a.getAttribute("data-row-size");
51
+ s && o(s);
52
+ }, []), /* @__PURE__ */ n("div", { ref: i, className: "gi-table-expand-icon-container", children: /* @__PURE__ */ n(
53
+ w,
54
+ {
55
+ variant: "flat",
56
+ appearance: "dark",
57
+ size: {
58
+ sm: "medium",
59
+ md: "large",
60
+ lg: "extraLarge"
61
+ }[r],
62
+ icon: {
63
+ icon: t ? "keyboard_arrow_up" : "keyboard_arrow_down"
64
+ },
65
+ "aria-label": t ? "Collapse row" : "Expand row",
66
+ className: "gi-cursor-pointer",
67
+ onClick: (a) => {
68
+ a.preventDefault(), e();
69
+ }
70
+ }
71
+ ) });
72
+ }, S = ({
73
+ children: t,
74
+ className: e,
75
+ ...r
76
+ }) => /* @__PURE__ */ n("td", { className: "gi-table-td", ...r, children: /* @__PURE__ */ n("div", { className: c("gi-table-data-slot-container", e), children: t }) });
33
77
  export {
34
- c as TableData
78
+ x as TableCell,
79
+ C as TableData,
80
+ S as TableDataSlot,
81
+ E as TableExpandIcon
35
82
  };
@@ -1,8 +1,11 @@
1
1
  import { ThHTMLAttributes } from 'react';
2
2
  import { TableAlign, VerticalAlign } from './table.js';
3
+ type SortedType = 'asc' | 'desc' | false;
3
4
  interface TableHeaderProps extends ThHTMLAttributes<HTMLTableCellElement> {
4
5
  align?: TableAlign;
5
6
  valign?: VerticalAlign;
7
+ sorted?: SortedType;
8
+ onSort?: (event: React.MouseEvent) => void;
6
9
  }
7
- export declare function TableHeader({ align, valign, className, children, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function TableHeader({ align, valign, className, sorted, onSort, children, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
8
11
  export {};
@@ -1,35 +1,75 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { cn as a } from "../cn.js";
3
- function c({
4
- align: t = "left",
5
- valign: e = "middle",
6
- className: i,
1
+ "use client";
2
+ import { jsx as o, jsxs as x } from "react/jsx-runtime";
3
+ import { Children as y } from "react";
4
+ import { cn as d } from "../cn.js";
5
+ import { Icon as m } from "../icon/icon.js";
6
+ const b = (e, r) => e ? r ? /* @__PURE__ */ o(
7
+ m,
8
+ {
9
+ inline: !0,
10
+ icon: r === "asc" ? "arrow_upward" : "arrow_downward",
11
+ size: "sm"
12
+ }
13
+ ) : /* @__PURE__ */ o(m, { inline: !0, icon: "swap_vert", size: "sm" }) : null;
14
+ function K({
15
+ align: e = "left",
16
+ valign: r = "middle",
17
+ className: u,
18
+ sorted: a = !1,
19
+ onSort: i,
7
20
  children: l,
8
- ...n
21
+ ...h
9
22
  }) {
10
- const g = {
23
+ const t = typeof l == "string", c = {
11
24
  left: "gi-text-left",
12
25
  center: "gi-text-center",
13
26
  right: "gi-text-right"
14
- }[t], o = {
27
+ }[e], p = {
15
28
  top: "gi-align-top",
16
29
  middle: "gi-align-middle",
17
30
  bottom: "gi-align-bottom"
18
- }[e];
19
- return /* @__PURE__ */ r(
31
+ }[r], g = (n) => {
32
+ i && t && (n.preventDefault(), i(n));
33
+ }, f = (n) => {
34
+ n.key === "Enter" && g(n);
35
+ }, w = y.count(l) > 0;
36
+ let s;
37
+ return a && t ? s = "button" : w || (s = "cell"), /* @__PURE__ */ o(
20
38
  "th",
21
39
  {
22
- className: a(
23
- g,
24
- o,
40
+ className: d(
41
+ c,
42
+ p,
25
43
  "gi-table-th",
26
- i
44
+ u,
45
+ { "gi-w-12": !t }
27
46
  ),
28
- ...n,
29
- children: l
47
+ role: s,
48
+ "data-sorted": !!i,
49
+ "data-header-string": t,
50
+ tabIndex: i && t ? 0 : -1,
51
+ onKeyDown: f,
52
+ ...h,
53
+ children: /* @__PURE__ */ x(
54
+ "div",
55
+ {
56
+ className: d(c, {
57
+ "gi-flex gi-gap-1 gi-h-full gi-items-center": t,
58
+ "gi-justify-center": e === "center",
59
+ "gi-justify-start": e === "left",
60
+ "gi-justify-end": e === "right"
61
+ }),
62
+ onClick: g,
63
+ onKeyDown: f,
64
+ children: [
65
+ l,
66
+ !!i && b(t, a)
67
+ ]
68
+ }
69
+ )
30
70
  }
31
71
  );
32
72
  }
33
73
  export {
34
- c as TableHeader
74
+ K as TableHeader
35
75
  };
@@ -0,0 +1,8 @@
1
+ export type TablePaginationProps = {
2
+ align?: 'start' | 'center' | 'end';
3
+ currentPage: number;
4
+ totalPages: number;
5
+ onPageChange: (page: number) => void;
6
+ };
7
+ export declare const TablePagination: React.FC<TablePaginationProps>;
8
+ export default TablePagination;
@@ -0,0 +1,97 @@
1
+ import { jsxs as t, jsx as l } from "react/jsx-runtime";
2
+ import { cn as f } from "../cn.js";
3
+ import { translate as e } from "../i18n/utility.js";
4
+ import { IconButton as o } from "../icon-button/icon-button.js";
5
+ const v = ({
6
+ currentPage: i,
7
+ totalPages: a,
8
+ onPageChange: n,
9
+ align: s = "end"
10
+ }) => {
11
+ const c = () => {
12
+ i > 1 && n(i - 1);
13
+ }, d = () => {
14
+ i < a && n(i + 1);
15
+ };
16
+ return /* @__PURE__ */ t(
17
+ "div",
18
+ {
19
+ className: f(
20
+ {
21
+ "gi-justify-first": s === "start",
22
+ "gi-justify-center": s === "center",
23
+ "gi-justify-end": s === "end"
24
+ },
25
+ "gi-table-pagination"
26
+ ),
27
+ children: [
28
+ /* @__PURE__ */ l(
29
+ o,
30
+ {
31
+ disabled: i === 1,
32
+ onClick: () => n(1),
33
+ appearance: "dark",
34
+ variant: "flat",
35
+ className: "gi-mr-4",
36
+ icon: {
37
+ icon: "first_page"
38
+ }
39
+ }
40
+ ),
41
+ /* @__PURE__ */ l(
42
+ o,
43
+ {
44
+ disabled: i === 1,
45
+ onClick: c,
46
+ appearance: "dark",
47
+ variant: "flat",
48
+ className: "gi-mr-2",
49
+ icon: {
50
+ icon: "chevron_left"
51
+ }
52
+ }
53
+ ),
54
+ /* @__PURE__ */ t("div", { className: "gi-table-pagination-label", "aria-live": "polite", children: [
55
+ /* @__PURE__ */ l("span", { className: "gi-font-bold", children: e("table.pagination.page", {
56
+ currentPage: i,
57
+ defaultValue: `Page ${i} `
58
+ }) }),
59
+ e("table.pagination.ofTotal", {
60
+ totalPages: a,
61
+ defaultValue: `of ${a}`
62
+ })
63
+ ] }),
64
+ /* @__PURE__ */ l(
65
+ o,
66
+ {
67
+ onClick: d,
68
+ disabled: i === a,
69
+ appearance: "dark",
70
+ variant: "flat",
71
+ className: "gi-ml-2",
72
+ icon: {
73
+ icon: "chevron_right"
74
+ }
75
+ }
76
+ ),
77
+ /* @__PURE__ */ l(
78
+ o,
79
+ {
80
+ disabled: i === a,
81
+ onClick: () => n(a),
82
+ appearance: "dark",
83
+ variant: "flat",
84
+ className: "gi-ml-4",
85
+ icon: {
86
+ icon: "last_page"
87
+ }
88
+ }
89
+ )
90
+ ]
91
+ }
92
+ );
93
+ };
94
+ export {
95
+ v as TablePagination,
96
+ v as default
97
+ };
@@ -1,10 +1,11 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- function n({
3
- children: r,
4
- ...o
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { cn as e } from "../cn.js";
3
+ function c({
4
+ children: t,
5
+ ...r
5
6
  }) {
6
- return /* @__PURE__ */ t("tr", { ...o, children: r });
7
+ return /* @__PURE__ */ a("tr", { className: e(r.className, "gi-table-tr"), ...r, children: t });
7
8
  }
8
9
  export {
9
- n as TableRow
10
+ c as TableRow
10
11
  };
@@ -20,6 +20,9 @@ declare const tableVariants: import('tailwind-variants').TVReturnType<{
20
20
  }, undefined, "gi-table", TVConfig<V, EV>, unknown, unknown, undefined>>;
21
21
  export type TableProps = VariantProps<typeof tableVariants> & {
22
22
  dataTestid?: string;
23
+ rowSize?: 'sm' | 'md' | 'lg';
24
+ stripped?: boolean;
25
+ noBorder?: boolean;
23
26
  } & React.TableHTMLAttributes<HTMLTableElement>;
24
- export declare function Table({ layout, dataTestid, children, ...props }: React.PropsWithChildren<TableProps>): import("react/jsx-runtime").JSX.Element;
27
+ export declare function Table({ layout, rowSize, stripped, noBorder, dataTestid, children, className, ...props }: React.PropsWithChildren<TableProps>): import("react/jsx-runtime").JSX.Element;
25
28
  export {};
@@ -1,7 +1,7 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { c as l } from "../index-DNkhmzZp.js";
3
- import { cn as r } from "../cn.js";
4
- const b = l({
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { c as b } from "../index-CB-zPpNk.js";
3
+ import { cn as f } from "../cn.js";
4
+ const m = b({
5
5
  base: "gi-table",
6
6
  variants: {
7
7
  layout: {
@@ -10,24 +10,31 @@ const b = l({
10
10
  }
11
11
  }
12
12
  });
13
- function u({
13
+ function g({
14
14
  layout: t = "auto",
15
- dataTestid: a,
16
- children: e,
17
- ...o
15
+ rowSize: a = "md",
16
+ stripped: e = !1,
17
+ noBorder: o = !1,
18
+ dataTestid: r,
19
+ children: s,
20
+ className: i,
21
+ ...l
18
22
  }) {
19
- const s = b({ layout: t });
20
- return /* @__PURE__ */ i(
23
+ const n = m({ layout: t });
24
+ return /* @__PURE__ */ d(
21
25
  "table",
22
26
  {
23
- className: r(s),
27
+ className: f(n, i),
24
28
  role: "table",
25
- "data-testid": a,
26
- ...o,
27
- children: e
29
+ "data-testid": r,
30
+ "data-row-size": a,
31
+ "data-stripped": e.toString(),
32
+ "data-no-border": o.toString(),
33
+ ...l,
34
+ children: s
28
35
  }
29
36
  );
30
37
  }
31
38
  export {
32
- u as Table
39
+ g as Table
33
40
  };
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ type ScrollableTabsProps = {
3
+ children: ReactNode;
4
+ tabName: string;
5
+ appearance?: 'default' | 'dark';
6
+ className?: string;
7
+ };
8
+ export declare const ScrollableTabs: React.FC<ScrollableTabsProps>;
9
+ export {};
@@ -0,0 +1,84 @@
1
+ import { jsx as d, jsxs as E } from "react/jsx-runtime";
2
+ import { useState as y, useRef as g, Children as l, useEffect as I, isValidElement as p, useLayoutEffect as L } from "react";
3
+ import { cn as k } from "../cn.js";
4
+ import { InternalTabItem as D } from "./tab-item.js";
5
+ const K = ({
6
+ children: r,
7
+ tabName: w,
8
+ className: R = "",
9
+ appearance: i = "default"
10
+ }) => {
11
+ const [n, a] = y(0), [f, T] = y({ left: 0, width: 0 }), u = g([]), m = g(null), b = l.count(r);
12
+ I(() => {
13
+ for (const t of l.toArray(r))
14
+ if (p(t)) {
15
+ if ((t == null ? void 0 : t.props).checked)
16
+ break;
17
+ continue;
18
+ }
19
+ }, [r]), L(() => {
20
+ const t = u.current[n], e = m.current;
21
+ if (!t || !e)
22
+ return;
23
+ const o = t.getBoundingClientRect(), s = e.getBoundingClientRect();
24
+ requestAnimationFrame(() => {
25
+ T({
26
+ left: o.left - s.left + e.scrollLeft,
27
+ width: o.width
28
+ }), t.scrollIntoView({ behavior: "smooth", inline: "center" });
29
+ });
30
+ }, [n]);
31
+ const A = (t, e) => (o) => {
32
+ a(t), e && e(o);
33
+ const s = o.currentTarget.getAttribute("aria-controls");
34
+ if (s)
35
+ for (const c of document.querySelectorAll('[role="tabpanel"]'))
36
+ c instanceof HTMLElement && (c.style.display = c.id === s ? "block" : "none");
37
+ }, C = (t) => {
38
+ if (t.key === "ArrowLeft" || t.key === "ArrowRight") {
39
+ let e = n + (t.key === "ArrowRight" ? 1 : -1);
40
+ e < 0 && (e = 0), e >= b && (e = b - 1), a(e), t.preventDefault();
41
+ }
42
+ }, h = l.map(r, (t, e) => p(t) ? /* @__PURE__ */ d(
43
+ D,
44
+ {
45
+ ...t == null ? void 0 : t.props,
46
+ appearance: i,
47
+ index: e,
48
+ checked: n === e,
49
+ onTabClick: A(e, t.props.onTabClick),
50
+ onTabKeyDown: C,
51
+ ref: (o) => {
52
+ u.current[e] = o;
53
+ }
54
+ }
55
+ ) : null), S = {
56
+ left: f.left,
57
+ width: f.width
58
+ };
59
+ return /* @__PURE__ */ E(
60
+ "div",
61
+ {
62
+ id: w,
63
+ ref: m,
64
+ role: "tablist",
65
+ className: k("gi-tab-list ", R),
66
+ children: [
67
+ h,
68
+ /* @__PURE__ */ d(
69
+ "span",
70
+ {
71
+ className: k("gi-tab-indicator", {
72
+ "gi-bg-color-border-system-neutral-interactive-default": i === "dark",
73
+ "gi-bg-color-border-tone-primary-accent-selected": i === "default"
74
+ }),
75
+ style: S
76
+ }
77
+ )
78
+ ]
79
+ }
80
+ );
81
+ };
82
+ export {
83
+ K as ScrollableTabs
84
+ };
@@ -1,17 +1,11 @@
1
- import { default as React, FC } from 'react';
2
- export type TabItemProps = {
3
- value: string;
4
- children: React.ReactNode;
5
- href?: string;
6
- checked?: boolean;
7
- ariaLabel?: string;
8
- ariaLabelledby?: string;
9
- onTabClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
10
- };
11
- export type InternalTabItemProps = TabItemProps & {
12
- onTabClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
1
+ import { FC } from 'react';
2
+ import { TabItemProps } from './types.js';
3
+ export declare const TabItem: FC<TabItemProps>;
4
+ export declare const InternalTabItem: import('react').ForwardRefExoticComponent<TabItemProps & {
13
5
  onTabKeyDown?: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
14
6
  index: number;
15
- };
16
- export declare const TabItem: FC<TabItemProps>;
17
- export declare const InternalTabItem: FC<InternalTabItemProps>;
7
+ appearance?: "default" | "dark";
8
+ size?: "md" | "sm";
9
+ stretch?: boolean;
10
+ labelAlignment?: "center" | "end" | "start";
11
+ } & import('react').RefAttributes<HTMLButtonElement>>;