@caseparts-org/caseblocks 0.0.147 → 0.0.149

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.
@@ -0,0 +1,178 @@
1
+ import { jsxs as S, jsx as s } from "react/jsx-runtime";
2
+ import d from "react";
3
+ import { c as p } from "./clsx-OuTLNxxd.js";
4
+ import { Icon as Y } from "./atoms/Icon/Icon.js";
5
+ import './assets/Table.css';const Z = "_table_14k11_2", $ = "_noPaddingRow_14k11_71", I = "_clickableRow_14k11_82", P = "_clickableCell_14k11_83", ee = "_expandedContentCell_14k11_85", ne = "_expandedContentRow_14k11_94", te = "_expandedRow_14k11_99", le = "_expanded_14k11_85", ae = "_columnContent_14k11_135", oe = "_clickableHeader_14k11_155", n = {
6
+ "table-container": "_table-container_14k11_2",
7
+ table: Z,
8
+ "table-alternating": "_table-alternating_14k11_17",
9
+ "sorted-column": "_sorted-column_14k11_22",
10
+ noPaddingRow: $,
11
+ clickableRow: I,
12
+ clickableCell: P,
13
+ expandedContentCell: ee,
14
+ expandedContentRow: ne,
15
+ expandedRow: te,
16
+ expanded: le,
17
+ columnContent: ae,
18
+ clickableHeader: oe,
19
+ "icon-ascending": "_icon-ascending_14k11_156"
20
+ }, V = ({ children: r }) => null;
21
+ V.displayName = "Table.Columns";
22
+ const v = ({ children: r }) => null;
23
+ v.displayName = "Table.Column";
24
+ const j = ({ children: r }) => null;
25
+ j.displayName = "Table.Body";
26
+ const M = ({ children: r }) => null;
27
+ M.displayName = "Table.Row";
28
+ const O = ({ children: r }) => null;
29
+ O.displayName = "Table.Cell";
30
+ const _ = ({ children: r, className: z, alternatingRows: D = !1, isSortable: w = !1, sortField: q, sortFieldKey: G, sortOrder: J = "descending", onSort: F, ...L }) => {
31
+ const B = [];
32
+ let R, g;
33
+ const i = (t, l) => {
34
+ var e;
35
+ return !!t && d.isValidElement(t) && ((e = t.type) == null ? void 0 : e.displayName) === l;
36
+ };
37
+ d.Children.forEach(r, (t) => {
38
+ i(t, "Table.Columns") ? R = t : i(t, "Table.Body") ? g = t : B.push(t);
39
+ });
40
+ const A = (t) => t.flatMap((l) => {
41
+ if (d.isValidElement(l) && l.type === d.Fragment) {
42
+ const e = l.props.children;
43
+ return d.Children.toArray(e);
44
+ }
45
+ return [l];
46
+ }), Q = () => {
47
+ if (!R) return null;
48
+ const t = d.Children.toArray(R.props.children);
49
+ return /* @__PURE__ */ s("thead", { className: n.thead, children: /* @__PURE__ */ s("tr", { children: t.map((l, e) => {
50
+ if (i(l, "Table.Column")) {
51
+ const c = l, {
52
+ children: a,
53
+ align: m,
54
+ colSpan: C,
55
+ width: b,
56
+ style: N,
57
+ sortField: u,
58
+ sortFieldKey: o,
59
+ ...f
60
+ } = c.props, E = {
61
+ textAlign: m ?? "left",
62
+ width: b,
63
+ ...N
64
+ }, y = !!u, k = w && y && (y && q === u) && (o !== void 0 ? G === o : !0), x = w && y && typeof F == "function";
65
+ return /* @__PURE__ */ s(
66
+ "th",
67
+ {
68
+ className: p(n.th, k && n["sorted-column"], x && n.clickableHeader),
69
+ style: E,
70
+ colSpan: C,
71
+ onClick: x ? () => F(u, o) : void 0,
72
+ ...f,
73
+ children: /* @__PURE__ */ S("div", { className: n.columnContent, children: [
74
+ a,
75
+ k && /* @__PURE__ */ s("span", { className: p(J === "ascending" && n["icon-ascending"]), children: /* @__PURE__ */ s(Y, { iconKey: "fa-solid fa-chevron-down", size: "3xs" }) })
76
+ ] })
77
+ },
78
+ e
79
+ );
80
+ }
81
+ return /* @__PURE__ */ s("th", { className: n.th, children: l }, e);
82
+ }) }) });
83
+ }, h = (t, l, e) => {
84
+ const c = d.Children.toArray(t).map((o, f) => {
85
+ if (i(o, "Table.Cell")) {
86
+ const E = o, {
87
+ children: y,
88
+ align: H,
89
+ colSpan: K,
90
+ width: k,
91
+ style: x,
92
+ ...T
93
+ } = E.props, W = {
94
+ textAlign: H ?? "left",
95
+ width: k,
96
+ ...x
97
+ }, X = !!(T && typeof T.onClick == "function");
98
+ return /* @__PURE__ */ s(
99
+ "td",
100
+ {
101
+ className: p(
102
+ n.cell,
103
+ (e == null ? void 0 : e.isExpanded) && n.expanded,
104
+ (e == null ? void 0 : e.isExpandedContent) && n.expandedContentCell,
105
+ X && n.clickableCell
106
+ ),
107
+ style: W,
108
+ colSpan: K,
109
+ ...T,
110
+ children: y
111
+ },
112
+ f
113
+ );
114
+ }
115
+ return d.isValidElement(o) && typeof o.type == "string" && o.type === "td" ? o : /* @__PURE__ */ s(
116
+ "td",
117
+ {
118
+ className: p(
119
+ n.cell,
120
+ (e == null ? void 0 : e.isExpanded) && n.expanded,
121
+ (e == null ? void 0 : e.isExpandedContent) && n.expandedContentCell
122
+ ),
123
+ children: o
124
+ },
125
+ f
126
+ );
127
+ }), { className: a, style: m, isExpanded: C, isExpandedContent: b, ...N } = e ?? {}, u = !!(e && typeof e.onClick == "function");
128
+ return /* @__PURE__ */ s(
129
+ "tr",
130
+ {
131
+ className: p(
132
+ n.row,
133
+ a,
134
+ C && n.expandedRow,
135
+ b && n.noPaddingRow,
136
+ b && n.expandedContentRow,
137
+ u && n.clickableRow
138
+ ),
139
+ style: m,
140
+ ...N,
141
+ children: c
142
+ },
143
+ l
144
+ );
145
+ }, U = () => {
146
+ if (g) {
147
+ const c = A(d.Children.toArray(g.props.children)).map((a, m) => {
148
+ if (i(a, "Table.Row")) {
149
+ const C = a;
150
+ return h(C.props.children, m, C.props);
151
+ }
152
+ return d.isValidElement(a) && typeof a.type == "string" && a.type === "tr" ? a : h(a, m);
153
+ });
154
+ return /* @__PURE__ */ s("tbody", { className: n.tbody, children: c });
155
+ }
156
+ const l = A(B).map((e, c) => {
157
+ if (i(e, "Table.Row")) {
158
+ const a = e;
159
+ return h(a.props.children, c, a.props);
160
+ }
161
+ return d.isValidElement(e) && typeof e.type == "string" && e.type === "tr" ? e : h(e, c);
162
+ });
163
+ return /* @__PURE__ */ s("tbody", { className: n.tbody, children: l });
164
+ };
165
+ return /* @__PURE__ */ S("table", { className: p(n.table, z, D && n["table-alternating"]), ...L, children: [
166
+ Q(),
167
+ U()
168
+ ] });
169
+ };
170
+ _.Columns = V;
171
+ _.Column = v;
172
+ _.Body = j;
173
+ _.Row = M;
174
+ _.Cell = O;
175
+ export {
176
+ _ as T,
177
+ n as s
178
+ };
@@ -39,7 +39,7 @@ import { AnimatedCheckMark as Mo } from "./molecules/StatefulButton/AnimatedChec
39
39
  import { AddToCart as vo } from "./molecules/AddToCart/AddToCart.js";
40
40
  import { Modal as ho } from "./molecules/Modal/Modal.js";
41
41
  import { ImageViewer as yo } from "./molecules/ImageViewer/ImageViewer.js";
42
- import { T as Ho } from "./Table-rSK2f682.js";
42
+ import { T as Ho } from "./Table-CPyc7fHI.js";
43
43
  import { MainNav as Vo } from "./organisms/MainNav/MainNav.js";
44
44
  import { ChipSelector as Go } from "./organisms/ChipSelector/ChipSelector.js";
45
45
  import { Product as Qo } from "./organisms/Product/Product.js";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../clsx-OuTLNxxd.js";
4
- import { T as i, T as e } from "../../Table-rSK2f682.js";
4
+ import { T as i, T as e } from "../../Table-CPyc7fHI.js";
5
5
  import "../../atoms/Icon/Icon.js";
6
6
  export {
7
7
  i as Table,
@@ -21,4 +21,5 @@ export default meta;
21
21
  type Story = StoryObj<typeof meta>;
22
22
  export declare const Default: Story;
23
23
  export declare const ExpandableRow: Story;
24
+ export declare const ExpandableRowFragment: Story;
24
25
  export declare const Sortable: Story;
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
- import { useState as s, useEffect as P } from "react";
3
- import { T as t, s as S } from "../../Table-rSK2f682.js";
2
+ import R, { useState as d, useEffect as P } from "react";
3
+ import { T as t, s as x } from "../../Table-CPyc7fHI.js";
4
4
  const v = {
5
5
  title: "Case Parts/Molecules/Table",
6
6
  component: t,
@@ -12,50 +12,50 @@ const v = {
12
12
  parameters: {
13
13
  layout: "centered"
14
14
  }
15
- }, R = (h) => {
16
- const [b, m] = s(3), [d, g] = s(!0);
15
+ }, A = (u) => {
16
+ const [b, p] = d(3), [g, s] = d(!0);
17
17
  P(() => {
18
18
  }, []);
19
- const u = [
19
+ const h = [
20
20
  { title: "Product", align: "left" },
21
21
  { title: "Qty", align: "center" },
22
- { title: "Price", align: d ? "right" : "left" }
22
+ { title: "Price", align: g ? "right" : "left" }
23
23
  ];
24
- return /* @__PURE__ */ l("div", { className: S["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
25
- /* @__PURE__ */ l(t, { ...h, children: [
26
- /* @__PURE__ */ e(t.Columns, { children: u.map((r, a) => /* @__PURE__ */ e(t.Column, { align: r.align, children: r.title }, a)) }),
27
- /* @__PURE__ */ e(t.Body, { children: Array.from({ length: b }).map((r, a) => /* @__PURE__ */ l(t.Row, { children: [
28
- /* @__PURE__ */ l(t.Cell, { onClick: () => alert(`Row ${a + 1}, Col 1`), children: [
24
+ return /* @__PURE__ */ l("div", { className: x["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
25
+ /* @__PURE__ */ l(t, { ...u, children: [
26
+ /* @__PURE__ */ e(t.Columns, { children: h.map((o, c) => /* @__PURE__ */ e(t.Column, { align: o.align, children: o.title }, c)) }),
27
+ /* @__PURE__ */ e(t.Body, { children: Array.from({ length: b }).map((o, c) => /* @__PURE__ */ l(t.Row, { children: [
28
+ /* @__PURE__ */ l(t.Cell, { onClick: () => alert(`Row ${c + 1}, Col 1`), children: [
29
29
  "Item ",
30
- a + 1
30
+ c + 1
31
31
  ] }),
32
- /* @__PURE__ */ e(t.Cell, { align: "center", children: a + 1 }),
33
- /* @__PURE__ */ l(t.Cell, { align: d ? "right" : "left", children: [
32
+ /* @__PURE__ */ e(t.Cell, { align: "center", children: c + 1 }),
33
+ /* @__PURE__ */ l(t.Cell, { align: g ? "right" : "left", children: [
34
34
  "\\$",
35
- (a + 1) * 10
35
+ (c + 1) * 10
36
36
  ] })
37
- ] }, a)) })
37
+ ] }, c)) })
38
38
  ] }),
39
39
  /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [
40
- /* @__PURE__ */ e("button", { type: "button", onClick: () => m((r) => Math.max(0, r - 1)), children: "Remove Row" }),
41
- /* @__PURE__ */ e("button", { type: "button", onClick: () => m((r) => r + 1), children: "Add Row" }),
42
- /* @__PURE__ */ l("button", { type: "button", onClick: () => g((r) => !r), children: [
40
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => p((o) => Math.max(0, o - 1)), children: "Remove Row" }),
41
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => p((o) => o + 1), children: "Add Row" }),
42
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => s((o) => !o), children: [
43
43
  "Toggle Price Alignment (",
44
- d ? "right" : "left",
44
+ g ? "right" : "left",
45
45
  ")"
46
46
  ] })
47
47
  ] })
48
48
  ] });
49
- }, I = {
49
+ }, E = {
50
50
  args: { alternatingRows: !1 },
51
- render: (h) => /* @__PURE__ */ e(R, { ...h })
51
+ render: (u) => /* @__PURE__ */ e(A, { ...u })
52
52
  }, $ = {
53
53
  args: { alternatingRows: !1 },
54
- render: (h) => /* @__PURE__ */ e((m) => {
55
- const [d, g] = s(4), [u, r] = s(!0), [a, y] = s(null), p = [
54
+ render: (u) => /* @__PURE__ */ e((p) => {
55
+ const [g, s] = d(4), [h, o] = d(!0), [c, f] = d(null), m = [
56
56
  { title: "Product", align: "left" },
57
57
  { title: "Qty", align: "center" },
58
- { title: "Price", align: u ? "right" : "left" },
58
+ { title: "Price", align: h ? "right" : "left" },
59
59
  { title: "Manufacturer", align: "left" },
60
60
  { title: "Category", align: "left" },
61
61
  { title: "SKU", align: "left" },
@@ -65,11 +65,11 @@ const v = {
65
65
  { title: "Ship Time", align: "center" },
66
66
  { title: "Stock", align: "right" }
67
67
  ];
68
- return /* @__PURE__ */ l("div", { className: S["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
69
- /* @__PURE__ */ l(t, { ...m, children: [
70
- /* @__PURE__ */ e(t.Columns, { children: p.map((c, n) => /* @__PURE__ */ e(t.Column, { align: c.align, children: c.title }, n)) }),
71
- /* @__PURE__ */ e(t.Body, { children: Array.from({ length: d }).flatMap((c, n) => {
72
- const i = a === n, o = [
68
+ return /* @__PURE__ */ l("div", { className: x["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
69
+ /* @__PURE__ */ l(t, { ...p, children: [
70
+ /* @__PURE__ */ e(t.Columns, { children: m.map((r, n) => /* @__PURE__ */ e(t.Column, { align: r.align, children: r.title }, n)) }),
71
+ /* @__PURE__ */ e(t.Body, { children: Array.from({ length: g }).flatMap((r, n) => {
72
+ const i = c === n, a = [
73
73
  `Item ${n + 1} – Super Durable Connector`,
74
74
  n + 1,
75
75
  `$${(n + 1) * 10}`,
@@ -81,36 +81,96 @@ const v = {
81
81
  "Extended warranty available for enterprise clients",
82
82
  n % 2 === 0 ? "3–5 business days" : "Ships in 24 hours",
83
83
  `${(n + 1) * 123}`
84
- ], f = /* @__PURE__ */ e(
84
+ ], C = /* @__PURE__ */ e(
85
85
  t.Row,
86
86
  {
87
87
  isExpanded: i,
88
- onClick: () => y(i ? null : n),
89
- children: p.map((w, x) => /* @__PURE__ */ e(t.Cell, { align: w.align, children: o[x] }, x))
88
+ onClick: () => f(i ? null : n),
89
+ children: m.map((w, S) => /* @__PURE__ */ e(t.Cell, { align: w.align, children: a[S] }, S))
90
90
  },
91
91
  `row-${n}`
92
- ), C = i ? /* @__PURE__ */ e(t.Row, { isExpandedContent: !0, children: /* @__PURE__ */ e(t.Cell, { colSpan: p.length, children: /* @__PURE__ */ l("div", { style: { padding: "0.5rem" }, children: [
92
+ ), y = i ? /* @__PURE__ */ e(t.Row, { isExpandedContent: !0, children: /* @__PURE__ */ e(t.Cell, { colSpan: m.length, children: /* @__PURE__ */ l("div", { style: { padding: "0.5rem" }, children: [
93
93
  "Expanded content for Item ",
94
94
  n + 1
95
95
  ] }) }) }, `expanded-${n}`) : null;
96
- return C ? [f, C] : [f];
96
+ return y ? [C, y] : [C];
97
97
  }) })
98
98
  ] }),
99
99
  /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [
100
- /* @__PURE__ */ e("button", { type: "button", onClick: () => g((c) => Math.max(0, c - 1)), children: "Remove Row" }),
101
- /* @__PURE__ */ e("button", { type: "button", onClick: () => g((c) => c + 1), children: "Add Row" }),
102
- /* @__PURE__ */ l("button", { type: "button", onClick: () => r((c) => !c), children: [
100
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => s((r) => Math.max(0, r - 1)), children: "Remove Row" }),
101
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => s((r) => r + 1), children: "Add Row" }),
102
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => o((r) => !r), children: [
103
103
  "Toggle Price Alignment (",
104
- u ? "right" : "left",
104
+ h ? "right" : "left",
105
105
  ")"
106
106
  ] })
107
107
  ] })
108
108
  ] });
109
- }, { ...h })
110
- }, E = {
109
+ }, { ...u })
110
+ }, D = {
111
+ args: { alternatingRows: !1 },
112
+ render: (u) => /* @__PURE__ */ e((p) => {
113
+ const [g, s] = d(4), [h, o] = d(!0), [c, f] = d(null), m = [
114
+ { title: "Product", align: "left" },
115
+ { title: "Qty", align: "center" },
116
+ { title: "Price", align: h ? "right" : "left" },
117
+ { title: "Manufacturer", align: "left" },
118
+ { title: "Category", align: "left" },
119
+ { title: "SKU", align: "left" },
120
+ { title: "Status", align: "center" },
121
+ { title: "Location", align: "left" },
122
+ { title: "Notes", align: "left" },
123
+ { title: "Ship Time", align: "center" },
124
+ { title: "Stock", align: "right" }
125
+ ];
126
+ return /* @__PURE__ */ l("div", { className: x["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
127
+ /* @__PURE__ */ l(t, { ...p, children: [
128
+ /* @__PURE__ */ e(t.Columns, { children: m.map((r, n) => /* @__PURE__ */ e(t.Column, { align: r.align, children: r.title }, n)) }),
129
+ /* @__PURE__ */ e(t.Body, { children: Array.from({ length: g }).map((r, n) => {
130
+ const i = c === n, a = [
131
+ `Item ${n + 1} – Super Durable Connector`,
132
+ n + 1,
133
+ `$${(n + 1) * 10}`,
134
+ "Acme Components Incorporated",
135
+ "Electrical Connectors & Fittings",
136
+ `CP-${1e3 + n}-SKU-0987654321`,
137
+ n % 2 === 0 ? "Backordered" : "In Stock",
138
+ "Warehouse Delta – Aisle 12B",
139
+ "Extended warranty available for enterprise clients",
140
+ n % 2 === 0 ? "3–5 business days" : "Ships in 24 hours",
141
+ `${(n + 1) * 123}`
142
+ ];
143
+ return /* @__PURE__ */ l(R.Fragment, { children: [
144
+ /* @__PURE__ */ e(
145
+ t.Row,
146
+ {
147
+ isExpanded: i,
148
+ onClick: () => f(i ? null : n),
149
+ children: m.map((C, y) => /* @__PURE__ */ e(t.Cell, { align: C.align, children: a[y] }, y))
150
+ }
151
+ ),
152
+ i && /* @__PURE__ */ e(t.Row, { isExpandedContent: !0, children: /* @__PURE__ */ e(t.Cell, { colSpan: m.length, children: /* @__PURE__ */ l("div", { style: { padding: "0.5rem" }, children: [
153
+ "Expanded content for Item ",
154
+ n + 1
155
+ ] }) }) })
156
+ ] }, n);
157
+ }) })
158
+ ] }),
159
+ /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [
160
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => s((r) => Math.max(0, r - 1)), children: "Remove Row" }),
161
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => s((r) => r + 1), children: "Add Row" }),
162
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => o((r) => !r), children: [
163
+ "Toggle Price Alignment (",
164
+ h ? "right" : "left",
165
+ ")"
166
+ ] })
167
+ ] })
168
+ ] });
169
+ }, { ...u })
170
+ }, K = {
111
171
  args: { alternatingRows: !1 },
112
- render: (h) => /* @__PURE__ */ e((m) => {
113
- const [d, g] = s("Product"), [u, r] = s(void 0), [a, y] = s("descending"), [p] = s(5), c = [
172
+ render: (u) => /* @__PURE__ */ e((p) => {
173
+ const [g, s] = d("Product"), [h, o] = d(void 0), [c, f] = d("descending"), [m] = d(5), r = [
114
174
  { title: "Product", align: "left", sortField: "Product" },
115
175
  { title: "Qty", align: "center", sortField: "Qty" },
116
176
  { title: "Price", align: "right", sortField: "Price" },
@@ -120,58 +180,59 @@ const v = {
120
180
  { title: "Status", align: "center", sortField: "Status" },
121
181
  { title: "Location", align: "left", sortField: "Location" },
122
182
  { title: "Notes", align: "left", sortField: "Notes" }
123
- ], n = (i, o) => {
124
- const f = i === d && o === u;
125
- y((C) => f && C === "descending" ? "ascending" : "descending"), g(i), r(o);
183
+ ], n = (i, a) => {
184
+ const C = i === g && a === h;
185
+ f((y) => C && y === "descending" ? "ascending" : "descending"), s(i), o(a);
126
186
  };
127
- return /* @__PURE__ */ l("div", { className: S["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
187
+ return /* @__PURE__ */ l("div", { className: x["table-container"], style: { display: "flex", flexDirection: "column", gap: "0.75rem", alignItems: "stretch", minWidth: 320 }, children: [
128
188
  /* @__PURE__ */ l(
129
189
  t,
130
190
  {
131
- ...m,
191
+ ...p,
132
192
  isSortable: !0,
133
- sortField: d,
134
- sortFieldKey: u,
135
- sortOrder: a,
193
+ sortField: g,
194
+ sortFieldKey: h,
195
+ sortOrder: c,
136
196
  onSort: n,
137
197
  children: [
138
- /* @__PURE__ */ e(t.Columns, { children: c.map((i, o) => /* @__PURE__ */ e(t.Column, { align: i.align, sortField: i.sortField, sortFieldKey: i.sortFieldKey, children: i.title }, o)) }),
139
- /* @__PURE__ */ e(t.Body, { children: Array.from({ length: p }).map((i, o) => /* @__PURE__ */ l(t.Row, { children: [
140
- /* @__PURE__ */ e(t.Cell, { children: `Item ${o + 1} – Responsive Test` }),
141
- /* @__PURE__ */ e(t.Cell, { align: "center", children: o + 1 }),
198
+ /* @__PURE__ */ e(t.Columns, { children: r.map((i, a) => /* @__PURE__ */ e(t.Column, { align: i.align, sortField: i.sortField, sortFieldKey: i.sortFieldKey, children: i.title }, a)) }),
199
+ /* @__PURE__ */ e(t.Body, { children: Array.from({ length: m }).map((i, a) => /* @__PURE__ */ l(t.Row, { children: [
200
+ /* @__PURE__ */ e(t.Cell, { children: `Item ${a + 1} – Responsive Test` }),
201
+ /* @__PURE__ */ e(t.Cell, { align: "center", children: a + 1 }),
142
202
  /* @__PURE__ */ l(t.Cell, { align: "right", children: [
143
203
  "$",
144
- (o + 1) * 10
204
+ (a + 1) * 10
145
205
  ] }),
146
206
  /* @__PURE__ */ e(t.Cell, { children: "Acme Corp" }),
147
207
  /* @__PURE__ */ e(t.Cell, { children: "Connectors" }),
148
- /* @__PURE__ */ e(t.Cell, { children: `CP-${1e3 + o}-SKU` }),
149
- /* @__PURE__ */ e(t.Cell, { align: "center", children: o % 2 === 0 ? "Backordered" : "In Stock" }),
208
+ /* @__PURE__ */ e(t.Cell, { children: `CP-${1e3 + a}-SKU` }),
209
+ /* @__PURE__ */ e(t.Cell, { align: "center", children: a % 2 === 0 ? "Backordered" : "In Stock" }),
150
210
  /* @__PURE__ */ e(t.Cell, { children: "Warehouse Delta – Aisle 12B" }),
151
211
  /* @__PURE__ */ e(t.Cell, { children: "Long note to test overflow behavior and truncation" })
152
- ] }, o)) })
212
+ ] }, a)) })
153
213
  ]
154
214
  }
155
215
  ),
156
216
  /* @__PURE__ */ l("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [
157
- /* @__PURE__ */ l("button", { type: "button", onClick: () => y((i) => i === "descending" ? "ascending" : "descending"), children: [
217
+ /* @__PURE__ */ l("button", { type: "button", onClick: () => f((i) => i === "descending" ? "ascending" : "descending"), children: [
158
218
  "Toggle Order (",
159
- a,
219
+ c,
160
220
  ")"
161
221
  ] }),
162
222
  /* @__PURE__ */ e("button", { type: "button", onClick: () => {
163
- g("Price"), r(void 0);
223
+ s("Price"), o(void 0);
164
224
  }, children: "Sort by Price" }),
165
225
  /* @__PURE__ */ e("button", { type: "button", onClick: () => {
166
- g("Attribute"), r(1001);
226
+ s("Attribute"), o(1001);
167
227
  }, children: "Sort by SKU (key 1001)" })
168
228
  ] })
169
229
  ] });
170
- }, { ...h })
230
+ }, { ...u })
171
231
  };
172
232
  export {
173
- I as Default,
233
+ E as Default,
174
234
  $ as ExpandableRow,
175
- E as Sortable,
235
+ D as ExpandableRowFragment,
236
+ K as Sortable,
176
237
  v as default
177
238
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.147",
4
+ "version": "0.0.149",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -1,172 +0,0 @@
1
- import { jsxs as K, jsx as o } from "react/jsx-runtime";
2
- import c from "react";
3
- import { c as m } from "./clsx-OuTLNxxd.js";
4
- import { Icon as X } from "./atoms/Icon/Icon.js";
5
- import './assets/Table.css';const Y = "_table_14k11_2", Z = "_noPaddingRow_14k11_71", $ = "_clickableRow_14k11_82", I = "_clickableCell_14k11_83", P = "_expandedContentCell_14k11_85", ee = "_expandedContentRow_14k11_94", ne = "_expandedRow_14k11_99", le = "_expanded_14k11_85", te = "_columnContent_14k11_135", ae = "_clickableHeader_14k11_155", n = {
6
- "table-container": "_table-container_14k11_2",
7
- table: Y,
8
- "table-alternating": "_table-alternating_14k11_17",
9
- "sorted-column": "_sorted-column_14k11_22",
10
- noPaddingRow: Z,
11
- clickableRow: $,
12
- clickableCell: I,
13
- expandedContentCell: P,
14
- expandedContentRow: ee,
15
- expandedRow: ne,
16
- expanded: le,
17
- columnContent: te,
18
- clickableHeader: ae,
19
- "icon-ascending": "_icon-ascending_14k11_156"
20
- }, S = ({ children: d }) => null;
21
- S.displayName = "Table.Columns";
22
- const v = ({ children: d }) => null;
23
- v.displayName = "Table.Column";
24
- const V = ({ children: d }) => null;
25
- V.displayName = "Table.Body";
26
- const j = ({ children: d }) => null;
27
- j.displayName = "Table.Row";
28
- const z = ({ children: d }) => null;
29
- z.displayName = "Table.Cell";
30
- const u = ({ children: d, className: D, alternatingRows: M = !1, isSortable: w = !1, sortField: q, sortFieldKey: G, sortOrder: J = "descending", onSort: F, ...L }) => {
31
- const H = [];
32
- let k, x;
33
- const i = (t, l) => {
34
- var e;
35
- return !!t && c.isValidElement(t) && ((e = t.type) == null ? void 0 : e.displayName) === l;
36
- };
37
- c.Children.forEach(d, (t) => {
38
- i(t, "Table.Columns") ? k = t : i(t, "Table.Body") ? x = t : H.push(t);
39
- });
40
- const O = () => {
41
- if (!k) return null;
42
- const t = c.Children.toArray(k.props.children);
43
- return /* @__PURE__ */ o("thead", { className: n.thead, children: /* @__PURE__ */ o("tr", { children: t.map((l, e) => {
44
- if (i(l, "Table.Column")) {
45
- const s = l, {
46
- children: r,
47
- align: R,
48
- colSpan: N,
49
- width: _,
50
- style: g,
51
- sortField: C,
52
- sortFieldKey: a,
53
- ...b
54
- } = s.props, T = {
55
- textAlign: R ?? "left",
56
- width: _,
57
- ...g
58
- }, p = !!C, h = w && p && (p && q === C) && (a !== void 0 ? G === a : !0), f = w && p && typeof F == "function";
59
- return /* @__PURE__ */ o(
60
- "th",
61
- {
62
- className: m(n.th, h && n["sorted-column"], f && n.clickableHeader),
63
- style: T,
64
- colSpan: N,
65
- onClick: f ? () => F(C, a) : void 0,
66
- ...b,
67
- children: /* @__PURE__ */ K("div", { className: n.columnContent, children: [
68
- r,
69
- h && /* @__PURE__ */ o("span", { className: m(J === "ascending" && n["icon-ascending"]), children: /* @__PURE__ */ o(X, { iconKey: "fa-solid fa-chevron-down", size: "3xs" }) })
70
- ] })
71
- },
72
- e
73
- );
74
- }
75
- return /* @__PURE__ */ o("th", { className: n.th, children: l }, e);
76
- }) }) });
77
- }, y = (t, l, e) => {
78
- const s = c.Children.toArray(t).map((a, b) => {
79
- if (i(a, "Table.Cell")) {
80
- const T = a, {
81
- children: p,
82
- align: A,
83
- colSpan: B,
84
- width: h,
85
- style: f,
86
- ...E
87
- } = T.props, U = {
88
- textAlign: A ?? "left",
89
- width: h,
90
- ...f
91
- }, W = !!(E && typeof E.onClick == "function");
92
- return /* @__PURE__ */ o(
93
- "td",
94
- {
95
- className: m(
96
- n.cell,
97
- (e == null ? void 0 : e.isExpanded) && n.expanded,
98
- (e == null ? void 0 : e.isExpandedContent) && n.expandedContentCell,
99
- W && n.clickableCell
100
- ),
101
- style: U,
102
- colSpan: B,
103
- ...E,
104
- children: p
105
- },
106
- b
107
- );
108
- }
109
- return c.isValidElement(a) && typeof a.type == "string" && a.type === "td" ? a : /* @__PURE__ */ o(
110
- "td",
111
- {
112
- className: m(
113
- n.cell,
114
- (e == null ? void 0 : e.isExpanded) && n.expanded,
115
- (e == null ? void 0 : e.isExpandedContent) && n.expandedContentCell
116
- ),
117
- children: a
118
- },
119
- b
120
- );
121
- }), { className: r, style: R, isExpanded: N, isExpandedContent: _, ...g } = e ?? {}, C = !!(e && typeof e.onClick == "function");
122
- return /* @__PURE__ */ o(
123
- "tr",
124
- {
125
- className: m(
126
- n.row,
127
- r,
128
- N && n.expandedRow,
129
- _ && n.noPaddingRow,
130
- _ && n.expandedContentRow,
131
- C && n.clickableRow
132
- ),
133
- style: R,
134
- ...g,
135
- children: s
136
- },
137
- l
138
- );
139
- }, Q = () => {
140
- if (x) {
141
- const l = c.Children.toArray(x.props.children).map((e, s) => {
142
- if (i(e, "Table.Row")) {
143
- const r = e;
144
- return y(r.props.children, s, r.props);
145
- }
146
- return c.isValidElement(e) && typeof e.type == "string" && e.type === "tr" ? e : y(e, s);
147
- });
148
- return /* @__PURE__ */ o("tbody", { className: n.tbody, children: l });
149
- }
150
- const t = H.map((l, e) => {
151
- if (i(l, "Table.Row")) {
152
- const s = l;
153
- return y(s.props.children, e, s.props);
154
- }
155
- return c.isValidElement(l) && typeof l.type == "string" && l.type === "tr" ? l : y(l, e);
156
- });
157
- return /* @__PURE__ */ o("tbody", { className: n.tbody, children: t });
158
- };
159
- return /* @__PURE__ */ K("table", { className: m(n.table, D, M && n["table-alternating"]), ...L, children: [
160
- O(),
161
- Q()
162
- ] });
163
- };
164
- u.Columns = S;
165
- u.Column = v;
166
- u.Body = V;
167
- u.Row = j;
168
- u.Cell = z;
169
- export {
170
- u as T,
171
- n as s
172
- };