@things-factory/id-rule-base 9.0.0-beta.8 → 9.0.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.
@@ -20,6 +20,67 @@ const FETCH_ID_RULE_GQL = type => {
20
20
  `;
21
21
  };
22
22
  let GristCodeInputPopup = class GristCodeInputPopup extends LitElement {
23
+ static { this.styles = [
24
+ css `
25
+ :host {
26
+ display: flex;
27
+ flex-direction: column;
28
+ padding: 0;
29
+ align-items: center;
30
+ box-sizing: border-box;
31
+ width: 100%;
32
+ border: 0;
33
+ color: var(--popup-content-color);
34
+ background-color: var(--popup-content-background-color);
35
+
36
+ font: var(--grist-object-editor-font);
37
+
38
+ justify-content: inherit;
39
+ }
40
+
41
+ :host * {
42
+ box-sizing: border-box;
43
+ }
44
+
45
+ #wrapper {
46
+ flex: 1;
47
+ width: 100%;
48
+ display: flex;
49
+ flex-direction: column;
50
+ padding: 5px;
51
+ }
52
+
53
+ #wrapper > h4 {
54
+ margin: 0;
55
+ }
56
+
57
+ #wrapper > ul {
58
+ width: 100%;
59
+ }
60
+
61
+ #wrapper > ul > li {
62
+ display: flex;
63
+ }
64
+ #wrapper > ul > li > span {
65
+ font-weight: bold;
66
+ flex-basis: 200px;
67
+ }
68
+
69
+ #wrapper > ul > li > ox-i18n {
70
+ flex: 1;
71
+ }
72
+
73
+ ox-input-code {
74
+ width: 100%;
75
+ flex: 1;
76
+ }
77
+
78
+ #footer {
79
+ display: flex;
80
+ justify-content: flex-end;
81
+ }
82
+ `
83
+ ]; }
23
84
  render() {
24
85
  return html `
25
86
  <div id="wrapper">
@@ -60,12 +121,11 @@ let GristCodeInputPopup = class GristCodeInputPopup extends LitElement {
60
121
  this.requestUpdate();
61
122
  }
62
123
  async createIdRule() {
63
- var _a;
64
124
  var idRule = {
65
125
  type: this.value,
66
126
  rule: `return ''`
67
127
  };
68
- return (_a = (await client.mutate({
128
+ return (await client.mutate({
69
129
  mutation: gql `
70
130
  mutation createIdRule($idRule: NewIdRule!) {
71
131
  createIdRule(idRule: $idRule) {
@@ -75,14 +135,17 @@ let GristCodeInputPopup = class GristCodeInputPopup extends LitElement {
75
135
  }
76
136
  `,
77
137
  variables: { idRule }
78
- })).data) === null || _a === void 0 ? void 0 : _a.createIdRule;
138
+ })).data?.createIdRule;
79
139
  }
80
140
  async updateIdRule() {
81
141
  if (!this._idRule)
82
142
  console.error('ID Rule not found');
83
143
  const rule = this.ruleEditor.value;
84
144
  const type = this._idRule.type;
85
- const patch = Object.assign(Object.assign({}, this._idRule), { rule });
145
+ const patch = {
146
+ ...this._idRule,
147
+ rule
148
+ };
86
149
  await client.mutate({
87
150
  mutation: gql `
88
151
  mutation updateIdRule($type: String!, $patch: IdRulePatch!) {
@@ -100,67 +163,6 @@ let GristCodeInputPopup = class GristCodeInputPopup extends LitElement {
100
163
  }));
101
164
  }
102
165
  };
103
- GristCodeInputPopup.styles = [
104
- css `
105
- :host {
106
- display: flex;
107
- flex-direction: column;
108
- padding: 0;
109
- align-items: center;
110
- box-sizing: border-box;
111
- width: 100%;
112
- border: 0;
113
- color: var(--popup-content-color);
114
- background-color: var(--popup-content-background-color);
115
-
116
- font: var(--grist-object-editor-font);
117
-
118
- justify-content: inherit;
119
- }
120
-
121
- :host * {
122
- box-sizing: border-box;
123
- }
124
-
125
- #wrapper {
126
- flex: 1;
127
- width: 100%;
128
- display: flex;
129
- flex-direction: column;
130
- padding: 5px;
131
- }
132
-
133
- #wrapper > h4 {
134
- margin: 0;
135
- }
136
-
137
- #wrapper > ul {
138
- width: 100%;
139
- }
140
-
141
- #wrapper > ul > li {
142
- display: flex;
143
- }
144
- #wrapper > ul > li > span {
145
- font-weight: bold;
146
- flex-basis: 200px;
147
- }
148
-
149
- #wrapper > ul > li > ox-i18n {
150
- flex: 1;
151
- }
152
-
153
- ox-input-code {
154
- width: 100%;
155
- flex: 1;
156
- }
157
-
158
- #footer {
159
- display: flex;
160
- justify-content: flex-end;
161
- }
162
- `
163
- ];
164
166
  __decorate([
165
167
  property({ type: String }),
166
168
  __metadata("design:type", String)
@@ -1 +1 @@
1
- {"version":3,"file":"grist-code-input-popup.js","sourceRoot":"","sources":["../../client/editors/grist-code-input-popup.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,0BAA0B,CAAA;AACjC,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE;IAC/B,OAAO,GAAG,CAAA;;mBAEO,IAAI;;;;;;CAMtB,CAAA;AACD,CAAC,CAAA;AAGM,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAyEjD,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;6DAO8C,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI;;;;oBAIlE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;qBAC/B,CAAC,CAAQ,EAAE,EAAE;YACpB,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC;;;;KAIR,CAAA;IACH,CAAC;IAED,OAAO,CAAC,OAAO;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACjD,IAAI,CAAC,OAAO,EAAE,CAAA;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,CAAC,aAAa,EAAE;YAC7B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAA;IACH,CAAC;;AAvKM,0BAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0DF;CACF,AA5DY,CA4DZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDAAa;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAuC;AAE1C;IAAvB,KAAK,CAAC,eAAe,CAAC;8BAAc,WAAW;uDAAA;AAvErC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CAyK/B","sourcesContent":["import '@material/web/button/elevated-button.js'\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/input/ox-input-code.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport { ColumnConfig, GristRecord } from '@operato/data-grist'\nimport { OxInputCode } from '@operato/input'\n\nconst FETCH_ID_RULE_GQL = type => {\n return gql`\n {\n idRule(type:\"${type}\") {\n id,\n type,\n rule\n }\n }\n`\n}\n\n@customElement('grist-code-input-popup')\nexport class GristCodeInputPopup extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n padding: 0;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n color: var(--popup-content-color);\n background-color: var(--popup-content-background-color);\n\n font: var(--grist-object-editor-font);\n\n justify-content: inherit;\n }\n\n :host * {\n box-sizing: border-box;\n }\n\n #wrapper {\n flex: 1;\n width: 100%;\n display: flex;\n flex-direction: column;\n padding: 5px;\n }\n\n #wrapper > h4 {\n margin: 0;\n }\n\n #wrapper > ul {\n width: 100%;\n }\n\n #wrapper > ul > li {\n display: flex;\n }\n #wrapper > ul > li > span {\n font-weight: bold;\n flex-basis: 200px;\n }\n\n #wrapper > ul > li > ox-i18n {\n flex: 1;\n }\n\n ox-input-code {\n width: 100%;\n flex: 1;\n }\n\n #footer {\n display: flex;\n justify-content: flex-end;\n }\n `\n ]\n\n @property({ type: String }) value?: string\n @property({ type: Object }) column?: ColumnConfig\n @property({ type: Object }) record?: GristRecord\n @property({ type: Number }) row?: number\n @property({ type: Object }) field?: any\n @property({ type: Object }) _idRule?: any\n @property({ type: Object }) headers?: { [header: string]: string }\n\n @query('ox-input-code') ruleEditor!: OxInputCode\n\n render() {\n return html`\n <div id=\"wrapper\">\n <h4><ox-i18n msgid=\"label.arguments\"></ox-i18n></h4>\n <ul>\n <li><span>domain</span><ox-i18n msgid=\"label.argument domain description\"></ox-i18n></li>\n <li><span>seed</span><ox-i18n msgid=\"label.argument seed description\"></ox-i18n></li>\n </ul>\n <ox-input-code id=\"rule-editor\" type=\"text\" .value=${(this._idRule || {}).rule}></ox-input-code>\n\n <div id=\"footer\">\n <md-elevated-button\n label=${String(i18next.t('button.save'))}\n @click=${(e: Event) => {\n this.updateIdRule()\n }}\n ></md-elevated-button>\n </div>\n </div>\n `\n }\n\n updated(changed) {\n if (changed.has('value')) {\n if (this.value && typeof this.value === 'string') {\n this.getRule()\n }\n }\n }\n\n async getRule() {\n var response = await client.query({\n query: FETCH_ID_RULE_GQL(this.value)\n })\n\n let idRule = response.data.idRule\n if (!idRule) {\n idRule = await this.createIdRule()\n }\n\n this._idRule = idRule\n this.requestUpdate()\n }\n\n async createIdRule() {\n var idRule = {\n type: this.value,\n rule: `return ''`\n }\n\n return (\n await client.mutate({\n mutation: gql`\n mutation createIdRule($idRule: NewIdRule!) {\n createIdRule(idRule: $idRule) {\n type\n rule\n }\n }\n `,\n variables: { idRule }\n })\n ).data?.createIdRule\n }\n\n async updateIdRule() {\n if (!this._idRule) console.error('ID Rule not found')\n\n const rule = this.ruleEditor.value\n\n const type = this._idRule.type\n\n const patch = {\n ...this._idRule,\n rule\n }\n\n await client.mutate({\n mutation: gql`\n mutation updateIdRule($type: String!, $patch: IdRulePatch!) {\n updateIdRule(type: $type, patch: $patch) {\n type\n rule\n }\n }\n `,\n variables: { type, patch }\n })\n\n this.dispatchEvent(\n new CustomEvent('close-popup', {\n bubbles: true,\n composed: true\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"grist-code-input-popup.js","sourceRoot":"","sources":["../../client/editors/grist-code-input-popup.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,0BAA0B,CAAA;AACjC,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAS,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE;IAC/B,OAAO,GAAG,CAAA;;mBAEO,IAAI;;;;;;CAMtB,CAAA;AACD,CAAC,C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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAuC;AAE1C;IAAvB,KAAK,CAAC,eAAe,CAAC;8BAAc,WAAW;uDAAA;AAvErC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CAyK/B","sourcesContent":["import '@material/web/button/elevated-button.js'\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/input/ox-input-code.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { client } from '@operato/graphql'\nimport { ColumnConfig, GristRecord } from '@operato/data-grist'\nimport { OxInputCode } from '@operato/input'\n\nconst FETCH_ID_RULE_GQL = type => {\n return gql`\n {\n idRule(type:\"${type}\") {\n id,\n type,\n rule\n }\n }\n`\n}\n\n@customElement('grist-code-input-popup')\nexport class GristCodeInputPopup extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n padding: 0;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n border: 0;\n color: var(--popup-content-color);\n background-color: var(--popup-content-background-color);\n\n font: var(--grist-object-editor-font);\n\n justify-content: inherit;\n }\n\n :host * {\n box-sizing: border-box;\n }\n\n #wrapper {\n flex: 1;\n width: 100%;\n display: flex;\n flex-direction: column;\n padding: 5px;\n }\n\n #wrapper > h4 {\n margin: 0;\n }\n\n #wrapper > ul {\n width: 100%;\n }\n\n #wrapper > ul > li {\n display: flex;\n }\n #wrapper > ul > li > span {\n font-weight: bold;\n flex-basis: 200px;\n }\n\n #wrapper > ul > li > ox-i18n {\n flex: 1;\n }\n\n ox-input-code {\n width: 100%;\n flex: 1;\n }\n\n #footer {\n display: flex;\n justify-content: flex-end;\n }\n `\n ]\n\n @property({ type: String }) value?: string\n @property({ type: Object }) column?: ColumnConfig\n @property({ type: Object }) record?: GristRecord\n @property({ type: Number }) row?: number\n @property({ type: Object }) field?: any\n @property({ type: Object }) _idRule?: any\n @property({ type: Object }) headers?: { [header: string]: string }\n\n @query('ox-input-code') ruleEditor!: OxInputCode\n\n render() {\n return html`\n <div id=\"wrapper\">\n <h4><ox-i18n msgid=\"label.arguments\"></ox-i18n></h4>\n <ul>\n <li><span>domain</span><ox-i18n msgid=\"label.argument domain description\"></ox-i18n></li>\n <li><span>seed</span><ox-i18n msgid=\"label.argument seed description\"></ox-i18n></li>\n </ul>\n <ox-input-code id=\"rule-editor\" type=\"text\" .value=${(this._idRule || {}).rule}></ox-input-code>\n\n <div id=\"footer\">\n <md-elevated-button\n label=${String(i18next.t('button.save'))}\n @click=${(e: Event) => {\n this.updateIdRule()\n }}\n ></md-elevated-button>\n </div>\n </div>\n `\n }\n\n updated(changed) {\n if (changed.has('value')) {\n if (this.value && typeof this.value === 'string') {\n this.getRule()\n }\n }\n }\n\n async getRule() {\n var response = await client.query({\n query: FETCH_ID_RULE_GQL(this.value)\n })\n\n let idRule = response.data.idRule\n if (!idRule) {\n idRule = await this.createIdRule()\n }\n\n this._idRule = idRule\n this.requestUpdate()\n }\n\n async createIdRule() {\n var idRule = {\n type: this.value,\n rule: `return ''`\n }\n\n return (\n await client.mutate({\n mutation: gql`\n mutation createIdRule($idRule: NewIdRule!) {\n createIdRule(idRule: $idRule) {\n type\n rule\n }\n }\n `,\n variables: { idRule }\n })\n ).data?.createIdRule\n }\n\n async updateIdRule() {\n if (!this._idRule) console.error('ID Rule not found')\n\n const rule = this.ruleEditor.value\n\n const type = this._idRule.type\n\n const patch = {\n ...this._idRule,\n rule\n }\n\n await client.mutate({\n mutation: gql`\n mutation updateIdRule($type: String!, $patch: IdRulePatch!) {\n updateIdRule(type: $type, patch: $patch) {\n type\n rule\n }\n }\n `,\n variables: { type, patch }\n })\n\n this.dispatchEvent(\n new CustomEvent('close-popup', {\n bubbles: true,\n composed: true\n })\n )\n }\n}\n"]}
@@ -6,6 +6,49 @@ import { OxGristEditor } from '@operato/data-grist';
6
6
  import { i18next } from '@operato/i18n';
7
7
  import './grist-code-input-popup';
8
8
  let GristCodeInput = class GristCodeInput extends OxGristEditor {
9
+ static { this.styles = [
10
+ css `
11
+ :host {
12
+ display: flex;
13
+ flex-flow: row nowrap;
14
+ align-items: center;
15
+
16
+ padding: 7px 0px;
17
+ box-sizing: border-box;
18
+
19
+ width: 100%;
20
+ height: 100%;
21
+
22
+ border: 0;
23
+ background-color: transparent;
24
+
25
+ font: var(--grist-object-editor-font);
26
+ color: var(--grist-object-editor-color);
27
+
28
+ justify-content: inherit;
29
+ }
30
+
31
+ md-icon {
32
+ width: 20px;
33
+ font-size: 1.5em;
34
+ }
35
+
36
+ #popup {
37
+ display: flex;
38
+ overflow: hidden;
39
+ }
40
+
41
+ input {
42
+ border: none;
43
+ background-color: transparent;
44
+ }
45
+
46
+ input:focus {
47
+ outline: none;
48
+ border: none;
49
+ }
50
+ `
51
+ ]; }
9
52
  render() {
10
53
  return html `
11
54
  <input
@@ -45,8 +88,7 @@ let GristCodeInput = class GristCodeInput extends OxGristEditor {
45
88
  .field=${this.field}
46
89
  .headers=${this.headers}
47
90
  @close-popup=${e => {
48
- var _a;
49
- (_a = this.popup) === null || _a === void 0 ? void 0 : _a.close();
91
+ this.popup?.close();
50
92
  this.popup = null;
51
93
  }}
52
94
  ></grist-code-input-popup>
@@ -61,49 +103,6 @@ let GristCodeInput = class GristCodeInput extends OxGristEditor {
61
103
  }));
62
104
  }
63
105
  };
64
- GristCodeInput.styles = [
65
- css `
66
- :host {
67
- display: flex;
68
- flex-flow: row nowrap;
69
- align-items: center;
70
-
71
- padding: 7px 0px;
72
- box-sizing: border-box;
73
-
74
- width: 100%;
75
- height: 100%;
76
-
77
- border: 0;
78
- background-color: transparent;
79
-
80
- font: var(--grist-object-editor-font);
81
- color: var(--grist-object-editor-color);
82
-
83
- justify-content: inherit;
84
- }
85
-
86
- md-icon {
87
- width: 20px;
88
- font-size: 1.5em;
89
- }
90
-
91
- #popup {
92
- display: flex;
93
- overflow: hidden;
94
- }
95
-
96
- input {
97
- border: none;
98
- background-color: transparent;
99
- }
100
-
101
- input:focus {
102
- outline: none;
103
- border: none;
104
- }
105
- `
106
- ];
107
106
  __decorate([
108
107
  property({ type: Object }),
109
108
  __metadata("design:type", Object)
@@ -1 +1 @@
1
- {"version":3,"file":"grist-code-input.js","sourceRoot":"","sources":["../../client/editors/grist-code-input.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,0BAA0B,CAAA;AAG1B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,aAAa;IAgD/C,MAAM;QACJ,OAAO,IAAI,CAAA;;;iBAGE,IAAI,CAAC,KAAK;kBACT,IAAI,CAAC,MAAM;kBACX,IAAI,CAAC,MAAM;iBACZ,IAAI,CAAC,MAAM;eACb,IAAI,CAAC,GAAG;;;kCAGW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE;KAClD,CAAA;IACH,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,cAAc,CAAA;QACzB,MAAM,KAAK,CAAC,YAAY,EAAE,CAAA;IAC5B,CAAC;IAED,SAAS;QACP,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAC1B,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE;oBACN,KAAK,EAAE,OAAO;oBACd,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,2CAA2C,CAAC;iBAChE;aACF,CAAC,CACH,CAAA;YAED,OAAM;QACR,CAAC;QAED,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,YAAY,EAAE;YAC5B,MAAM,EAAE;gBACN,QAAQ,EAAE,IAAI,CAAA;;uBAED,IAAI,CAAC,KAAK;wBACT,IAAI,CAAC,MAAM;wBACX,IAAI,CAAC,MAAM;qBACd,IAAI,CAAC,GAAG;uBACN,IAAI,CAAC,KAAK;yBACR,IAAI,CAAC,OAAO;6BACR,CAAC,CAAC,EAAE;;oBACjB,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,EAAE,CAAA;oBACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;gBACnB,CAAC;;WAEJ;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;iBACzC;gBACD,QAAQ,EAAE,KAAK,CAAC,EAAE;oBAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;gBACpB,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;;AA3GM,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCF;CACF,AA1CY,CA0CZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8BAAW,MAAM;+CAAA;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAuB;AA9CvC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA6G1B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { OxPopup } from '@operato/popup'\n\nimport './grist-code-input-popup'\n\n@customElement('grist-code-input')\nexport class GristCodeInput extends OxGristEditor {\n static styles = [\n css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n\n justify-content: inherit;\n }\n\n md-icon {\n width: 20px;\n font-size: 1.5em;\n }\n\n #popup {\n display: flex;\n overflow: hidden;\n }\n\n input {\n border: none;\n background-color: transparent;\n }\n\n input:focus {\n outline: none;\n border: none;\n }\n `\n ]\n\n @property({ type: Object }) headers?: Object\n @property({ type: Object }) popup?: OxPopup | null\n\n render() {\n return html`\n <input\n type=\"text\"\n .value=${this.value}\n .record=${this.record}\n .column=${this.column}\n .field=${this.column}\n .row=${this.row}\n ></input>\n\n <md-icon id=\"more\" @click=${e => this.openPopup()}>more_vert</md-icon>\n `\n }\n\n async firstUpdated() {\n await this.updateComplete\n await super.firstUpdated()\n }\n\n openPopup() {\n if (this.record.__dirty__) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: i18next.t('text.please_save_your_modifications_first')\n }\n })\n )\n\n return\n }\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: html`\n <grist-code-input-popup\n .value=${this.value}\n .column=${this.column}\n .record=${this.record}\n .row=${this.row}\n .field=${this.field}\n .headers=${this.headers}\n @close-popup=${e => {\n this.popup?.close()\n this.popup = null\n }}\n ></grist-code-input-popup>\n `,\n options: {\n title: i18next.t('title.ID Rule Editor')\n },\n callback: popup => {\n this.popup = popup\n }\n }\n })\n )\n }\n}\n"]}
1
+ {"version":3,"file":"grist-code-input.js","sourceRoot":"","sources":["../../client/editors/grist-code-input.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eA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AAO,EAAE;oBACP,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC;iBACzC;gBACD,QAAQ,EAAE,KAAK,CAAC,EAAE;oBAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;gBACpB,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;;AA/D2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8BAAW,MAAM;+CAAA;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CAAuB;AA9CvC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA6G1B","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { OxPopup } from '@operato/popup'\n\nimport './grist-code-input-popup'\n\n@customElement('grist-code-input')\nexport class GristCodeInput extends OxGristEditor {\n static styles = [\n css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n\n justify-content: inherit;\n }\n\n md-icon {\n width: 20px;\n font-size: 1.5em;\n }\n\n #popup {\n display: flex;\n overflow: hidden;\n }\n\n input {\n border: none;\n background-color: transparent;\n }\n\n input:focus {\n outline: none;\n border: none;\n }\n `\n ]\n\n @property({ type: Object }) headers?: Object\n @property({ type: Object }) popup?: OxPopup | null\n\n render() {\n return html`\n <input\n type=\"text\"\n .value=${this.value}\n .record=${this.record}\n .column=${this.column}\n .field=${this.column}\n .row=${this.row}\n ></input>\n\n <md-icon id=\"more\" @click=${e => this.openPopup()}>more_vert</md-icon>\n `\n }\n\n async firstUpdated() {\n await this.updateComplete\n await super.firstUpdated()\n }\n\n openPopup() {\n if (this.record.__dirty__) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n level: 'error',\n message: i18next.t('text.please_save_your_modifications_first')\n }\n })\n )\n\n return\n }\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: html`\n <grist-code-input-popup\n .value=${this.value}\n .column=${this.column}\n .record=${this.record}\n .row=${this.row}\n .field=${this.field}\n .headers=${this.headers}\n @close-popup=${e => {\n this.popup?.close()\n this.popup = null\n }}\n ></grist-code-input-popup>\n `,\n options: {\n title: i18next.t('title.ID Rule Editor')\n },\n callback: popup => {\n this.popup = popup\n }\n }\n })\n )\n }\n}\n"]}