@gravitee/graphene-core 2.7.1 → 2.8.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/USAGE_GUIDE.md +3 -1
- package/dist/base/Table/Table.harness.d.ts +23 -0
- package/dist/base/Table/Table.harness.d.ts.map +1 -0
- package/dist/composed/CopyableText/CopyableText.d.ts +22 -0
- package/dist/composed/CopyableText/CopyableText.d.ts.map +1 -0
- package/dist/composed/CopyableText/index.d.ts +3 -0
- package/dist/composed/CopyableText/index.d.ts.map +1 -0
- package/dist/composed/DataTable/DataTable.harness.d.ts +26 -0
- package/dist/composed/DataTable/DataTable.harness.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6219 -6174
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +125 -5
- package/package.json +1 -1
package/dist/testing/index.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export { selectHarness } from '../base/Select/Select.harness';
|
|
|
13
13
|
export type { SelectHarness } from '../base/Select/Select.harness';
|
|
14
14
|
export { switchHarness } from '../base/Switch/Switch.harness';
|
|
15
15
|
export type { SwitchHarness } from '../base/Switch/Switch.harness';
|
|
16
|
+
export { tableHarness } from '../base/Table/Table.harness';
|
|
17
|
+
export type { TableHarness, TableRowHarness } from '../base/Table/Table.harness';
|
|
16
18
|
export { textareaHarness } from '../base/Textarea/Textarea.harness';
|
|
17
19
|
export type { TextareaHarness } from '../base/Textarea/Textarea.harness';
|
|
20
|
+
export { dataTableHarness } from '../composed/DataTable/DataTable.harness';
|
|
21
|
+
export type { DataTableHarness, DataTableRowHarness, } from '../composed/DataTable/DataTable.harness';
|
|
18
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAA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xF,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,YAAY,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4DAA4D,CAAC;AAC7G,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,4DAA4D,CAAC;AAClH,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,YAAY,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACnF,YAAY,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AACzF,YAAY,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,YAAY,EACV,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,8DAA8D,CAAC"}
|
package/dist/testing/index.js
CHANGED
|
@@ -197,19 +197,79 @@ function g(e = {}) {
|
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
199
|
//#endregion
|
|
200
|
+
//#region src/base/Table/Table.harness.tsx
|
|
201
|
+
function _(e, t) {
|
|
202
|
+
let n = (e.textContent ?? "").trim(), r = (e.getAttribute("aria-label") ?? "").trim();
|
|
203
|
+
return typeof t == "string" ? n === t || r === t : t.test(n) || t.test(r);
|
|
204
|
+
}
|
|
205
|
+
function v(e) {
|
|
206
|
+
return e.map((e) => {
|
|
207
|
+
let t = (e.textContent ?? "").trim(), n = (e.getAttribute("aria-label") ?? "").trim();
|
|
208
|
+
return t || (n ? `aria-label="${n}"` : "<empty>");
|
|
209
|
+
}).join(", ");
|
|
210
|
+
}
|
|
211
|
+
function y(e) {
|
|
212
|
+
let t = e.tHead;
|
|
213
|
+
return t ? Array.from(t.children).filter((e) => e.tagName === "TR").flatMap((e) => Array.from(e.children).filter((e) => e.tagName === "TH")) : [];
|
|
214
|
+
}
|
|
215
|
+
function b(e) {
|
|
216
|
+
return Array.from(e.tBodies).flatMap((e) => Array.from(e.children).filter((e) => e.tagName === "TR"));
|
|
217
|
+
}
|
|
218
|
+
function x(e, t) {
|
|
219
|
+
let n = () => Array.from(e.children).filter((e) => e.tagName === "TD"), r = (e) => {
|
|
220
|
+
let r = t(), i = r.findIndex((t) => _(t, e));
|
|
221
|
+
if (i === -1) throw Error(`tableHarness: header matching ${String(e)} not found in [${v(r)}]`);
|
|
222
|
+
let a = n();
|
|
223
|
+
if (!a[i]) throw Error(`tableHarness: row has ${a.length} cells, no cell at column index ${i}`);
|
|
224
|
+
return a[i];
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
getElement: () => e,
|
|
228
|
+
getCells: () => n().map((e) => (e.textContent ?? "").trim()),
|
|
229
|
+
getCellText: (e) => (r(e).textContent ?? "").trim(),
|
|
230
|
+
getCellElement: r
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function S(e = {}) {
|
|
234
|
+
let t = e.within ? i(e.within) : r, { name: n, selector: a } = e, o = () => a === void 0 ? n === void 0 ? t.getByRole("table") : t.getByRole("table", { name: n }) : c(n === void 0 ? t.getAllByRole("table") : t.getAllByRole("table", { name: n }), e, "table"), s = () => y(o()), l = () => s().map((e) => (e.textContent ?? "").trim()), u = () => b(o()), d = (e) => u().find((t) => {
|
|
235
|
+
let n = (t.textContent ?? "").trim();
|
|
236
|
+
return typeof e == "string" ? n.includes(e) : e.test(n);
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
getElement: o,
|
|
240
|
+
getHeaders: l,
|
|
241
|
+
getRowCount: () => u().length,
|
|
242
|
+
getRow: (e) => {
|
|
243
|
+
if (typeof e == "number") {
|
|
244
|
+
let t = u(), n = t[e];
|
|
245
|
+
if (!n) throw Error(`tableHarness: no row at index ${e} (count=${t.length})`);
|
|
246
|
+
return x(n, s);
|
|
247
|
+
}
|
|
248
|
+
let t = d(e);
|
|
249
|
+
if (!t) throw Error(`tableHarness: no row matching ${String(e)}`);
|
|
250
|
+
return x(t, s);
|
|
251
|
+
},
|
|
252
|
+
queryRow: (e) => {
|
|
253
|
+
let t = d(e);
|
|
254
|
+
return t ? x(t, s) : null;
|
|
255
|
+
},
|
|
256
|
+
getRows: () => u().map((e) => x(e, s))
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
200
260
|
//#region src/base/Textarea/Textarea.harness.tsx
|
|
201
|
-
function
|
|
261
|
+
function C(e) {
|
|
202
262
|
return e instanceof HTMLTextAreaElement;
|
|
203
263
|
}
|
|
204
|
-
function
|
|
264
|
+
function w(e = {}) {
|
|
205
265
|
let t = e.within ? i(e.within) : r, { name: n, selector: o } = e, s = () => {
|
|
206
266
|
if (o === void 0) {
|
|
207
267
|
let e = n === void 0 ? t.getByRole("textbox") : t.getByRole("textbox", { name: n });
|
|
208
|
-
if (!
|
|
268
|
+
if (!C(e)) throw Error(`textareaHarness: matched element is <${e.tagName.toLowerCase()}>, not <textarea>`);
|
|
209
269
|
return e;
|
|
210
270
|
}
|
|
211
271
|
let r = e.within ?? document.body;
|
|
212
|
-
return c(n === void 0 ? Array.from(r.querySelectorAll("textarea")) : t.getAllByRole("textbox", { name: n }).filter(
|
|
272
|
+
return c(n === void 0 ? Array.from(r.querySelectorAll("textarea")) : t.getAllByRole("textbox", { name: n }).filter(C), e, "textarea");
|
|
213
273
|
}, l = a.setup();
|
|
214
274
|
return {
|
|
215
275
|
type: (e) => l.type(s(), e),
|
|
@@ -225,4 +285,64 @@ function v(e = {}) {
|
|
|
225
285
|
};
|
|
226
286
|
}
|
|
227
287
|
//#endregion
|
|
228
|
-
|
|
288
|
+
//#region src/composed/DataTable/DataTable.harness.tsx
|
|
289
|
+
function T(e, t) {
|
|
290
|
+
let n = y(e), r = n.find((e) => _(e, t));
|
|
291
|
+
if (!r) throw Error(`dataTableHarness: header matching ${String(t)} not found in [${v(n)}]`);
|
|
292
|
+
return r;
|
|
293
|
+
}
|
|
294
|
+
function E(e = {}) {
|
|
295
|
+
let t = S(e), n = a.setup(), r = (e) => ({
|
|
296
|
+
...e,
|
|
297
|
+
isSelected: () => e.getElement().getAttribute("data-state") === "selected",
|
|
298
|
+
select: async () => {
|
|
299
|
+
let t = i(e.getElement()).getByRole("checkbox", { name: /select row/i });
|
|
300
|
+
t.getAttribute("aria-checked") !== "true" && await n.click(t);
|
|
301
|
+
},
|
|
302
|
+
unselect: async () => {
|
|
303
|
+
let t = i(e.getElement()).getByRole("checkbox", { name: /select row/i });
|
|
304
|
+
t.getAttribute("aria-checked") === "true" && await n.click(t);
|
|
305
|
+
}
|
|
306
|
+
}), o = () => {
|
|
307
|
+
let e = t.getElement().tHead;
|
|
308
|
+
if (!e) throw Error("dataTableHarness: <thead> not found");
|
|
309
|
+
return i(e).getByRole("checkbox", { name: /select all/i });
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
getElement: t.getElement,
|
|
313
|
+
getHeaders: t.getHeaders,
|
|
314
|
+
getRowCount: t.getRowCount,
|
|
315
|
+
getRow: (e) => r(t.getRow(e)),
|
|
316
|
+
queryRow: (e) => {
|
|
317
|
+
let n = t.queryRow(e);
|
|
318
|
+
return n ? r(n) : null;
|
|
319
|
+
},
|
|
320
|
+
getRows: () => t.getRows().map(r),
|
|
321
|
+
sortBy: async (e) => {
|
|
322
|
+
let r = T(t.getElement(), e), i = r.querySelector("button");
|
|
323
|
+
await n.click(i ?? r);
|
|
324
|
+
},
|
|
325
|
+
getSortDirection: (e) => {
|
|
326
|
+
let n = T(t.getElement(), e).getAttribute("aria-sort");
|
|
327
|
+
return n === "ascending" || n === "descending" || n === "none" ? n : null;
|
|
328
|
+
},
|
|
329
|
+
selectAll: async () => {
|
|
330
|
+
let e = o();
|
|
331
|
+
e.getAttribute("aria-checked") !== "true" && await n.click(e);
|
|
332
|
+
},
|
|
333
|
+
unselectAll: async () => {
|
|
334
|
+
let e = o();
|
|
335
|
+
e.getAttribute("aria-checked") !== "false" && await n.click(e);
|
|
336
|
+
},
|
|
337
|
+
getSelectedCount: () => t.getRows().filter((e) => e.getElement().getAttribute("data-state") === "selected").length,
|
|
338
|
+
isLoading: () => t.getElement().closest("[aria-busy]")?.getAttribute("aria-busy") === "true",
|
|
339
|
+
isEmpty: () => {
|
|
340
|
+
let e = t.getRows();
|
|
341
|
+
if (e.length !== 1) return !1;
|
|
342
|
+
let n = Array.from(e[0].getElement().children).filter((e) => e.tagName === "TD");
|
|
343
|
+
return n.length === 1 && n[0].hasAttribute("colspan");
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
//#endregion
|
|
348
|
+
export { l as buttonHarness, u as checkboxHarness, E as dataTableHarness, d as inputHarness, p as radioGroupHarness, m as radioHarness, o as renderWithGraphene, h as selectHarness, g as switchHarness, S as tableHarness, w as textareaHarness };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravitee/graphene-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Gravitee's Graphene design system: accessible React components, design tokens, icons, and shared ESLint/TypeScript configs. Built on shadcn/ui and Tailwind.",
|
|
6
6
|
"keywords": [
|