@iyulab/flex-table 0.10.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.
@@ -0,0 +1,8 @@
1
+ import { F as t, R as o, U as r, e as l, r as s } from "./flex-table-C0CCHc1F.js";
2
+ export {
3
+ t as FlexTable,
4
+ o as RowSelectionState,
5
+ r as UndoStack,
6
+ l as exportData,
7
+ s as renderCell
8
+ };
@@ -0,0 +1,71 @@
1
+ import { useState as r, useRef as J, useCallback as y, useEffect as N } from "react";
2
+ import Q from "odata-query";
3
+ function I(i, f = {}) {
4
+ const { pageSize: a = 20, defaultOrderBy: o, fixedFilter: d } = f, [x, S] = r([]), [B, b] = r(0), [E, C] = r(!1), [O, g] = r(null), [h, p] = r(0), [l, R] = r(() => o ? U(o) : []), [u, T] = r(""), [q, A] = r(0), k = J(null), D = y(() => {
5
+ A((e) => e + 1);
6
+ }, []), L = y((e) => {
7
+ T(e), p(0);
8
+ }, []), P = y((e) => {
9
+ var n;
10
+ const c = (n = e.detail) == null ? void 0 : n.criteria;
11
+ c && (R(c), p(0));
12
+ }, []);
13
+ return N(() => {
14
+ var w;
15
+ (w = k.current) == null || w.abort();
16
+ const e = new AbortController();
17
+ k.current = e, C(!0), g(null);
18
+ const c = l.length > 0 ? l.map((t) => `${t.key} ${t.direction}`).join(", ") : o, n = {
19
+ top: a,
20
+ skip: h * a,
21
+ count: !0
22
+ };
23
+ c && (n.orderBy = c), d && (n.filter = d), u && (n.search = u);
24
+ const v = Q(n), z = `${window.location.origin}${i}${v}`;
25
+ return fetch(z, { signal: e.signal }).then(async (t) => {
26
+ var $;
27
+ if (!t.ok) {
28
+ const F = await t.text().catch(() => "");
29
+ let m = `요청 실패 (${t.status})`;
30
+ try {
31
+ const s = JSON.parse(F);
32
+ m = (($ = s == null ? void 0 : s.error) == null ? void 0 : $.message) ?? (s == null ? void 0 : s.message) ?? m;
33
+ } catch {
34
+ }
35
+ throw new Error(m);
36
+ }
37
+ return t.json();
38
+ }).then((t) => {
39
+ e.signal.aborted || (S(t.value ?? t), b(t["@odata.count"] ?? 0), g(null));
40
+ }).catch((t) => {
41
+ e.signal.aborted || t.name !== "AbortError" && (g(t.message), S([]), b(0));
42
+ }).finally(() => {
43
+ e.signal.aborted || C(!1);
44
+ }), () => e.abort();
45
+ }, [i, h, a, l, u, d, o, q]), {
46
+ data: x,
47
+ totalCount: B,
48
+ loading: E,
49
+ error: O,
50
+ page: h,
51
+ setPage: p,
52
+ sortCriteria: l,
53
+ onSortChange: P,
54
+ search: u,
55
+ setSearch: L,
56
+ refresh: D
57
+ };
58
+ }
59
+ function U(i) {
60
+ return i.split(",").map((f) => {
61
+ var o;
62
+ const a = f.trim().split(/\s+/);
63
+ return {
64
+ key: a[0],
65
+ direction: ((o = a[1]) == null ? void 0 : o.toLowerCase()) === "desc" ? "desc" : "asc"
66
+ };
67
+ });
68
+ }
69
+ export {
70
+ I as useODataSource
71
+ };
package/dist/react.js ADDED
@@ -0,0 +1,36 @@
1
+ import e from "react";
2
+ import { createComponent as o } from "@lit/react";
3
+ import { F as l } from "./flex-table-C0CCHc1F.js";
4
+ const a = o({
5
+ tagName: "flex-table",
6
+ elementClass: l,
7
+ react: e,
8
+ events: {
9
+ onCellSelect: "cell-select",
10
+ onCellEditCommit: "cell-edit-commit",
11
+ onCellEditCancel: "cell-edit-cancel",
12
+ onCellEditStart: "cell-edit-start",
13
+ onSortChange: "sort-change",
14
+ onFilterChange: "filter-change",
15
+ onRowAdd: "row-add",
16
+ onRowDelete: "row-delete",
17
+ onColumnResize: "column-resize",
18
+ onColumnSelect: "column-select",
19
+ onColumnAdd: "column-add",
20
+ onColumnDelete: "column-delete",
21
+ onColumnReorder: "column-reorder",
22
+ onSelectionChange: "selection-change",
23
+ onClipboardCopy: "clipboard-copy",
24
+ onClipboardCut: "clipboard-cut",
25
+ onClipboardPaste: "clipboard-paste",
26
+ onClipboardError: "clipboard-error",
27
+ onUndoStateChange: "undo-state-change",
28
+ onValidationError: "validation-error",
29
+ onBatchUpdate: "batch-update",
30
+ onContextMenu: "context-menu",
31
+ onFilterError: "filter-error"
32
+ }
33
+ });
34
+ export {
35
+ a as FlexTableReact
36
+ };
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@iyulab/flex-table",
3
+ "version": "0.10.0",
4
+ "description": "A minimalist, input-centric data grid web component",
5
+ "type": "module",
6
+ "main": "./dist/flex-table.js",
7
+ "module": "./dist/flex-table.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/flex-table.js"
13
+ },
14
+ "./react": {
15
+ "types": "./dist/react.d.ts",
16
+ "import": "./dist/react.js"
17
+ },
18
+ "./odata": {
19
+ "types": "./dist/odata/index.d.ts",
20
+ "import": "./dist/odata/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "dev": "vite serve demo",
28
+ "build": "tsc && vite build",
29
+ "build:demo": "vite build --config vite.config.demo.ts",
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "test:coverage": "vitest run --coverage",
34
+ "lint": "eslint src/",
35
+ "lint:fix": "eslint src/ --fix"
36
+ },
37
+ "keywords": [
38
+ "web-component",
39
+ "data-grid",
40
+ "table",
41
+ "lit",
42
+ "spreadsheet"
43
+ ],
44
+ "license": "MIT",
45
+ "author": "iyulab",
46
+ "homepage": "https://github.com/iyulab/flex-table#readme",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/iyulab/flex-table.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/iyulab/flex-table/issues"
53
+ },
54
+ "dependencies": {
55
+ "lit": "^3.2.0",
56
+ "odata-query": "^8.0.7"
57
+ },
58
+ "peerDependencies": {
59
+ "@lit/react": "^1.0.0",
60
+ "react": "^18.0.0 || ^19.0.0"
61
+ },
62
+ "peerDependenciesMeta": {
63
+ "@lit/react": {
64
+ "optional": true
65
+ },
66
+ "react": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "devDependencies": {
71
+ "@lit/react": "^1.0.8",
72
+ "@types/react": "^19.2.14",
73
+ "@typescript-eslint/eslint-plugin": "^8.58.0",
74
+ "@typescript-eslint/parser": "^8.58.0",
75
+ "eslint": "^10.1.0",
76
+ "eslint-plugin-lit": "^2.2.1",
77
+ "jsdom": "^28.1.0",
78
+ "loupe": "^3.2.1",
79
+ "react": "^19.2.4",
80
+ "strip-literal": "^3.1.0",
81
+ "typescript": "~5.7.0",
82
+ "vite": "^6.0.0",
83
+ "vitest": "^3.0.0"
84
+ }
85
+ }