@operato/data-grist 8.0.0-alpha.5 → 8.0.0-alpha.51
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 +169 -0
- package/dist/src/data-card/record-card.js +10 -1
- package/dist/src/data-card/record-card.js.map +1 -1
- package/dist/src/data-grid/data-grid-body.js +21 -7
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-footer.js +2 -0
- package/dist/src/data-grid/data-grid-footer.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.d.ts +1 -1
- package/dist/src/data-grid/data-grid-header.js +13 -9
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-list/record-partial.js +10 -1
- package/dist/src/data-list/record-partial.js.map +1 -1
- 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/ox-grist-editor.js +3 -3
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/editors/registry.js +3 -1
- package/dist/src/editors/registry.js.map +1 -1
- package/dist/src/gutters/gutter-sequence.d.ts +1 -1
- package/dist/src/record-view/record-view-body.js +4 -5
- package/dist/src/record-view/record-view-body.js.map +1 -1
- package/dist/src/renderers/ox-grist-renderer-boolean.js +1 -1
- package/dist/src/renderers/ox-grist-renderer-boolean.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -18
- package/src/data-card/record-card.ts +10 -1
- package/src/data-grid/data-grid-body.ts +23 -7
- package/src/data-grid/data-grid-footer.ts +2 -0
- package/src/data-grid/data-grid-header.ts +13 -9
- package/src/data-list/record-partial.ts +10 -1
- package/src/editors/ox-grist-editor-varname.ts +36 -0
- package/src/editors/ox-grist-editor.ts +3 -3
- package/src/editors/registry.ts +3 -1
- package/src/record-view/record-view-body.ts +11 -13
- package/src/renderers/ox-grist-renderer-boolean.ts +1 -1
- package/themes/calendar-theme.css +3 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@operato/data-grist",
|
3
|
-
"version": "8.0.0-alpha.
|
3
|
+
"version": "8.0.0-alpha.51",
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
5
5
|
"author": "heartyoh",
|
6
6
|
"main": "dist/index.js",
|
@@ -62,32 +62,32 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@material/web": "^2.0.0",
|
65
|
-
"@operato/headroom": "^8.0.0-alpha.
|
66
|
-
"@operato/input": "^8.0.0-alpha.
|
67
|
-
"@operato/p13n": "^8.0.0-alpha.
|
68
|
-
"@operato/popup": "^8.0.0-alpha.
|
69
|
-
"@operato/pull-to-refresh": "^8.0.0-alpha.
|
70
|
-
"@operato/styles": "^8.0.0-alpha.
|
71
|
-
"@operato/time-calculator": "^8.0.0-alpha.
|
72
|
-
"@operato/utils": "^8.0.0-alpha.
|
65
|
+
"@operato/headroom": "^8.0.0-alpha.37",
|
66
|
+
"@operato/input": "^8.0.0-alpha.51",
|
67
|
+
"@operato/p13n": "^8.0.0-alpha.51",
|
68
|
+
"@operato/popup": "^8.0.0-alpha.51",
|
69
|
+
"@operato/pull-to-refresh": "^8.0.0-alpha.37",
|
70
|
+
"@operato/styles": "^8.0.0-alpha.50",
|
71
|
+
"@operato/time-calculator": "^8.0.0-alpha.37",
|
72
|
+
"@operato/utils": "^8.0.0-alpha.37",
|
73
73
|
"i18next": "^23.11.5",
|
74
74
|
"json5": "^2.2.0",
|
75
75
|
"lit": "^3.1.2",
|
76
76
|
"lodash-es": "^4.17.21"
|
77
77
|
},
|
78
78
|
"devDependencies": {
|
79
|
-
"@custom-elements-manifest/analyzer": "^0.
|
79
|
+
"@custom-elements-manifest/analyzer": "^0.10.0",
|
80
80
|
"@hatiolab/prettier-config": "^1.0.0",
|
81
81
|
"@open-wc/eslint-config": "^12.0.3",
|
82
|
-
"@open-wc/testing": "^
|
82
|
+
"@open-wc/testing": "^4.0.0",
|
83
83
|
"@types/lodash-es": "^4.17.5",
|
84
|
-
"@typescript-eslint/eslint-plugin": "^
|
85
|
-
"@typescript-eslint/parser": "^
|
86
|
-
"@web/dev-server": "^0.
|
84
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
85
|
+
"@typescript-eslint/parser": "^8.0.0",
|
86
|
+
"@web/dev-server": "^0.4.0",
|
87
87
|
"@web/dev-server-storybook": "^2.0.1",
|
88
|
-
"@web/test-runner": "^0.
|
89
|
-
"concurrently": "^
|
90
|
-
"eslint": "^
|
88
|
+
"@web/test-runner": "^0.19.0",
|
89
|
+
"concurrently": "^9.0.0",
|
90
|
+
"eslint": "^9.0.0",
|
91
91
|
"eslint-config-prettier": "^9.1.0",
|
92
92
|
"husky": "^9.0.11",
|
93
93
|
"lint-staged": "^15.2.2",
|
@@ -108,5 +108,5 @@
|
|
108
108
|
"prettier --write"
|
109
109
|
]
|
110
110
|
},
|
111
|
-
"gitHead": "
|
111
|
+
"gitHead": "ac94e729e3647d45c921be99f96f4c2e65cef797"
|
112
112
|
}
|
@@ -25,7 +25,16 @@ const OPTIONS: Intl.DateTimeFormatOptions = {
|
|
25
25
|
// timeZone: 'America/Los_Angeles'
|
26
26
|
}
|
27
27
|
|
28
|
-
|
28
|
+
function getSafeFormatter(locale: string, options: Intl.DateTimeFormatOptions) {
|
29
|
+
try {
|
30
|
+
const safeLocale = locale || 'en-US'
|
31
|
+
return new Intl.DateTimeFormat(safeLocale, options)
|
32
|
+
} catch (e) {
|
33
|
+
return new Intl.DateTimeFormat('en-US', options)
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
const formatter = getSafeFormatter(navigator.language, OPTIONS)
|
29
38
|
|
30
39
|
@customElement('ox-record-card')
|
31
40
|
export class RecordCard extends LitElement {
|
@@ -61,6 +61,9 @@ export class DataGridBody extends LitElement {
|
|
61
61
|
css`
|
62
62
|
:host {
|
63
63
|
font-variation-settings: 'FILL' 1;
|
64
|
+
|
65
|
+
overscroll-behavior: none;
|
66
|
+
user-select: none;
|
64
67
|
}
|
65
68
|
|
66
69
|
[select-block] {
|
@@ -72,6 +75,7 @@ export class DataGridBody extends LitElement {
|
|
72
75
|
border: var(--grid-record-focused-cell-border);
|
73
76
|
background-image: var(--focused-background-image);
|
74
77
|
pointer-events: none;
|
78
|
+
|
75
79
|
z-index: 5;
|
76
80
|
}
|
77
81
|
|
@@ -289,14 +293,16 @@ export class DataGridBody extends LitElement {
|
|
289
293
|
)
|
290
294
|
})
|
291
295
|
|
292
|
-
this.renderRoot.addEventListener('
|
293
|
-
const e = event as MouseEvent
|
296
|
+
this.renderRoot.addEventListener('pointerdown', (e: Event) => {
|
294
297
|
this.setSelectBlock()
|
295
298
|
|
296
|
-
if (e.buttons !== 1) {
|
299
|
+
if ('buttons' in e && e.buttons !== 1) {
|
297
300
|
return
|
298
301
|
}
|
299
302
|
|
303
|
+
e.preventDefault()
|
304
|
+
e.stopPropagation()
|
305
|
+
|
300
306
|
this._draggable = true
|
301
307
|
|
302
308
|
var target = (e.target as Element).closest('ox-grid-field') as DataGridField
|
@@ -318,12 +324,15 @@ export class DataGridBody extends LitElement {
|
|
318
324
|
}
|
319
325
|
})
|
320
326
|
|
321
|
-
this.renderRoot.addEventListener('
|
327
|
+
this.renderRoot.addEventListener('pointermove', (event: Event) => {
|
322
328
|
const e = event as MouseEvent
|
323
|
-
if (e.buttons !== 1 || !this._draggable) {
|
329
|
+
if (('buttons' in e && e.buttons !== 1) || !this._draggable) {
|
324
330
|
return
|
325
331
|
}
|
326
332
|
|
333
|
+
e.preventDefault()
|
334
|
+
e.stopPropagation()
|
335
|
+
|
327
336
|
const field = e.target as DataGridField
|
328
337
|
if (!this._selectBlock) {
|
329
338
|
this.setSelectBlock(this.focusedField || field, this.focusedField || field)
|
@@ -340,7 +349,10 @@ export class DataGridBody extends LitElement {
|
|
340
349
|
}
|
341
350
|
})
|
342
351
|
|
343
|
-
this.renderRoot.addEventListener('
|
352
|
+
this.renderRoot.addEventListener('pointerup', (event: Event) => {
|
353
|
+
event.preventDefault()
|
354
|
+
event.stopPropagation()
|
355
|
+
|
344
356
|
this._draggable = false
|
345
357
|
})
|
346
358
|
|
@@ -650,7 +662,11 @@ export class DataGridBody extends LitElement {
|
|
650
662
|
value = parseToNumberOrNull(value)
|
651
663
|
break
|
652
664
|
default:
|
653
|
-
|
665
|
+
try {
|
666
|
+
value = JSON.parse(value)
|
667
|
+
} catch (err) {
|
668
|
+
value = value
|
669
|
+
}
|
654
670
|
}
|
655
671
|
|
656
672
|
if (targetColumn && !targetColumn.gutterName && editable) {
|
@@ -28,6 +28,8 @@ export class DataGridHeader extends LitElement {
|
|
28
28
|
overflow: hidden;
|
29
29
|
|
30
30
|
font-variation-settings: 'FILL' 1;
|
31
|
+
|
32
|
+
user-select: none;
|
31
33
|
}
|
32
34
|
|
33
35
|
:host([raised]) [fixed] {
|
@@ -266,7 +268,9 @@ export class DataGridHeader extends LitElement {
|
|
266
268
|
: nothing}
|
267
269
|
${column.resizable !== false
|
268
270
|
? html`
|
269
|
-
<span splitter draggable="false" @
|
271
|
+
<span splitter draggable="false" @pointerdown=${(e: PointerEvent) => this._pointerdown(e, index)}
|
272
|
+
> </span
|
273
|
+
>
|
270
274
|
`
|
271
275
|
: nothing}
|
272
276
|
</div>
|
@@ -543,11 +547,11 @@ export class DataGridHeader extends LitElement {
|
|
543
547
|
this._throttledNotifier(idx, width)
|
544
548
|
}
|
545
549
|
|
546
|
-
|
550
|
+
_pointerdown(e: MouseEvent, idx: number) {
|
547
551
|
e.stopPropagation()
|
548
552
|
e.preventDefault()
|
549
553
|
|
550
|
-
var
|
554
|
+
var pointermoveHandler = ((e: MouseEvent) => {
|
551
555
|
e.stopPropagation()
|
552
556
|
e.preventDefault()
|
553
557
|
let column = this.columns[idx]
|
@@ -561,14 +565,14 @@ export class DataGridHeader extends LitElement {
|
|
561
565
|
this._notifyWidthChange(idx, width)
|
562
566
|
}).bind(this)
|
563
567
|
|
564
|
-
var
|
565
|
-
document.removeEventListener('
|
566
|
-
document.removeEventListener('
|
568
|
+
var pointerupHandler = ((e: MouseEvent) => {
|
569
|
+
document.removeEventListener('pointermove', pointermoveHandler)
|
570
|
+
document.removeEventListener('pointerup', pointerupHandler)
|
567
571
|
|
568
|
-
|
572
|
+
pointermoveHandler(e)
|
569
573
|
}).bind(this)
|
570
574
|
|
571
|
-
document.addEventListener('
|
572
|
-
document.addEventListener('
|
575
|
+
document.addEventListener('pointermove', pointermoveHandler)
|
576
|
+
document.addEventListener('pointerup', pointerupHandler)
|
573
577
|
}
|
574
578
|
}
|
@@ -26,7 +26,16 @@ const OPTIONS: Intl.DateTimeFormatOptions = {
|
|
26
26
|
// timeZone: 'America/Los_Angeles'
|
27
27
|
}
|
28
28
|
|
29
|
-
|
29
|
+
function getSafeFormatter(locale: string, options: Intl.DateTimeFormatOptions) {
|
30
|
+
try {
|
31
|
+
const safeLocale = locale || 'en-US'
|
32
|
+
return new Intl.DateTimeFormat(safeLocale, options)
|
33
|
+
} catch (e) {
|
34
|
+
return new Intl.DateTimeFormat('en-US', options)
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
const formatter = getSafeFormatter(navigator.language, OPTIONS)
|
30
39
|
|
31
40
|
@customElement('ox-record-partial')
|
32
41
|
export class RecordPartial extends LitElement {
|
@@ -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
|
+
}
|
@@ -107,9 +107,9 @@ export class OxGristEditor extends LitElement {
|
|
107
107
|
this.addEventListener('keydown', this._onkeydown.bind(this))
|
108
108
|
|
109
109
|
/* editor mode 인 경우의 마우스 움직임이, grist-body의 이벤트 처리에 의해서 에디터를 리셋시킬 수 있으므로, 이벤트 전파를 막는다. */
|
110
|
-
this.addEventListener('
|
111
|
-
this.addEventListener('
|
112
|
-
this.addEventListener('
|
110
|
+
this.addEventListener('pointerdown', (e: Event) => e.stopPropagation())
|
111
|
+
this.addEventListener('pointermove', (e: Event) => e.stopPropagation())
|
112
|
+
this.addEventListener('pointerup', (e: Event) => e.stopPropagation())
|
113
113
|
|
114
114
|
const { name = '' } = this.column
|
115
115
|
const { align, defaultValue } = this.column.record
|
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 }) {
|
@@ -24,7 +24,7 @@ export class RecordViewBody extends LitElement {
|
|
24
24
|
}
|
25
25
|
|
26
26
|
div[content] {
|
27
|
-
align-self:
|
27
|
+
align-self: center;
|
28
28
|
|
29
29
|
display: grid;
|
30
30
|
grid-template-columns: 2fr 3fr 2fr 3fr;
|
@@ -70,7 +70,6 @@ export class RecordViewBody extends LitElement {
|
|
70
70
|
}
|
71
71
|
|
72
72
|
ox-grid-field {
|
73
|
-
justify-content: var();
|
74
73
|
background-color: var(--record-view-grid-field-background-color, var(--md-sys-color-surface-container-lowest));
|
75
74
|
border: var(--record-view-grid-field-border);
|
76
75
|
border-radius: var(--md-sys-shape-corner-small);
|
@@ -96,12 +95,12 @@ export class RecordViewBody extends LitElement {
|
|
96
95
|
color: var(--record-view-focus-color);
|
97
96
|
font-weight: bold;
|
98
97
|
}
|
99
|
-
|
98
|
+
|
100
99
|
.highlight-invalid {
|
101
100
|
position: relative;
|
102
101
|
padding: var(--spacing-tiny) var(--spacing-small);
|
103
102
|
}
|
104
|
-
|
103
|
+
|
105
104
|
.highlight-invalid::after {
|
106
105
|
content: attr(data-reason); /* 콘텐츠를 동적으로 변경하기 위해 data-reason 속성을 사용 */
|
107
106
|
color: red;
|
@@ -110,7 +109,7 @@ export class RecordViewBody extends LitElement {
|
|
110
109
|
left: 0;
|
111
110
|
bottom: -8px; /* 라벨 아래쪽에 메시지를 표시 */
|
112
111
|
}
|
113
|
-
|
112
|
+
|
114
113
|
@media only screen and (max-width: 1000px) {
|
115
114
|
div[content] {
|
116
115
|
grid-template-columns: 2fr 3fr;
|
@@ -166,7 +165,7 @@ export class RecordViewBody extends LitElement {
|
|
166
165
|
super.disconnectedCallback()
|
167
166
|
this.removeEventListener('keydown', this._onKeyDown)
|
168
167
|
}
|
169
|
-
|
168
|
+
|
170
169
|
setFocus(fieldElement: HTMLElement) {
|
171
170
|
fieldElement?.dispatchEvent(new CustomEvent('click', { bubbles: true, composed: true }))
|
172
171
|
}
|
@@ -176,26 +175,25 @@ export class RecordViewBody extends LitElement {
|
|
176
175
|
allLabels.forEach((label: HTMLLabelElement) => {
|
177
176
|
label.classList.remove('highlight-invalid')
|
178
177
|
label.removeAttribute('data-reason')
|
179
|
-
})
|
180
|
-
|
178
|
+
})
|
179
|
+
|
181
180
|
// 유효성 검사를 통과하지 못한 필드에 대해 처리
|
182
181
|
invalidFields.forEach(({ field, reason }, index) => {
|
183
182
|
const labelElement = this.renderRoot.querySelector(`[data-name="${field}"]`) as HTMLLabelElement
|
184
183
|
const fieldElement = this.renderRoot.querySelector(`[data-name="${field}"] + ox-grid-field`) as HTMLInputElement
|
185
|
-
|
184
|
+
|
186
185
|
// 동적으로 data-reason 속성을 설정하여 메시지를 변경
|
187
186
|
if (labelElement) {
|
188
|
-
labelElement.classList.add('highlight-invalid')
|
187
|
+
labelElement.classList.add('highlight-invalid')
|
189
188
|
labelElement.setAttribute('data-reason', '(' + i18next.t(`text.validation-reason.${reason}`) + ')')
|
190
189
|
}
|
191
|
-
|
190
|
+
|
192
191
|
// 첫 번째 필드에 포커스 설정
|
193
192
|
if (index === 0 && fieldElement) {
|
194
193
|
this.setFocus(fieldElement)
|
195
194
|
}
|
196
|
-
})
|
195
|
+
})
|
197
196
|
}
|
198
|
-
|
199
197
|
|
200
198
|
_onKeyDown(event: KeyboardEvent) {
|
201
199
|
if (event.key === 'Tab') {
|
@@ -12,7 +12,7 @@ export const OxGristRendererBoolean: FieldRenderer = (value, column, record, row
|
|
12
12
|
type="checkbox"
|
13
13
|
.checked=${!!value && !!String(value).match(/true/i)}
|
14
14
|
?disabled=${!editable}
|
15
|
-
@
|
15
|
+
@pointerdown=${(e: Event) => {
|
16
16
|
/* edit mode로 전환되지 않도록 차단함. 체크박스인풋은 렌더러 모드에서도 처리가능하므로. */
|
17
17
|
e.stopPropagation()
|
18
18
|
}}
|
@@ -9,7 +9,8 @@ body {
|
|
9
9
|
/* monthly layout */
|
10
10
|
--calendar-monthly-ol-margin: var(--margin-default) 0;
|
11
11
|
--calendar-monthly-ol-top-border: 2px solid var(--md-sys-color-secondary);
|
12
|
-
--calendar-current-
|
12
|
+
--calendar-current-month-background-color: var(--md-sys-color-surface-variant);
|
13
|
+
--calendar-current-month-color: var(--md-sys-color-on-surface);
|
13
14
|
--calendar-monthly-label-align: left;
|
14
15
|
--calendar-monthly-label-padding: var(--padding-narrow) 0;
|
15
16
|
--calendar-monthly-label-color: var(--md-sys-color-secondary);
|
@@ -35,6 +36,7 @@ body {
|
|
35
36
|
--calendar-weekly-ol-margin: var(--margin-default) 0;
|
36
37
|
--calendar-weekly-ol-top-border: 2px solid var(--md-sys-color-secondary);
|
37
38
|
--calendar-current-week-background-color: var(--md-sys-color-surface-variant);
|
39
|
+
--calendar-current-week-color: var(--md-sys-color-on-surface);
|
38
40
|
--calendar-weekly-label-align: center;
|
39
41
|
--calendar-weekly-label-padding: var(--padding-narrow) 0;
|
40
42
|
--calendar-weekly-label-color: var(--md-sys-color-secondary);
|