@intable/react 0.0.7
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/dist/index.d.ts +7 -0
- package/dist/index.js +26 -0
- package/dist/plugins/antd.d.ts +2 -0
- package/dist/plugins/antd.js +42 -0
- package/dist/style.css +1 -0
- package/dist/types/auto-imports.d.js +0 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
import { type TableProps } from 'intable';
|
|
3
|
+
import 'intable/wc';
|
|
4
|
+
import './style.scss';
|
|
5
|
+
export declare const Intable: FC<TableProps>;
|
|
6
|
+
export declare const component: <T extends Record<string, any>>(Comp: FC<T>) => (props: T) => HTMLDivElement;
|
|
7
|
+
export default Intable;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import './style.css';/* empty css */
|
|
2
|
+
import { createElement, useEffect, useRef } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { flushSync } from "react-dom";
|
|
5
|
+
import "intable/wc";
|
|
6
|
+
import { onCleanup } from "solid-js";
|
|
7
|
+
const Intable = (a) => {
|
|
8
|
+
let o = useRef(null);
|
|
9
|
+
return useEffect(() => {
|
|
10
|
+
o.current && (o.current.options = {
|
|
11
|
+
...a,
|
|
12
|
+
renderer: component,
|
|
13
|
+
plugins: [...a.plugins || []]
|
|
14
|
+
});
|
|
15
|
+
}, [a]), createElement("wc-table", {
|
|
16
|
+
ref: o,
|
|
17
|
+
style: { display: "contents" }
|
|
18
|
+
});
|
|
19
|
+
}, component = (r) => (i) => {
|
|
20
|
+
let s = document.createElement("div");
|
|
21
|
+
s.remove ??= () => {};
|
|
22
|
+
let c = createRoot(s);
|
|
23
|
+
return flushSync(() => c.render(createElement(r, i))), onCleanup(() => c.unmount()), s;
|
|
24
|
+
};
|
|
25
|
+
var src_default = Intable;
|
|
26
|
+
export { Intable, component, src_default as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { resolveOptions } from "intable/utils";
|
|
4
|
+
import { Checkbox, ColorPicker, DatePicker, Input, InputNumber, Rate, Select, Switch, TimePicker } from "antd";
|
|
5
|
+
const AntdPlugin = {
|
|
6
|
+
name: "antd",
|
|
7
|
+
store(e) {
|
|
8
|
+
e.editors.text = editor(Input), e.editors.number = editor(InputNumber), e.editors.rate = editor(Rate), e.editors.switch = editor(Switch), e.editors.checkbox = editor(Checkbox), e.editors.color = selector(ColorPicker, { transform: (e) => e?.toHexString?.() || e }), e.editors.select = selector(Select), e.editors.date = selector(DatePicker), e.editors.time = selector(TimePicker), e.editors.datetime = selector(DatePicker, { showTime: !0 });
|
|
9
|
+
},
|
|
10
|
+
rewriteProps: { class: ({ class: e }) => `antd ${e}` }
|
|
11
|
+
};
|
|
12
|
+
var getEl = (e) => e && (e instanceof Text && (e = e.nextElementSibling), e?.querySelector("input") ?? e?.querySelector("button") ?? e?.querySelector("[class*=trigger]") ?? e), createEditor = (s, c, l) => (u) => {
|
|
13
|
+
let { eventKey: d, value: f, col: p, ok: m, cancel: h, props: g } = u, _ = document.createElement("div"), v = createRoot(_), y = d || f, b;
|
|
14
|
+
v.render(createElement(() => {
|
|
15
|
+
let [o, u] = useState(y), d = useRef(null);
|
|
16
|
+
return useEffect(() => {
|
|
17
|
+
b = d.current, l ? setTimeout(() => (getEl(d.current)?.click?.(), d.current?.focus?.()), 0) : d.current?.focus?.();
|
|
18
|
+
}, []), createElement(s, {
|
|
19
|
+
ref: d,
|
|
20
|
+
value: o,
|
|
21
|
+
onChange: (e) => {
|
|
22
|
+
y = c.transform ? c.transform(e) : e, u(y), l && setTimeout(m, 100);
|
|
23
|
+
},
|
|
24
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
25
|
+
onKeyDown: (e) => {
|
|
26
|
+
e.stopPropagation(), e.key === "Enter" && m(), e.key === "Escape" && h();
|
|
27
|
+
},
|
|
28
|
+
...p?.enum && { options: resolveOptions(p.enum) },
|
|
29
|
+
...c,
|
|
30
|
+
...g
|
|
31
|
+
});
|
|
32
|
+
}));
|
|
33
|
+
let x = document.createDocumentFragment();
|
|
34
|
+
return x.appendChild(_), {
|
|
35
|
+
el: x,
|
|
36
|
+
getValue: () => y,
|
|
37
|
+
destroy: () => v.unmount(),
|
|
38
|
+
focus: () => (l && getEl(b)?.click?.(), b?.focus?.()),
|
|
39
|
+
blur: () => b?.blur?.()
|
|
40
|
+
};
|
|
41
|
+
}, editor = (e, a = {}) => createEditor(e, a, !1), selector = (e, a = {}) => createEditor(e, a, !0);
|
|
42
|
+
export { AntdPlugin };
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.antd .is-editing>.area{display:none}.antd .in-cell-edit-wrapper{align-items:center;padding:4px;display:flex}.antd .in-cell-edit-wrapper>.ant-input-affix-wrapper>.ant-input-prefix{display:none}
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intable/react",
|
|
3
|
+
"version": "0.0.7",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./*": {
|
|
12
|
+
"import": "./dist/*.js",
|
|
13
|
+
"types": "./dist/*.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"intable": "^0.0.7",
|
|
21
|
+
"solid-js": "^1.9.9"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": "^18.0.0 || ^19.0.0 || ^20.0.0",
|
|
25
|
+
"react-dom": "^18.0.0 || ^19.0.0 || ^20.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "^18",
|
|
29
|
+
"@types/react-dom": "^18",
|
|
30
|
+
"antd": "^5.22.5"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
}
|
|
36
|
+
}
|