@ogcio/design-system-react 1.17.2 → 1.18.1

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.
@@ -1,9 +1,11 @@
1
1
  import { TdHTMLAttributes, ReactNode } from 'react';
2
2
  import { TableAlign, VerticalAlign } from './table.js';
3
+ type TableDataSize = 'xs-fixed' | 'sm-fixed' | 'md-fixed' | 'lg-flex' | 'fluid';
3
4
  interface TableDataProps extends TdHTMLAttributes<HTMLTableCellElement> {
4
5
  align?: TableAlign;
5
6
  valign?: VerticalAlign;
6
7
  tableCellClassName?: string;
8
+ size?: TableDataSize;
7
9
  children: any;
8
10
  }
9
11
  type TableCellProps = {
@@ -15,7 +17,7 @@ type TableExpandIconProps = {
15
17
  onClick: any;
16
18
  };
17
19
  type TableDataSlotProps = Omit<TableDataProps, 'align' | 'valign'>;
18
- export declare function TableData({ align, valign, className, children, tableCellClassName, ...props }: TableDataProps): import("react/jsx-runtime").JSX.Element;
20
+ export declare function TableData({ align, valign, size, className, children, tableCellClassName, ...props }: TableDataProps): import("react/jsx-runtime").JSX.Element;
19
21
  export declare const TableCell: ({ children, className }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
20
22
  export declare const TableExpandIcon: ({ expanded, onClick, }: TableExpandIconProps) => import("react/jsx-runtime").JSX.Element;
21
23
  export declare const TableDataSlot: ({ children, className, ...props }: TableDataSlotProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,56 +1,58 @@
1
1
  "use client";
2
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({
3
+ import { useRef as g, useState as u, useEffect as f } from "react";
4
+ import { cn as m } from "../cn.js";
5
+ import { IconButton as v } from "../icon-button/icon-button.js";
6
+ function S({
7
7
  align: t = "left",
8
8
  valign: e = "middle",
9
- className: r,
9
+ size: l,
10
+ className: s,
10
11
  children: o,
11
- tableCellClassName: i,
12
- ...m
12
+ tableCellClassName: d,
13
+ ...a
13
14
  }) {
14
- const a = {
15
+ const r = {
15
16
  left: "gi-text-left",
16
17
  center: "gi-text-center",
17
18
  right: "gi-text-right"
18
- }[t], s = {
19
+ }[t], i = {
19
20
  top: "gi-align-top",
20
21
  middle: "gi-align-middle",
21
22
  bottom: "gi-align-bottom"
22
- }[e], l = d(null), [f, p] = g(!1);
23
- return u(() => {
24
- if (!l.current)
23
+ }[e], p = l ? `gi-table-td-${l}` : void 0, c = g(null), [b, w] = u(!1);
24
+ return f(() => {
25
+ if (!c.current)
25
26
  return;
26
- const b = l.current.querySelectorAll("input, select, button");
27
- p(b.length > 0);
27
+ const x = c.current.querySelectorAll("input, select, button");
28
+ w(x.length > 0);
28
29
  }, []), /* @__PURE__ */ n(
29
30
  "td",
30
31
  {
31
- ref: l,
32
- className: c(
32
+ ref: c,
33
+ className: m(
33
34
  "gi-table-td",
34
- a,
35
- s,
36
- r
35
+ p,
36
+ r,
37
+ i,
38
+ s
37
39
  ),
38
- ...m,
39
- children: f ? o : /* @__PURE__ */ n(x, { className: i, children: o })
40
+ ...a,
41
+ children: b ? o : /* @__PURE__ */ n(z, { className: d, children: o })
40
42
  }
41
43
  );
42
44
  }
43
- const x = ({ children: t, className: e }) => /* @__PURE__ */ n("div", { className: c("gi-table-data-cell", e), children: t }), E = ({
45
+ const z = ({ children: t, className: e }) => /* @__PURE__ */ n("div", { className: m("gi-table-data-cell", e), children: t }), k = ({
44
46
  expanded: t,
45
47
  onClick: e
46
48
  }) => {
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,
49
+ const [l, s] = u("md"), o = g(null);
50
+ return f(() => {
51
+ var i;
52
+ const a = (i = o.current) == null ? void 0 : i.closest(".gi-table"), r = a == null ? void 0 : a.getAttribute("data-row-size");
53
+ r && s(r);
54
+ }, []), /* @__PURE__ */ n("div", { ref: o, className: "gi-table-expand-icon-container", children: /* @__PURE__ */ n(
55
+ v,
54
56
  {
55
57
  variant: "flat",
56
58
  appearance: "dark",
@@ -58,7 +60,7 @@ const x = ({ children: t, className: e }) => /* @__PURE__ */ n("div", { classNam
58
60
  sm: "medium",
59
61
  md: "large",
60
62
  lg: "extraLarge"
61
- }[r],
63
+ }[l],
62
64
  icon: {
63
65
  icon: t ? "keyboard_arrow_up" : "keyboard_arrow_down"
64
66
  },
@@ -69,14 +71,14 @@ const x = ({ children: t, className: e }) => /* @__PURE__ */ n("div", { classNam
69
71
  }
70
72
  }
71
73
  ) });
72
- }, S = ({
74
+ }, T = ({
73
75
  children: t,
74
76
  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 }) });
77
+ ...l
78
+ }) => /* @__PURE__ */ n("td", { className: "gi-table-td", ...l, children: /* @__PURE__ */ n("div", { className: m("gi-table-data-slot-container", e), children: t }) });
77
79
  export {
78
- x as TableCell,
79
- C as TableData,
80
- S as TableDataSlot,
81
- E as TableExpandIcon
80
+ z as TableCell,
81
+ S as TableData,
82
+ T as TableDataSlot,
83
+ k as TableExpandIcon
82
84
  };
@@ -1,11 +1,13 @@
1
1
  import { ThHTMLAttributes } from 'react';
2
2
  import { TableAlign, VerticalAlign } from './table.js';
3
3
  type SortedType = 'asc' | 'desc' | false;
4
+ export type TableHeaderSize = 'xs-fixed' | 'sm-fixed' | 'md-fixed' | 'lg-flex' | 'fluid';
4
5
  interface TableHeaderProps extends ThHTMLAttributes<HTMLTableCellElement> {
5
6
  align?: TableAlign;
6
7
  valign?: VerticalAlign;
7
8
  sorted?: SortedType;
8
9
  onSort?: (event: React.MouseEvent) => void;
10
+ size?: TableHeaderSize;
9
11
  }
10
- export declare function TableHeader({ align, valign, className, sorted, onSort, children, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function TableHeader({ align, valign, className, sorted, onSort, children, size, ...props }: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
11
13
  export {};
@@ -1,69 +1,71 @@
1
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,
2
+ import { jsx as o, jsxs as b } from "react/jsx-runtime";
3
+ import { Children as C } from "react";
4
+ import { cn as m } from "../cn.js";
5
+ import { Icon as u } from "../icon/icon.js";
6
+ const j = (e, r) => e ? r ? /* @__PURE__ */ o(
7
+ u,
8
8
  {
9
9
  inline: !0,
10
10
  icon: r === "asc" ? "arrow_upward" : "arrow_downward",
11
11
  size: "sm"
12
12
  }
13
- ) : /* @__PURE__ */ o(m, { inline: !0, icon: "swap_vert", size: "sm" }) : null;
14
- function K({
13
+ ) : /* @__PURE__ */ o(u, { inline: !0, icon: "swap_vert", size: "sm" }) : null;
14
+ function _({
15
15
  align: e = "left",
16
16
  valign: r = "middle",
17
- className: u,
17
+ className: h,
18
18
  sorted: a = !1,
19
19
  onSort: i,
20
20
  children: l,
21
- ...h
21
+ size: c,
22
+ ...p
22
23
  }) {
23
- const t = typeof l == "string", c = {
24
+ const t = typeof l == "string", g = {
24
25
  left: "gi-text-left",
25
26
  center: "gi-text-center",
26
27
  right: "gi-text-right"
27
- }[e], p = {
28
+ }[e], w = {
28
29
  top: "gi-align-top",
29
30
  middle: "gi-align-middle",
30
31
  bottom: "gi-align-bottom"
31
- }[r], g = (n) => {
32
+ }[r], x = c ? `gi-table-th-${c}` : void 0, f = (n) => {
32
33
  i && t && (n.preventDefault(), i(n));
33
- }, f = (n) => {
34
- n.key === "Enter" && g(n);
35
- }, w = y.count(l) > 0;
34
+ }, d = (n) => {
35
+ n.key === "Enter" && f(n);
36
+ }, y = C.count(l) > 0;
36
37
  let s;
37
- return a && t ? s = "button" : w || (s = "cell"), /* @__PURE__ */ o(
38
+ return a && t ? s = "button" : y || (s = "cell"), /* @__PURE__ */ o(
38
39
  "th",
39
40
  {
40
- className: d(
41
- c,
42
- p,
41
+ className: m(
42
+ g,
43
+ w,
43
44
  "gi-table-th",
44
- u,
45
+ x,
46
+ h,
45
47
  { "gi-w-12": !t }
46
48
  ),
47
49
  role: s,
48
50
  "data-sorted": !!i,
49
51
  "data-header-string": t,
50
52
  tabIndex: i && t ? 0 : -1,
51
- onKeyDown: f,
52
- ...h,
53
- children: /* @__PURE__ */ x(
53
+ onKeyDown: d,
54
+ ...p,
55
+ children: /* @__PURE__ */ b(
54
56
  "div",
55
57
  {
56
- className: d(c, {
58
+ className: m(g, {
57
59
  "gi-flex gi-gap-1 gi-h-full gi-items-center": t,
58
60
  "gi-justify-center": e === "center",
59
61
  "gi-justify-start": e === "left",
60
62
  "gi-justify-end": e === "right"
61
63
  }),
62
- onClick: g,
63
- onKeyDown: f,
64
+ onClick: f,
65
+ onKeyDown: d,
64
66
  children: [
65
67
  l,
66
- !!i && b(t, a)
68
+ !!i && j(t, a)
67
69
  ]
68
70
  }
69
71
  )
@@ -71,5 +73,5 @@ function K({
71
73
  );
72
74
  }
73
75
  export {
74
- K as TableHeader
76
+ _ as TableHeader
75
77
  };
@@ -1,36 +1,36 @@
1
- import { jsxs as o, jsx as i } from "react/jsx-runtime";
2
- import { cn as m } from "../cn.js";
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { cn as p } from "../cn.js";
3
3
  import { translate as s } from "../i18n/utility.js";
4
- import { IconButton as n } from "../icon-button/icon-button.js";
4
+ import { IconButton as t } from "../icon-button/icon-button.js";
5
5
  import { SelectNative as f, SelectItem as v } from "../select/select-native.js";
6
6
  const j = ({
7
- currentPage: a,
8
- totalPages: l,
9
- onPageChange: e,
10
- align: t = "end"
7
+ currentPage: i,
8
+ totalPages: e,
9
+ onPageChange: l,
10
+ align: n = "end"
11
11
  }) => {
12
12
  const d = () => {
13
- a > 1 && e(a - 1);
14
- }, p = () => {
15
- a < l && e(a + 1);
13
+ i > 1 && l(i - 1);
14
+ }, m = () => {
15
+ i < e && l(i + 1);
16
16
  };
17
17
  return /* @__PURE__ */ o(
18
18
  "div",
19
19
  {
20
- className: m(
20
+ className: p(
21
21
  {
22
- "gi-justify-first": t === "start",
23
- "gi-justify-center": t === "center",
24
- "gi-justify-end": t === "end"
22
+ "gi-justify-first": n === "start",
23
+ "gi-justify-center": n === "center",
24
+ "gi-justify-end": n === "end"
25
25
  },
26
26
  "gi-table-pagination"
27
27
  ),
28
28
  children: [
29
- /* @__PURE__ */ i(
30
- n,
29
+ /* @__PURE__ */ a(
30
+ t,
31
31
  {
32
- disabled: a === 1,
33
- onClick: () => e(1),
32
+ disabled: i === 1,
33
+ onClick: () => l(1),
34
34
  appearance: "dark",
35
35
  variant: "flat",
36
36
  className: "gi-mr-2",
@@ -39,10 +39,10 @@ const j = ({
39
39
  }
40
40
  }
41
41
  ),
42
- /* @__PURE__ */ i(
43
- n,
42
+ /* @__PURE__ */ a(
43
+ t,
44
44
  {
45
- disabled: a === 1,
45
+ disabled: i === 1,
46
46
  onClick: d,
47
47
  appearance: "dark",
48
48
  variant: "flat",
@@ -58,31 +58,31 @@ const j = ({
58
58
  className: "gi-table-pagination-label gi-space-x-2",
59
59
  "aria-live": "polite",
60
60
  children: [
61
- /* @__PURE__ */ i("span", { children: s("table.pagination.page", {
61
+ /* @__PURE__ */ a("span", { children: s("table.pagination.page", {
62
62
  defaultValue: "Page"
63
63
  }) }),
64
- /* @__PURE__ */ i(
64
+ /* @__PURE__ */ a(
65
65
  f,
66
66
  {
67
67
  "aria-label": "Select page",
68
- value: a,
69
- className: "!gi-min-w-12",
70
- onChange: (r) => e(Number(r.target.value)),
71
- children: Array.from({ length: l }, (r, c) => /* @__PURE__ */ i(v, { value: c + 1, children: c + 1 }, c + 1))
68
+ value: i,
69
+ className: "!gi-min-w-12 !gi-border-color-border-system-neutral-interactive-muted",
70
+ onChange: (c) => l(Number(c.target.value)),
71
+ children: Array.from({ length: e }, (c, r) => /* @__PURE__ */ a(v, { value: r + 1, children: r + 1 }, r + 1))
72
72
  }
73
73
  ),
74
- /* @__PURE__ */ i("span", { children: s("table.pagination.ofTotal", {
75
- totalPages: l,
76
- defaultValue: `of ${l}`
74
+ /* @__PURE__ */ a("span", { children: s("table.pagination.ofTotal", {
75
+ totalPages: e,
76
+ defaultValue: `of ${e}`
77
77
  }) })
78
78
  ]
79
79
  }
80
80
  ),
81
- /* @__PURE__ */ i(
82
- n,
81
+ /* @__PURE__ */ a(
82
+ t,
83
83
  {
84
- onClick: p,
85
- disabled: a === l,
84
+ onClick: m,
85
+ disabled: i === e,
86
86
  appearance: "dark",
87
87
  variant: "flat",
88
88
  className: "gi-ml-2",
@@ -91,11 +91,11 @@ const j = ({
91
91
  }
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ i(
95
- n,
94
+ /* @__PURE__ */ a(
95
+ t,
96
96
  {
97
- disabled: a === l,
98
- onClick: () => e(l),
97
+ disabled: i === e,
98
+ onClick: () => l(e),
99
99
  appearance: "dark",
100
100
  variant: "flat",
101
101
  className: "gi-ml-2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/design-system-react",
3
- "version": "1.17.2",
3
+ "version": "1.18.1",
4
4
  "description": "The GOV IE design system React components.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,9 +52,9 @@
52
52
  "react-dom": "19.0.0",
53
53
  "@ogcio/design-system-eslint-config": "1.2.6",
54
54
  "@ogcio/design-system-prettier-config": "1.0.6",
55
- "@ogcio/design-system-tailwind": "1.14.3",
56
55
  "@ogcio/theme-doete": "1.0.0",
57
- "@ogcio/theme-govie": "1.7.0"
56
+ "@ogcio/design-system-tailwind": "1.15.1",
57
+ "@ogcio/theme-govie": "1.7.1"
58
58
  },
59
59
  "scripts": {
60
60
  "format": "prettier 'src/**/*.{ts,tsx}' --write",