@operato/data-grist 7.1.13 → 7.1.21
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/CHANGELOG.md +10 -0
- package/dist/src/editors/ox-grist-editor-varname.d.ts +6 -0
- package/dist/src/editors/ox-grist-editor-varname.js +36 -0
- package/dist/src/editors/ox-grist-editor-varname.js.map +1 -0
- package/dist/src/editors/registry.js +3 -1
- package/dist/src/editors/registry.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/editors/ox-grist-editor-varname.ts +36 -0
- package/src/editors/registry.ts +3 -1
- package/yarn-error.log +0 -16971
@@ -0,0 +1,36 @@
|
|
1
|
+
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
+
import { customElement } from 'lit/decorators.js'
|
3
|
+
import { html } from 'lit'
|
4
|
+
|
5
|
+
@customElement('ox-grist-editor-varname')
|
6
|
+
export class OxGristEditorVarname extends OxGristEditor {
|
7
|
+
get inlineEditable() {
|
8
|
+
return true
|
9
|
+
}
|
10
|
+
|
11
|
+
get editorTemplate() {
|
12
|
+
return html`
|
13
|
+
<input
|
14
|
+
type="text"
|
15
|
+
.value=${this.value}
|
16
|
+
@input=${this.handleInput}
|
17
|
+
pattern="^[A-Za-z_][A-Za-z0-9_]*$"
|
18
|
+
title="Variable names must start with a letter or underscore and contain only letters, numbers, or underscores."
|
19
|
+
/>
|
20
|
+
`
|
21
|
+
}
|
22
|
+
|
23
|
+
handleInput(event: KeyboardEvent) {
|
24
|
+
const input = event.target as HTMLInputElement
|
25
|
+
const regex = /^[A-Za-z_][A-Za-z0-9_]*$/
|
26
|
+
|
27
|
+
// Only allow valid characters as the user types
|
28
|
+
if (!regex.test(input.value)) {
|
29
|
+
// Keep only valid characters and start with a letter or underscore
|
30
|
+
input.value = input.value.replace(/[^A-Za-z0-9_]/g, '').replace(/^[^A-Za-z_]+/, '')
|
31
|
+
}
|
32
|
+
|
33
|
+
// Update the component's internal value state
|
34
|
+
this.value = input.value
|
35
|
+
}
|
36
|
+
}
|
package/src/editors/registry.ts
CHANGED
@@ -19,6 +19,7 @@ import { OxGristEditorTextarea } from './ox-grist-editor-textarea'
|
|
19
19
|
import { OxGristEditorTime } from './ox-grist-editor-time'
|
20
20
|
import { OxGristEditorTree } from './ox-grist-editor-tree'
|
21
21
|
import { OxGristEditorWeek } from './ox-grist-editor-week'
|
22
|
+
import { OxGristEditorVarname } from './ox-grist-editor-varname'
|
22
23
|
|
23
24
|
var EDITORS: { [name: string]: { new (): OxGristEditor } } = {
|
24
25
|
string: OxGristEditorText,
|
@@ -44,7 +45,8 @@ var EDITORS: { [name: string]: { new (): OxGristEditor } } = {
|
|
44
45
|
image: OxGristEditorImage,
|
45
46
|
file: OxGristEditorFile,
|
46
47
|
'string[]': OxGristEditorMultipleSelect,
|
47
|
-
tree: OxGristEditorTree
|
48
|
+
tree: OxGristEditorTree,
|
49
|
+
varname: OxGristEditorVarname
|
48
50
|
}
|
49
51
|
|
50
52
|
export function registerEditor(type: string, editor: { new (): OxGristEditor }) {
|