@caseparts-org/caseblocks 0.0.148 → 0.0.150

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 u } 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: i }) => null;
21
+ V.displayName = "Table.Columns";
22
+ const v = ({ children: i }) => null;
23
+ v.displayName = "Table.Column";
24
+ const j = ({ children: i }) => null;
25
+ j.displayName = "Table.Body";
26
+ const M = ({ children: i }) => null;
27
+ M.displayName = "Table.Row";
28
+ const O = ({ children: i }) => null;
29
+ O.displayName = "Table.Cell";
30
+ const f = ({ children: i, 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 m = (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(i, (t) => {
38
+ m(t, "Table.Columns") ? R = t : m(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 (m(l, "Table.Column")) {
51
+ const c = l, {
52
+ children: a,
53
+ align: r,
54
+ colSpan: C,
55
+ width: b,
56
+ style: N,
57
+ sortField: y,
58
+ sortFieldKey: o,
59
+ ...k
60
+ } = c.props, E = {
61
+ textAlign: r ?? "left",
62
+ width: b,
63
+ ...N
64
+ }, T = r === "right" ? "flex-end" : r === "center" ? "center" : "flex-start", _ = !!y, x = w && _ && (_ && q === y) && (o !== void 0 ? G === o : !0), p = w && _ && typeof F == "function";
65
+ return /* @__PURE__ */ s(
66
+ "th",
67
+ {
68
+ className: u(n.th, x && n["sorted-column"], p && n.clickableHeader),
69
+ style: E,
70
+ colSpan: C,
71
+ onClick: p ? () => F(y, o) : void 0,
72
+ ...k,
73
+ children: /* @__PURE__ */ S("div", { className: n.columnContent, style: { justifyContent: T }, children: [
74
+ a,
75
+ x && /* @__PURE__ */ s("span", { className: u(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, k) => {
85
+ if (m(o, "Table.Cell")) {
86
+ const E = o, {
87
+ children: T,
88
+ align: _,
89
+ colSpan: H,
90
+ width: K,
91
+ style: x,
92
+ ...p
93
+ } = E.props, W = {
94
+ textAlign: _ ?? "left",
95
+ width: K,
96
+ ...x
97
+ }, X = !!(p && typeof p.onClick == "function");
98
+ return /* @__PURE__ */ s(
99
+ "td",
100
+ {
101
+ className: u(
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: H,
109
+ ...p,
110
+ children: T
111
+ },
112
+ k
113
+ );
114
+ }
115
+ return d.isValidElement(o) && typeof o.type == "string" && o.type === "td" ? o : /* @__PURE__ */ s(
116
+ "td",
117
+ {
118
+ className: u(
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
+ k
126
+ );
127
+ }), { className: a, style: r, isExpanded: C, isExpandedContent: b, ...N } = e ?? {}, y = !!(e && typeof e.onClick == "function");
128
+ return /* @__PURE__ */ s(
129
+ "tr",
130
+ {
131
+ className: u(
132
+ n.row,
133
+ a,
134
+ C && n.expandedRow,
135
+ b && n.noPaddingRow,
136
+ b && n.expandedContentRow,
137
+ y && n.clickableRow
138
+ ),
139
+ style: r,
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, r) => {
148
+ if (m(a, "Table.Row")) {
149
+ const C = a;
150
+ return h(C.props.children, r, C.props);
151
+ }
152
+ return d.isValidElement(a) && typeof a.type == "string" && a.type === "tr" ? a : h(a, r);
153
+ });
154
+ return /* @__PURE__ */ s("tbody", { className: n.tbody, children: c });
155
+ }
156
+ const l = A(B).map((e, c) => {
157
+ if (m(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: u(n.table, z, D && n["table-alternating"]), ...L, children: [
166
+ Q(),
167
+ U()
168
+ ] });
169
+ };
170
+ f.Columns = V;
171
+ f.Column = v;
172
+ f.Body = j;
173
+ f.Row = M;
174
+ f.Cell = O;
175
+ export {
176
+ f 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-DwAM6AAI.js";
42
+ import { T as Ho } from "./Table-BX4PtCNE.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-DwAM6AAI.js";
4
+ import { T as i, T as e } from "../../Table-BX4PtCNE.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-DwAM6AAI.js";
2
+ import R, { useState as d, useEffect as P } from "react";
3
+ import { T as t, s as x } from "../../Table-BX4PtCNE.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.148",
4
+ "version": "0.0.150",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",
@@ -1,178 +0,0 @@
1
- import { jsxs as K, jsx as s } from "react/jsx-runtime";
2
- import c from "react";
3
- import { c as C } 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
- }, S = ({ children: r }) => null;
21
- S.displayName = "Table.Columns";
22
- const V = ({ children: r }) => null;
23
- V.displayName = "Table.Column";
24
- const v = ({ children: r }) => null;
25
- v.displayName = "Table.Body";
26
- const j = ({ children: r }) => null;
27
- j.displayName = "Table.Row";
28
- const M = ({ children: r }) => null;
29
- M.displayName = "Table.Cell";
30
- const y = ({ children: r, className: O, alternatingRows: z = !1, isSortable: w = !1, sortField: D, sortFieldKey: q, sortOrder: G = "descending", onSort: F, ...J }) => {
31
- const A = [];
32
- let x, R;
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(r, (t) => {
38
- i(t, "Table.Columns") ? x = t : i(t, "Table.Body") ? R = t : A.push(t);
39
- });
40
- const L = (t) => t.flatMap((l) => {
41
- if (c.isValidElement(l) && l.type === c.Fragment) {
42
- const e = l.props.children;
43
- return c.Children.toArray(e);
44
- }
45
- return [l];
46
- }), Q = () => {
47
- if (!x) return null;
48
- const t = c.Children.toArray(x.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 a = l, {
52
- children: d,
53
- align: m,
54
- colSpan: g,
55
- width: b,
56
- style: N,
57
- sortField: p,
58
- sortFieldKey: o,
59
- ...h
60
- } = a.props, E = {
61
- textAlign: m ?? "left",
62
- width: b,
63
- ...N
64
- }, u = !!p, f = w && u && (u && D === p) && (o !== void 0 ? q === o : !0), k = w && u && typeof F == "function";
65
- return /* @__PURE__ */ s(
66
- "th",
67
- {
68
- className: C(n.th, f && n["sorted-column"], k && n.clickableHeader),
69
- style: E,
70
- colSpan: g,
71
- onClick: k ? () => F(p, o) : void 0,
72
- ...h,
73
- children: /* @__PURE__ */ K("div", { className: n.columnContent, children: [
74
- d,
75
- f && /* @__PURE__ */ s("span", { className: C(G === "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
- }, _ = (t, l, e) => {
84
- const a = c.Children.toArray(t).map((o, h) => {
85
- if (i(o, "Table.Cell")) {
86
- const E = o, {
87
- children: u,
88
- align: H,
89
- colSpan: B,
90
- width: f,
91
- style: k,
92
- ...T
93
- } = E.props, W = {
94
- textAlign: H ?? "left",
95
- width: f,
96
- ...k
97
- }, X = !!(T && typeof T.onClick == "function");
98
- return /* @__PURE__ */ s(
99
- "td",
100
- {
101
- className: C(
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: B,
109
- ...T,
110
- children: u
111
- },
112
- h
113
- );
114
- }
115
- return c.isValidElement(o) && typeof o.type == "string" && o.type === "td" ? o : /* @__PURE__ */ s(
116
- "td",
117
- {
118
- className: C(
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
- h
126
- );
127
- }), { className: d, style: m, isExpanded: g, isExpandedContent: b, ...N } = e ?? {}, p = !!(e && typeof e.onClick == "function");
128
- return /* @__PURE__ */ s(
129
- "tr",
130
- {
131
- className: C(
132
- n.row,
133
- d,
134
- g && n.expandedRow,
135
- b && n.noPaddingRow,
136
- b && n.expandedContentRow,
137
- p && n.clickableRow
138
- ),
139
- style: m,
140
- ...N,
141
- children: a
142
- },
143
- l
144
- );
145
- }, U = () => {
146
- if (R) {
147
- const e = c.Children.toArray(R.props.children).map((a, d) => {
148
- if (i(a, "Table.Row")) {
149
- const m = a;
150
- return _(m.props.children, d, m.props);
151
- }
152
- return c.isValidElement(a) && typeof a.type == "string" && a.type === "tr" ? a : _(a, d);
153
- });
154
- return /* @__PURE__ */ s("tbody", { className: n.tbody, children: e });
155
- }
156
- const l = L(A).map((e, a) => {
157
- if (i(e, "Table.Row")) {
158
- const d = e;
159
- return _(d.props.children, a, d.props);
160
- }
161
- return c.isValidElement(e) && typeof e.type == "string" && e.type === "tr" ? e : _(e, a);
162
- });
163
- return /* @__PURE__ */ s("tbody", { className: n.tbody, children: l });
164
- };
165
- return /* @__PURE__ */ K("table", { className: C(n.table, O, z && n["table-alternating"]), ...J, children: [
166
- Q(),
167
- U()
168
- ] });
169
- };
170
- y.Columns = S;
171
- y.Column = V;
172
- y.Body = v;
173
- y.Row = j;
174
- y.Cell = M;
175
- export {
176
- y as T,
177
- n as s
178
- };