@operato/data-grist 7.1.27 → 7.1.30
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 +18 -0
- package/dist/src/data-grid/data-grid-body-style.js +14 -0
- package/dist/src/data-grid/data-grid-body-style.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.js +9 -0
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/record-view/ox-record-creator.js +7 -20
- package/dist/src/record-view/ox-record-creator.js.map +1 -1
- package/dist/src/record-view/record-creator.d.ts +17 -0
- package/dist/src/record-view/record-creator.js +148 -0
- package/dist/src/record-view/record-creator.js.map +1 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/stories/click-event-custom.stories.js +2 -1
- package/dist/stories/click-event-custom.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/data-grid/data-grid-body-style.ts +14 -0
- package/src/data-grid/data-grid-field.ts +9 -0
- package/src/record-view/ox-record-creator.ts +15 -27
- package/src/types.ts +1 -1
- package/stories/click-event-custom.stories.ts +2 -1
- package/yarn-error.log +16971 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,24 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
### [7.1.30](https://github.com/hatiolab/operato/compare/v7.1.29...v7.1.30) (2025-01-10)
|
7
|
+
|
8
|
+
|
9
|
+
### :bug: Bug Fix
|
10
|
+
|
11
|
+
* grist disabled 필드 색상 조절 기능 추가 ([415fe22](https://github.com/hatiolab/operato/commit/415fe2250438c5b14945391ebca59ba13b56b6d3))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
### [7.1.28](https://github.com/hatiolab/operato/compare/v7.1.27...v7.1.28) (2024-12-09)
|
16
|
+
|
17
|
+
|
18
|
+
### :bug: Bug Fix
|
19
|
+
|
20
|
+
* enhancement of ox-record-creator validation ([6466cf1](https://github.com/hatiolab/operato/commit/6466cf1df0bed4a131715c58f87a2b2aacd0c2b4))
|
21
|
+
|
22
|
+
|
23
|
+
|
6
24
|
### [7.1.27](https://github.com/hatiolab/operato/compare/v7.1.26...v7.1.27) (2024-12-09)
|
7
25
|
|
8
26
|
|
@@ -16,6 +16,20 @@ export const dataGridBodyStyle = css `
|
|
16
16
|
background-color: var(--grid-record-odd-background-color);
|
17
17
|
}
|
18
18
|
|
19
|
+
ox-grid-field[disabled] {
|
20
|
+
background-color: var(--grid-record-disabled-background-color, #eee);
|
21
|
+
color: var(--grid-record-disabled-color, var(--grid-record-color));
|
22
|
+
opacity: var(--grid-record-disabled-opacity, 1);
|
23
|
+
}
|
24
|
+
ox-grid-field[odd][disabled] {
|
25
|
+
background-color: var(
|
26
|
+
--grid-odd-record-disabled-background-color,
|
27
|
+
var(--grid-record-disabled-background-color, #eee)
|
28
|
+
);
|
29
|
+
color: var(--grid-odd-record-disabled-color, var(--grid-record-disabled-color, var(--grid-record-color)));
|
30
|
+
opacity: var(--grid-odd-record-disabled-opacity, var(--grid-record-disabled-opacity, 1));
|
31
|
+
}
|
32
|
+
|
19
33
|
ox-grid-field[selected-row] {
|
20
34
|
background-color: var(--grid-record-selected-background-color);
|
21
35
|
color: var(--grid-record-selected-color);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"data-grid-body-style.js","sourceRoot":"","sources":["../../../src/data-grid/data-grid-body-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA
|
1
|
+
{"version":3,"file":"data-grid-body-style.js","sourceRoot":"","sources":["../../../src/data-grid/data-grid-body-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGnC,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport const dataGridBodyStyle = css`\n :host {\n display: grid;\n grid-template-columns: var(--grid-template-columns);\n grid-auto-rows: var(--grid-record-height, min-content);\n\n overflow: auto;\n outline: none;\n color: var(--grid-record-color);\n position: relative;\n border-bottom: var(--grid-body-bottom-border);\n }\n\n ox-grid-field[odd] {\n background-color: var(--grid-record-odd-background-color);\n }\n\n ox-grid-field[disabled] {\n background-color: var(--grid-record-disabled-background-color, #eee);\n color: var(--grid-record-disabled-color, var(--grid-record-color));\n opacity: var(--grid-record-disabled-opacity, 1);\n }\n ox-grid-field[odd][disabled] {\n background-color: var(\n --grid-odd-record-disabled-background-color,\n var(--grid-record-disabled-background-color, #eee)\n );\n color: var(--grid-odd-record-disabled-color, var(--grid-record-disabled-color, var(--grid-record-color)));\n opacity: var(--grid-odd-record-disabled-opacity, var(--grid-record-disabled-opacity, 1));\n }\n\n ox-grid-field[selected-row] {\n background-color: var(--grid-record-selected-background-color);\n color: var(--grid-record-selected-color);\n }\n\n ox-grid-field[focused-row] {\n box-shadow: var(--grid-record-focused-box-shadow);\n font-weight: bold;\n color: var(--grid-record-focused-color);\n background-image: var(--focused-background-image);\n background-blend-mode: darken;\n }\n\n ox-grid-field[focused] {\n border: var(--grid-record-focused-cell-border);\n }\n\n ox-grid-field[emphasized-row],\n ox-grid-field[emphasized-row][focused] {\n background-color: var(--grid-record-emphasized-background-color);\n color: var(--grid-record-emphasized-color);\n }\n\n [editing] {\n background-color: var(--grid-record-editing-background-color);\n }\n\n @media print {\n :host {\n grid-template-columns: var(--grid-template-print-columns);\n }\n ox-grid-field[focused] {\n border: none;\n }\n\n ox-grid-field[selected-row] {\n background-color: transparent;\n }\n\n ox-grid-field[emphasized-row] {\n background-color: transparent;\n color: initial;\n }\n\n ox-grid-field[focused-row] {\n background-color: transparent;\n color: initial;\n }\n\n ox-grid-field[editing] {\n background-color: transparent;\n }\n }\n\n @media (prefers-color-scheme: dark) {\n ox-grid-field[focused-row] {\n background-blend-mode: lighten;\n }\n }\n\n @media (prefers-color-scheme: light) {\n ox-grid-field[focused-row] {\n background-blend-mode: darken;\n }\n }\n`\n"]}
|
@@ -84,6 +84,15 @@ let DataGridField = class DataGridField extends LitElement {
|
|
84
84
|
this.style.left = 'unset';
|
85
85
|
}
|
86
86
|
}
|
87
|
+
const disabled = this.column.record.disabled || false;
|
88
|
+
if (!!disabled) {
|
89
|
+
// 비황성화 여부 표시
|
90
|
+
this.setAttribute('disabled', '');
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
// 비황성화 여부 제거
|
94
|
+
this.removeAttribute('disabled');
|
95
|
+
}
|
87
96
|
const emphasized = ((_a = this.column.record.classifier.call(this, this.record, this.rowIndex)) === null || _a === void 0 ? void 0 : _a.emphasized) || this.emphasized;
|
88
97
|
if (!!emphasized) {
|
89
98
|
this.setAttribute('emphasized-row', '');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"data-grid-field.js","sourceRoot":"","sources":["../../../src/data-grid/data-grid-field.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AAC3E,kDAAkD;AAClD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGtD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAG1B,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAwGwC,UAAK,GAAG,kBAAkB,CAAA;QAC3C,WAAM,GAAgB,EAAE,CAAA;QACxB,WAAM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IAAI,EAAE,CAAC;4CAAe;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAc;AACZ;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAA2B;AAG3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAiB;AAtHjC,aAAa;IADzB,aAAa,CAAC,eAAe,CAAC;GAClB,aAAa,CAsNzB","sourcesContent":["import { css, html, LitElement, PropertyValues, TemplateResult } from 'lit'\n// import { guard } from 'lit/directives/guard.js'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { TooltipReactiveController } from '@operato/utils'\n\nimport { ZERO_COLUMN } from '../configure/zero-config'\nimport { ColumnConfig, GristRecord } from '../types'\n\nconst DEFAULT_TEXT_ALIGN = 'left'\n\n@customElement('ox-grid-field')\nexport class DataGridField extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n\n align-items: center;\n justify-content: var(--data-grid-field-justify-content, flex-start);\n position: relative;\n\n white-space: nowrap;\n background-color: var(--grid-record-background-color);\n padding: var(--grid-record-padding);\n border: 1px solid transparent;\n border-width: 1px 0;\n border-bottom: var(--grid-record-border-bottom);\n\n font-size: var(--grid-record-wide-fontsize);\n min-height: 30px;\n box-sizing: border-box;\n }\n\n :host([gutter]) {\n padding: var(--grid-gutter-padding);\n text-align: center;\n }\n\n :host([gutter]) * {\n cursor: default;\n }\n\n :host([editing]) {\n border-top: var(--grid-record-editing-border);\n border-bottom: var(--grid-record-editing-border);\n }\n\n :host([focused]) {\n --grid-record-border-bottom: var(--grid-record-focused-cell-border);\n }\n\n :host([dirty])::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n\n width: 0px;\n height: 0px;\n border-top: 9px solid red;\n border-left: 9px solid transparent;\n }\n\n span,\n pre {\n display: block;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n * {\n margin: 0;\n text-align: var(--data-grid-field-text-align);\n }\n\n *[center] {\n flex: none;\n margin: 0 auto;\n }\n\n :host > button {\n display: flex;\n gap: var(--spacing-small);\n border: 0;\n align-items: center;\n padding: var(--spacing-small);\n\n color: var(--md-sys-color-on-primary);\n background-color: var(--md-sys-color-primary);\n border-radius: var(--data-card-item-btn-border-radius, var(--md-sys-shape-corner-tiny));\n\n font-size: 0.8rem;\n line-height: 0.8rem;\n\n md-icon {\n border: 0;\n padding: 0;\n background-color: unset;\n }\n }\n\n :host([danger]) > button {\n color: var(--md-sys-color-on-primary);\n background-color: var(--md-sys-color-error);\n border-color: var(--md-sys-color-error);\n }\n\n :host([danger]) > button:hover {\n color: var(--md-sys-color-on-secondary);\n background-color: var(--md-sys-color-secondary);\n border-color: var(--md-sys-color-secondary);\n }\n `\n ]\n\n @property({ type: String, attribute: true }) align = DEFAULT_TEXT_ALIGN\n @property({ type: Object }) record: GristRecord = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Number }) rowIndex = 0\n @property({ type: Number }) columnIndex = 0\n @property({ type: Boolean }) editing = false\n @property({ type: Object }) value = {}\n @property({ type: String }) valueWith: string | null = null\n @property({ attribute: false }) emphasized: any = false\n @property({ type: String, attribute: true }) fixed?: string\n @property({ type: String }) type?: string\n @property({ type: Boolean }) isWorking: boolean = false\n\n /* check in tree의 변화에 대응하기 위함임. 만일, record control 오브젝트로 통일되면 대체될 것임. */\n @property({ type: String }) checked?: string\n\n private _editCancelled?: boolean\n private _onFieldChange: (e: Event) => void = e => {}\n private _onKeydownInEditingMode: (e: KeyboardEvent) => void = e => {}\n\n private tooltipController?: TooltipReactiveController = new TooltipReactiveController(this)\n\n render(): TemplateResult {\n if (!this.column) {\n return html``\n }\n\n var { value, column, record, rowIndex } = this\n var { renderer, editor } = column.record\n\n return html`\n ${this.editing\n ? editor?.call(this, value, column, record, rowIndex, this)\n : renderer?.call(this, value, column, record, rowIndex, this)}\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('editing')) {\n if (this.editing) {\n this._onKeydownInEditingMode = ((e: KeyboardEvent) => {\n if (e.key === 'Esc' || e.key === 'Escape') {\n /* 편집 취소 */\n this._editCancelled = true\n }\n }).bind(this)\n\n this._onFieldChange = ((e: Event) => {\n this._editCancelled && e.stopPropagation()\n }).bind(this)\n\n delete this._editCancelled\n this.addEventListener('field-change', this._onFieldChange)\n this.addEventListener('keydown', this._onKeydownInEditingMode)\n } else {\n this.removeEventListener('field-change', this._onFieldChange)\n this.removeEventListener('keydown', this._onKeydownInEditingMode)\n }\n }\n\n if (changes.has('column')) {\n var align = this.column.record.align || DEFAULT_TEXT_ALIGN\n if (align != DEFAULT_TEXT_ALIGN) {\n let justify = 'center'\n switch (align) {\n case 'right':\n justify = 'flex-end'\n break\n }\n this.style.setProperty('--data-grid-field-justify-content', justify)\n this.style.setProperty('--data-grid-field-text-align', align)\n }\n\n const { danger } = this.column\n if (danger) {\n this.setAttribute('danger', '')\n } else {\n this.removeAttribute('danger')\n }\n }\n\n if (changes.has('fixed')) {\n if (this.fixed) {\n this.style.left = this.fixed + 'px'\n } else {\n this.style.left = 'unset'\n }\n }\n\n const emphasized =\n this.column.record.classifier.call(this, this.record, this.rowIndex)?.emphasized || this.emphasized\n\n if (!!emphasized) {\n this.setAttribute('emphasized-row', '')\n\n if (Symbol.iterator in Object(emphasized)) {\n const [backgroundColor, foregroundColor] = emphasized as string[]\n backgroundColor && this.style.setProperty('--grid-record-emphasized-background-color', backgroundColor)\n foregroundColor && this.style.setProperty('--grid-record-emphasized-color', foregroundColor)\n }\n } else {\n this.removeAttribute('emphasized-row')\n }\n }\n\n get editableOnClick() {\n const renderer = this.renderRoot.firstElementChild as HTMLElement\n //@ts-ignore\n return renderer && 'editableOnClick' in renderer ? renderer.editableOnClick : true\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"data-grid-field.js","sourceRoot":"","sources":["../../../src/data-grid/data-grid-field.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,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AAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;4CAA2B;AAC3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAa;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAgB;AACd;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAgB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAgC;AAC3B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDAAwB;AACV;IAA5C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;4CAAe;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAc;AACZ;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAA2B;AAG3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAiB;AAtHjC,aAAa;IADzB,aAAa,CAAC,eAAe,CAAC;GAClB,aAAa,CA+NzB","sourcesContent":["import { css, html, LitElement, PropertyValues, TemplateResult } from 'lit'\n// import { guard } from 'lit/directives/guard.js'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { TooltipReactiveController } from '@operato/utils'\n\nimport { ZERO_COLUMN } from '../configure/zero-config'\nimport { ColumnConfig, GristRecord } from '../types'\n\nconst DEFAULT_TEXT_ALIGN = 'left'\n\n@customElement('ox-grid-field')\nexport class DataGridField extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n\n align-items: center;\n justify-content: var(--data-grid-field-justify-content, flex-start);\n position: relative;\n\n white-space: nowrap;\n background-color: var(--grid-record-background-color);\n padding: var(--grid-record-padding);\n border: 1px solid transparent;\n border-width: 1px 0;\n border-bottom: var(--grid-record-border-bottom);\n\n font-size: var(--grid-record-wide-fontsize);\n min-height: 30px;\n box-sizing: border-box;\n }\n\n :host([gutter]) {\n padding: var(--grid-gutter-padding);\n text-align: center;\n }\n\n :host([gutter]) * {\n cursor: default;\n }\n\n :host([editing]) {\n border-top: var(--grid-record-editing-border);\n border-bottom: var(--grid-record-editing-border);\n }\n\n :host([focused]) {\n --grid-record-border-bottom: var(--grid-record-focused-cell-border);\n }\n\n :host([dirty])::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n\n width: 0px;\n height: 0px;\n border-top: 9px solid red;\n border-left: 9px solid transparent;\n }\n\n span,\n pre {\n display: block;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n * {\n margin: 0;\n text-align: var(--data-grid-field-text-align);\n }\n\n *[center] {\n flex: none;\n margin: 0 auto;\n }\n\n :host > button {\n display: flex;\n gap: var(--spacing-small);\n border: 0;\n align-items: center;\n padding: var(--spacing-small);\n\n color: var(--md-sys-color-on-primary);\n background-color: var(--md-sys-color-primary);\n border-radius: var(--data-card-item-btn-border-radius, var(--md-sys-shape-corner-tiny));\n\n font-size: 0.8rem;\n line-height: 0.8rem;\n\n md-icon {\n border: 0;\n padding: 0;\n background-color: unset;\n }\n }\n\n :host([danger]) > button {\n color: var(--md-sys-color-on-primary);\n background-color: var(--md-sys-color-error);\n border-color: var(--md-sys-color-error);\n }\n\n :host([danger]) > button:hover {\n color: var(--md-sys-color-on-secondary);\n background-color: var(--md-sys-color-secondary);\n border-color: var(--md-sys-color-secondary);\n }\n `\n ]\n\n @property({ type: String, attribute: true }) align = DEFAULT_TEXT_ALIGN\n @property({ type: Object }) record: GristRecord = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Number }) rowIndex = 0\n @property({ type: Number }) columnIndex = 0\n @property({ type: Boolean }) editing = false\n @property({ type: Object }) value = {}\n @property({ type: String }) valueWith: string | null = null\n @property({ attribute: false }) emphasized: any = false\n @property({ type: String, attribute: true }) fixed?: string\n @property({ type: String }) type?: string\n @property({ type: Boolean }) isWorking: boolean = false\n\n /* check in tree의 변화에 대응하기 위함임. 만일, record control 오브젝트로 통일되면 대체될 것임. */\n @property({ type: String }) checked?: string\n\n private _editCancelled?: boolean\n private _onFieldChange: (e: Event) => void = e => {}\n private _onKeydownInEditingMode: (e: KeyboardEvent) => void = e => {}\n\n private tooltipController?: TooltipReactiveController = new TooltipReactiveController(this)\n\n render(): TemplateResult {\n if (!this.column) {\n return html``\n }\n\n var { value, column, record, rowIndex } = this\n var { renderer, editor } = column.record\n\n return html`\n ${this.editing\n ? editor?.call(this, value, column, record, rowIndex, this)\n : renderer?.call(this, value, column, record, rowIndex, this)}\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('editing')) {\n if (this.editing) {\n this._onKeydownInEditingMode = ((e: KeyboardEvent) => {\n if (e.key === 'Esc' || e.key === 'Escape') {\n /* 편집 취소 */\n this._editCancelled = true\n }\n }).bind(this)\n\n this._onFieldChange = ((e: Event) => {\n this._editCancelled && e.stopPropagation()\n }).bind(this)\n\n delete this._editCancelled\n this.addEventListener('field-change', this._onFieldChange)\n this.addEventListener('keydown', this._onKeydownInEditingMode)\n } else {\n this.removeEventListener('field-change', this._onFieldChange)\n this.removeEventListener('keydown', this._onKeydownInEditingMode)\n }\n }\n\n if (changes.has('column')) {\n var align = this.column.record.align || DEFAULT_TEXT_ALIGN\n if (align != DEFAULT_TEXT_ALIGN) {\n let justify = 'center'\n switch (align) {\n case 'right':\n justify = 'flex-end'\n break\n }\n this.style.setProperty('--data-grid-field-justify-content', justify)\n this.style.setProperty('--data-grid-field-text-align', align)\n }\n\n const { danger } = this.column\n if (danger) {\n this.setAttribute('danger', '')\n } else {\n this.removeAttribute('danger')\n }\n }\n\n if (changes.has('fixed')) {\n if (this.fixed) {\n this.style.left = this.fixed + 'px'\n } else {\n this.style.left = 'unset'\n }\n }\n\n const disabled = this.column.record.disabled || false\n if (!!disabled) {\n // 비황성화 여부 표시\n this.setAttribute('disabled', '')\n } else {\n // 비황성화 여부 제거\n this.removeAttribute('disabled')\n }\n\n const emphasized =\n this.column.record.classifier.call(this, this.record, this.rowIndex)?.emphasized || this.emphasized\n\n if (!!emphasized) {\n this.setAttribute('emphasized-row', '')\n\n if (Symbol.iterator in Object(emphasized)) {\n const [backgroundColor, foregroundColor] = emphasized as string[]\n backgroundColor && this.style.setProperty('--grid-record-emphasized-background-color', backgroundColor)\n foregroundColor && this.style.setProperty('--grid-record-emphasized-color', foregroundColor)\n }\n } else {\n this.removeAttribute('emphasized-row')\n }\n }\n\n get editableOnClick() {\n const renderer = this.renderRoot.firstElementChild as HTMLElement\n //@ts-ignore\n return renderer && 'editableOnClick' in renderer ? renderer.editableOnClick : true\n }\n}\n"]}
|
@@ -34,7 +34,9 @@ let OxRecordCreator = class OxRecordCreator extends LitElement {
|
|
34
34
|
validateRecord(record) {
|
35
35
|
const columns = this.grist.compiledConfig.columns;
|
36
36
|
const invalidFields = [];
|
37
|
-
columns
|
37
|
+
columns
|
38
|
+
.filter(column => !column.hidden)
|
39
|
+
.forEach(column => {
|
38
40
|
var _a;
|
39
41
|
if (((_a = column.record) === null || _a === void 0 ? void 0 : _a.mandatory) &&
|
40
42
|
(record[column.name] === undefined || record[column.name] === null || record[column.name] === '')) {
|
@@ -106,13 +108,8 @@ let OxRecordCreator = class OxRecordCreator extends LitElement {
|
|
106
108
|
}}
|
107
109
|
@ok=${async (e) => {
|
108
110
|
const view = e.currentTarget;
|
109
|
-
// 레코드 밸리데이션 체크
|
110
111
|
const invalidFields = await this.validateRecord(view.record);
|
111
112
|
if (invalidFields.length > 0) {
|
112
|
-
// const firstInvalidField = invalidFields[0];
|
113
|
-
// if (firstInvalidField) {
|
114
|
-
// view.setFocus(firstInvalidField.field)
|
115
|
-
// }
|
116
113
|
view.setFocusOnInvalid(invalidFields);
|
117
114
|
return false;
|
118
115
|
}
|
@@ -156,28 +153,18 @@ let OxRecordCreator = class OxRecordCreator extends LitElement {
|
|
156
153
|
popup.close();
|
157
154
|
});
|
158
155
|
recordView.addEventListener('ok', async (e) => {
|
159
|
-
var _a
|
156
|
+
var _a;
|
160
157
|
const view = e.currentTarget;
|
161
|
-
// 레코드 밸리데이션 체크
|
162
158
|
const invalidFields = await this.validateRecord(view.record);
|
163
159
|
if (invalidFields.length > 0) {
|
164
|
-
|
165
|
-
if (firstInvalidField) {
|
166
|
-
const fieldElement = (_a = view.renderRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`[name="${firstInvalidField}"]`);
|
167
|
-
if (fieldElement) {
|
168
|
-
;
|
169
|
-
fieldElement.focus();
|
170
|
-
}
|
171
|
-
}
|
160
|
+
view.setFocusOnInvalid(invalidFields);
|
172
161
|
return false;
|
173
162
|
}
|
174
|
-
if (await ((
|
163
|
+
if (await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, view.record))) {
|
175
164
|
popup.close();
|
176
165
|
}
|
177
166
|
else {
|
178
|
-
|
179
|
-
console.error('레코드 밸리데이션 실패');
|
180
|
-
// 여기에 사용자에게 오류 메시지를 표시하는 로직을 추가할 수 있습니다.
|
167
|
+
console.error('validation failed');
|
181
168
|
}
|
182
169
|
});
|
183
170
|
recordView.addEventListener('field-change', async (e) => {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-record-creator.js","sourceRoot":"","sources":["../../../src/record-view/ox-record-creator.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE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,CAAC,CAAA,CAAC,mBAAmB;IAC9D,CAAC;IAED,kBAAkB,CAAC,eAA4B;QAC7C,MAAM,KAAK,GAAG,QAAQ,CAAA;QACtB,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,IAAI,CAAgB,CAAA;QACnE,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAEpC,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,YAAY,EAAE;YAC5B,MAAM,EAAE;gBACN,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,OAAO;oBACb,KAAK;iBACN;gBACD,QAAQ,EAAE,IAAI,CAAC,mBAAmB;aACnC;SACF,CAAC,CACH,CAAA;IACH,CAAC;;AA7RM,sBAAM,GAAG;IACd,GAAG,CAAA;;;;KAIF;CACF,AANY,CAMZ;AAEQ;IAAR,KAAK,EAAE;8CAAkB;AAEE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA4C;AAC3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA8C;AAClB;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;mDAA4B;AACjB;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;2DAA2B;AAdhF,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA+R3B","sourcesContent":["import '@material/web/icon/icon.js'\nimport './record-view'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\n\nimport { DataGrist } from '../data-grist'\nimport { ColumnConfig, GristRecord, ValidationReason } from '../types'\nimport { RecordView } from './record-view'\n\n@customElement('ox-record-creator')\nexport class OxRecordCreator extends LitElement {\n static styles = [\n css`\n ::slotted([slot='popup']) {\n display: none;\n }\n `\n ]\n\n @state() grist?: DataGrist\n\n @property({ type: Object }) callback?: (record: GristRecord) => boolean\n @property({ type: Object }) customPopupCallback?: (popup: any) => boolean\n @property({ type: Boolean, attribute: 'light-popup' }) lightPopup: boolean = false\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur = false\n\n constructor() {\n super()\n\n this.addEventListener('click', (e: Event) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (this.lightPopup) {\n this.openLightPopup()\n } else {\n this.openPopup()\n }\n })\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n\n this.grist = this.closest('ox-grist') as DataGrist\n }\n\n render() {\n return html`\n <slot></slot>\n <slot name=\"popup\"></slot>\n `\n }\n\n validateRecord(record: GristRecord): { field: string; reason: ValidationReason }[] {\n const columns = this.grist!.compiledConfig.columns\n const invalidFields: { field: string; reason: ValidationReason }[] = []\n\n columns.forEach(column => {\n if (\n column.record?.mandatory &&\n (record[column.name] === undefined || record[column.name] === null || record[column.name] === '')\n ) {\n invalidFields.push({\n field: column.name,\n reason: ValidationReason.MANDATORY\n })\n }\n })\n\n return invalidFields\n }\n\n openLightPopup() {\n const slot = this.renderRoot?.querySelector(`slot[name='popup']`) as HTMLSlotElement\n const slottedElements = slot?.assignedElements({ flatten: true })\n const originalContent = slottedElements?.[0] as HTMLElement\n\n if (originalContent) {\n this.lightPopupCustomCreator(originalContent)\n } else {\n this.lightPopupRecordView()\n }\n }\n\n openPopup() {\n const slot = this.renderRoot?.querySelector(`slot[name='popup']`) as HTMLSlotElement\n const slottedElements = slot?.assignedElements({ flatten: true })\n const originalContent = slottedElements?.[0] as HTMLElement\n\n if (originalContent) {\n this.popupCustomCreator(originalContent)\n } else {\n this.popupRecordView()\n }\n }\n\n lightPopupRecordView() {\n const config = this.grist!.compiledConfig\n var title = 'create'\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var popup = OxPopup.open({\n template: html`\n <div title>${title}</div>\n <ox-record-view\n @field-change=${(e: CustomEvent) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!validation.call(this, after, before, record, column)) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n }}\n .columns=${columns}\n .record=${record}\n .rowIndex=${rowIndex}\n @reset=${(e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n }}\n @cancel=${(e: Event) => {\n popup.close()\n }}\n @ok=${async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n // 레코드 밸리데이션 체크\n const invalidFields = await this.validateRecord(view.record)\n if (invalidFields.length > 0) {\n // const firstInvalidField = invalidFields[0];\n // if (firstInvalidField) {\n // view.setFocus(firstInvalidField.field)\n // }\n view.setFocusOnInvalid(invalidFields)\n return false\n }\n\n popup.close()\n\n this.dispatchEvent(\n new CustomEvent('ok', {\n bubbles: true,\n composed: true,\n detail: view.record\n })\n )\n }}\n ></ox-record-view>\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n }\n\n popupRecordView() {\n const config = this.grist!.compiledConfig\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var title = 'create'\n\n var recordView = document.createElement('ox-record-view') as RecordView\n\n recordView.columns = columns\n recordView.record = record\n recordView.rowIndex = rowIndex\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: recordView,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: (popup: any) => {\n recordView.addEventListener('reset', (e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n })\n\n recordView.addEventListener('cancel', (e: Event) => {\n popup.close()\n })\n\n recordView.addEventListener('ok', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n // 레코드 밸리데이션 체크\n const invalidFields = await this.validateRecord(view.record)\n if (invalidFields.length > 0) {\n const firstInvalidField = invalidFields[0]\n if (firstInvalidField) {\n const fieldElement = view.renderRoot?.querySelector(`[name=\"${firstInvalidField}\"]`)\n if (fieldElement) {\n ;(fieldElement as HTMLElement).focus()\n }\n }\n return false\n }\n\n if (await this.callback?.(view.record)) {\n popup.close()\n } else {\n // 밸리데이션 실패 시 처리\n console.error('레코드 밸리데이션 실패')\n // 여기에 사용자에게 오류 메시지를 표시하는 로직을 추가할 수 있습니다.\n }\n })\n\n recordView.addEventListener('field-change', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!(await validation.call(this, after, before, record, column))) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n })\n\n popup.onclosed = () => {}\n }\n }\n })\n )\n }\n\n lightPopupCustomCreator(originalContent: HTMLElement) {\n const title = 'create'\n const popupContent = originalContent.cloneNode(true) as HTMLElement\n popupContent.removeAttribute('slot')\n\n OxPopup.open({\n template: html`\n <div title>${title}</div>\n ${popupContent}\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n\n this.customPopupCallback?.(popupContent) // 사용자 정의 팝업용 콜백 실행\n }\n\n popupCustomCreator(originalContent: HTMLElement) {\n const title = 'create'\n const popupContent = originalContent.cloneNode(true) as HTMLElement\n popupContent.removeAttribute('slot')\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: popupContent,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: this.customPopupCallback\n }\n })\n )\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-record-creator.js","sourceRoot":"","sources":["../../../src/record-view/ox-record-creator.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,eAAe,CAAA;AAEtB,OAAO,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AAA;QAEpC,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,YAAY,EAAE;YAC5B,MAAM,EAAE;gBACN,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,OAAO;oBACb,KAAK;iBACN;gBACD,QAAQ,EAAE,IAAI,CAAC,mBAAmB;aACnC;SACF,CAAC,CACH,CAAA;IACH,CAAC;;AAjRM,sBAAM,GAAG;IACd,GAAG,CAAA;;;;KAIF;CACF,AANY,CAMZ;AAEQ;IAAR,KAAK,EAAE;8CAAkB;AAEE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA4C;AAC3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA8C;AAClB;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;mDAA4B;AACjB;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;2DAA2B;AAdhF,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAmR3B","sourcesContent":["import '@material/web/icon/icon.js'\nimport './record-view'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\n\nimport { DataGrist } from '../data-grist'\nimport { ColumnConfig, GristRecord, ValidationReason } from '../types'\nimport { RecordView } from './record-view'\n\n@customElement('ox-record-creator')\nexport class OxRecordCreator extends LitElement {\n static styles = [\n css`\n ::slotted([slot='popup']) {\n display: none;\n }\n `\n ]\n\n @state() grist?: DataGrist\n\n @property({ type: Object }) callback?: (record: GristRecord) => boolean\n @property({ type: Object }) customPopupCallback?: (popup: any) => boolean\n @property({ type: Boolean, attribute: 'light-popup' }) lightPopup: boolean = false\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur = false\n\n constructor() {\n super()\n\n this.addEventListener('click', (e: Event) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (this.lightPopup) {\n this.openLightPopup()\n } else {\n this.openPopup()\n }\n })\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n\n this.grist = this.closest('ox-grist') as DataGrist\n }\n\n render() {\n return html`\n <slot></slot>\n <slot name=\"popup\"></slot>\n `\n }\n\n validateRecord(record: GristRecord): { field: string; reason: ValidationReason }[] {\n const columns = this.grist!.compiledConfig.columns\n const invalidFields: { field: string; reason: ValidationReason }[] = []\n\n columns\n .filter(column => !column.hidden)\n .forEach(column => {\n if (\n column.record?.mandatory &&\n (record[column.name] === undefined || record[column.name] === null || record[column.name] === '')\n ) {\n invalidFields.push({\n field: column.name,\n reason: ValidationReason.MANDATORY\n })\n }\n })\n\n return invalidFields\n }\n\n openLightPopup() {\n const slot = this.renderRoot?.querySelector(`slot[name='popup']`) as HTMLSlotElement\n const slottedElements = slot?.assignedElements({ flatten: true })\n const originalContent = slottedElements?.[0] as HTMLElement\n\n if (originalContent) {\n this.lightPopupCustomCreator(originalContent)\n } else {\n this.lightPopupRecordView()\n }\n }\n\n openPopup() {\n const slot = this.renderRoot?.querySelector(`slot[name='popup']`) as HTMLSlotElement\n const slottedElements = slot?.assignedElements({ flatten: true })\n const originalContent = slottedElements?.[0] as HTMLElement\n\n if (originalContent) {\n this.popupCustomCreator(originalContent)\n } else {\n this.popupRecordView()\n }\n }\n\n lightPopupRecordView() {\n const config = this.grist!.compiledConfig\n var title = 'create'\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var popup = OxPopup.open({\n template: html`\n <div title>${title}</div>\n <ox-record-view\n @field-change=${(e: CustomEvent) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!validation.call(this, after, before, record, column)) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n }}\n .columns=${columns}\n .record=${record}\n .rowIndex=${rowIndex}\n @reset=${(e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n }}\n @cancel=${(e: Event) => {\n popup.close()\n }}\n @ok=${async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n const invalidFields = await this.validateRecord(view.record)\n if (invalidFields.length > 0) {\n view.setFocusOnInvalid(invalidFields)\n return false\n }\n\n popup.close()\n\n this.dispatchEvent(\n new CustomEvent('ok', {\n bubbles: true,\n composed: true,\n detail: view.record\n })\n )\n }}\n ></ox-record-view>\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n }\n\n popupRecordView() {\n const config = this.grist!.compiledConfig\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var title = 'create'\n\n var recordView = document.createElement('ox-record-view') as RecordView\n\n recordView.columns = columns\n recordView.record = record\n recordView.rowIndex = rowIndex\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: recordView,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: (popup: any) => {\n recordView.addEventListener('reset', (e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n })\n\n recordView.addEventListener('cancel', (e: Event) => {\n popup.close()\n })\n\n recordView.addEventListener('ok', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n const invalidFields = await this.validateRecord(view.record)\n if (invalidFields.length > 0) {\n view.setFocusOnInvalid(invalidFields)\n return false\n }\n\n if (await this.callback?.(view.record)) {\n popup.close()\n } else {\n console.error('validation failed')\n }\n })\n\n recordView.addEventListener('field-change', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!(await validation.call(this, after, before, record, column))) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n })\n\n popup.onclosed = () => {}\n }\n }\n })\n )\n }\n\n lightPopupCustomCreator(originalContent: HTMLElement) {\n const title = 'create'\n const popupContent = originalContent.cloneNode(true) as HTMLElement\n popupContent.removeAttribute('slot')\n\n OxPopup.open({\n template: html`\n <div title>${title}</div>\n ${popupContent}\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n\n this.customPopupCallback?.(popupContent) // 사용자 정의 팝업용 콜백 실행\n }\n\n popupCustomCreator(originalContent: HTMLElement) {\n const title = 'create'\n const popupContent = originalContent.cloneNode(true) as HTMLElement\n popupContent.removeAttribute('slot')\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: popupContent,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: this.customPopupCallback\n }\n })\n )\n }\n}\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import '@material/web/icon/icon.js';
|
2
|
+
import './record-view';
|
3
|
+
import { LitElement } from 'lit';
|
4
|
+
import { DataGrist } from '../data-grist';
|
5
|
+
export declare class RecordCreator extends LitElement {
|
6
|
+
grist?: DataGrist;
|
7
|
+
callback?: (operation: {
|
8
|
+
[key: string]: any;
|
9
|
+
}) => boolean;
|
10
|
+
lightPopup: boolean;
|
11
|
+
preventCloseOnBlur: boolean;
|
12
|
+
constructor();
|
13
|
+
connectedCallback(): void;
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
15
|
+
lightPopupRecordView(): void;
|
16
|
+
popupRecordView(): void;
|
17
|
+
}
|
@@ -0,0 +1,148 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
2
|
+
import '@material/web/icon/icon.js';
|
3
|
+
import './record-view';
|
4
|
+
import { html, LitElement } from 'lit';
|
5
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
6
|
+
import { OxPopup } from '@operato/popup';
|
7
|
+
let RecordCreator = class RecordCreator extends LitElement {
|
8
|
+
constructor() {
|
9
|
+
super();
|
10
|
+
this.lightPopup = false;
|
11
|
+
this.preventCloseOnBlur = false;
|
12
|
+
this.addEventListener('click', (e) => {
|
13
|
+
e.preventDefault();
|
14
|
+
e.stopPropagation();
|
15
|
+
if (this.lightPopup) {
|
16
|
+
this.lightPopupRecordView();
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
this.popupRecordView();
|
20
|
+
}
|
21
|
+
});
|
22
|
+
}
|
23
|
+
connectedCallback() {
|
24
|
+
super.connectedCallback();
|
25
|
+
this.grist = this.closest('ox-grist');
|
26
|
+
}
|
27
|
+
render() {
|
28
|
+
return html `<slot></slot>`;
|
29
|
+
}
|
30
|
+
lightPopupRecordView() {
|
31
|
+
const config = this.grist.compiledConfig;
|
32
|
+
var title = 'create';
|
33
|
+
const rowIndex = -1;
|
34
|
+
var record = {};
|
35
|
+
const columns = config.columns;
|
36
|
+
var popup = OxPopup.open({
|
37
|
+
template: html `
|
38
|
+
<div title>${title}</div>
|
39
|
+
<ox-record-view
|
40
|
+
@field-change=${(e) => {
|
41
|
+
const view = e.currentTarget;
|
42
|
+
var { after, before, column, record, row } = e.detail;
|
43
|
+
var validation = column.validation;
|
44
|
+
if (validation && typeof validation == 'function') {
|
45
|
+
if (!validation.call(this, after, before, record, column)) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
view.record = {
|
50
|
+
...record,
|
51
|
+
[column.name]: after
|
52
|
+
};
|
53
|
+
}}
|
54
|
+
.columns=${columns}
|
55
|
+
.record=${record}
|
56
|
+
.rowIndex=${rowIndex}
|
57
|
+
@reset=${(e) => {
|
58
|
+
const view = e.currentTarget;
|
59
|
+
view.record = {};
|
60
|
+
}}
|
61
|
+
@cancel=${(e) => {
|
62
|
+
popup.close();
|
63
|
+
}}
|
64
|
+
@ok=${(e) => {
|
65
|
+
popup.close();
|
66
|
+
const view = e.currentTarget;
|
67
|
+
this.dispatchEvent(new CustomEvent('ok', {
|
68
|
+
bubbles: true,
|
69
|
+
composed: true,
|
70
|
+
detail: view.record
|
71
|
+
}));
|
72
|
+
}}
|
73
|
+
></ox-record-view>
|
74
|
+
`,
|
75
|
+
parent: document.body,
|
76
|
+
preventCloseOnBlur: this.preventCloseOnBlur
|
77
|
+
});
|
78
|
+
}
|
79
|
+
popupRecordView() {
|
80
|
+
const config = this.grist.compiledConfig;
|
81
|
+
const rowIndex = -1;
|
82
|
+
var record = {};
|
83
|
+
const columns = config.columns;
|
84
|
+
var title = 'create';
|
85
|
+
var recordView = document.createElement('ox-record-view');
|
86
|
+
recordView.columns = columns;
|
87
|
+
recordView.record = record;
|
88
|
+
recordView.rowIndex = rowIndex;
|
89
|
+
document.dispatchEvent(new CustomEvent('open-popup', {
|
90
|
+
detail: {
|
91
|
+
template: recordView,
|
92
|
+
options: {
|
93
|
+
backdrop: true,
|
94
|
+
size: 'large',
|
95
|
+
title
|
96
|
+
},
|
97
|
+
callback: (popup) => {
|
98
|
+
recordView.addEventListener('reset', (e) => {
|
99
|
+
const view = e.currentTarget;
|
100
|
+
view.record = {};
|
101
|
+
});
|
102
|
+
recordView.addEventListener('cancel', (e) => {
|
103
|
+
popup.close();
|
104
|
+
});
|
105
|
+
recordView.addEventListener('ok', async (e) => {
|
106
|
+
var _a;
|
107
|
+
const view = e.currentTarget;
|
108
|
+
if (await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, view.record))) {
|
109
|
+
popup.close();
|
110
|
+
}
|
111
|
+
});
|
112
|
+
recordView.addEventListener('field-change', async (e) => {
|
113
|
+
const view = e.currentTarget;
|
114
|
+
var { after, before, column, record, row } = e.detail;
|
115
|
+
var validation = column.validation;
|
116
|
+
if (validation && typeof validation == 'function') {
|
117
|
+
if (!(await validation.call(this, after, before, record, column))) {
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
view.record = {
|
122
|
+
...record,
|
123
|
+
[column.name]: after
|
124
|
+
};
|
125
|
+
});
|
126
|
+
popup.onclosed = () => { };
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}));
|
130
|
+
}
|
131
|
+
};
|
132
|
+
__decorate([
|
133
|
+
state()
|
134
|
+
], RecordCreator.prototype, "grist", void 0);
|
135
|
+
__decorate([
|
136
|
+
property({ type: Object })
|
137
|
+
], RecordCreator.prototype, "callback", void 0);
|
138
|
+
__decorate([
|
139
|
+
property({ type: Boolean, attribute: 'light-popup' })
|
140
|
+
], RecordCreator.prototype, "lightPopup", void 0);
|
141
|
+
__decorate([
|
142
|
+
property({ type: Boolean, attribute: 'prevent-close-on-blur' })
|
143
|
+
], RecordCreator.prototype, "preventCloseOnBlur", void 0);
|
144
|
+
RecordCreator = __decorate([
|
145
|
+
customElement('ox-record-creator')
|
146
|
+
], RecordCreator);
|
147
|
+
export { RecordCreator };
|
148
|
+
//# sourceMappingURL=record-creator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"record-creator.js","sourceRoot":"","sources":["../../../src/record-view/record-creator.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAOjC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAO3C;QACE,KAAK,EAAE,CAAA;QAJ8C,eAAU,GAAY,KAAK,CAAA;QACjB,uBAAkB,GAAG,KAAK,CAAA;QAKzF,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;YAC1C,CAAC,CAAC,cAAc,EAAE,CAAA;YAClB,CAAC,CAAC,eAAe,EAAE,CAAA;YAEnB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,oBAA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,CAAC;gCAClE,OAAM;4BACR,CAAC;wBACH,CAAC;wBAED,IAAI,CAAC,MAAM,GAAG;4BACZ,GAAG,MAAM;4BACT,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK;yBACrB,CAAA;oBACH,CAAC,CAAC,CAAA;oBAEF,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;gBAC3B,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AArKU;IAAR,KAAK,EAAE;4CAAkB;AAEE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA0D;AAC9B;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;iDAA4B;AACjB;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;yDAA2B;AALhF,aAAa;IADzB,aAAa,CAAC,mBAAmB,CAAC;GACtB,aAAa,CAsKzB","sourcesContent":["import '@material/web/icon/icon.js'\nimport './record-view'\n\nimport { html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\n\nimport { DataGrist } from '../data-grist'\nimport { ColumnConfig, GristRecord } from '../types'\nimport { RecordView } from './record-view'\n\n@customElement('ox-record-creator')\nexport class RecordCreator extends LitElement {\n @state() grist?: DataGrist\n\n @property({ type: Object }) callback?: (operation: { [key: string]: any }) => boolean\n @property({ type: Boolean, attribute: 'light-popup' }) lightPopup: boolean = false\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur = false\n\n constructor() {\n super()\n\n this.addEventListener('click', (e: Event) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (this.lightPopup) {\n this.lightPopupRecordView()\n } else {\n this.popupRecordView()\n }\n })\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n\n this.grist = this.closest('ox-grist') as DataGrist\n }\n\n render() {\n return html`<slot></slot>`\n }\n\n lightPopupRecordView() {\n const config = this.grist!.compiledConfig\n var title = 'create'\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var popup = OxPopup.open({\n template: html`\n <div title>${title}</div>\n <ox-record-view\n @field-change=${(e: CustomEvent) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!validation.call(this, after, before, record, column)) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n }}\n .columns=${columns}\n .record=${record}\n .rowIndex=${rowIndex}\n @reset=${(e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n }}\n @cancel=${(e: Event) => {\n popup.close()\n }}\n @ok=${(e: Event) => {\n popup.close()\n\n const view = e.currentTarget as RecordView\n\n this.dispatchEvent(\n new CustomEvent('ok', {\n bubbles: true,\n composed: true,\n detail: view.record\n })\n )\n }}\n ></ox-record-view>\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n }\n\n popupRecordView() {\n const config = this.grist!.compiledConfig\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var title = 'create'\n\n var recordView = document.createElement('ox-record-view') as RecordView\n\n recordView.columns = columns\n recordView.record = record\n recordView.rowIndex = rowIndex\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: recordView,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: (popup: any) => {\n recordView.addEventListener('reset', (e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n })\n\n recordView.addEventListener('cancel', (e: Event) => {\n popup.close()\n })\n\n recordView.addEventListener('ok', async (e: Event) => {\n const view = e.currentTarget as RecordView\n if (await this.callback?.(view.record)) {\n popup.close()\n }\n })\n\n recordView.addEventListener('field-change', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!(await validation.call(this, after, before, record, column))) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n })\n\n popup.onclosed = () => {}\n }\n }\n })\n )\n }\n}\n"]}
|
package/dist/src/types.d.ts
CHANGED