@operato/grist-editor 2.0.0-alpha.5 → 2.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +264 -0
  2. package/dist/src/index.js +4 -0
  3. package/dist/src/index.js.map +1 -1
  4. package/dist/src/ox-grist-editor-crontab.d.ts +1 -1
  5. package/dist/src/ox-grist-editor-duration.d.ts +1 -1
  6. package/dist/src/ox-grist-editor-hashtags.d.ts +1 -1
  7. package/dist/src/ox-grist-editor-i18n-label.d.ts +13 -0
  8. package/dist/src/ox-grist-editor-i18n-label.js +85 -0
  9. package/dist/src/ox-grist-editor-i18n-label.js.map +1 -0
  10. package/dist/src/ox-grist-editor-parameters.d.ts +1 -1
  11. package/dist/src/ox-grist-editor-partition-keys.d.ts +1 -1
  12. package/dist/src/ox-grist-editor-quantifier.d.ts +1 -1
  13. package/dist/src/ox-grist-editor-value-map.d.ts +1 -1
  14. package/dist/src/ox-grist-editor-value-ranges.d.ts +1 -1
  15. package/dist/src/ox-grist-renderer-i18n-label.d.ts +2 -0
  16. package/dist/src/ox-grist-renderer-i18n-label.js +9 -0
  17. package/dist/src/ox-grist-renderer-i18n-label.js.map +1 -0
  18. package/dist/src/ox-popup-crontab-input.d.ts +1 -1
  19. package/dist/src/ox-popup-duration-input.d.ts +1 -1
  20. package/dist/src/ox-popup-hashtags-input.d.ts +1 -1
  21. package/dist/src/ox-popup-i18n-label-input.d.ts +15 -0
  22. package/dist/src/ox-popup-i18n-label-input.js +101 -0
  23. package/dist/src/ox-popup-i18n-label-input.js.map +1 -0
  24. package/dist/src/ox-popup-parameters-builder.d.ts +1 -1
  25. package/dist/src/ox-popup-partition-keys-input.d.ts +1 -1
  26. package/dist/src/ox-popup-value-map-input.d.ts +1 -1
  27. package/dist/src/ox-popup-value-ranges-input.d.ts +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +43 -31
  30. package/src/index.ts +4 -0
  31. package/src/ox-grist-editor-i18n-label.ts +101 -0
  32. package/src/ox-grist-renderer-i18n-label.ts +12 -0
  33. package/src/ox-popup-i18n-label-input.ts +98 -0
  34. package/themes/grist-theme.css +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/grist-editor",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.51",
4
4
  "description": "Webcomponent for grist-editor following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/src/index.js",
@@ -17,42 +17,51 @@
17
17
  },
18
18
  "exports": {
19
19
  ".": "./dist/src/index.js",
20
- "./ox-grist-editor-duration.js": "./dist/src/ox-grist-editor-duration.js",
21
20
  "./ox-grist-editor-crontab.js": "./dist/src/ox-grist-editor-crontab.js",
21
+ "./ox-grist-editor-duration.js": "./dist/src/ox-grist-editor-duration.js",
22
+ "./ox-grist-editor-hashtags.js": "./dist/src/ox-grist-editor-hashtags.js",
23
+ "./ox-grist-editor-i18n-label.js": "./dist/src/ox-grist-editor-i18n-label.js",
22
24
  "./ox-grist-editor-parameters.js": "./dist/src/ox-grist-editor-parameters.js",
23
- "./ox-grist-editor-value-map.js": "./dist/src/ox-grist-editor-value-map.js",
24
- "./ox-grist-editor-value-ranges.js": "./dist/src/ox-grist-editor-value-ranges.js",
25
25
  "./ox-grist-editor-partition-keys.js": "./dist/src/ox-grist-editor-partition-keys.js",
26
26
  "./ox-grist-editor-quantifier.js": "./dist/src/ox-grist-editor-quantifier.js",
27
+ "./ox-grist-editor-value-map.js": "./dist/src/ox-grist-editor-value-map.js",
28
+ "./ox-grist-editor-value-ranges.js": "./dist/src/ox-grist-editor-value-ranges.js",
27
29
  "./ox-grist-renderer-crontab.js": "./dist/src/ox-grist-renderer-crontab.js",
28
30
  "./ox-grist-renderer-duration.js": "./dist/src/ox-grist-renderer-duration.js",
29
31
  "./ox-grist-renderer-hashtags.js": "./dist/src/ox-grist-renderer-hashtags.js",
32
+ "./ox-grist-renderer-i18n-label.js": "./dist/src/ox-grist-renderer-i18n-label.js",
30
33
  "./ox-grist-renderer-partition-keys.js": "./dist/src/ox-grist-renderer-partition-keys.js",
31
34
  "./ox-grist-renderer-quantifier.js": "./dist/src/ox-grist-renderer-quantifier.js"
32
35
  },
33
36
  "typesVersions": {
34
37
  "*": {
38
+ "ox-grist-editor-crontab.js": [
39
+ "dist/src/ox-grist-editor-crontab.d.ts"
40
+ ],
35
41
  "ox-grist-editor-duration.js": [
36
42
  "dist/src/ox-grist-editor-duration.d.ts"
37
43
  ],
38
- "ox-grist-editor-crontab.js": [
39
- "dist/src/ox-grist-editor-crontab.d.ts"
44
+ "ox-grist-editor-hashtags.js": [
45
+ "dist/src/ox-grist-editor-hashtags.d.ts"
46
+ ],
47
+ "ox-grist-editor-i18n-label.js": [
48
+ "dist/src/ox-grist-editor-i18n-label.d.ts"
40
49
  ],
41
50
  "ox-grist-editor-parameters.js": [
42
51
  "dist/src/ox-grist-editor-parameters.d.ts"
43
52
  ],
44
- "ox-grist-editor-value-map.js": [
45
- "dist/src/ox-grist-editor-value-map.d.ts"
46
- ],
47
- "ox-grist-editor-value-ranges.js": [
48
- "dist/src/ox-grist-editor-value-ranges.d.ts"
49
- ],
50
53
  "ox-grist-editor-partition-keys.js": [
51
54
  "dist/src/ox-grist-editor-partition-keys.d.ts"
52
55
  ],
53
56
  "ox-grist-editor-quantifier.js": [
54
57
  "dist/src/ox-grist-editor-quantifier.d.ts"
55
58
  ],
59
+ "ox-grist-editor-value-map.js": [
60
+ "dist/src/ox-grist-editor-value-map.d.ts"
61
+ ],
62
+ "ox-grist-editor-value-ranges.js": [
63
+ "dist/src/ox-grist-editor-value-ranges.d.ts"
64
+ ],
56
65
  "ox-grist-renderer-crontab.js": [
57
66
  "dist/src/ox-grist-renderer-crontab.d.ts"
58
67
  ],
@@ -62,6 +71,9 @@
62
71
  "ox-grist-renderer-hashtags.js": [
63
72
  "dist/src/ox-grist-renderer-hashtags.d.ts"
64
73
  ],
74
+ "ox-grist-renderer-i18n-label.js": [
75
+ "dist/src/ox-grist-renderer-i18n-label.d.ts"
76
+ ],
65
77
  "ox-grist-renderer-partition-keys.js": [
66
78
  "dist/src/ox-grist-renderer-partition-keys.d.ts"
67
79
  ],
@@ -86,38 +98,38 @@
86
98
  "@material/mwc-button": "^0.27.0",
87
99
  "@material/mwc-icon": "^0.27.0",
88
100
  "@material/mwc-icon-button": "^0.27.0",
89
- "@operato/data-grist": "^2.0.0-alpha.5",
90
- "@operato/help": "^2.0.0-alpha.5",
91
- "@operato/i18n": "^2.0.0-alpha.0",
92
- "@operato/input": "^2.0.0-alpha.4",
93
- "@operato/popup": "^2.0.0-alpha.4",
94
- "@operato/property-editor": "^2.0.0-alpha.5",
95
- "@operato/styles": "^2.0.0-alpha.0",
101
+ "@operato/data-grist": "^2.0.0-alpha.51",
102
+ "@operato/help": "^2.0.0-alpha.51",
103
+ "@operato/i18n": "^2.0.0-alpha.51",
104
+ "@operato/input": "^2.0.0-alpha.51",
105
+ "@operato/popup": "^2.0.0-alpha.51",
106
+ "@operato/property-editor": "^2.0.0-alpha.51",
107
+ "@operato/styles": "^2.0.0-alpha.51",
96
108
  "cronstrue": "^2.2.0",
97
109
  "cross-fetch": "^3.1.5",
98
- "lit": "^2.5.0",
110
+ "lit": "^3.1.2",
99
111
  "lodash-es": "^4.17.21"
100
112
  },
101
113
  "devDependencies": {
102
- "@custom-elements-manifest/analyzer": "^0.8.1",
114
+ "@custom-elements-manifest/analyzer": "^0.9.2",
103
115
  "@hatiolab/prettier-config": "^1.0.0",
104
116
  "@material/mwc-fab": "^0.27.0",
105
117
  "@material/mwc-icon": "^0.27.0",
106
- "@open-wc/eslint-config": "^10.0.0",
118
+ "@open-wc/eslint-config": "^12.0.3",
107
119
  "@open-wc/testing": "^3.1.6",
108
120
  "@types/lodash-es": "^4.17.5",
109
121
  "@types/w3c-web-usb": "^1.0.5",
110
- "@typescript-eslint/eslint-plugin": "^5.59.1",
111
- "@typescript-eslint/parser": "^5.59.1",
122
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
123
+ "@typescript-eslint/parser": "^7.0.1",
112
124
  "@web/dev-server": "^0.3.0",
113
- "@web/dev-server-storybook": "^0.7.4",
114
- "@web/test-runner": "^0.17.0",
125
+ "@web/dev-server-storybook": "^2.0.1",
126
+ "@web/test-runner": "^0.18.0",
115
127
  "concurrently": "^8.0.1",
116
128
  "eslint": "^8.39.0",
117
- "eslint-config-prettier": "^8.3.0",
118
- "husky": "^8.0.1",
119
- "lint-staged": "^13.2.2",
120
- "prettier": "^2.4.1",
129
+ "eslint-config-prettier": "^9.1.0",
130
+ "husky": "^9.0.11",
131
+ "lint-staged": "^15.2.2",
132
+ "prettier": "^3.2.5",
121
133
  "tslib": "^2.3.1",
122
134
  "typescript": "^5.0.4"
123
135
  },
@@ -134,5 +146,5 @@
134
146
  "prettier --write"
135
147
  ]
136
148
  },
137
- "gitHead": "45ed2c243777f7d06668edc5248c5dcf493526dd"
149
+ "gitHead": "22f2d7d9f6e6b6062a1b8d9178d6a17ae3f37755"
138
150
  }
package/src/index.ts CHANGED
@@ -12,6 +12,8 @@ import { OxGristRendererQuantifier } from './ox-grist-renderer-quantifier'
12
12
  import { OxGristRendererHashtags } from './ox-grist-renderer-hashtags'
13
13
  import { OxGristRendererPartitionKeys } from './ox-grist-renderer-partition-keys.js'
14
14
  import { OxGristEditorValueRanges } from './ox-grist-editor-value-ranges.js'
15
+ import { OxGristEditorI18nLabel } from './ox-grist-editor-i18n-label.js'
16
+ import { OxGristRendererI18nLabel } from './ox-grist-renderer-i18n-label.js'
15
17
 
16
18
  /* register grist renderer/editor for id */
17
19
  registerEditor('parameters', OxGristEditorParameters)
@@ -22,6 +24,7 @@ registerEditor('crontab', OxGristEditorCrontab)
22
24
  registerEditor('duration', OxGristEditorDuration)
23
25
  registerEditor('quantifier', OxGristEditorQuantifier)
24
26
  registerEditor('hashtags', OxGristEditorHashtags)
27
+ registerEditor('i18n-label', OxGristEditorI18nLabel)
25
28
 
26
29
  registerRenderer('parameters', OxGristRendererJson5)
27
30
  registerRenderer('value-map', OxGristRendererJson5)
@@ -30,3 +33,4 @@ registerRenderer('partition-keys', OxGristRendererPartitionKeys)
30
33
  registerRenderer('duration', OxGristRendererDuration)
31
34
  registerRenderer('quantifier', OxGristRendererQuantifier)
32
35
  registerRenderer('hashtags', OxGristRendererHashtags)
36
+ registerRenderer('i18n-label', OxGristRendererI18nLabel)
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './ox-popup-i18n-label-input.js'
6
+
7
+ import { html } from 'lit'
8
+ import { customElement } from 'lit/decorators.js'
9
+ import json5 from 'json5'
10
+
11
+ import { cloneDeep } from 'lodash-es'
12
+
13
+ import { OxGristEditor } from '@operato/data-grist'
14
+ import { i18next } from '@operato/i18n'
15
+ import { openPopup, PopupHandle } from '@operato/popup'
16
+
17
+ @customElement('ox-grist-editor-i18n-label')
18
+ export class OxGristEditorI18nLabel extends OxGristEditor {
19
+ private popup?: PopupHandle
20
+
21
+ get options() {
22
+ return this.column.record?.options || {}
23
+ }
24
+
25
+ get editorTemplate() {
26
+ const { displayColumn } = this.column.record.options || {}
27
+
28
+ const value =
29
+ this.value && typeof this.value === 'object'
30
+ ? this.value[i18next.language || 'en-US']
31
+ : displayColumn
32
+ ? this.record[displayColumn]
33
+ : ''
34
+
35
+ return html`<div tabindex="0">${value || ''}</div>`
36
+ }
37
+
38
+ _onclick(e: Event): void {
39
+ e.stopPropagation()
40
+ this.openSelector()
41
+ }
42
+
43
+ _onkeydown(e: KeyboardEvent): void {
44
+ const key = e.key
45
+ if (key == 'Enter') {
46
+ e.stopPropagation()
47
+ this.openSelector()
48
+ }
49
+ }
50
+
51
+ async openSelector() {
52
+ if (this.popup) {
53
+ delete this.popup
54
+ }
55
+
56
+ const { name, help, languages, objectified = false } = this.options || {}
57
+
58
+ const confirmCallback = (newval: any) => {
59
+ this.dispatchEvent(
60
+ new CustomEvent('field-change', {
61
+ bubbles: true,
62
+ composed: true,
63
+ detail: {
64
+ before: this.value,
65
+ after: !objectified ? JSON.stringify(newval) : newval,
66
+ record: this.record,
67
+ column: this.column,
68
+ row: this.row
69
+ }
70
+ })
71
+ )
72
+ }
73
+
74
+ try {
75
+ var value: any =
76
+ !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})
77
+ } catch (e) {
78
+ var value: any = {}
79
+ }
80
+
81
+ /*
82
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
83
+ layout의 구성에 변화가 발생하면, 다시 render된다.
84
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
85
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
86
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
87
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
88
+ */
89
+ var template = html`
90
+ <ox-popup-i18n-label-input .value=${value} .languages=${languages} .confirmCallback=${confirmCallback}>
91
+ </ox-popup-i18n-label-input>
92
+ `
93
+
94
+ this.popup = openPopup(template, {
95
+ backdrop: true,
96
+ size: 'large',
97
+ title: `${name?.toUpperCase() || i18next.t('title.i18n-label')} `,
98
+ help
99
+ })
100
+ }
101
+ }
@@ -0,0 +1,12 @@
1
+ import { html } from 'lit'
2
+
3
+ import { FieldRenderer } from '@operato/data-grist'
4
+ import i18next from 'i18next'
5
+
6
+ export const OxGristRendererI18nLabel: FieldRenderer = (value, column, record, rowIndex, field) => {
7
+ const language = i18next.language || 'en-US'
8
+ const labels = value || {}
9
+ const label = labels[language] || labels[language.substring(0, 2)] || labels['en'] || ''
10
+
11
+ return html`<span>${label}</span>`
12
+ }
@@ -0,0 +1,98 @@
1
+ import '@operato/input/ox-input-i18n-label.js'
2
+
3
+ import { css, html, LitElement } from 'lit'
4
+ import { customElement, property } from 'lit/decorators.js'
5
+
6
+ import { i18next } from '@operato/i18n'
7
+ import { closePopup } from '@operato/popup'
8
+ import { ScrollbarStyles } from '@operato/styles'
9
+
10
+ @customElement('ox-popup-i18n-label-input')
11
+ export class OxPopupValueMapInput extends LitElement {
12
+ static styles = [
13
+ ScrollbarStyles,
14
+ css`
15
+ :host {
16
+ display: flex;
17
+ flex-direction: column;
18
+
19
+ background-color: #fff;
20
+
21
+ width: var(--overlay-center-normal-width, 50%);
22
+ height: var(--overlay-center-normal-height, 50%);
23
+ }
24
+
25
+ ox-input-i18n-label {
26
+ flex: 1;
27
+ overflow-y: auto;
28
+ padding: var(--padding-default);
29
+ }
30
+
31
+ span {
32
+ flex: 1;
33
+
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+
38
+ color: var(--primary-color);
39
+ }
40
+
41
+ .button-container {
42
+ display: flex;
43
+ margin-left: auto;
44
+ }
45
+ `
46
+ ]
47
+
48
+ @property({ type: Object }) value: any
49
+ @property({ type: Array }) languages: { code: string; display: string }[] = []
50
+ @property({ type: Object }) confirmCallback!: (newval: any) => void
51
+
52
+ render() {
53
+ return html`
54
+ <ox-input-i18n-label .value=${this.value} .languages=${this.languages} @change=${this.onChange.bind(this)}>
55
+ </ox-input-i18n-label>
56
+
57
+ <div class="button-container">
58
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
59
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
60
+ </div>
61
+ `
62
+ }
63
+
64
+ private onChange(e: CustomEvent) {
65
+ e.stopPropagation()
66
+
67
+ /*
68
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
69
+ layout의 구성에 변화가 발생하면, 다시 render된다.
70
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
71
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
72
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
73
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
74
+ (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
75
+ =>
76
+ 이런 이유로, Object.assign(...)을 사용하였다.
77
+ */
78
+
79
+ if (!this.value || typeof this.value !== 'object') {
80
+ this.value = {}
81
+ }
82
+
83
+ for (let key in this.value) {
84
+ delete this.value[key]
85
+ }
86
+
87
+ Object.assign(this.value, e.detail)
88
+ }
89
+
90
+ private onCancel(e: Event) {
91
+ closePopup(this)
92
+ }
93
+
94
+ private onConfirm(e: Event) {
95
+ this.confirmCallback && this.confirmCallback(this.value)
96
+ closePopup(this)
97
+ }
98
+ }
@@ -37,7 +37,7 @@ body {
37
37
 
38
38
  --grid-record-background-color: var(--theme-white-color);
39
39
  --grid-record-odd-background-color: #f9f7f5;
40
- --grid-record-padding: var(--padding-default);
40
+ --grid-record-padding: 0 5px 0 5px;
41
41
  --grid-record-color: var(--secondary-color);
42
42
  --grid-record-color-hover: var(--primary-color);
43
43
  --grid-record-wide-fontsize: var(--fontsize-small);