@oods/components-react 0.3.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.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +35 -0
- package/dist/chunk-A4T7OOIY.js +1191 -0
- package/dist/chunk-G74PKSW3.js +338 -0
- package/dist/chunk-YCI5AEWL.js +187 -0
- package/dist/index.cjs +3605 -0
- package/dist/index.d.cts +287 -0
- package/dist/index.d.ts +287 -0
- package/dist/index.js +1781 -0
- package/dist/ported.cjs +1551 -0
- package/dist/ported.d.cts +163 -0
- package/dist/ported.d.ts +163 -0
- package/dist/ported.js +2 -0
- package/dist/status.cjs +346 -0
- package/dist/status.d.cts +35 -0
- package/dist/status.d.ts +35 -0
- package/dist/status.js +1 -0
- package/dist/table.cjs +515 -0
- package/dist/table.d.cts +12 -0
- package/dist/table.d.ts +12 -0
- package/dist/table.js +2 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +580 -0
- package/dist/types.d.ts +580 -0
- package/dist/types.js +1 -0
- package/evidence/react-ported-readiness.v1.json +113 -0
- package/evidence/react-readiness.v1.json +8000 -0
- package/package.json +79 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentTone } from './types.cjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
type StatusTone = ComponentTone;
|
|
5
|
+
type StatusDomain = string;
|
|
6
|
+
type StatusTokenSet = {
|
|
7
|
+
readonly background: string;
|
|
8
|
+
readonly border: string;
|
|
9
|
+
readonly foreground: string;
|
|
10
|
+
};
|
|
11
|
+
type StatusPresentation = {
|
|
12
|
+
readonly domain: StatusDomain;
|
|
13
|
+
readonly status: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly tone: StatusTone;
|
|
17
|
+
readonly iconName?: string;
|
|
18
|
+
readonly badge: {
|
|
19
|
+
readonly subtle: StatusTokenSet;
|
|
20
|
+
readonly solid: StatusTokenSet;
|
|
21
|
+
};
|
|
22
|
+
readonly banner: {
|
|
23
|
+
readonly subtle: StatusTokenSet;
|
|
24
|
+
readonly solid: StatusTokenSet;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare const STATUS_DOMAINS: readonly StatusDomain[];
|
|
28
|
+
declare function getStatusPresentation(domain: StatusDomain, status: string): StatusPresentation;
|
|
29
|
+
declare function listStatuses(domain: StatusDomain): readonly StatusPresentation[];
|
|
30
|
+
declare function getToneTokenSet(tone: StatusTone): StatusTokenSet;
|
|
31
|
+
declare function getBannerToneTokenSet(tone: StatusTone): StatusTokenSet;
|
|
32
|
+
declare function resolveStatusGlyph(iconName: string | undefined): string | undefined;
|
|
33
|
+
declare function defaultStatusGlyph(): string;
|
|
34
|
+
|
|
35
|
+
export { STATUS_DOMAINS, type StatusDomain, type StatusPresentation, type StatusTokenSet, type StatusTone, defaultStatusGlyph, getBannerToneTokenSet, getStatusPresentation, getToneTokenSet, listStatuses, resolveStatusGlyph };
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentTone } from './types.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
type StatusTone = ComponentTone;
|
|
5
|
+
type StatusDomain = string;
|
|
6
|
+
type StatusTokenSet = {
|
|
7
|
+
readonly background: string;
|
|
8
|
+
readonly border: string;
|
|
9
|
+
readonly foreground: string;
|
|
10
|
+
};
|
|
11
|
+
type StatusPresentation = {
|
|
12
|
+
readonly domain: StatusDomain;
|
|
13
|
+
readonly status: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly tone: StatusTone;
|
|
17
|
+
readonly iconName?: string;
|
|
18
|
+
readonly badge: {
|
|
19
|
+
readonly subtle: StatusTokenSet;
|
|
20
|
+
readonly solid: StatusTokenSet;
|
|
21
|
+
};
|
|
22
|
+
readonly banner: {
|
|
23
|
+
readonly subtle: StatusTokenSet;
|
|
24
|
+
readonly solid: StatusTokenSet;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare const STATUS_DOMAINS: readonly StatusDomain[];
|
|
28
|
+
declare function getStatusPresentation(domain: StatusDomain, status: string): StatusPresentation;
|
|
29
|
+
declare function listStatuses(domain: StatusDomain): readonly StatusPresentation[];
|
|
30
|
+
declare function getToneTokenSet(tone: StatusTone): StatusTokenSet;
|
|
31
|
+
declare function getBannerToneTokenSet(tone: StatusTone): StatusTokenSet;
|
|
32
|
+
declare function resolveStatusGlyph(iconName: string | undefined): string | undefined;
|
|
33
|
+
declare function defaultStatusGlyph(): string;
|
|
34
|
+
|
|
35
|
+
export { STATUS_DOMAINS, type StatusDomain, type StatusPresentation, type StatusTokenSet, type StatusTone, defaultStatusGlyph, getBannerToneTokenSet, getStatusPresentation, getToneTokenSet, listStatuses, resolveStatusGlyph };
|
package/dist/status.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { STATUS_DOMAINS, defaultStatusGlyph, getBannerToneTokenSet, getStatusPresentation, getToneTokenSet, listStatuses, resolveStatusGlyph } from './chunk-G74PKSW3.js';
|
package/dist/table.cjs
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
25
|
+
|
|
26
|
+
// src/table.tsx
|
|
27
|
+
|
|
28
|
+
// src/status-map.json
|
|
29
|
+
var status_map_default = {
|
|
30
|
+
domains: {
|
|
31
|
+
subscription: {
|
|
32
|
+
future: {
|
|
33
|
+
description: "Subscription is scheduled but not yet active.",
|
|
34
|
+
chip: {
|
|
35
|
+
foreground: "color.text.info",
|
|
36
|
+
background: "color.background.info.subtle",
|
|
37
|
+
border: "color.border.info",
|
|
38
|
+
icon: "icon.status.scheduled"
|
|
39
|
+
},
|
|
40
|
+
banner: {
|
|
41
|
+
foreground: "color.text.info",
|
|
42
|
+
background: "color.background.surface.default",
|
|
43
|
+
border: "color.border.info",
|
|
44
|
+
icon: "icon.status.scheduled"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
trialing: {
|
|
48
|
+
description: "Subscription is in a trial period before billing begins.",
|
|
49
|
+
chip: {
|
|
50
|
+
foreground: "color.text.accent",
|
|
51
|
+
background: "color.background.accent.subtle",
|
|
52
|
+
border: "color.border.accent",
|
|
53
|
+
icon: "icon.status.trial"
|
|
54
|
+
},
|
|
55
|
+
banner: {
|
|
56
|
+
foreground: "color.text.accent",
|
|
57
|
+
background: "color.background.surface.default",
|
|
58
|
+
border: "color.border.accent",
|
|
59
|
+
icon: "icon.status.trial"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
active: {
|
|
63
|
+
description: "Subscription is paid and service is provisioned.",
|
|
64
|
+
chip: {
|
|
65
|
+
foreground: "color.text.positive",
|
|
66
|
+
background: "color.background.positive.subtle",
|
|
67
|
+
border: "color.border.positive",
|
|
68
|
+
icon: "icon.status.success"
|
|
69
|
+
},
|
|
70
|
+
banner: {
|
|
71
|
+
foreground: "color.text.positive",
|
|
72
|
+
background: "color.background.surface.default",
|
|
73
|
+
border: "color.border.positive",
|
|
74
|
+
icon: "icon.status.success"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
paused: {
|
|
78
|
+
description: "Billing paused temporarily by finance or customer request.",
|
|
79
|
+
chip: {
|
|
80
|
+
foreground: "color.text.neutral",
|
|
81
|
+
background: "color.background.neutral.subtle",
|
|
82
|
+
border: "color.border.neutral",
|
|
83
|
+
icon: "icon.status.paused"
|
|
84
|
+
},
|
|
85
|
+
banner: {
|
|
86
|
+
foreground: "color.text.neutral",
|
|
87
|
+
background: "color.background.surface.muted",
|
|
88
|
+
border: "color.border.neutral",
|
|
89
|
+
icon: "icon.status.paused"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
pending_cancellation: {
|
|
93
|
+
description: "Subscription will cancel at period end but remains active now.",
|
|
94
|
+
chip: {
|
|
95
|
+
foreground: "color.text.info",
|
|
96
|
+
background: "color.background.info.subtle",
|
|
97
|
+
border: "color.border.info",
|
|
98
|
+
icon: "icon.status.pending"
|
|
99
|
+
},
|
|
100
|
+
banner: {
|
|
101
|
+
foreground: "color.text.info",
|
|
102
|
+
background: "color.background.surface.default",
|
|
103
|
+
border: "color.border.info",
|
|
104
|
+
icon: "icon.status.pending"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
past_due: {
|
|
108
|
+
description: "Renewal payment failed; smart retries ongoing and access retained during the grace window.",
|
|
109
|
+
chip: {
|
|
110
|
+
foreground: "color.text.danger",
|
|
111
|
+
background: "color.background.danger.subtle",
|
|
112
|
+
border: "color.border.danger",
|
|
113
|
+
icon: "icon.status.warning"
|
|
114
|
+
},
|
|
115
|
+
banner: {
|
|
116
|
+
foreground: "color.text.onbold",
|
|
117
|
+
background: "color.background.danger.bold",
|
|
118
|
+
border: "color.border.danger",
|
|
119
|
+
icon: "icon.status.warning"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
unpaid: {
|
|
123
|
+
description: "Payment retries exhausted; service access revoked.",
|
|
124
|
+
chip: {
|
|
125
|
+
foreground: "color.text.danger",
|
|
126
|
+
background: "color.background.danger.subtle",
|
|
127
|
+
border: "color.border.danger",
|
|
128
|
+
icon: "icon.status.error"
|
|
129
|
+
},
|
|
130
|
+
banner: {
|
|
131
|
+
foreground: "color.text.onbold",
|
|
132
|
+
background: "color.background.danger.bold",
|
|
133
|
+
border: "color.border.danger",
|
|
134
|
+
icon: "icon.status.error"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
terminated: {
|
|
138
|
+
description: "Subscription ended; service access revoked and billing stopped.",
|
|
139
|
+
chip: {
|
|
140
|
+
foreground: "color.text.disabled",
|
|
141
|
+
background: "color.background.disabled",
|
|
142
|
+
border: "color.border.disabled",
|
|
143
|
+
icon: "icon.status.canceled"
|
|
144
|
+
},
|
|
145
|
+
banner: {
|
|
146
|
+
foreground: "color.text.neutral",
|
|
147
|
+
background: "color.background.neutral.subtle",
|
|
148
|
+
border: "color.border.neutral",
|
|
149
|
+
icon: "icon.status.canceled"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
invoice: {
|
|
154
|
+
draft: {
|
|
155
|
+
description: "Invoice is editable and not yet finalized.",
|
|
156
|
+
chip: {
|
|
157
|
+
foreground: "color.text.neutral",
|
|
158
|
+
background: "color.background.neutral.subtle",
|
|
159
|
+
border: "color.border.neutral",
|
|
160
|
+
icon: "icon.status.draft"
|
|
161
|
+
},
|
|
162
|
+
banner: {
|
|
163
|
+
foreground: "color.text.neutral",
|
|
164
|
+
background: "color.background.surface.muted",
|
|
165
|
+
border: "color.border.neutral",
|
|
166
|
+
icon: "icon.status.draft"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
posted: {
|
|
170
|
+
description: "Invoice finalized with terms before collection.",
|
|
171
|
+
chip: {
|
|
172
|
+
foreground: "color.text.info",
|
|
173
|
+
background: "color.background.info.subtle",
|
|
174
|
+
border: "color.border.info",
|
|
175
|
+
icon: "icon.status.pending"
|
|
176
|
+
},
|
|
177
|
+
banner: {
|
|
178
|
+
foreground: "color.text.info",
|
|
179
|
+
background: "color.background.surface.default",
|
|
180
|
+
border: "color.border.info",
|
|
181
|
+
icon: "icon.status.pending"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
paid: {
|
|
185
|
+
description: "Invoice collected successfully in full.",
|
|
186
|
+
chip: {
|
|
187
|
+
foreground: "color.text.positive",
|
|
188
|
+
background: "color.background.positive.subtle",
|
|
189
|
+
border: "color.border.positive",
|
|
190
|
+
icon: "icon.status.success"
|
|
191
|
+
},
|
|
192
|
+
banner: {
|
|
193
|
+
foreground: "color.text.positive",
|
|
194
|
+
background: "color.background.surface.default",
|
|
195
|
+
border: "color.border.positive",
|
|
196
|
+
icon: "icon.status.success"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
past_due: {
|
|
200
|
+
description: "Invoice is unpaid past its due date.",
|
|
201
|
+
chip: {
|
|
202
|
+
foreground: "color.text.danger",
|
|
203
|
+
background: "color.background.danger.subtle",
|
|
204
|
+
border: "color.border.danger",
|
|
205
|
+
icon: "icon.status.error"
|
|
206
|
+
},
|
|
207
|
+
banner: {
|
|
208
|
+
foreground: "color.text.onbold",
|
|
209
|
+
background: "color.background.danger.bold",
|
|
210
|
+
border: "color.border.danger",
|
|
211
|
+
icon: "icon.status.error"
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
void: {
|
|
215
|
+
description: "Invoice canceled and no longer payable.",
|
|
216
|
+
chip: {
|
|
217
|
+
foreground: "color.text.disabled",
|
|
218
|
+
background: "color.background.disabled",
|
|
219
|
+
border: "color.border.disabled",
|
|
220
|
+
icon: "icon.status.void"
|
|
221
|
+
},
|
|
222
|
+
banner: {
|
|
223
|
+
foreground: "color.text.neutral",
|
|
224
|
+
background: "color.background.neutral.subtle",
|
|
225
|
+
border: "color.border.neutral",
|
|
226
|
+
icon: "icon.status.void"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// src/status.ts
|
|
234
|
+
var TONE_ALIASES = {
|
|
235
|
+
info: "info",
|
|
236
|
+
informational: "info",
|
|
237
|
+
accent: "accent",
|
|
238
|
+
highlight: "accent",
|
|
239
|
+
positive: "success",
|
|
240
|
+
success: "success",
|
|
241
|
+
ok: "success",
|
|
242
|
+
warning: "warning",
|
|
243
|
+
caution: "warning",
|
|
244
|
+
danger: "critical",
|
|
245
|
+
critical: "critical",
|
|
246
|
+
error: "critical",
|
|
247
|
+
negative: "critical",
|
|
248
|
+
neutral: "neutral",
|
|
249
|
+
pending: "info"
|
|
250
|
+
};
|
|
251
|
+
var toLabel = (status) => status.split(/[_-]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
|
|
252
|
+
var inferTone = (entry) => {
|
|
253
|
+
if (!entry) return "neutral";
|
|
254
|
+
for (const reference of [entry.foreground, entry.background, entry.border]) {
|
|
255
|
+
const segments = reference.replace(/^\{|\}$/g, "").split(/[\s./_-]+/).reverse();
|
|
256
|
+
for (const segment of segments) {
|
|
257
|
+
const tone = TONE_ALIASES[segment.toLowerCase()];
|
|
258
|
+
if (tone) return tone;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return "neutral";
|
|
262
|
+
};
|
|
263
|
+
var componentTokenSet = (tone) => {
|
|
264
|
+
const normalized = tone === "positive" ? "success" : tone === "danger" ? "critical" : tone;
|
|
265
|
+
return {
|
|
266
|
+
background: `var(--sys-status-${normalized}-surface)`,
|
|
267
|
+
border: `var(--sys-status-${normalized}-border)`,
|
|
268
|
+
foreground: `var(--sys-status-${normalized}-text)`
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
var rawTokenSet = (entry) => {
|
|
272
|
+
const tone = inferTone(entry);
|
|
273
|
+
return componentTokenSet(tone);
|
|
274
|
+
};
|
|
275
|
+
var bannerFallback = (tone) => tone === "neutral" ? {
|
|
276
|
+
background: "var(--cmp-banner-background)",
|
|
277
|
+
border: "var(--cmp-banner-border)",
|
|
278
|
+
foreground: "var(--cmp-banner-text)"
|
|
279
|
+
} : componentTokenSet(tone);
|
|
280
|
+
var fallback = (domain, status, tone = "neutral") => ({
|
|
281
|
+
domain,
|
|
282
|
+
status,
|
|
283
|
+
label: toLabel(status || "Unknown"),
|
|
284
|
+
description: "Status not found in registry; falling back to the requested token set.",
|
|
285
|
+
tone,
|
|
286
|
+
badge: { subtle: componentTokenSet(tone), solid: componentTokenSet(tone) },
|
|
287
|
+
banner: { subtle: bannerFallback(tone), solid: componentTokenSet(tone) }
|
|
288
|
+
});
|
|
289
|
+
var registry = /* @__PURE__ */ new Map();
|
|
290
|
+
for (const [domain, entries] of Object.entries(status_map_default.domains)) {
|
|
291
|
+
const domainEntries = /* @__PURE__ */ new Map();
|
|
292
|
+
for (const [status, entry] of Object.entries(entries)) {
|
|
293
|
+
const tone = inferTone(entry.chip);
|
|
294
|
+
domainEntries.set(status.toLowerCase(), {
|
|
295
|
+
domain,
|
|
296
|
+
status,
|
|
297
|
+
label: toLabel(status),
|
|
298
|
+
description: entry.description,
|
|
299
|
+
tone,
|
|
300
|
+
iconName: entry.chip.icon ?? entry.banner?.icon,
|
|
301
|
+
badge: { subtle: rawTokenSet(entry.chip), solid: componentTokenSet(tone) },
|
|
302
|
+
banner: {
|
|
303
|
+
subtle: entry.banner ? rawTokenSet(entry.banner) : bannerFallback(tone),
|
|
304
|
+
solid: componentTokenSet(tone)
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
registry.set(domain, domainEntries);
|
|
309
|
+
}
|
|
310
|
+
var LEGACY_STATUS_ALIASES = {
|
|
311
|
+
subscription: { delinquent: "unpaid" }
|
|
312
|
+
};
|
|
313
|
+
Object.freeze([...registry.keys()]);
|
|
314
|
+
function getStatusPresentation(domain, status) {
|
|
315
|
+
const entries = registry.get(domain);
|
|
316
|
+
if (!entries) return fallback(domain, status);
|
|
317
|
+
const normalized = status.toLowerCase();
|
|
318
|
+
const direct = entries.get(normalized);
|
|
319
|
+
if (direct) return direct;
|
|
320
|
+
const alias = LEGACY_STATUS_ALIASES[domain]?.[normalized];
|
|
321
|
+
const aliased = alias ? entries.get(alias) : void 0;
|
|
322
|
+
return aliased ? { ...aliased, status, label: toLabel(status) } : fallback(domain, status);
|
|
323
|
+
}
|
|
324
|
+
function getToneTokenSet(tone) {
|
|
325
|
+
return componentTokenSet(tone);
|
|
326
|
+
}
|
|
327
|
+
var classes = (...values) => values.filter(Boolean).join(" ");
|
|
328
|
+
var TableHead = React__namespace.forwardRef(
|
|
329
|
+
({ className, ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: classes("oods-table__header", className), ...rest })
|
|
330
|
+
);
|
|
331
|
+
TableHead.displayName = "OODS.Table.Head";
|
|
332
|
+
var TableBody = React__namespace.forwardRef(
|
|
333
|
+
({ className, ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className: classes("oods-table__body", className), ...rest })
|
|
334
|
+
);
|
|
335
|
+
TableBody.displayName = "OODS.Table.Body";
|
|
336
|
+
var TableCaption = React__namespace.forwardRef(
|
|
337
|
+
({ className, ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className: classes("oods-table__caption", className), ...rest })
|
|
338
|
+
);
|
|
339
|
+
TableCaption.displayName = "OODS.Table.Caption";
|
|
340
|
+
var TableRow = React__namespace.forwardRef(
|
|
341
|
+
({
|
|
342
|
+
selectable = false,
|
|
343
|
+
selected = false,
|
|
344
|
+
onActivate,
|
|
345
|
+
className,
|
|
346
|
+
tabIndex,
|
|
347
|
+
onClick,
|
|
348
|
+
onKeyDown,
|
|
349
|
+
...rest
|
|
350
|
+
}, ref) => {
|
|
351
|
+
const handleClick = (event) => {
|
|
352
|
+
onClick?.(event);
|
|
353
|
+
if (!event.defaultPrevented) onActivate?.(event);
|
|
354
|
+
};
|
|
355
|
+
const handleKeyDown = (event) => {
|
|
356
|
+
onKeyDown?.(event);
|
|
357
|
+
if (!event.defaultPrevented && selectable && (event.key === "Enter" || event.key === " ")) {
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
onActivate?.(event);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
363
|
+
"tr",
|
|
364
|
+
{
|
|
365
|
+
ref,
|
|
366
|
+
className: classes("oods-table__row", className),
|
|
367
|
+
"data-selectable": selectable ? "true" : void 0,
|
|
368
|
+
"data-selected": selected ? "true" : void 0,
|
|
369
|
+
"aria-selected": selectable ? selected : void 0,
|
|
370
|
+
tabIndex: selectable ? tabIndex ?? 0 : tabIndex,
|
|
371
|
+
onClick: handleClick,
|
|
372
|
+
onKeyDown: handleKeyDown,
|
|
373
|
+
...rest
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
TableRow.displayName = "OODS.Table.Row";
|
|
379
|
+
var TableHeaderCell = React__namespace.forwardRef(
|
|
380
|
+
({ numeric = false, className, scope = "col", ...rest }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
381
|
+
"th",
|
|
382
|
+
{
|
|
383
|
+
ref,
|
|
384
|
+
className: classes(
|
|
385
|
+
"oods-table__header-cell",
|
|
386
|
+
numeric && "oods-table__header-cell--numeric",
|
|
387
|
+
className
|
|
388
|
+
),
|
|
389
|
+
"data-numeric": numeric ? "true" : void 0,
|
|
390
|
+
scope,
|
|
391
|
+
...rest
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
);
|
|
395
|
+
TableHeaderCell.displayName = "OODS.Table.HeaderCell";
|
|
396
|
+
var TableCell = React__namespace.forwardRef(
|
|
397
|
+
({
|
|
398
|
+
numeric = false,
|
|
399
|
+
status,
|
|
400
|
+
statusDomain = "subscription",
|
|
401
|
+
tone: toneOverride,
|
|
402
|
+
statusEmphasis = "surface",
|
|
403
|
+
className,
|
|
404
|
+
children,
|
|
405
|
+
style,
|
|
406
|
+
title,
|
|
407
|
+
...rest
|
|
408
|
+
}, ref) => {
|
|
409
|
+
const presentation = status ? getStatusPresentation(statusDomain, status) : void 0;
|
|
410
|
+
const tone = toneOverride ?? presentation?.tone;
|
|
411
|
+
const tokens = tone ? getToneTokenSet(tone) : void 0;
|
|
412
|
+
const statusStyle = tokens ? statusEmphasis === "text" ? { "--table-cell-status-foreground": tokens.foreground } : {
|
|
413
|
+
"--table-cell-status-background": tokens.background,
|
|
414
|
+
"--table-cell-status-border": tokens.border,
|
|
415
|
+
"--table-cell-status-foreground": tokens.foreground
|
|
416
|
+
} : {};
|
|
417
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
418
|
+
"td",
|
|
419
|
+
{
|
|
420
|
+
ref,
|
|
421
|
+
className: classes(
|
|
422
|
+
"oods-table__cell",
|
|
423
|
+
numeric && "oods-table__cell--numeric",
|
|
424
|
+
status && "oods-table__cell--status",
|
|
425
|
+
className
|
|
426
|
+
),
|
|
427
|
+
"data-numeric": numeric ? "true" : void 0,
|
|
428
|
+
"data-status": status,
|
|
429
|
+
"data-status-domain": status ? statusDomain : void 0,
|
|
430
|
+
"data-status-tone": status ? tone : void 0,
|
|
431
|
+
"data-status-emphasis": status ? statusEmphasis : void 0,
|
|
432
|
+
"data-has-status": status ? "true" : void 0,
|
|
433
|
+
title: title ?? presentation?.description,
|
|
434
|
+
style: { ...statusStyle, ...style },
|
|
435
|
+
...rest,
|
|
436
|
+
children: children ?? presentation?.label ?? status
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
TableCell.displayName = "OODS.Table.Cell";
|
|
442
|
+
var TableRoot = React__namespace.forwardRef(
|
|
443
|
+
({
|
|
444
|
+
caption,
|
|
445
|
+
columns,
|
|
446
|
+
rows,
|
|
447
|
+
density = "comfortable",
|
|
448
|
+
selectable = false,
|
|
449
|
+
onRowActivate,
|
|
450
|
+
children,
|
|
451
|
+
containerClassName,
|
|
452
|
+
containerStyle,
|
|
453
|
+
className,
|
|
454
|
+
...rest
|
|
455
|
+
}, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
456
|
+
"div",
|
|
457
|
+
{
|
|
458
|
+
className: classes("oods-table__container", containerClassName),
|
|
459
|
+
style: containerStyle,
|
|
460
|
+
"data-density": density,
|
|
461
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
462
|
+
"table",
|
|
463
|
+
{
|
|
464
|
+
ref,
|
|
465
|
+
className: classes("oods-table", className),
|
|
466
|
+
"data-oods-component": "Table",
|
|
467
|
+
"data-density": density,
|
|
468
|
+
...rest,
|
|
469
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
470
|
+
caption ? /* @__PURE__ */ jsxRuntime.jsx(TableCaption, { children: caption }) : null,
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: columns?.map((column) => /* @__PURE__ */ jsxRuntime.jsx(TableHeaderCell, { numeric: column.numeric, children: column.label }, column.key)) }) }),
|
|
472
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: (rows?.length ?? 0) === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { className: "oods-table__row", children: /* @__PURE__ */ jsxRuntime.jsx(TableCell, { colSpan: Math.max(columns?.length ?? 0, 1), children: "No rows available." }) }) : rows?.map((row) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
473
|
+
"tr",
|
|
474
|
+
{
|
|
475
|
+
className: "oods-table__row",
|
|
476
|
+
"data-selectable": selectable ? "true" : void 0,
|
|
477
|
+
children: columns?.map((column, columnIndex) => {
|
|
478
|
+
const value = row[column.key];
|
|
479
|
+
const rendered = column.render ? column.render(value, row) : String(value ?? "");
|
|
480
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TableCell, { numeric: column.numeric, children: selectable && columnIndex === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
481
|
+
"button",
|
|
482
|
+
{
|
|
483
|
+
type: "button",
|
|
484
|
+
className: "oods-table-row-action",
|
|
485
|
+
onClick: (event) => onRowActivate?.(row.id, row, event),
|
|
486
|
+
children: rendered
|
|
487
|
+
}
|
|
488
|
+
) : rendered }, column.key);
|
|
489
|
+
})
|
|
490
|
+
},
|
|
491
|
+
row.id
|
|
492
|
+
)) })
|
|
493
|
+
] })
|
|
494
|
+
}
|
|
495
|
+
)
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
);
|
|
499
|
+
TableRoot.displayName = "OODS.Table";
|
|
500
|
+
var Table = Object.assign(TableRoot, {
|
|
501
|
+
Head: TableHead,
|
|
502
|
+
Body: TableBody,
|
|
503
|
+
Caption: TableCaption,
|
|
504
|
+
Row: TableRow,
|
|
505
|
+
HeaderCell: TableHeaderCell,
|
|
506
|
+
Cell: TableCell
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
exports.Table = Table;
|
|
510
|
+
exports.TableBody = TableBody;
|
|
511
|
+
exports.TableCaption = TableCaption;
|
|
512
|
+
exports.TableCell = TableCell;
|
|
513
|
+
exports.TableHead = TableHead;
|
|
514
|
+
exports.TableHeaderCell = TableHeaderCell;
|
|
515
|
+
exports.TableRow = TableRow;
|
package/dist/table.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TableCompound, TableHeadProps, TableBodyProps, TableRowProps, TableHeaderCellProps, TableCellProps } from './types.cjs';
|
|
3
|
+
|
|
4
|
+
declare const TableHead: React.ForwardRefExoticComponent<TableHeadProps & React.RefAttributes<HTMLTableSectionElement>>;
|
|
5
|
+
declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & React.RefAttributes<HTMLTableSectionElement>>;
|
|
6
|
+
declare const TableCaption: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLTableCaptionElement>>;
|
|
7
|
+
declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLTableRowElement>>;
|
|
8
|
+
declare const TableHeaderCell: React.ForwardRefExoticComponent<TableHeaderCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
9
|
+
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
10
|
+
declare const Table: TableCompound;
|
|
11
|
+
|
|
12
|
+
export { Table, TableBody, TableCaption, TableCell, TableHead, TableHeaderCell, TableRow };
|
package/dist/table.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TableCompound, TableHeadProps, TableBodyProps, TableRowProps, TableHeaderCellProps, TableCellProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare const TableHead: React.ForwardRefExoticComponent<TableHeadProps & React.RefAttributes<HTMLTableSectionElement>>;
|
|
5
|
+
declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & React.RefAttributes<HTMLTableSectionElement>>;
|
|
6
|
+
declare const TableCaption: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLTableCaptionElement>>;
|
|
7
|
+
declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLTableRowElement>>;
|
|
8
|
+
declare const TableHeaderCell: React.ForwardRefExoticComponent<TableHeaderCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
9
|
+
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
10
|
+
declare const Table: TableCompound;
|
|
11
|
+
|
|
12
|
+
export { Table, TableBody, TableCaption, TableCell, TableHead, TableHeaderCell, TableRow };
|
package/dist/table.js
ADDED
package/dist/types.cjs
ADDED