@operato/input 1.0.0-alpha.9 → 1.0.0-beta.2

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 (101) hide show
  1. package/CHANGELOG.md +412 -0
  2. package/assets/images/icon-properties-line-type.png +0 -0
  3. package/assets/images/icon-properties-table.png +0 -0
  4. package/demo/index-crontab.html +37 -0
  5. package/demo/index-partition-keys.html +71 -0
  6. package/demo/index-select.html +21 -14
  7. package/demo/index-table.html +39 -0
  8. package/demo/index-value-map.html +80 -0
  9. package/demo/index-value-ranges.html +80 -0
  10. package/demo/index-work-shift.html +59 -0
  11. package/demo/index.html +10 -0
  12. package/dist/src/index.d.ts +9 -3
  13. package/dist/src/index.js +9 -3
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/ox-checkbox.d.ts +1 -1
  16. package/dist/src/ox-checkbox.js +1 -1
  17. package/dist/src/ox-checkbox.js.map +1 -1
  18. package/dist/src/ox-form-field.d.ts +2 -2
  19. package/dist/src/ox-form-field.js.map +1 -1
  20. package/dist/src/ox-input-barcode.d.ts +1 -1
  21. package/dist/src/ox-input-barcode.js +1 -1
  22. package/dist/src/ox-input-barcode.js.map +1 -1
  23. package/dist/src/ox-input-code.d.ts +1 -1
  24. package/dist/src/ox-input-code.js +12 -7
  25. package/dist/src/ox-input-code.js.map +1 -1
  26. package/dist/src/ox-input-color-gradient.d.ts +4 -4
  27. package/dist/src/ox-input-color-gradient.js +3 -3
  28. package/dist/src/ox-input-color-gradient.js.map +1 -1
  29. package/dist/src/ox-input-color-stops.js +1 -1
  30. package/dist/src/ox-input-color-stops.js.map +1 -1
  31. package/dist/src/ox-input-crontab.d.ts +23 -0
  32. package/dist/src/ox-input-crontab.js +560 -0
  33. package/dist/src/ox-input-crontab.js.map +1 -0
  34. package/dist/src/ox-input-layout/ox-input-card-layout.d.ts +4 -0
  35. package/dist/src/ox-input-layout/ox-input-card-layout.js +57 -0
  36. package/dist/src/ox-input-layout/ox-input-card-layout.js.map +1 -0
  37. package/dist/src/ox-input-layout/ox-input-grid-layout.d.ts +4 -0
  38. package/dist/src/ox-input-layout/ox-input-grid-layout.js +63 -0
  39. package/dist/src/ox-input-layout/ox-input-grid-layout.js.map +1 -0
  40. package/dist/src/ox-input-layout/ox-input-layout.d.ts +5 -0
  41. package/dist/src/ox-input-layout/ox-input-layout.js +73 -0
  42. package/dist/src/ox-input-layout/ox-input-layout.js.map +1 -0
  43. package/dist/src/ox-input-multiple-colors.d.ts +2 -2
  44. package/dist/src/ox-input-multiple-colors.js +2 -2
  45. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  46. package/dist/src/ox-input-options.js.map +1 -1
  47. package/dist/src/ox-input-partition-keys.d.ts +36 -0
  48. package/dist/src/ox-input-partition-keys.js +204 -0
  49. package/dist/src/ox-input-partition-keys.js.map +1 -0
  50. package/dist/src/ox-input-search.d.ts +1 -0
  51. package/dist/src/ox-input-search.js +7 -1
  52. package/dist/src/ox-input-search.js.map +1 -1
  53. package/dist/src/ox-input-table.d.ts +8 -0
  54. package/dist/src/ox-input-table.js +379 -0
  55. package/dist/src/ox-input-table.js.map +1 -0
  56. package/dist/src/ox-input-value-map.d.ts +41 -0
  57. package/dist/src/ox-input-value-map.js +279 -0
  58. package/dist/src/ox-input-value-map.js.map +1 -0
  59. package/dist/src/ox-input-value-ranges.d.ts +41 -0
  60. package/dist/src/ox-input-value-ranges.js +298 -0
  61. package/dist/src/ox-input-value-ranges.js.map +1 -0
  62. package/dist/src/ox-input-work-shift.d.ts +33 -0
  63. package/dist/src/ox-input-work-shift.js +229 -0
  64. package/dist/src/ox-input-work-shift.js.map +1 -0
  65. package/dist/src/ox-select.d.ts +3 -0
  66. package/dist/src/ox-select.js +28 -3
  67. package/dist/src/ox-select.js.map +1 -1
  68. package/dist/tsconfig.tsbuildinfo +1 -1
  69. package/package.json +18 -8
  70. package/src/index.ts +9 -3
  71. package/src/ox-checkbox.ts +2 -2
  72. package/src/ox-form-field.ts +2 -2
  73. package/src/ox-input-barcode.ts +2 -3
  74. package/src/ox-input-code.ts +14 -8
  75. package/src/{ox-input-color-gradient.ts.xxx → ox-input-color-gradient.ts} +4 -4
  76. package/src/ox-input-color-stops.ts +1 -1
  77. package/src/ox-input-crontab.ts +561 -0
  78. package/src/ox-input-layout/ox-input-card-layout.ts +58 -0
  79. package/src/ox-input-layout/ox-input-grid-layout.ts +64 -0
  80. package/src/ox-input-layout/ox-input-layout.ts +77 -0
  81. package/src/ox-input-multiple-colors.ts +2 -2
  82. package/src/ox-input-options.ts +1 -1
  83. package/src/ox-input-partition-keys.ts +243 -0
  84. package/src/ox-input-search.ts +9 -1
  85. package/src/ox-input-table.ts +404 -0
  86. package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +120 -89
  87. package/src/ox-input-value-ranges.ts +325 -0
  88. package/src/ox-input-work-shift.ts +251 -0
  89. package/src/ox-select.ts +31 -5
  90. package/dist/src/ox-input-background-pattern.d.ts +0 -31
  91. package/dist/src/ox-input-background-pattern.js +0 -147
  92. package/dist/src/ox-input-background-pattern.js.map +0 -1
  93. package/dist/src/ox-input-fill-style.d.ts +0 -42
  94. package/dist/src/ox-input-fill-style.js +0 -323
  95. package/dist/src/ox-input-fill-style.js.map +0 -1
  96. package/dist/src/ox-input-id.d.ts +0 -11
  97. package/dist/src/ox-input-id.js +0 -68
  98. package/dist/src/ox-input-id.js.map +0 -1
  99. package/src/ox-input-background-pattern.ts.xxx +0 -163
  100. package/src/ox-input-fill-style.ts.xxx +0 -361
  101. package/src/ox-input-ranges.ts.ing +0 -292
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import { LitElement, css, html } from 'lit';
6
+ import { customElement, property } from 'lit/decorators.js';
7
+ const DEFAULT = {
8
+ activeIndex: 0
9
+ };
10
+ let OxInputCardLayout = class OxInputCardLayout extends LitElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.activeIndex = 0;
14
+ }
15
+ static { this.styles = css `
16
+ :host {
17
+ display: inline-block;
18
+ }
19
+ `; }
20
+ firstUpdated() {
21
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this));
22
+ }
23
+ updated(changes) {
24
+ if (changes.has('value')) {
25
+ let { activeIndex } = this.value || DEFAULT;
26
+ this.activeIndex = activeIndex;
27
+ }
28
+ }
29
+ render() {
30
+ return html `
31
+ <label>active index</label>
32
+ <input type="number" value-key="activeIndex" .value=${this.activeIndex} />
33
+ `;
34
+ }
35
+ _onValueChange(e) {
36
+ var element = e.target;
37
+ var key = element.getAttribute('value-key');
38
+ if (!key) {
39
+ return;
40
+ }
41
+ this[key] = Number(element.value);
42
+ this.value = {
43
+ activeIndex: this.activeIndex
44
+ };
45
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
46
+ }
47
+ };
48
+ __decorate([
49
+ property({ type: Object })
50
+ ], OxInputCardLayout.prototype, "value", void 0);
51
+ __decorate([
52
+ property({ type: Number })
53
+ ], OxInputCardLayout.prototype, "activeIndex", void 0);
54
+ OxInputCardLayout = __decorate([
55
+ customElement('ox-input-card-layout')
56
+ ], OxInputCardLayout);
57
+ //# sourceMappingURL=ox-input-card-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-card-layout.js","sourceRoot":"","sources":["../../../src/ox-input-layout/ox-input-card-layout.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAElE,MAAM,OAAO,GAAG;IACd,WAAW,EAAE,CAAC;CACf,CAAA;AAGD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAQ8B,gBAAW,GAAW,CAAC,CAAA;IAqCrD,CAAC;aA5CQ,WAAM,GAAG,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\nimport { LitElement, PropertyValues, css, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nconst DEFAULT = {\n activeIndex: 0\n}\n\n@customElement('ox-input-card-layout')\nclass OxInputCardLayout extends LitElement {\n static styles = css`\n :host {\n display: inline-block;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: Number }) activeIndex: number = 0\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChange.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n let { activeIndex } = this.value || DEFAULT\n\n this.activeIndex = activeIndex\n }\n }\n\n render() {\n return html`\n <label>active index</label>\n <input type=\"number\" value-key=\"activeIndex\" .value=${this.activeIndex} />\n `\n }\n\n _onValueChange(e: Event) {\n var element = e.target as HTMLInputElement\n var key = element.getAttribute('value-key') as 'activeIndex'\n\n if (!key) {\n return\n }\n\n this[key] = Number(element.value)\n\n this.value = {\n activeIndex: this.activeIndex\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export {};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import { LitElement, css, html } from 'lit';
6
+ import { customElement, property } from 'lit/decorators.js';
7
+ let OxInputGridLayout = class OxInputGridLayout extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.direction = 'row';
11
+ }
12
+ static { this.styles = css `
13
+ :host {
14
+ display: inline-block;
15
+ }
16
+ `; }
17
+ firstUpdated() {
18
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this));
19
+ }
20
+ updated(changes) {
21
+ if (changes.has('value')) {
22
+ let { direction = 'row' } = this.value || {};
23
+ this.direction = direction;
24
+ }
25
+ if (changes.has('value')) {
26
+ }
27
+ }
28
+ render() {
29
+ return html `
30
+ <label>direction</label>
31
+ <select value-key="direction" .value=${this.direction}>
32
+ <option value="row" selected>row</option>
33
+ <option value="column">column</option>
34
+ </select>
35
+ `;
36
+ }
37
+ _onValueChange(e) {
38
+ var element = e.target;
39
+ var key = element.getAttribute('value-key');
40
+ if (!key) {
41
+ return;
42
+ }
43
+ switch (key) {
44
+ case 'direction':
45
+ this.direction = element.value;
46
+ default:
47
+ }
48
+ this.value = {
49
+ direction: this.direction
50
+ };
51
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
52
+ }
53
+ };
54
+ __decorate([
55
+ property({ type: Object })
56
+ ], OxInputGridLayout.prototype, "value", void 0);
57
+ __decorate([
58
+ property({ type: String })
59
+ ], OxInputGridLayout.prototype, "direction", void 0);
60
+ OxInputGridLayout = __decorate([
61
+ customElement('ox-input-grid-layout')
62
+ ], OxInputGridLayout);
63
+ //# sourceMappingURL=ox-input-grid-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-grid-layout.js","sourceRoot":"","sources":["../../../src/ox-input-layout/ox-input-grid-layout.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAGlE,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAQ8B,cAAS,GAAqB,KAAK,CAAA;IA+CjE,CAAC;aAtDQ,WAAM,GAAG,GAAG,CAAA;;;;GAIlB,CAAA;IAKD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACxB,IAAI,EAAE,SAAS,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;YAE5C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;SAC3B;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;SACzB;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;6CAE8B,IAAI,CAAC,SAAS;;;;KAItD,CAAA;IACH,CAAC;IAED,cAAc,CAAC,CAAQ;QACrB,IAAI,OAAO,GAAG,CAAC,CAAC,MAA2B,CAAA;QAC3C,IAAI,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;QAE3C,IAAI,CAAC,GAAG,EAAE;YACR,OAAM;SACP;QAED,QAAQ,GAAG,EAAE;YACX,KAAK,WAAW;gBACd,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,KAAyB,CAAA;YACpD,QAAQ;SACT;QAED,IAAI,CAAC,KAAK,GAAG;YACX,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAA;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AAhD6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAoC;AAR3D,iBAAiB;IADtB,aAAa,CAAC,sBAAsB,CAAC;GAChC,iBAAiB,CAuDtB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, PropertyValues, css, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\n@customElement('ox-input-grid-layout')\nclass OxInputGridLayout extends LitElement {\n static styles = css`\n :host {\n display: inline-block;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: String }) direction: 'row' | 'column' = 'row'\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChange.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n let { direction = 'row' } = this.value || {}\n\n this.direction = direction\n }\n\n if (changes.has('value')) {\n }\n }\n\n render() {\n return html`\n <label>direction</label>\n <select value-key=\"direction\" .value=${this.direction}>\n <option value=\"row\" selected>row</option>\n <option value=\"column\">column</option>\n </select>\n `\n }\n\n _onValueChange(e: Event) {\n var element = e.target as HTMLSelectElement\n var key = element.getAttribute('value-key')\n\n if (!key) {\n return\n }\n\n switch (key) {\n case 'direction':\n this.direction = element.value as 'row' | 'column'\n default:\n }\n\n this.value = {\n direction: this.direction\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import './things-grid-layout';
5
+ import './things-card-layout';
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import './things-grid-layout';
6
+ import './things-card-layout';
7
+ import { LitElement, html } from 'lit';
8
+ import { customElement, property } from 'lit/decorators.js';
9
+ // import './things-linear-horizontal-layout'
10
+ // import './things-linear-vertical-layout'
11
+ const layouts = ['absolute', 'card', 'grid', 'linear-horizontal', 'linear-vertical', 'table'];
12
+ let OxInputLayout = class OxInputLayout extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.value = {};
16
+ this.layout = '';
17
+ this.options = {};
18
+ }
19
+ firstUpdated() {
20
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this));
21
+ }
22
+ updated(changes) {
23
+ if (changes.has('value')) {
24
+ this.layout = this.value.layout;
25
+ this.options = this.value.options;
26
+ }
27
+ }
28
+ render() {
29
+ return html `
30
+ <div>
31
+ <select value-key="layout" .value=${this.layout}>
32
+ <option value="" selected></option>
33
+ ${layouts.map(layout => {
34
+ return html ` <option value=${layout}>${layout}</option> `;
35
+ })}
36
+ </select>
37
+
38
+ ${this.layout == 'grid'
39
+ ? html ` <things-grid-layout value-key="options" .value=${this.options}></things-grid-layout> `
40
+ : this.layout == 'card'
41
+ ? html ` <things-card-layout value-key="options" .value=${this.options}></things-card-layout> `
42
+ : html ``}
43
+ </div>
44
+ `;
45
+ }
46
+ _onValueChange(e) {
47
+ var element = e.target;
48
+ var key = element.getAttribute('value-key');
49
+ if (!key) {
50
+ return;
51
+ }
52
+ //@ts-ignore
53
+ this[key] = element.value;
54
+ this.value = {
55
+ layout: this.layout,
56
+ options: this.options
57
+ };
58
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
59
+ }
60
+ };
61
+ __decorate([
62
+ property({ type: Object })
63
+ ], OxInputLayout.prototype, "value", void 0);
64
+ __decorate([
65
+ property({ type: String })
66
+ ], OxInputLayout.prototype, "layout", void 0);
67
+ __decorate([
68
+ property({ type: Object })
69
+ ], OxInputLayout.prototype, "options", void 0);
70
+ OxInputLayout = __decorate([
71
+ customElement('ox-input-layout')
72
+ ], OxInputLayout);
73
+ //# sourceMappingURL=ox-input-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-layout.js","sourceRoot":"","sources":["../../../src/ox-input-layout/ox-input-layout.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,sBAAsB,CAAA;AAC7B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAElE,6CAA6C;AAC7C,2CAA2C;AAE3C,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;AAG7F,I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C,GAAG,OAAO,CAAC,KAAK,CAAA;QAEzB,IAAI,CAAC,KAAK,GAAG;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AA3D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAOX;AACY;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAkB;AAVzC,aAAa;IADlB,aAAa,CAAC,iBAAiB,CAAC;GAC3B,aAAa,CA4DlB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './things-grid-layout'\nimport './things-card-layout'\n\nimport { LitElement, PropertyValues, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\n// import './things-linear-horizontal-layout'\n// import './things-linear-vertical-layout'\n\nconst layouts = ['absolute', 'card', 'grid', 'linear-horizontal', 'linear-vertical', 'table']\n\n@customElement('ox-input-layout')\nclass OxInputLayout extends LitElement {\n @property({ type: Object }) value: any = {}\n @property({ type: String }) layout:\n | ''\n | 'absolute'\n | 'card'\n | 'grid'\n | 'linear-horizontal'\n | 'linear-vertical'\n | 'table' = ''\n @property({ type: Object }) options: any = {}\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChange.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n this.layout = this.value.layout\n this.options = this.value.options\n }\n }\n\n render() {\n return html`\n <div>\n <select value-key=\"layout\" .value=${this.layout}>\n <option value=\"\" selected></option>\n ${layouts.map(layout => {\n return html` <option value=${layout}>${layout}</option> `\n })}\n </select>\n\n ${this.layout == 'grid'\n ? html` <things-grid-layout value-key=\"options\" .value=${this.options}></things-grid-layout> `\n : this.layout == 'card'\n ? html` <things-card-layout value-key=\"options\" .value=${this.options}></things-card-layout> `\n : html``}\n </div>\n `\n }\n\n _onValueChange(e: Event) {\n var element = e.target as HTMLElement\n var key = element.getAttribute('value-key')\n\n if (!key) {\n return\n }\n\n //@ts-ignore\n this[key] = element.value\n\n this.value = {\n layout: this.layout,\n options: this.options\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -12,8 +12,8 @@ import { OxInputColor } from './ox-input-color.js';
12
12
 
13
13
  Example:
14
14
 
15
- <ox-input-multiple-color values=${values}>
16
- </ox-input-multiple-color>
15
+ <ox-input-multiple-colors values=${values}>
16
+ </ox-input-multiple-colors>
17
17
  */
18
18
  export declare class OxInputMultipleColors extends OxFormField {
19
19
  static styles: import("lit").CSSResult;
@@ -14,8 +14,8 @@ import { OxFormField } from './ox-form-field.js';
14
14
 
15
15
  Example:
16
16
 
17
- <ox-input-multiple-color values=${values}>
18
- </ox-input-multiple-color>
17
+ <ox-input-multiple-colors values=${values}>
18
+ </ox-input-multiple-colors>
19
19
  */
20
20
  let OxInputMultipleColors = class OxInputMultipleColors extends OxFormField {
21
21
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-multiple-colors.js","sourceRoot":"","sources":["../../src/ox-input-multiple-colors.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD;;;;;;;;;;EAUE;AAGF,IAAa,qBAAqB,GAAlC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F,CAAC;IAED,kBAAkB,CAAC,CAAQ;QACzB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,IAAI,MAAM,CAAE,CAAC,CAAC,MAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAQ;;gBAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAChC;QAED,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QACnB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AAxD4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAqB;AAEnB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8DAAiC;AAChC;IAA3B,QAAQ,CAAC,gBAAgB,CAAC;qDAAkC;AAlClD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAuFjC;SAvFY,qBAAqB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputColor } from './ox-input-color.js'\n\n/**\n색상 배열을 편집하는 컴포넌트이다.\n\n새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />\n색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />\n\nExample:\n\n <ox-input-multiple-color values=${values}>\n </ox-input-multiple-color>\n*/\n\n@customElement('ox-input-multiple-colors')\nexport class OxInputMultipleColors extends OxFormField {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n #colors-container > div {\n display: grid;\n grid-template-columns: 22px 1fr 22px;\n grid-gap: 5px;\n align-items: center;\n justify-content: left;\n }\n\n ox-input-color {\n height: 25px;\n width: 100%;\n }\n\n input[type='button'] {\n width: 22px;\n height: 25px;\n border: 1px solid rgba(0, 0, 0, 0.15);\n padding-top: 0px;\n padding-bottom: 2px;\n background-color: #f1f2f4;\n color: #8f9192;\n font-size: 16px;\n }\n `\n\n @property({ type: Array }) value: string[] = []\n\n @query('#colors-container') colorsContainer!: HTMLDivElement\n @queryAll('ox-input-color') colors!: NodeListOf<OxInputColor>\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n render() {\n return html`\n <div id=\"colors-container\">\n ${(this.value || []).map(\n (item, index) => html`\n <div>\n <input type=\"button\" value=\"+\" @click=${() => this._appendEditorColor()} data-index=${index} />\n\n <ox-input-color .value=${item}> </ox-input-color>\n\n ${(this.value || []).length > 1\n ? html`\n <input\n type=\"button\"\n value=\"-\"\n @click=${(e: Event) => this._removeEditorColor(e)}\n data-index=${index}\n />\n `\n : html``}\n </div>\n `\n )}\n </div>\n `\n }\n\n _onValueChanged() {\n this.value = Array.from(this.colors).map(color => color.value!)\n }\n\n _appendEditorColor() {\n this.value = [...this.value, 'black']\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _removeEditorColor(e: Event) {\n var values = []\n for (var i = 0; i < this.value.length; i++) {\n if (i == Number((e.target as HTMLElement).dataset.index)) continue\n else values.push(this.value[i])\n }\n\n this.value = values\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
1
+ {"version":3,"file":"ox-input-multiple-colors.js","sourceRoot":"","sources":["../../src/ox-input-multiple-colors.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MA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AC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;IAED,kBAAkB,CAAC,CAAQ;QACzB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,IAAI,MAAM,CAAE,CAAC,CAAC,MAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAQ;;gBAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAChC;QAED,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QACnB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AAxD4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAqB;AAEnB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8DAAiC;AAChC;IAA3B,QAAQ,CAAC,gBAAgB,CAAC;qDAAkC;AAlClD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAuFjC;SAvFY,qBAAqB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputColor } from './ox-input-color.js'\n\n/**\n색상 배열을 편집하는 컴포넌트이다.\n\n새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />\n색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />\n\nExample:\n\n <ox-input-multiple-colors values=${values}>\n </ox-input-multiple-colors>\n*/\n\n@customElement('ox-input-multiple-colors')\nexport class OxInputMultipleColors extends OxFormField {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n #colors-container > div {\n display: grid;\n grid-template-columns: 22px 1fr 22px;\n grid-gap: 5px;\n align-items: center;\n justify-content: left;\n }\n\n ox-input-color {\n height: 25px;\n width: 100%;\n }\n\n input[type='button'] {\n width: 22px;\n height: 25px;\n border: 1px solid rgba(0, 0, 0, 0.15);\n padding-top: 0px;\n padding-bottom: 2px;\n background-color: #f1f2f4;\n color: #8f9192;\n font-size: 16px;\n }\n `\n\n @property({ type: Array }) value: string[] = []\n\n @query('#colors-container') colorsContainer!: HTMLDivElement\n @queryAll('ox-input-color') colors!: NodeListOf<OxInputColor>\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n render() {\n return html`\n <div id=\"colors-container\">\n ${(this.value || []).map(\n (item, index) => html`\n <div>\n <input type=\"button\" value=\"+\" @click=${() => this._appendEditorColor()} data-index=${index} />\n\n <ox-input-color .value=${item}> </ox-input-color>\n\n ${(this.value || []).length > 1\n ? html`\n <input\n type=\"button\"\n value=\"-\"\n @click=${(e: Event) => this._removeEditorColor(e)}\n data-index=${index}\n />\n `\n : html``}\n </div>\n `\n )}\n </div>\n `\n }\n\n _onValueChanged() {\n this.value = Array.from(this.colors).map(color => color.value!)\n }\n\n _appendEditorColor() {\n this.value = [...this.value, 'black']\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _removeEditorColor(e: Event) {\n var values = []\n for (var i = 0; i < this.value.length; i++) {\n if (i == Number((e.target as HTMLElement).dataset.index)) continue\n else values.push(this.value[i])\n }\n\n this.value = values\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ox-input-options.js","sourceRoot":"","sources":["../../src/ox-input-options.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAc,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,WAAW;IAA/C;;QAsB6B,UAAK,GAAa,EAAE,CAAA;QA4BvC,iBAAY,GAAY,KAAK,CAAA;IAsGvC,CAAC;aAvJQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;GAmBlB,CAAA;IAID,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QAE7D,OAAO,IAAI,CAAA;QACP,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CACnB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAA;;wEAEoD,IAAI,CAAC,IAAI;0EACP,IAAI,CAAC,KAAK;mDACjC,CAAC,CAAa,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;;SAE5E,CACF;;;;gFAIyE,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;+CAC1D,CAAC,CAAa,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;;KAExE,CAAA;IACH,CAAC;IAID,SAAS,CAAC,CAAQ;QAChB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AC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6CAAqB;AAtBpC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwJ1B;SAxJY,cAAc","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype Option = { text: string; value: string }\n\n@customElement('ox-input-options')\nexport class OxInputOptions extends OxFormField {\n static styles = css`\n div {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n }\n\n input[data-text] {\n grid-column: span 5;\n }\n\n input[data-value] {\n grid-column: span 4;\n }\n\n button {\n grid-column: span 1;\n }\n `\n\n @property({ type: Array }) value: Option[] = []\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const options = this.value instanceof Array ? this.value : []\n\n return html`\n ${(options || []).map(\n item => html`\n <div data-record=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" .value=${item.text} />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" .value=${item.value} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n </div>\n `\n )}\n\n <div data-record-new=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" value=\"\" />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" value=\"\" @change=${(e: Event) => this._add()} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n `\n }\n\n private _changingNow: boolean = false\n\n _onChange(e: Event) {\n if (this._changingNow) return\n\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var div = input.parentElement\n\n if (div && div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || ''\n }\n }\n }\n\n if (div && div.hasAttribute('data-record')) this._build(true)\n else if (div && div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()\n\n e.stopPropagation()\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: any) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newoptions: Option[] = []\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var text = (record.querySelector('[data-text]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])') as NodeListOf<HTMLInputElement>\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1]\n var value = input.value\n\n if (text) newoptions.push({ text: text, value: value || text })\n }\n\n this.value = newoptions\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n sort() {\n var sorter = function (a: Option, b: Option) {\n return b.text < a.text ? 1 : -1\n }\n\n this.value = [...this.value.sort(sorter)]\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as HTMLElement).parentElement\n const input = record && (record.querySelector('[data-text]') as HTMLInputElement)\n\n if (input) {\n input.value = ''\n }\n\n this._build()\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n if (!this.name) return\n\n const value = this.value\n\n formData.append(\n this.name!,\n typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)\n )\n }\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CAAqB;AAtBpC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAwJ1B;SAxJY,cAAc","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype Option = { text: string; value: string }\n\n@customElement('ox-input-options')\nexport class OxInputOptions extends OxFormField {\n static styles = css`\n div {\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n }\n\n input[data-text] {\n grid-column: span 5;\n }\n\n input[data-value] {\n grid-column: span 4;\n }\n\n button {\n grid-column: span 1;\n }\n `\n\n @property({ type: Array }) value: Option[] = []\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const options = this.value instanceof Array ? this.value : []\n\n return html`\n ${(options || []).map(\n item => html`\n <div data-record=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" .value=${item.text} />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" .value=${item.value} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n </div>\n `\n )}\n\n <div data-record-new=\"\">\n <input type=\"text\" data-text=\"\" placeholder=\"text\" value=\"\" />\n <input type=\"text\" data-value=\"\" placeholder=\"value\" value=\"\" @change=${(e: Event) => this._add()} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n `\n }\n\n private _changingNow: boolean = false\n\n _onChange(e: Event) {\n if (this._changingNow) return\n\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var div = input.parentElement\n\n if (div && div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || ''\n }\n }\n }\n\n if (div && div.hasAttribute('data-record')) this._build(true)\n else if (div && div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()\n\n e.stopPropagation()\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: any) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newoptions: Option[] = []\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var text = (record.querySelector('[data-text]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])') as NodeListOf<HTMLInputElement>\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1]\n var value = input.value\n\n if (text) newoptions.push({ text: text, value: value || text })\n }\n\n this.value = newoptions\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n sort() {\n var sorter = function (a: Option, b: Option) {\n return b.text < a.text ? 1 : -1\n }\n\n this.value = [...this.value.sort(sorter)]\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as HTMLElement).parentElement\n const input = record && (record.querySelector('[data-text]') as HTMLInputElement)\n\n if (input) {\n input.value = ''\n }\n\n this._build()\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n if (!this.name) return\n\n const value = this.value\n\n formData.append(\n this.name!,\n typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)\n )\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { OxFormField } from './ox-form-field';
5
+ declare type PartitionKeys = {
6
+ [key: string]: any;
7
+ };
8
+ declare type ArrayedPartitionKeys = {
9
+ key: string;
10
+ value: any;
11
+ };
12
+ /**
13
+ key-value map for partitions editor element
14
+
15
+ Example:
16
+
17
+ <ox-input-partition-keys
18
+ value=${map}
19
+ </ox-input-partition-keys>
20
+ */
21
+ export declare class OxInputPartitionKeys extends OxFormField {
22
+ static styles: import("lit").CSSResult;
23
+ value: PartitionKeys;
24
+ private _changingNow;
25
+ firstUpdated(): void;
26
+ render(): import("lit-html").TemplateResult<1>;
27
+ _onChange(e: Event): void;
28
+ _build(includeNewRecord?: boolean): void;
29
+ _toArray(map: PartitionKeys): ArrayedPartitionKeys[];
30
+ _add(): void;
31
+ _delete(e: MouseEvent): void;
32
+ records: NodeListOf<HTMLElement>;
33
+ _up(e: MouseEvent): void;
34
+ _down(e: MouseEvent): void;
35
+ }
36
+ export {};
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import { css, html } from 'lit';
6
+ import { customElement, property, queryAll } from 'lit/decorators.js';
7
+ import { OxFormField } from './ox-form-field';
8
+ /**
9
+ key-value map for partitions editor element
10
+
11
+ Example:
12
+
13
+ <ox-input-partition-keys
14
+ value=${map}
15
+ </ox-input-partition-keys>
16
+ */
17
+ let OxInputPartitionKeys = class OxInputPartitionKeys extends OxFormField {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.value = {};
21
+ this._changingNow = false;
22
+ }
23
+ static { this.styles = css `
24
+ :host {
25
+ display: flex;
26
+ flex-direction: column;
27
+ align-content: center;
28
+
29
+ width: 100%;
30
+ overflow: hidden;
31
+ border: 1px solid #ccc;
32
+ }
33
+
34
+ div {
35
+ display: flex;
36
+ flex-flow: row nowrap;
37
+ align-items: center;
38
+
39
+ border-bottom: 1px solid #c0c0c0;
40
+ }
41
+
42
+ div:last-child {
43
+ border-bottom: none;
44
+ }
45
+
46
+ div > * {
47
+ min-width: 0px;
48
+ margin: 2px;
49
+ padding: 0;
50
+ }
51
+
52
+ button {
53
+ width: 20px;
54
+ text-align: center;
55
+ }
56
+
57
+ input {
58
+ flex: 1;
59
+ }
60
+ `; }
61
+ firstUpdated() {
62
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
63
+ }
64
+ render() {
65
+ const value = !this.value || typeof this.value !== 'object' ? {} : this.value;
66
+ return html `
67
+ ${this._toArray(value).map(item => html `
68
+ <div data-record>
69
+ <input type="text" data-key placeholder="key" .value=${item.key} />
70
+ <input type="text" data-value placeholder="value" .value=${item.value} list="value-template" />
71
+ <button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">-</button>
72
+ <button class="record-action" @click=${(e) => this._up(e)} tabindex="-1">↑</button>
73
+ <button class="record-action" @click=${(e) => this._down(e)} tabindex="-1">↓</button>
74
+ </div>
75
+ `)}
76
+
77
+ <div data-record-new>
78
+ <input type="text" data-key placeholder="key" value="" />
79
+ <input type="text" data-value placeholder="value" value="" list="value-template" />
80
+ <button class="record-action" @click=${(e) => this._add()} tabindex="-1">+</button>
81
+ </div>
82
+
83
+ <datalist id="value-template">
84
+ <option value="%YYYY">year</option>
85
+ <option value="%MM">month</option>
86
+ <option value="%DD">day</option>
87
+ <option value="%YYYYMMDD">date</option>
88
+ </datalist>
89
+ `;
90
+ }
91
+ _onChange(e) {
92
+ if (this._changingNow) {
93
+ return;
94
+ }
95
+ this._changingNow = true;
96
+ const input = e.target;
97
+ var value = input.value;
98
+ const record = e.target.closest('[data-record],[data-record-new]');
99
+ if (record.hasAttribute('data-record')) {
100
+ this._build();
101
+ }
102
+ else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
103
+ this._add();
104
+ }
105
+ this._changingNow = false;
106
+ }
107
+ _build(includeNewRecord) {
108
+ if (includeNewRecord) {
109
+ var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
110
+ }
111
+ else {
112
+ var records = this.renderRoot.querySelectorAll('[data-record]');
113
+ }
114
+ var newmap = {};
115
+ for (var i = 0; i < records.length; i++) {
116
+ var record = records[i];
117
+ const key = record.querySelector('[data-key]').value;
118
+ const inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])');
119
+ if (!inputs || inputs.length == 0) {
120
+ continue;
121
+ }
122
+ var input = inputs[inputs.length - 1];
123
+ var value = input.value;
124
+ if (key) {
125
+ newmap[key] = value || '';
126
+ }
127
+ }
128
+ this.value = newmap;
129
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
130
+ }
131
+ /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
132
+ _toArray(map) {
133
+ var array = [];
134
+ for (var key in map) {
135
+ array.push({
136
+ key: key,
137
+ value: map[key]
138
+ });
139
+ }
140
+ return array;
141
+ }
142
+ _add() {
143
+ this._build(true);
144
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])');
145
+ for (var i = 0; i < inputs.length; i++) {
146
+ let input = inputs[i];
147
+ if (input.type == 'checkbox')
148
+ input.checked = false;
149
+ else
150
+ input.value = '';
151
+ }
152
+ inputs[0].focus();
153
+ }
154
+ _delete(e) {
155
+ const record = e.target.closest('[data-record]');
156
+ record.querySelector('[data-key]').value = '';
157
+ this._build();
158
+ }
159
+ _up(e) {
160
+ const record = e.target.closest('[data-record]');
161
+ const array = Array.from(this.records);
162
+ const index = array.indexOf(record) - 1;
163
+ if (index < 0) {
164
+ return;
165
+ }
166
+ const deleted = array.splice(index, 1);
167
+ array.splice(index + 1, 0, ...deleted);
168
+ this.value = array.reduce((sum, record) => {
169
+ const key = record.querySelector('[data-key]').value;
170
+ const value = record.querySelector('[data-value]').value;
171
+ sum[key] = value;
172
+ return sum;
173
+ }, {});
174
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
175
+ }
176
+ _down(e) {
177
+ const record = e.target.closest('[data-record]');
178
+ const array = Array.from(this.records);
179
+ const index = array.indexOf(record);
180
+ if (index > array.length) {
181
+ return;
182
+ }
183
+ array.splice(index, 1);
184
+ array.splice(index + 1, 0, record);
185
+ this.value = array.reduce((sum, record) => {
186
+ const key = record.querySelector('[data-key]').value;
187
+ const value = record.querySelector('[data-value]').value;
188
+ sum[key] = value;
189
+ return sum;
190
+ }, {});
191
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
192
+ }
193
+ };
194
+ __decorate([
195
+ property({ type: Object })
196
+ ], OxInputPartitionKeys.prototype, "value", void 0);
197
+ __decorate([
198
+ queryAll('[data-record]')
199
+ ], OxInputPartitionKeys.prototype, "records", void 0);
200
+ OxInputPartitionKeys = __decorate([
201
+ customElement('ox-input-partition-keys')
202
+ ], OxInputPartitionKeys);
203
+ export { OxInputPartitionKeys };
204
+ //# sourceMappingURL=ox-input-partition-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-partition-keys.js","sourceRoot":"","sources":["../../src/ox-input-partition-keys.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAK7C;;;;;;;;GAQG;AAEH,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,WAAW;IAArD;;QAwC8B,UAAK,GAAkB,EAAE,CAAA;QAE7C,iBAAY,GAAY,KAAK,CAAA;IAkLvC,CAAC;aA3NQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqClB,CAAA;IAMD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,I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K,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACxC,MAAM,GAAG,GAAI,MAAM,CAAC,aAAa,CAAC,YAAY,CAAsB,CAAC,KAAK,CAAA;YAC1E,MAAM,KAAK,GAAI,MAAM,CAAC,aAAa,CAAC,cAAc,CAAsB,CAAC,KAAK,CAAA;YAE9E,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YAChB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA+B,CAAC,CAAA;QAEnC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;CACF,CAAA;AApL6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA0B;AAqI1B;IAA1B,QAAQ,CAAC,eAAe,CAAC;qDAAkC;AA7KjD,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CA4NhC;SA5NY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\ntype PartitionKeys = { [key: string]: any }\ntype ArrayedPartitionKeys = { key: string; value: any }\n\n/**\n key-value map for partitions editor element\n \n Example:\n \n <ox-input-partition-keys \n value=${map}\n </ox-input-partition-keys>\n */\n@customElement('ox-input-partition-keys')\nexport class OxInputPartitionKeys extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n align-content: center;\n\n width: 100%;\n overflow: hidden;\n border: 1px solid #ccc;\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n border-bottom: 1px solid #c0c0c0;\n }\n\n div:last-child {\n border-bottom: none;\n }\n\n div > * {\n min-width: 0px;\n margin: 2px;\n padding: 0;\n }\n\n button {\n width: 20px;\n text-align: center;\n }\n\n input {\n flex: 1;\n }\n `\n\n @property({ type: Object }) value: PartitionKeys = {}\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n\n return html`\n ${this._toArray(value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-key placeholder=\"key\" .value=${item.key} />\n <input type=\"text\" data-value placeholder=\"value\" .value=${item.value} list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._up(e)} tabindex=\"-1\">↑</button>\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._down(e)} tabindex=\"-1\">↓</button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-key placeholder=\"key\" value=\"\" />\n <input type=\"text\" data-value placeholder=\"value\" value=\"\" list=\"value-template\" />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n\n <datalist id=\"value-template\">\n <option value=\"%YYYY\">year</option>\n <option value=\"%MM\">month</option>\n <option value=\"%DD\">day</option>\n <option value=\"%YYYYMMDD\">date</option>\n </datalist>\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n var value = input.value\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: PartitionKeys = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = value || ''\n }\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: PartitionKeys) {\n var array: ArrayedPartitionKeys[] = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = value\n return sum\n }, {} as { [key: string]: string })\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
@@ -10,4 +10,5 @@ export declare class OxInputSearch extends OxFormField {
10
10
  render(): import("lit-html").TemplateResult<1>;
11
11
  firstUpdated(): void;
12
12
  _onChangeValue(e: Event): void;
13
+ _onClickSearch(e: Event): void;
13
14
  }
@@ -37,7 +37,7 @@ let OxInputSearch = class OxInputSearch extends OxFormField {
37
37
  ]; }
38
38
  render() {
39
39
  return html `
40
- <mwc-icon>search</mwc-icon>
40
+ <mwc-icon @click=${(e) => this._onClickSearch(e)}>search</mwc-icon>
41
41
  <input
42
42
  type="text"
43
43
  .value=${this.value || ''}
@@ -58,6 +58,12 @@ let OxInputSearch = class OxInputSearch extends OxFormField {
58
58
  detail: this.value
59
59
  }));
60
60
  }
61
+ _onClickSearch(e) {
62
+ e.stopPropagation();
63
+ if (this._form) {
64
+ this._form.requestSubmit();
65
+ }
66
+ }
61
67
  };
62
68
  __decorate([
63
69
  property({ type: String })