@ishibashi0112/spreadsheet-grid-core 1.6.0 → 1.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/dist/controllers/changeTracker.cjs +1 -0
- package/dist/controllers/changeTracker.d.ts +38 -0
- package/dist/controllers/changeTracker.js +233 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +3 -2
- package/dist/controllers/editController.js +171 -152
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +18 -15
- package/dist/controllers/searchSelectEditorController.cjs +1 -0
- package/dist/controllers/searchSelectEditorController.d.ts +48 -0
- package/dist/controllers/searchSelectEditorController.js +188 -0
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +19 -18
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +5 -0
- package/dist/engine/features.js +24 -1
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +33 -31
- package/dist/engine/gridApi.cjs +8 -7
- package/dist/engine/gridApi.d.ts +3 -0
- package/dist/engine/gridApi.js +115 -83
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +12 -0
- package/dist/logic/cellNote.cjs +1 -1
- package/dist/logic/cellNote.d.ts +1 -1
- package/dist/logic/cellNote.js +9 -1
- package/dist/logic/changeTracking.cjs +1 -0
- package/dist/logic/changeTracking.d.ts +51 -0
- package/dist/logic/changeTracking.js +185 -0
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.js +54 -54
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +4 -3
- package/dist/logic/contextMenuTarget.js +42 -36
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +127 -118
- package/dist/logic/gridAsk.cjs +2 -2
- package/dist/logic/gridAsk.js +71 -71
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +12 -12
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +14 -13
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +16 -0
- package/dist/logic/localeTextFeatures.js +20 -6
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +16 -1
- package/dist/logic/selectEditorState.js +30 -21
- package/dist/logic/selectFillRow.cjs +1 -0
- package/dist/logic/selectFillRow.d.ts +4 -0
- package/dist/logic/selectFillRow.js +25 -0
- package/dist/logic/selectLabels.cjs +1 -1
- package/dist/logic/selectLabels.js +25 -22
- package/dist/logic/selectSearch.cjs +1 -0
- package/dist/logic/selectSearch.d.ts +27 -0
- package/dist/logic/selectSearch.js +102 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.js +13 -13
- package/dist/model/gridTypes.core.d.ts +201 -9
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.js +65 -65
- package/dist/utils/editorVisibleBounds.cjs +1 -1
- package/dist/utils/editorVisibleBounds.d.ts +4 -0
- package/dist/utils/editorVisibleBounds.js +12 -2
- package/dist/utils/overflowTitle.cjs +1 -0
- package/dist/utils/overflowTitle.d.ts +1 -0
- package/dist/utils/overflowTitle.js +7 -0
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +6 -0
- package/dist/utils/permissions.js +11 -2
- package/package.json +1 -1
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { resolveEnterDirection as e } from "./editorKeys.js";
|
|
2
2
|
//#region src/logic/selectEditorState.ts
|
|
3
|
-
var t = 180, n =
|
|
3
|
+
var t = 180, n = 240, r = 28, i = 4, a = 1, o = 8, s = 8, c = 2, l = () => {
|
|
4
|
+
let e = null;
|
|
5
|
+
return (t) => {
|
|
6
|
+
let n = typeof t.movementX != "number" || t.movementX !== 0 || t.movementY !== 0 || e !== null && (e.x !== t.clientX || e.y !== t.clientY);
|
|
7
|
+
return e = {
|
|
8
|
+
x: t.clientX,
|
|
9
|
+
y: t.clientY
|
|
10
|
+
}, n;
|
|
11
|
+
};
|
|
12
|
+
}, u = 700, d = (e, t) => {
|
|
4
13
|
let n = String(t ?? ""), r = e.findIndex((e) => e.value === n);
|
|
5
14
|
return r >= 0 ? r : 0;
|
|
6
|
-
},
|
|
15
|
+
}, f = (e, t, n) => {
|
|
7
16
|
if (n <= 0) return 0;
|
|
8
17
|
let r = e + t;
|
|
9
18
|
return r < 0 ? 0 : r > n - 1 ? n - 1 : r;
|
|
10
|
-
},
|
|
19
|
+
}, p = () => ({
|
|
11
20
|
buffer: "",
|
|
12
21
|
lastInputTime: 0
|
|
13
|
-
}),
|
|
22
|
+
}), m = (e, t, n, r) => {
|
|
14
23
|
let i = (n - e.lastInputTime > 700 ? "" : e.buffer) + t.toLocaleLowerCase(), a = r.findIndex((e) => e.label.toLocaleLowerCase().startsWith(i));
|
|
15
24
|
return {
|
|
16
25
|
state: {
|
|
@@ -19,35 +28,35 @@ var t = 180, n = 28, r = 4, i = 1, a = 8, o = 8, s = 2, c = 700, l = (e, t) => {
|
|
|
19
28
|
},
|
|
20
29
|
index: a >= 0 ? a : null
|
|
21
30
|
};
|
|
22
|
-
},
|
|
23
|
-
let
|
|
31
|
+
}, h = 44, g = () => typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches ? 44 : 28, _ = (e, t, n, r, i = 28, a = 180) => {
|
|
32
|
+
let l = Math.max(e.width, a), u = Math.max(s, n - l - s), d = Math.min(Math.max(e.left, s), u), f = Math.min(Math.max(t, 1), o) * i + 8 + 2, p = e.bottom + c;
|
|
24
33
|
return {
|
|
25
|
-
left:
|
|
26
|
-
top:
|
|
27
|
-
width:
|
|
28
|
-
maxHeight:
|
|
34
|
+
left: d,
|
|
35
|
+
top: p + f <= r - s ? p : Math.max(s, e.top - c - f),
|
|
36
|
+
width: l,
|
|
37
|
+
maxHeight: f
|
|
29
38
|
};
|
|
30
|
-
},
|
|
31
|
-
let n =
|
|
39
|
+
}, v = /[\uFF01-\uFF5E]/g, y = (e) => e.replace(v, (e) => String.fromCharCode(e.charCodeAt(0) - 65248)).replace(/\u3000/g, " ").toLocaleLowerCase(), b = (e, t) => {
|
|
40
|
+
let n = y(t).trim();
|
|
32
41
|
if (n === "") return null;
|
|
33
|
-
let r = e.map((e) =>
|
|
42
|
+
let r = e.map((e) => y(e.label)), i = r.findIndex((e) => e.startsWith(n));
|
|
34
43
|
if (i >= 0) return i;
|
|
35
44
|
let a = r.findIndex((e) => e.includes(n));
|
|
36
45
|
return a >= 0 ? a : null;
|
|
37
|
-
},
|
|
46
|
+
}, x = 8, S = (t, n) => {
|
|
38
47
|
let { key: r } = t, i = n.optionCount;
|
|
39
|
-
r === "ArrowDown" || r === "ArrowUp" || r === "Home" || r === "End" || r === "PageUp" || r === "PageDown" ? (t.preventDefault(), (r === "ArrowDown" || r === "ArrowUp" || i > 0) && n.onMove((e) =>
|
|
40
|
-
},
|
|
41
|
-
let i =
|
|
48
|
+
r === "ArrowDown" || r === "ArrowUp" || r === "Home" || r === "End" || r === "PageUp" || r === "PageDown" ? (t.preventDefault(), (r === "ArrowDown" || r === "ArrowUp" || i > 0) && n.onMove((e) => C(r, e, i))) : r === "Enter" || r === "Tab" ? (t.preventDefault(), n.onCommit(r === "Enter" ? e(n.enterMove) : t.shiftKey ? "left" : "right")) : r === "Escape" ? (t.preventDefault(), n.onCancel()) : r.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey && (t.preventDefault(), n.onTypeahead(r));
|
|
49
|
+
}, C = (e, t, n) => e === "ArrowDown" || e === "ArrowUp" ? f(t, e === "ArrowDown" ? 1 : -1, n) : e === "Home" || e === "End" ? e === "Home" ? 0 : n - 1 : Math.min(Math.max((t < 0 ? 0 : t) + (e === "PageDown" ? 8 : -8), 0), n - 1), w = (e, t, n, r) => {
|
|
50
|
+
let i = d(e, t);
|
|
42
51
|
if (!n) return {
|
|
43
52
|
highlight: i,
|
|
44
|
-
typeahead:
|
|
53
|
+
typeahead: p()
|
|
45
54
|
};
|
|
46
|
-
let a =
|
|
55
|
+
let a = m(p(), n, r, e);
|
|
47
56
|
return {
|
|
48
57
|
highlight: a.index ?? i,
|
|
49
58
|
typeahead: a.state
|
|
50
59
|
};
|
|
51
|
-
};
|
|
60
|
+
}, T = (e) => e?.type === "select" && (e.search ?? (e.loadOptions !== void 0 || e.allowFreeText === !0));
|
|
52
61
|
//#endregion
|
|
53
|
-
export {
|
|
62
|
+
export { r as SELECT_OPTION_ROW_HEIGHT, h as SELECT_OPTION_ROW_HEIGHT_COARSE, x as SELECT_PAGE_STEP, a as SELECT_POPOVER_BORDER_Y, t as SELECT_POPOVER_MIN_WIDTH, i as SELECT_POPOVER_PADDING_Y, n as SELECT_SEARCH_POPOVER_MIN_WIDTH, u as SELECT_TYPEAHEAD_RESET_MS, _ as computeSelectPopoverPlacement, l as createPointerMoveFilter, p as createTypeaheadState, b as findOptionByComposedText, S as handleSelectEditorKeyDown, T as isSearchSelectEditor, f as moveHighlight, C as moveSelectHighlight, d as resolveInitialHighlight, w as resolveSelectEditorStart, g as resolveSelectOptionRowHeight, m as typeaheadJump };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./validation.cjs");var t=(t,n,r,i,a,o)=>{let s=t.editor;if(i===void 0||s?.type!==`select`||s.fillRow===void 0)return null;let c=s.fillRow(i,{row:n,rowKey:r});if(typeof c!=`object`||!c)return null;let l=null;for(let r of Object.keys(c)){if(r===t.key)continue;let i=c[r];if(Object.is(n?.[r],i))continue;let s=a.find(e=>e.key===r);s!==void 0&&e.decideCellWrite(s,n,i,o).action===`reject`||((l??={})[r]=i)}return l},n=e=>({key:e,title:e});exports.resolveSelectFillRow=t,exports.toFillRowColumn=n;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GridColumn, GridRowKey, GridSelectEditorOption } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ValidationLocaleText } from './validation.js';
|
|
3
|
+
export declare const resolveSelectFillRow: <T>(column: GridColumn<T>, row: T, rowKey: GridRowKey, option: GridSelectEditorOption | undefined, columns: readonly GridColumn<T>[], texts?: ValidationLocaleText) => Record<string, unknown> | null;
|
|
4
|
+
export declare const toFillRowColumn: <T>(key: string) => GridColumn<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { decideCellWrite as e } from "./validation.js";
|
|
2
|
+
//#region src/logic/selectFillRow.ts
|
|
3
|
+
var t = (t, n, r, i, a, o) => {
|
|
4
|
+
let s = t.editor;
|
|
5
|
+
if (i === void 0 || s?.type !== "select" || s.fillRow === void 0) return null;
|
|
6
|
+
let c = s.fillRow(i, {
|
|
7
|
+
row: n,
|
|
8
|
+
rowKey: r
|
|
9
|
+
});
|
|
10
|
+
if (typeof c != "object" || !c) return null;
|
|
11
|
+
let l = null;
|
|
12
|
+
for (let r of Object.keys(c)) {
|
|
13
|
+
if (r === t.key) continue;
|
|
14
|
+
let i = c[r];
|
|
15
|
+
if (Object.is(n?.[r], i)) continue;
|
|
16
|
+
let s = a.find((e) => e.key === r);
|
|
17
|
+
s !== void 0 && e(s, n, i, o).action === "reject" || ((l ??= {})[r] = i);
|
|
18
|
+
}
|
|
19
|
+
return l;
|
|
20
|
+
}, n = (e) => ({
|
|
21
|
+
key: e,
|
|
22
|
+
title: e
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { t as resolveSelectFillRow, n as toFillRowColumn };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=new WeakMap,n=e=>{let n=t.get(e);if(!n||n.size!==e.length){n={size:e.length,labelByValue:new Map,valueByLabel:new Map};for(let t of e){n.labelByValue.has(t.value)||n.labelByValue.set(t.value,t.label);let e=t.label.trim();e!==``&&!n.valueByLabel.has(e)&&n.valueByLabel.set(e,t.value)}t.set(e,n)}return n},r=(e,t)=>{let n=e.editor;if(n?.type!==`select`||n.clipboard!==`label`)return;if(typeof n.options!=`function`)return Array.isArray(n.options)?n.options:void 0;if(t===void 0)return;let r=n.options(t);return Array.isArray(r)?r:void 0},i=(e,t,i)=>{if(e.formatClipboardValue&&i!==void 0)return e.formatClipboardValue(t,i);let a=String(t??``),o=r(e,i);if(o===void 0)return a;let s=n(o).labelByValue.get(a);return s===void 0||s.trim()===``?a:s},a=t=>{let i=t.editor;if(!(i?.type!==`select`||i.clipboard!==`label`))return(i,a)=>{let o=r(t,a);if(o===void 0)return i;let s=n(o),c=i.trim(),l=e.getCellValue(a,t);if(c!==``&&typeof l==`string`&&s.labelByValue.get(l)?.trim()===c)return l;let u=s.valueByLabel.get(c);return u===void 0?s.labelByValue.has(i)?i:s.labelByValue.has(c)?c:i:u}};exports.formatCellClipboardText=i,exports.resolveSelectLabelParser=a;
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
+
import { getCellValue as e } from "../utils/permissions.js";
|
|
1
2
|
//#region src/logic/selectLabels.ts
|
|
2
|
-
var
|
|
3
|
-
let n =
|
|
4
|
-
if (!n || n.size !==
|
|
3
|
+
var t = /* @__PURE__ */ new WeakMap(), n = (e) => {
|
|
4
|
+
let n = t.get(e);
|
|
5
|
+
if (!n || n.size !== e.length) {
|
|
5
6
|
n = {
|
|
6
|
-
size:
|
|
7
|
+
size: e.length,
|
|
7
8
|
labelByValue: /* @__PURE__ */ new Map(),
|
|
8
9
|
valueByLabel: /* @__PURE__ */ new Map()
|
|
9
10
|
};
|
|
10
|
-
for (let
|
|
11
|
-
n.labelByValue.has(
|
|
12
|
-
let
|
|
13
|
-
|
|
11
|
+
for (let t of e) {
|
|
12
|
+
n.labelByValue.has(t.value) || n.labelByValue.set(t.value, t.label);
|
|
13
|
+
let e = t.label.trim();
|
|
14
|
+
e !== "" && !n.valueByLabel.has(e) && n.valueByLabel.set(e, t.value);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
t.set(e, n);
|
|
16
17
|
}
|
|
17
18
|
return n;
|
|
18
|
-
},
|
|
19
|
+
}, r = (e, t) => {
|
|
19
20
|
let n = e.editor;
|
|
20
21
|
if (n?.type !== "select" || n.clipboard !== "label") return;
|
|
21
22
|
if (typeof n.options != "function") return Array.isArray(n.options) ? n.options : void 0;
|
|
22
23
|
if (t === void 0) return;
|
|
23
24
|
let r = n.options(t);
|
|
24
25
|
return Array.isArray(r) ? r : void 0;
|
|
25
|
-
},
|
|
26
|
-
if (e.formatClipboardValue && i !== void 0) return e.formatClipboardValue(
|
|
27
|
-
let a = String(
|
|
26
|
+
}, i = (e, t, i) => {
|
|
27
|
+
if (e.formatClipboardValue && i !== void 0) return e.formatClipboardValue(t, i);
|
|
28
|
+
let a = String(t ?? ""), o = r(e, i);
|
|
28
29
|
if (o === void 0) return a;
|
|
29
|
-
let s =
|
|
30
|
+
let s = n(o).labelByValue.get(a);
|
|
30
31
|
return s === void 0 || s.trim() === "" ? a : s;
|
|
31
|
-
},
|
|
32
|
-
let
|
|
33
|
-
if (!(
|
|
34
|
-
let
|
|
35
|
-
if (
|
|
36
|
-
let
|
|
37
|
-
|
|
32
|
+
}, a = (t) => {
|
|
33
|
+
let i = t.editor;
|
|
34
|
+
if (!(i?.type !== "select" || i.clipboard !== "label")) return (i, a) => {
|
|
35
|
+
let o = r(t, a);
|
|
36
|
+
if (o === void 0) return i;
|
|
37
|
+
let s = n(o), c = i.trim(), l = e(a, t);
|
|
38
|
+
if (c !== "" && typeof l == "string" && s.labelByValue.get(l)?.trim() === c) return l;
|
|
39
|
+
let u = s.valueByLabel.get(c);
|
|
40
|
+
return u === void 0 ? s.labelByValue.has(i) ? i : s.labelByValue.has(c) ? c : i : u;
|
|
38
41
|
};
|
|
39
42
|
};
|
|
40
43
|
//#endregion
|
|
41
|
-
export {
|
|
44
|
+
export { i as formatCellClipboardText, a as resolveSelectLabelParser };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=/\s/,t=/^[゙゚]$/,n=e=>e>=12449&&e<=12534||e===12541||e===12542?e-96:e===12540||e>=8208&&e<=8213||e===8722?45:e,r=e=>{let t=e.charCodeAt(0);if(t<128)return t>=65&&t<=90?String.fromCharCode(t+32):e;let r=e.normalize(`NFKC`).toLowerCase(),i=``;for(let e of r)i+=String.fromCharCode(n(e.charCodeAt(0)))+e.slice(1);return i},i=n=>{let i=``,a=[],o=[],s=0;for(let c of n){let n=s;if(s+=c.length,e.test(c))continue;let l=r(c);for(let e of l){if(t.test(e)&&i.length>0){let t=(i[i.length-1]+e).normalize(`NFC`);if(t.length===1){i=i.slice(0,-1)+t,o[o.length-1]=s;continue}}for(let t=0;t<e.length;t+=1)i+=e[t],a.push(n),o.push(s)}}return{text:i,starts:a,ends:o}},a=e=>i(e).text,o=new WeakMap,s=e=>{let t=o.get(e);if(t===void 0){let n=i(String(e.label??``)),r=e.description?i(String(e.description)):null,s=[n.text];r!==null&&s.push(r.text),e.searchText&&s.push(a(String(e.searchText))),s.push(a(String(e.value??``))),t={label:n,description:r,targets:s},o.set(e,t)}return t},c=(e,t)=>{if(e===null||t===``)return null;let n=e.text.indexOf(t);return n<0?null:[e.starts[n],e.ends[n+t.length-1]]},l=(e,t,n)=>{let r=s(e);return{option:e,index:t,labelMatch:c(r.label,n),descriptionMatch:c(r.description,n)}},u=(e,t)=>{if(t===``)return e.map((e,t)=>l(e,t,``));let n=[],r=[],i=[];return e.forEach((e,a)=>{let{targets:o}=s(e),c=-1;for(let e of o){if(e===t){c=2;break}e.startsWith(t)?c=1:c<0&&e.includes(t)&&(c=0)}c>=0&&(c===2?n:c===1?r:i).push(l(e,a,t))}),n.concat(r,i)},d=(e,t)=>e.map((e,n)=>l(e,n,t)),f=(e,t)=>{let n=a(t);if(n!==``)return e.find(e=>s(e).label.text===n)},p=(e,t)=>{if(t===null||t[0]>=t[1])return[{text:e,match:!1}];let n=[];return t[0]>0&&n.push({text:e.slice(0,t[0]),match:!1}),n.push({text:e.slice(t[0],t[1]),match:!0}),t[1]<e.length&&n.push({text:e.slice(t[1]),match:!1}),n},m=(e,t,n,r,i=4)=>{if(r<=0||n<=0)return{start:0,end:0};let a=Math.floor(Math.max(e,0)/n),o=Math.ceil(Math.max(t,n)/n);return{start:Math.max(0,a-i),end:Math.min(r,a+o+i)}},h=(e,t,n,r)=>{if(e<0)return t;let i=e*r,a=i+r;return i<t?i:a>t+n?Math.max(0,a-n):t};exports.findSelectOptionByLabel=f,exports.foldSearchQuery=a,exports.foldSearchText=i,exports.markSelectSearchMatches=d,exports.resolveSelectListWindow=m,exports.revealSelectListRow=h,exports.searchSelectOptions=u,exports.splitSelectSearchText=p;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GridSelectEditorOption } from '../model/gridTypes.unbound.js';
|
|
2
|
+
export type FoldedSearchText = {
|
|
3
|
+
text: string;
|
|
4
|
+
starts: number[];
|
|
5
|
+
ends: number[];
|
|
6
|
+
};
|
|
7
|
+
export type SelectSearchRange = readonly [start: number, end: number];
|
|
8
|
+
export type SelectSearchResult = {
|
|
9
|
+
option: GridSelectEditorOption;
|
|
10
|
+
index: number;
|
|
11
|
+
labelMatch: SelectSearchRange | null;
|
|
12
|
+
descriptionMatch: SelectSearchRange | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const foldSearchText: (text: string) => FoldedSearchText;
|
|
15
|
+
export declare const foldSearchQuery: (query: string) => string;
|
|
16
|
+
export declare const searchSelectOptions: (options: readonly GridSelectEditorOption[], query: string) => SelectSearchResult[];
|
|
17
|
+
export declare const markSelectSearchMatches: (options: readonly GridSelectEditorOption[], query: string) => SelectSearchResult[];
|
|
18
|
+
export declare const findSelectOptionByLabel: (options: readonly GridSelectEditorOption[], text: string) => GridSelectEditorOption | undefined;
|
|
19
|
+
export declare const splitSelectSearchText: (text: string, range: SelectSearchRange | null) => {
|
|
20
|
+
text: string;
|
|
21
|
+
match: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
export declare const resolveSelectListWindow: (scrollTop: number, viewportHeight: number, rowHeight: number, count: number, overscan?: number) => {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
};
|
|
27
|
+
export declare const revealSelectListRow: (index: number, scrollTop: number, viewportHeight: number, rowHeight: number) => number;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//#region src/logic/selectSearch.ts
|
|
2
|
+
var e = /\s/, t = /^[゙゚]$/, n = (e) => e >= 12449 && e <= 12534 || e === 12541 || e === 12542 ? e - 96 : e === 12540 || e >= 8208 && e <= 8213 || e === 8722 ? 45 : e, r = (e) => {
|
|
3
|
+
let t = e.charCodeAt(0);
|
|
4
|
+
if (t < 128) return t >= 65 && t <= 90 ? String.fromCharCode(t + 32) : e;
|
|
5
|
+
let r = e.normalize("NFKC").toLowerCase(), i = "";
|
|
6
|
+
for (let e of r) i += String.fromCharCode(n(e.charCodeAt(0))) + e.slice(1);
|
|
7
|
+
return i;
|
|
8
|
+
}, i = (n) => {
|
|
9
|
+
let i = "", a = [], o = [], s = 0;
|
|
10
|
+
for (let c of n) {
|
|
11
|
+
let n = s;
|
|
12
|
+
if (s += c.length, e.test(c)) continue;
|
|
13
|
+
let l = r(c);
|
|
14
|
+
for (let e of l) {
|
|
15
|
+
if (t.test(e) && i.length > 0) {
|
|
16
|
+
let t = (i[i.length - 1] + e).normalize("NFC");
|
|
17
|
+
if (t.length === 1) {
|
|
18
|
+
i = i.slice(0, -1) + t, o[o.length - 1] = s;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
for (let t = 0; t < e.length; t += 1) i += e[t], a.push(n), o.push(s);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
text: i,
|
|
27
|
+
starts: a,
|
|
28
|
+
ends: o
|
|
29
|
+
};
|
|
30
|
+
}, a = (e) => i(e).text, o = /* @__PURE__ */ new WeakMap(), s = (e) => {
|
|
31
|
+
let t = o.get(e);
|
|
32
|
+
if (t === void 0) {
|
|
33
|
+
let n = i(String(e.label ?? "")), r = e.description ? i(String(e.description)) : null, s = [n.text];
|
|
34
|
+
r !== null && s.push(r.text), e.searchText && s.push(a(String(e.searchText))), s.push(a(String(e.value ?? ""))), t = {
|
|
35
|
+
label: n,
|
|
36
|
+
description: r,
|
|
37
|
+
targets: s
|
|
38
|
+
}, o.set(e, t);
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
}, c = (e, t) => {
|
|
42
|
+
if (e === null || t === "") return null;
|
|
43
|
+
let n = e.text.indexOf(t);
|
|
44
|
+
return n < 0 ? null : [e.starts[n], e.ends[n + t.length - 1]];
|
|
45
|
+
}, l = (e, t, n) => {
|
|
46
|
+
let r = s(e);
|
|
47
|
+
return {
|
|
48
|
+
option: e,
|
|
49
|
+
index: t,
|
|
50
|
+
labelMatch: c(r.label, n),
|
|
51
|
+
descriptionMatch: c(r.description, n)
|
|
52
|
+
};
|
|
53
|
+
}, u = (e, t) => {
|
|
54
|
+
if (t === "") return e.map((e, t) => l(e, t, ""));
|
|
55
|
+
let n = [], r = [], i = [];
|
|
56
|
+
return e.forEach((e, a) => {
|
|
57
|
+
let { targets: o } = s(e), c = -1;
|
|
58
|
+
for (let e of o) {
|
|
59
|
+
if (e === t) {
|
|
60
|
+
c = 2;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
e.startsWith(t) ? c = 1 : c < 0 && e.includes(t) && (c = 0);
|
|
64
|
+
}
|
|
65
|
+
c >= 0 && (c === 2 ? n : c === 1 ? r : i).push(l(e, a, t));
|
|
66
|
+
}), n.concat(r, i);
|
|
67
|
+
}, d = (e, t) => e.map((e, n) => l(e, n, t)), f = (e, t) => {
|
|
68
|
+
let n = a(t);
|
|
69
|
+
if (n !== "") return e.find((e) => s(e).label.text === n);
|
|
70
|
+
}, p = (e, t) => {
|
|
71
|
+
if (t === null || t[0] >= t[1]) return [{
|
|
72
|
+
text: e,
|
|
73
|
+
match: !1
|
|
74
|
+
}];
|
|
75
|
+
let n = [];
|
|
76
|
+
return t[0] > 0 && n.push({
|
|
77
|
+
text: e.slice(0, t[0]),
|
|
78
|
+
match: !1
|
|
79
|
+
}), n.push({
|
|
80
|
+
text: e.slice(t[0], t[1]),
|
|
81
|
+
match: !0
|
|
82
|
+
}), t[1] < e.length && n.push({
|
|
83
|
+
text: e.slice(t[1]),
|
|
84
|
+
match: !1
|
|
85
|
+
}), n;
|
|
86
|
+
}, m = (e, t, n, r, i = 4) => {
|
|
87
|
+
if (r <= 0 || n <= 0) return {
|
|
88
|
+
start: 0,
|
|
89
|
+
end: 0
|
|
90
|
+
};
|
|
91
|
+
let a = Math.floor(Math.max(e, 0) / n), o = Math.ceil(Math.max(t, n) / n);
|
|
92
|
+
return {
|
|
93
|
+
start: Math.max(0, a - i),
|
|
94
|
+
end: Math.min(r, a + o + i)
|
|
95
|
+
};
|
|
96
|
+
}, h = (e, t, n, r) => {
|
|
97
|
+
if (e < 0) return t;
|
|
98
|
+
let i = e * r, a = i + r;
|
|
99
|
+
return i < t ? i : a > t + n ? Math.max(0, a - n) : t;
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
export { f as findSelectOptionByLabel, a as foldSearchQuery, i as foldSearchText, d as markSelectSearchMatches, m as resolveSelectListWindow, h as revealSelectListRow, u as searchSelectOptions, p as splitSelectSearchText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./localeTextFilters.cjs"),n=require("./localeText.cjs"),r=require("./editorValues.cjs");var i=n.DEFAULT_GRID_LOCALE_TEXT.invalidValue,a=(e,t=i)=>e===!0?{valid:!0,message:``}:e===!1?{valid:!1,message:t}:typeof e==`string`?{valid:!1,message:e||t}:{valid:!1,message:e.message||t},o=({editor:e})=>e?.type===`number`&&(e.min!=null||e.max!=null||e.integer||e.strict)?e:void 0,s=({editor:e})=>e?.type===`date`&&e.strict===!0,c=(e,t,n)=>!s(e)||t==null||typeof t==`string`&&!t.trim()||(t instanceof Date||typeof t==`string`)&&r.toDateInputValue(t)!==``?null:n.enterDate,l=(e,n,i)=>{let a=o(e);if(!a||n==null||typeof n==`string`&&!n.trim())return null;let{min:s,max:c}=a,l=typeof n==`string`?r.parseNumberText(n)??NaN:typeof n==`number`?n:NaN;return Number.isFinite(l)?a.integer&&!Number.isInteger(l)?i.enterInteger:s!=null&&l<s||c!=null&&l>c?c==null?t.formatLocaleText(i.enterMin,{min:s}):s==null?t.formatLocaleText(i.enterMax,{max:c}):t.formatLocaleText(i.enterRange,{min:s,max:c}):null:i.enterNumber},u=e=>!!(e.validate||o(e)||s(e)),d=(e,t,r,i=n.DEFAULT_GRID_LOCALE_TEXT)=>{if(e.validate){let n=a(e.validate({value:r,row:t,column:e}),i.invalidValue);if(!n.valid)return n.message}return l(e,r,i)??c(e,r,i)},f=(e,t,n,r)=>{if((e.validationMode??`mark`)!==`reject`)return{action:`write`};let i=d(e,t,n,r);return i===null?{action:`write`}:{action:`reject`,message:i}},p=(t,n,r,i,a)=>{let o=n.filter(u);if(o.length===0)return[];let s=[];return t.forEach((t,n)=>{if(!i?.(t,n))for(let i of o){let o=d(i,t,e.getCellValue(t,i),a);o!==null&&s.push({rowKey:r(t,n)??n,sourceRowIndex:n,columnKey:i.key,message:o})}}),s};exports.DEFAULT_INVALID_MESSAGE=i,exports.decideCellWrite=f,exports.getInvalidMessage=d,exports.hasCellValidation=u,exports.normalizeValidationResult=a,exports.scanInvalidCells=p;
|
package/dist/logic/validation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { formatLocaleText as t } from "./localeTextFilters.js";
|
|
3
|
+
import { DEFAULT_GRID_LOCALE_TEXT as n } from "./localeText.js";
|
|
4
|
+
import { parseNumberText as r, toDateInputValue as i } from "./editorValues.js";
|
|
5
5
|
//#region src/logic/validation.ts
|
|
6
|
-
var a =
|
|
6
|
+
var a = n.invalidValue, o = (e, t = a) => e === !0 ? {
|
|
7
7
|
valid: !0,
|
|
8
8
|
message: ""
|
|
9
9
|
} : e === !1 ? {
|
|
@@ -15,24 +15,24 @@ var a = i.invalidValue, o = (e, t = a) => e === !0 ? {
|
|
|
15
15
|
} : {
|
|
16
16
|
valid: !1,
|
|
17
17
|
message: e.message || t
|
|
18
|
-
}, s = ({ editor: e }) => e?.type === "number" && (e.min != null || e.max != null || e.integer || e.strict) ? e : void 0, c = ({ editor: e }) => e?.type === "date" && e.strict === !0, l = (e, t,
|
|
18
|
+
}, s = ({ editor: e }) => e?.type === "number" && (e.min != null || e.max != null || e.integer || e.strict) ? e : void 0, c = ({ editor: e }) => e?.type === "date" && e.strict === !0, l = (e, t, n) => !c(e) || t == null || typeof t == "string" && !t.trim() || (t instanceof Date || typeof t == "string") && i(t) !== "" ? null : n.enterDate, u = (e, n, i) => {
|
|
19
19
|
let a = s(e);
|
|
20
20
|
if (!a || n == null || typeof n == "string" && !n.trim()) return null;
|
|
21
|
-
let { min: o, max: c } = a, l = typeof n == "string" ?
|
|
22
|
-
return Number.isFinite(l) ? a.integer && !Number.isInteger(l) ? i.enterInteger : o != null && l < o || c != null && l > c ? c == null ?
|
|
21
|
+
let { min: o, max: c } = a, l = typeof n == "string" ? r(n) ?? NaN : typeof n == "number" ? n : NaN;
|
|
22
|
+
return Number.isFinite(l) ? a.integer && !Number.isInteger(l) ? i.enterInteger : o != null && l < o || c != null && l > c ? c == null ? t(i.enterMin, { min: o }) : o == null ? t(i.enterMax, { max: c }) : t(i.enterRange, {
|
|
23
23
|
min: o,
|
|
24
24
|
max: c
|
|
25
25
|
}) : null : i.enterNumber;
|
|
26
|
-
}, d = (e) => !!(e.validate || s(e) || c(e)), f = (e, t,
|
|
26
|
+
}, d = (e) => !!(e.validate || s(e) || c(e)), f = (e, t, r, i = n) => {
|
|
27
27
|
if (e.validate) {
|
|
28
|
-
let
|
|
29
|
-
value:
|
|
28
|
+
let n = o(e.validate({
|
|
29
|
+
value: r,
|
|
30
30
|
row: t,
|
|
31
31
|
column: e
|
|
32
|
-
}),
|
|
33
|
-
if (!
|
|
32
|
+
}), i.invalidValue);
|
|
33
|
+
if (!n.valid) return n.message;
|
|
34
34
|
}
|
|
35
|
-
return u(e,
|
|
35
|
+
return u(e, r, i) ?? l(e, r, i);
|
|
36
36
|
}, p = (e, t, n, r) => {
|
|
37
37
|
if ((e.validationMode ?? "mark") !== "reject") return { action: "write" };
|
|
38
38
|
let i = f(e, t, n, r);
|