@lensui/lens-table 0.1.90 → 0.1.91
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.cjs +66 -34
- package/dist/index.css +43 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +66 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -953,47 +953,59 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
|
|
|
953
953
|
var import_react6 = require("react");
|
|
954
954
|
var import_react_dom = require("react-dom");
|
|
955
955
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
956
|
-
function TextAreaEditor({ value, title, maxLength, style, labels, onChange, onCommit, onCancel }) {
|
|
956
|
+
function TextAreaEditor({ value, title, maxLength, inline = false, style, labels, onChange, onCommit, onCancel }) {
|
|
957
957
|
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
958
|
+
const inlineHeaderHeight = typeof style.height === "number" ? style.height : 34;
|
|
959
|
+
const editorStyle = inline && open ? {
|
|
960
|
+
...style,
|
|
961
|
+
"--rvg-textarea-inline-header-height": `${inlineHeaderHeight}px`
|
|
962
|
+
} : style;
|
|
958
963
|
const handleKeyDown = (event) => {
|
|
959
964
|
event.stopPropagation();
|
|
960
965
|
if (event.key === "Enter") onCommit(value);
|
|
961
966
|
if (event.key === "Escape") onCancel();
|
|
962
967
|
};
|
|
963
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
{
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
maxLength,
|
|
970
|
-
onChange: (event) => onChange(event.target.value),
|
|
971
|
-
onKeyDown: handleKeyDown
|
|
972
|
-
}
|
|
973
|
-
),
|
|
974
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
975
|
-
"button",
|
|
976
|
-
{
|
|
977
|
-
type: "button",
|
|
978
|
-
className: "rvg-textarea-trigger",
|
|
979
|
-
"aria-label": title,
|
|
980
|
-
onPointerDown: (event) => {
|
|
981
|
-
event.preventDefault();
|
|
982
|
-
event.stopPropagation();
|
|
983
|
-
},
|
|
984
|
-
onClick: () => setOpen(true),
|
|
985
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultilineEditorIcon, {})
|
|
986
|
-
}
|
|
987
|
-
),
|
|
988
|
-
open && (0, import_react_dom.createPortal)(
|
|
989
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: "rvg-textarea-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
990
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { children: title }),
|
|
968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
969
|
+
"div",
|
|
970
|
+
{
|
|
971
|
+
className: `rvg-native-editor rvg-textarea-editor${inline && open ? " is-inline-expanded" : ""}`,
|
|
972
|
+
style: editorStyle,
|
|
973
|
+
children: [
|
|
991
974
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
975
|
+
"input",
|
|
976
|
+
{
|
|
977
|
+
value,
|
|
978
|
+
autoFocus: true,
|
|
979
|
+
maxLength,
|
|
980
|
+
onChange: (event) => onChange(event.target.value),
|
|
981
|
+
onKeyDown: handleKeyDown
|
|
982
|
+
}
|
|
983
|
+
),
|
|
984
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
985
|
+
"button",
|
|
986
|
+
{
|
|
987
|
+
type: "button",
|
|
988
|
+
className: "rvg-textarea-trigger",
|
|
989
|
+
"aria-label": title,
|
|
990
|
+
"aria-expanded": inline ? open : void 0,
|
|
991
|
+
onPointerDown: (event) => {
|
|
992
|
+
event.preventDefault();
|
|
993
|
+
event.stopPropagation();
|
|
994
|
+
},
|
|
995
|
+
onClick: () => setOpen((current) => inline ? !current : true),
|
|
996
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MultilineEditorIcon, {})
|
|
997
|
+
}
|
|
998
|
+
),
|
|
999
|
+
open && inline && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
992
1000
|
"textarea",
|
|
993
1001
|
{
|
|
1002
|
+
className: "rvg-textarea-inline",
|
|
1003
|
+
"aria-label": title,
|
|
1004
|
+
"data-rvg-preserve-edit": true,
|
|
994
1005
|
value,
|
|
995
1006
|
autoFocus: true,
|
|
996
1007
|
maxLength,
|
|
1008
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
997
1009
|
onChange: (event) => onChange(event.target.value),
|
|
998
1010
|
onKeyDown: (event) => {
|
|
999
1011
|
event.stopPropagation();
|
|
@@ -1002,11 +1014,30 @@ function TextAreaEditor({ value, title, maxLength, style, labels, onChange, onCo
|
|
|
1002
1014
|
}
|
|
1003
1015
|
}
|
|
1004
1016
|
),
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1017
|
+
open && !inline && (0, import_react_dom.createPortal)(
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: "rvg-textarea-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { children: title }),
|
|
1020
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1021
|
+
"textarea",
|
|
1022
|
+
{
|
|
1023
|
+
value,
|
|
1024
|
+
autoFocus: true,
|
|
1025
|
+
maxLength,
|
|
1026
|
+
onChange: (event) => onChange(event.target.value),
|
|
1027
|
+
onKeyDown: (event) => {
|
|
1028
|
+
event.stopPropagation();
|
|
1029
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") onCommit(value);
|
|
1030
|
+
if (event.key === "Escape") setOpen(false);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
),
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("footer", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", onClick: () => onCommit(value), children: labels.confirm }) })
|
|
1035
|
+
] }) }),
|
|
1036
|
+
document.body
|
|
1037
|
+
)
|
|
1038
|
+
]
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1010
1041
|
}
|
|
1011
1042
|
|
|
1012
1043
|
// src/core/format.ts
|
|
@@ -3829,6 +3860,7 @@ function TableInner({
|
|
|
3829
3860
|
value: draft,
|
|
3830
3861
|
title: column.editor.title ?? column.title,
|
|
3831
3862
|
maxLength: column.editor.maxLength,
|
|
3863
|
+
inline: column.editor.inline,
|
|
3832
3864
|
style: editorStyle,
|
|
3833
3865
|
labels,
|
|
3834
3866
|
onChange: setDraft,
|
package/dist/index.css
CHANGED
|
@@ -2753,6 +2753,24 @@
|
|
|
2753
2753
|
.rvg-textarea-editor {
|
|
2754
2754
|
padding-right: 24px;
|
|
2755
2755
|
}
|
|
2756
|
+
.rvg-textarea-editor.is-inline-expanded {
|
|
2757
|
+
z-index: 8;
|
|
2758
|
+
display: grid;
|
|
2759
|
+
height: calc(var(--rvg-textarea-inline-header-height) + 116px) !important;
|
|
2760
|
+
padding: 0;
|
|
2761
|
+
grid-template-rows: var(--rvg-textarea-inline-header-height) minmax(0, 1fr);
|
|
2762
|
+
align-items: stretch;
|
|
2763
|
+
gap: 0;
|
|
2764
|
+
overflow: hidden;
|
|
2765
|
+
border: 2px solid var(--rvg-color-primary);
|
|
2766
|
+
background: var(--rvg-color-bg);
|
|
2767
|
+
}
|
|
2768
|
+
.rvg-textarea-editor.is-inline-expanded > input {
|
|
2769
|
+
width: 100%;
|
|
2770
|
+
height: 100%;
|
|
2771
|
+
min-height: 0;
|
|
2772
|
+
padding: 0 24px 0 4px;
|
|
2773
|
+
}
|
|
2756
2774
|
.rvg-textarea-trigger {
|
|
2757
2775
|
position: absolute;
|
|
2758
2776
|
top: 50%;
|
|
@@ -2769,11 +2787,36 @@
|
|
|
2769
2787
|
cursor: pointer;
|
|
2770
2788
|
transform: translateY(-50%);
|
|
2771
2789
|
}
|
|
2790
|
+
.rvg-textarea-editor.is-inline-expanded .rvg-textarea-trigger {
|
|
2791
|
+
top: calc(var(--rvg-textarea-inline-header-height) / 2);
|
|
2792
|
+
}
|
|
2772
2793
|
.rvg-multiline-icon {
|
|
2773
2794
|
width: 13px;
|
|
2774
2795
|
height: 13px;
|
|
2775
2796
|
fill: currentColor;
|
|
2776
2797
|
}
|
|
2798
|
+
.rvg-textarea-inline {
|
|
2799
|
+
display: block;
|
|
2800
|
+
width: 100%;
|
|
2801
|
+
height: 100%;
|
|
2802
|
+
min-width: 0;
|
|
2803
|
+
min-height: 0;
|
|
2804
|
+
margin: 0;
|
|
2805
|
+
padding: 8px;
|
|
2806
|
+
resize: none;
|
|
2807
|
+
border: 0;
|
|
2808
|
+
border-top: 1px solid var(--rvg-color-primary);
|
|
2809
|
+
border-radius: 0;
|
|
2810
|
+
outline: none;
|
|
2811
|
+
background: var(--rvg-color-bg);
|
|
2812
|
+
color: var(--rvg-color-text);
|
|
2813
|
+
font:
|
|
2814
|
+
var(--rvg-font-size-body)/1.5 Inter,
|
|
2815
|
+
ui-sans-serif,
|
|
2816
|
+
system-ui,
|
|
2817
|
+
sans-serif;
|
|
2818
|
+
box-sizing: border-box;
|
|
2819
|
+
}
|
|
2777
2820
|
.rvg-textarea-backdrop {
|
|
2778
2821
|
position: fixed;
|
|
2779
2822
|
z-index: 1200;
|
package/dist/index.d.cts
CHANGED
|
@@ -218,6 +218,8 @@ interface GridColumn<Row> {
|
|
|
218
218
|
type: 'textarea';
|
|
219
219
|
title?: string;
|
|
220
220
|
maxLength?: number;
|
|
221
|
+
/** Expands one integrated multiline editor below the active cell instead of opening a modal dialog. */
|
|
222
|
+
inline?: boolean;
|
|
221
223
|
} | {
|
|
222
224
|
type: 'date' | 'time' | 'date-time' | 'year' | 'month' | 'date-range' | 'time-range' | 'date-time-range';
|
|
223
225
|
format?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -218,6 +218,8 @@ interface GridColumn<Row> {
|
|
|
218
218
|
type: 'textarea';
|
|
219
219
|
title?: string;
|
|
220
220
|
maxLength?: number;
|
|
221
|
+
/** Expands one integrated multiline editor below the active cell instead of opening a modal dialog. */
|
|
222
|
+
inline?: boolean;
|
|
221
223
|
} | {
|
|
222
224
|
type: 'date' | 'time' | 'date-time' | 'year' | 'month' | 'date-range' | 'time-range' | 'date-time-range';
|
|
223
225
|
format?: string;
|
package/dist/index.js
CHANGED
|
@@ -923,47 +923,59 @@ function TextEditor({ value, type, min, max, integer = false, style, labels, onC
|
|
|
923
923
|
import { useState as useState4 } from "react";
|
|
924
924
|
import { createPortal } from "react-dom";
|
|
925
925
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
926
|
-
function TextAreaEditor({ value, title, maxLength, style, labels, onChange, onCommit, onCancel }) {
|
|
926
|
+
function TextAreaEditor({ value, title, maxLength, inline = false, style, labels, onChange, onCommit, onCancel }) {
|
|
927
927
|
const [open, setOpen] = useState4(false);
|
|
928
|
+
const inlineHeaderHeight = typeof style.height === "number" ? style.height : 34;
|
|
929
|
+
const editorStyle = inline && open ? {
|
|
930
|
+
...style,
|
|
931
|
+
"--rvg-textarea-inline-header-height": `${inlineHeaderHeight}px`
|
|
932
|
+
} : style;
|
|
928
933
|
const handleKeyDown = (event) => {
|
|
929
934
|
event.stopPropagation();
|
|
930
935
|
if (event.key === "Enter") onCommit(value);
|
|
931
936
|
if (event.key === "Escape") onCancel();
|
|
932
937
|
};
|
|
933
|
-
return /* @__PURE__ */ jsxs7(
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
{
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
maxLength,
|
|
940
|
-
onChange: (event) => onChange(event.target.value),
|
|
941
|
-
onKeyDown: handleKeyDown
|
|
942
|
-
}
|
|
943
|
-
),
|
|
944
|
-
/* @__PURE__ */ jsx7(
|
|
945
|
-
"button",
|
|
946
|
-
{
|
|
947
|
-
type: "button",
|
|
948
|
-
className: "rvg-textarea-trigger",
|
|
949
|
-
"aria-label": title,
|
|
950
|
-
onPointerDown: (event) => {
|
|
951
|
-
event.preventDefault();
|
|
952
|
-
event.stopPropagation();
|
|
953
|
-
},
|
|
954
|
-
onClick: () => setOpen(true),
|
|
955
|
-
children: /* @__PURE__ */ jsx7(MultilineEditorIcon, {})
|
|
956
|
-
}
|
|
957
|
-
),
|
|
958
|
-
open && createPortal(
|
|
959
|
-
/* @__PURE__ */ jsx7("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ jsxs7("section", { className: "rvg-textarea-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
960
|
-
/* @__PURE__ */ jsx7("header", { children: title }),
|
|
938
|
+
return /* @__PURE__ */ jsxs7(
|
|
939
|
+
"div",
|
|
940
|
+
{
|
|
941
|
+
className: `rvg-native-editor rvg-textarea-editor${inline && open ? " is-inline-expanded" : ""}`,
|
|
942
|
+
style: editorStyle,
|
|
943
|
+
children: [
|
|
961
944
|
/* @__PURE__ */ jsx7(
|
|
945
|
+
"input",
|
|
946
|
+
{
|
|
947
|
+
value,
|
|
948
|
+
autoFocus: true,
|
|
949
|
+
maxLength,
|
|
950
|
+
onChange: (event) => onChange(event.target.value),
|
|
951
|
+
onKeyDown: handleKeyDown
|
|
952
|
+
}
|
|
953
|
+
),
|
|
954
|
+
/* @__PURE__ */ jsx7(
|
|
955
|
+
"button",
|
|
956
|
+
{
|
|
957
|
+
type: "button",
|
|
958
|
+
className: "rvg-textarea-trigger",
|
|
959
|
+
"aria-label": title,
|
|
960
|
+
"aria-expanded": inline ? open : void 0,
|
|
961
|
+
onPointerDown: (event) => {
|
|
962
|
+
event.preventDefault();
|
|
963
|
+
event.stopPropagation();
|
|
964
|
+
},
|
|
965
|
+
onClick: () => setOpen((current) => inline ? !current : true),
|
|
966
|
+
children: /* @__PURE__ */ jsx7(MultilineEditorIcon, {})
|
|
967
|
+
}
|
|
968
|
+
),
|
|
969
|
+
open && inline && /* @__PURE__ */ jsx7(
|
|
962
970
|
"textarea",
|
|
963
971
|
{
|
|
972
|
+
className: "rvg-textarea-inline",
|
|
973
|
+
"aria-label": title,
|
|
974
|
+
"data-rvg-preserve-edit": true,
|
|
964
975
|
value,
|
|
965
976
|
autoFocus: true,
|
|
966
977
|
maxLength,
|
|
978
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
967
979
|
onChange: (event) => onChange(event.target.value),
|
|
968
980
|
onKeyDown: (event) => {
|
|
969
981
|
event.stopPropagation();
|
|
@@ -972,11 +984,30 @@ function TextAreaEditor({ value, title, maxLength, style, labels, onChange, onCo
|
|
|
972
984
|
}
|
|
973
985
|
}
|
|
974
986
|
),
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
987
|
+
open && !inline && createPortal(
|
|
988
|
+
/* @__PURE__ */ jsx7("div", { className: "rvg-textarea-backdrop", role: "presentation", children: /* @__PURE__ */ jsxs7("section", { className: "rvg-textarea-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
989
|
+
/* @__PURE__ */ jsx7("header", { children: title }),
|
|
990
|
+
/* @__PURE__ */ jsx7(
|
|
991
|
+
"textarea",
|
|
992
|
+
{
|
|
993
|
+
value,
|
|
994
|
+
autoFocus: true,
|
|
995
|
+
maxLength,
|
|
996
|
+
onChange: (event) => onChange(event.target.value),
|
|
997
|
+
onKeyDown: (event) => {
|
|
998
|
+
event.stopPropagation();
|
|
999
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") onCommit(value);
|
|
1000
|
+
if (event.key === "Escape") setOpen(false);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
),
|
|
1004
|
+
/* @__PURE__ */ jsx7("footer", { children: /* @__PURE__ */ jsx7("button", { type: "button", onClick: () => onCommit(value), children: labels.confirm }) })
|
|
1005
|
+
] }) }),
|
|
1006
|
+
document.body
|
|
1007
|
+
)
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
980
1011
|
}
|
|
981
1012
|
|
|
982
1013
|
// src/core/format.ts
|
|
@@ -3799,6 +3830,7 @@ function TableInner({
|
|
|
3799
3830
|
value: draft,
|
|
3800
3831
|
title: column.editor.title ?? column.title,
|
|
3801
3832
|
maxLength: column.editor.maxLength,
|
|
3833
|
+
inline: column.editor.inline,
|
|
3802
3834
|
style: editorStyle,
|
|
3803
3835
|
labels,
|
|
3804
3836
|
onChange: setDraft,
|