@operato/property-editor 1.0.0-beta.9 → 1.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +359 -0
  2. package/demo/index.html +19 -5
  3. package/dist/src/ox-properties-dynamic-view.js +14 -10
  4. package/dist/src/ox-properties-dynamic-view.js.map +1 -1
  5. package/dist/src/ox-property-editor-angle.d.ts +2 -1
  6. package/dist/src/ox-property-editor-angle.js +4 -6
  7. package/dist/src/ox-property-editor-angle.js.map +1 -1
  8. package/dist/src/ox-property-editor-checkbox.d.ts +2 -1
  9. package/dist/src/ox-property-editor-checkbox.js +4 -4
  10. package/dist/src/ox-property-editor-checkbox.js.map +1 -1
  11. package/dist/src/ox-property-editor-color.d.ts +2 -1
  12. package/dist/src/ox-property-editor-color.js +4 -9
  13. package/dist/src/ox-property-editor-color.js.map +1 -1
  14. package/dist/src/ox-property-editor-crontab.d.ts +2 -1
  15. package/dist/src/ox-property-editor-crontab.js +3 -2
  16. package/dist/src/ox-property-editor-crontab.js.map +1 -1
  17. package/dist/src/ox-property-editor-data.d.ts +2 -1
  18. package/dist/src/ox-property-editor-data.js +5 -4
  19. package/dist/src/ox-property-editor-data.js.map +1 -1
  20. package/dist/src/ox-property-editor-date.d.ts +2 -1
  21. package/dist/src/ox-property-editor-date.js +4 -4
  22. package/dist/src/ox-property-editor-date.js.map +1 -1
  23. package/dist/src/ox-property-editor-duration.d.ts +6 -0
  24. package/dist/src/ox-property-editor-duration.js +16 -0
  25. package/dist/src/ox-property-editor-duration.js.map +1 -0
  26. package/dist/src/ox-property-editor-file.d.ts +2 -1
  27. package/dist/src/ox-property-editor-file.js +8 -5
  28. package/dist/src/ox-property-editor-file.js.map +1 -1
  29. package/dist/src/ox-property-editor-gradient-colorstops.d.ts +2 -1
  30. package/dist/src/ox-property-editor-gradient-colorstops.js +8 -7
  31. package/dist/src/ox-property-editor-gradient-colorstops.js.map +1 -1
  32. package/dist/src/ox-property-editor-image.d.ts +2 -1
  33. package/dist/src/ox-property-editor-image.js +5 -4
  34. package/dist/src/ox-property-editor-image.js.map +1 -1
  35. package/dist/src/ox-property-editor-key-values.d.ts +6 -0
  36. package/dist/src/ox-property-editor-key-values.js +24 -0
  37. package/dist/src/ox-property-editor-key-values.js.map +1 -0
  38. package/dist/src/ox-property-editor-legend.d.ts +2 -1
  39. package/dist/src/ox-property-editor-legend.js +4 -4
  40. package/dist/src/ox-property-editor-legend.js.map +1 -1
  41. package/dist/src/ox-property-editor-multiple-colors.d.ts +2 -1
  42. package/dist/src/ox-property-editor-multiple-colors.js +4 -4
  43. package/dist/src/ox-property-editor-multiple-colors.js.map +1 -1
  44. package/dist/src/ox-property-editor-number.d.ts +2 -1
  45. package/dist/src/ox-property-editor-number.js +6 -6
  46. package/dist/src/ox-property-editor-number.js.map +1 -1
  47. package/dist/src/ox-property-editor-options.d.ts +2 -1
  48. package/dist/src/ox-property-editor-options.js +5 -4
  49. package/dist/src/ox-property-editor-options.js.map +1 -1
  50. package/dist/src/ox-property-editor-partition-keys.d.ts +6 -0
  51. package/dist/src/ox-property-editor-partition-keys.js +18 -0
  52. package/dist/src/ox-property-editor-partition-keys.js.map +1 -0
  53. package/dist/src/ox-property-editor-password.d.ts +2 -1
  54. package/dist/src/ox-property-editor-password.js +4 -4
  55. package/dist/src/ox-property-editor-password.js.map +1 -1
  56. package/dist/src/ox-property-editor-range.d.ts +2 -1
  57. package/dist/src/ox-property-editor-range.js +13 -5
  58. package/dist/src/ox-property-editor-range.js.map +1 -1
  59. package/dist/src/ox-property-editor-scene-component-id.d.ts +2 -1
  60. package/dist/src/ox-property-editor-scene-component-id.js +4 -8
  61. package/dist/src/ox-property-editor-scene-component-id.js.map +1 -1
  62. package/dist/src/ox-property-editor-select.d.ts +4 -1
  63. package/dist/src/ox-property-editor-select.js +11 -5
  64. package/dist/src/ox-property-editor-select.js.map +1 -1
  65. package/dist/src/ox-property-editor-solid-colorstops.d.ts +2 -1
  66. package/dist/src/ox-property-editor-solid-colorstops.js +8 -7
  67. package/dist/src/ox-property-editor-solid-colorstops.js.map +1 -1
  68. package/dist/src/ox-property-editor-string.d.ts +2 -1
  69. package/dist/src/ox-property-editor-string.js +4 -4
  70. package/dist/src/ox-property-editor-string.js.map +1 -1
  71. package/dist/src/ox-property-editor-table.d.ts +2 -1
  72. package/dist/src/ox-property-editor-table.js +5 -4
  73. package/dist/src/ox-property-editor-table.js.map +1 -1
  74. package/dist/src/ox-property-editor-textarea.d.ts +2 -1
  75. package/dist/src/ox-property-editor-textarea.js +9 -8
  76. package/dist/src/ox-property-editor-textarea.js.map +1 -1
  77. package/dist/src/ox-property-editor-value-map.d.ts +2 -1
  78. package/dist/src/ox-property-editor-value-map.js +11 -5
  79. package/dist/src/ox-property-editor-value-map.js.map +1 -1
  80. package/dist/src/ox-property-editor-value-ranges.d.ts +2 -1
  81. package/dist/src/ox-property-editor-value-ranges.js +9 -3
  82. package/dist/src/ox-property-editor-value-ranges.js.map +1 -1
  83. package/dist/src/ox-property-editor-work-shift.d.ts +3 -2
  84. package/dist/src/ox-property-editor-work-shift.js +8 -7
  85. package/dist/src/ox-property-editor-work-shift.js.map +1 -1
  86. package/dist/src/ox-property-editor.d.ts +8 -6
  87. package/dist/src/ox-property-editor.js +60 -7
  88. package/dist/src/ox-property-editor.js.map +1 -1
  89. package/dist/src/types.d.ts +5 -0
  90. package/dist/src/types.js.map +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +14 -11
  93. package/src/ox-properties-dynamic-view.ts +15 -10
  94. package/src/ox-property-editor-angle.ts +6 -6
  95. package/src/ox-property-editor-checkbox.ts +6 -4
  96. package/src/ox-property-editor-color.ts +6 -9
  97. package/src/ox-property-editor-crontab.ts +5 -2
  98. package/src/ox-property-editor-data.ts +8 -4
  99. package/src/ox-property-editor-date.ts +6 -4
  100. package/src/ox-property-editor-duration.ts +16 -0
  101. package/src/ox-property-editor-file.ts +11 -5
  102. package/src/ox-property-editor-gradient-colorstops.ts +11 -7
  103. package/src/ox-property-editor-image.ts +9 -4
  104. package/src/ox-property-editor-key-values.ts +24 -0
  105. package/src/ox-property-editor-legend.ts +6 -4
  106. package/src/ox-property-editor-multiple-colors.ts +6 -4
  107. package/src/ox-property-editor-number.ts +8 -6
  108. package/src/ox-property-editor-options.ts +8 -4
  109. package/src/ox-property-editor-partition-keys.ts +18 -0
  110. package/src/ox-property-editor-password.ts +6 -4
  111. package/src/ox-property-editor-range.ts +15 -5
  112. package/src/ox-property-editor-scene-component-id.ts +6 -8
  113. package/src/ox-property-editor-select.ts +12 -6
  114. package/src/ox-property-editor-solid-colorstops.ts +11 -7
  115. package/src/ox-property-editor-string.ts +6 -4
  116. package/src/ox-property-editor-table.ts +8 -4
  117. package/src/ox-property-editor-textarea.ts +12 -8
  118. package/src/ox-property-editor-value-map.ts +13 -5
  119. package/src/ox-property-editor-value-ranges.ts +10 -3
  120. package/src/ox-property-editor-work-shift.ts +6 -4
  121. package/src/ox-property-editor.ts +59 -10
  122. package/src/types.ts +6 -0
  123. package/yarn-error.log +0 -18150
@@ -1,12 +1,16 @@
1
1
  import '@operato/input/ox-input-options.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-options')
8
10
  export class OxPropertyEditorOptions extends OxPropertyEditor {
9
- editorTemplate() {
10
- return html` <ox-input-options id="editor" .value=${this.value || []}></ox-input-options> `
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { fullwidth = false } = spec.editor || {}
13
+
14
+ return html` <ox-input-options id="editor" .value=${value || []} ?fullwidth=${fullwidth}></ox-input-options> `
11
15
  }
12
16
  }
@@ -0,0 +1,18 @@
1
+ import '@operato/input/ox-input-partition-keys.js'
2
+
3
+ import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
8
+
9
+ @customElement('ox-property-editor-partition-keys')
10
+ export class OxPropertyEditorPartitionKeys extends OxPropertyEditor {
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { fullwidth = true } = spec.editor || {}
13
+
14
+ return html`
15
+ <ox-input-partition-keys id="editor" .value=${value} ?fullwidth=${fullwidth}></ox-input-partition-keys>
16
+ `
17
+ }
18
+ }
@@ -1,10 +1,12 @@
1
- import { OxPropertyEditor } from './ox-property-editor.js'
2
- import { customElement } from 'lit/decorators.js'
3
1
  import { html } from 'lit'
2
+ import { customElement } from 'lit/decorators.js'
3
+
4
+ import { OxPropertyEditor } from './ox-property-editor.js'
5
+ import { PropertySpec } from './types.js'
4
6
 
5
7
  @customElement('ox-property-editor-password')
6
8
  export class OxPropertyEditorPassword extends OxPropertyEditor {
7
- editorTemplate() {
8
- return html` <input type="password" id="editor" .value=${this.value} placeholder=${this.placeholder || ''} /> `
9
+ editorTemplate(value: any, spec: PropertySpec) {
10
+ return html` <input type="password" id="editor" .value=${value} placeholder=${spec.placeholder || ''} /> `
9
11
  }
10
12
  }
@@ -1,16 +1,26 @@
1
1
  import '@operato/input/ox-input-range.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-range')
8
10
  export class OxPropertyEditorRange extends OxPropertyEditor {
9
- editorTemplate() {
10
- const { step, min, max } = this.property || {}
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { step, min, max } = spec.property || {}
13
+ const { fullwidth = false } = spec.editor || {}
11
14
 
12
15
  return html`
13
- <ox-input-range id="editor" .value=${this.value} .step=${step} .min=${min} .max=${max}></ox-input-range>
16
+ <ox-input-range
17
+ id="editor"
18
+ .value=${value}
19
+ .step=${step}
20
+ .min=${min}
21
+ .max=${max}
22
+ ?fullwidth=${fullwidth}
23
+ ></ox-input-range>
14
24
  `
15
25
  }
16
26
  }
@@ -1,18 +1,16 @@
1
1
  import '@operato/input/ox-input-scene-component-id.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-scene-component-id')
8
10
  export class OxPropertyEditorSceneComponentId extends OxPropertyEditor {
9
- editorTemplate() {
11
+ editorTemplate(value: any, spec: PropertySpec) {
10
12
  return html`
11
- <ox-input-scene-component-id
12
- id="editor"
13
- .value=${this.value}
14
- .property=${this.property}
15
- ></ox-input-scene-component-id>
13
+ <ox-input-scene-component-id id="editor" .value=${value} .property=${spec.property}></ox-input-scene-component-id>
16
14
  `
17
15
  }
18
16
  }
@@ -1,10 +1,11 @@
1
1
  import '@operato/input/ox-select.js'
2
2
  import '@operato/popup/ox-popup-list.js'
3
3
 
4
- import { css, html } from 'lit'
4
+ import { css, html, LitElement } from 'lit'
5
+ import { customElement, query } from 'lit/decorators.js'
5
6
 
6
7
  import { OxPropertyEditor } from './ox-property-editor.js'
7
- import { customElement } from 'lit/decorators.js'
8
+ import { PropertySpec } from './types.js'
8
9
 
9
10
  type Option = { display: string; value: any } | string
10
11
 
@@ -22,6 +23,8 @@ export class OxPropertyEditorSelect extends OxPropertyEditor {
22
23
  `
23
24
  ]
24
25
 
26
+ @query('ox-select') oxSelect!: LitElement
27
+
25
28
  async connectedCallback() {
26
29
  super.connectedCallback()
27
30
 
@@ -31,21 +34,24 @@ export class OxPropertyEditorSelect extends OxPropertyEditor {
31
34
  ...this.property,
32
35
  options: await options.apply(this)
33
36
  }
37
+ await this.updateComplete
38
+ this.oxSelect.requestUpdate()
34
39
  }
35
40
  }
36
41
 
37
- editorTemplate() {
38
- var options = this.property?.options as Option[]
42
+ editorTemplate(value: any, spec: PropertySpec) {
43
+ var options = spec.property?.options as Option[]
39
44
  if (!(options instanceof Array)) {
40
45
  options = []
41
46
  }
47
+ const { fullwidth = false } = spec.editor || {}
42
48
 
43
49
  return html`
44
- <ox-select id="editor" .value=${this.value} placeholder=${this.placeholder}>
50
+ <ox-select id="editor" .value=${value} placeholder=${spec.placeholder} ?fullwidth=${fullwidth}>
45
51
  <ox-popup-list with-search>
46
52
  ${options.map(
47
53
  item => html`
48
- <div option value=${this._getOptionValue(item)} ?selected=${this._isSelected(this.value, item)}>
54
+ <div option value=${this._getOptionValue(item)} ?selected=${this._isSelected(value, item)}>
49
55
  ${this._getOptionDisplay(item) || html`&nbsp;`}
50
56
  </div>
51
57
  `
@@ -1,20 +1,24 @@
1
1
  import '@operato/input/ox-input-color-stops.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-solid-colorstops')
8
10
  export class OxPropertyEditorSolidColorStops extends OxPropertyEditor {
9
- editorTemplate() {
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { fullwidth = true } = spec.editor || {}
13
+
10
14
  return html`
11
15
  <ox-input-color-stops
12
16
  id="editor"
13
17
  type="solid"
14
- .value=${this.value}
15
- .min=${this.property && this.property.min}
16
- .max=${this.property && this.property.max}
17
- fullwidth
18
+ .value=${value}
19
+ .min=${spec.property && spec.property.min}
20
+ .max=${spec.property && spec.property.max}
21
+ ?fullwidth=${fullwidth}
18
22
  >
19
23
  </ox-input-color-stops>
20
24
  `
@@ -1,10 +1,12 @@
1
- import { OxPropertyEditor } from './ox-property-editor.js'
2
- import { customElement } from 'lit/decorators.js'
3
1
  import { html } from 'lit'
2
+ import { customElement } from 'lit/decorators.js'
3
+
4
+ import { OxPropertyEditor } from './ox-property-editor.js'
5
+ import { PropertySpec } from './types.js'
4
6
 
5
7
  @customElement('ox-property-editor-string')
6
8
  export class OxPropertyEditorString extends OxPropertyEditor {
7
- editorTemplate() {
8
- return html` <input type="text" id="editor" .value=${this.value || ''} placeholder=${this.placeholder || ''} /> `
9
+ editorTemplate(value: any, spec: PropertySpec) {
10
+ return html` <input type="text" id="editor" .value=${value || ''} placeholder=${spec.placeholder || ''} /> `
9
11
  }
10
12
  }
@@ -1,12 +1,16 @@
1
1
  import '@operato/input/ox-input-table.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-table')
8
10
  export class OxPropertyEditorString extends OxPropertyEditor {
9
- editorTemplate() {
10
- return html` <ox-input-table id="editor" .property=${this.property} fullwidth></ox-input-table> `
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { fullwidth = true } = spec.editor || {}
13
+
14
+ return html` <ox-input-table id="editor" .property=${spec.property} ?fullwidth=${fullwidth}></ox-input-table> `
11
15
  }
12
16
  }
@@ -1,20 +1,24 @@
1
1
  import '@operato/input/ox-input-code.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-textarea')
8
10
  export class OxPropertyEditorTextArea extends OxPropertyEditor {
9
- editorTemplate() {
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { fullwidth = true } = spec.editor || {}
13
+
10
14
  return html`
11
15
  <ox-input-code
12
16
  id="editor"
13
- .value=${this.value}
14
- mode=${this.property?.mode || ''}
15
- tab-size=${this.property?.tabSize || ''}
16
- tab-as-space=${this.property?.tabAsSpace || 'false'}
17
- fullwidth
17
+ .value=${value}
18
+ mode=${spec.property?.mode || ''}
19
+ tab-size=${spec.property?.tabSize || ''}
20
+ tab-as-space=${spec.property?.tabAsSpace || 'false'}
21
+ ?fullwidth=${fullwidth}
18
22
  >
19
23
  </ox-input-code>
20
24
  `
@@ -1,18 +1,26 @@
1
1
  import '@operato/input/ox-input-value-map.js'
2
2
 
3
- import { OxPropertyEditor } from './ox-property-editor.js'
4
- import { customElement } from 'lit/decorators.js'
5
3
  import { html } from 'lit'
4
+ import { customElement } from 'lit/decorators.js'
5
+
6
+ import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
6
8
 
7
9
  @customElement('ox-property-editor-value-map')
8
10
  export class OxPropertyEditorValueMap extends OxPropertyEditor {
9
- editorTemplate() {
10
- const { value, property } = this
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { property } = spec
11
13
  const valuetype = property?.valuetype || 'string'
12
14
  /* IMPLEMENT-ME valuetype 에 editor를 전달할 수 있는 기능 개발 */
15
+ const { fullwidth = true } = spec.editor || {}
13
16
 
14
17
  return html`
15
- <ox-input-value-map id="editor" .valuetype=${valuetype} .value=${value} fullwidth></ox-input-value-map>
18
+ <ox-input-value-map
19
+ id="editor"
20
+ .valuetype=${valuetype}
21
+ .value=${value}
22
+ ?fullwidth=${fullwidth}
23
+ ></ox-input-value-map>
16
24
  `
17
25
  }
18
26
  }
@@ -4,16 +4,23 @@ import { html } from 'lit'
4
4
  import { customElement } from 'lit/decorators.js'
5
5
 
6
6
  import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
7
8
 
8
9
  @customElement('ox-property-editor-value-ranges')
9
10
  export class OxPropertyEditorValueRanges extends OxPropertyEditor {
10
- editorTemplate() {
11
- const { value, property } = this
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { property } = spec
12
13
  const valuetype = property?.valuetype || 'string'
13
14
  /* IMPLEMENT-ME valuetype 에 editor를 전달할 수 있는 기능 개발 */
15
+ const { fullwidth = true } = spec.editor || {}
14
16
 
15
17
  return html`
16
- <ox-input-value-ranges id="editor" .valuetype=${valuetype} .value=${value} fullwidth></ox-input-value-ranges>
18
+ <ox-input-value-ranges
19
+ id="editor"
20
+ .valuetype=${valuetype}
21
+ .value=${value}
22
+ ?fullwidth=${fullwidth}
23
+ ></ox-input-value-ranges>
17
24
  `
18
25
  }
19
26
  }
@@ -4,12 +4,14 @@ import { html } from 'lit'
4
4
  import { customElement } from 'lit/decorators.js'
5
5
 
6
6
  import { OxPropertyEditor } from './ox-property-editor.js'
7
+ import { PropertySpec } from './types.js'
7
8
 
8
9
  @customElement('ox-property-editor-work-shift')
9
- export class OxPropertyEditorValueRanges extends OxPropertyEditor {
10
- editorTemplate() {
11
- const { value } = this
10
+ export class OxPropertyEditorWorkShift extends OxPropertyEditor {
11
+ editorTemplate(value: any, spec: PropertySpec) {
12
+ const { editor } = spec
13
+ const { fullwidth = true } = editor || {}
12
14
 
13
- return html` <ox-input-work-shift id="editor" .value=${value} fullwidth></ox-input-work-shift> `
15
+ return html` <ox-input-work-shift id="editor" .value=${value} ?fullwidth=${fullwidth}></ox-input-work-shift> `
14
16
  }
15
17
  }
@@ -1,9 +1,11 @@
1
1
  import '@operato/i18n/ox-i18n.js'
2
2
 
3
- import { css, html, LitElement } from 'lit'
3
+ import { css, html, LitElement, TemplateResult } from 'lit'
4
4
  import { property, state } from 'lit/decorators.js'
5
5
  import deepClone from 'lodash-es/cloneDeep'
6
6
 
7
+ import { EditorProperty, PropertySpec } from './types'
8
+
7
9
  export class OxPropertyEditor extends LitElement {
8
10
  static registry: { [type: string]: string } = {}
9
11
 
@@ -25,6 +27,7 @@ export class OxPropertyEditor extends LitElement {
25
27
  display: grid;
26
28
  grid-template-columns: repeat(10, 1fr);
27
29
  grid-gap: 5px;
30
+ grid-auto-rows: minmax(24px, auto);
28
31
 
29
32
  align-items: center;
30
33
 
@@ -60,10 +63,9 @@ export class OxPropertyEditor extends LitElement {
60
63
  text-align: left;
61
64
  }
62
65
 
63
- :host > select,
64
- :host > ox-select,
65
- :host > input[type='text'],
66
- :host > input[type='number'] {
66
+ select,
67
+ ox-select,
68
+ input:not([type='checkbox']) {
67
69
  border: 1px solid rgba(0, 0, 0, 0.2);
68
70
  }
69
71
 
@@ -88,15 +90,38 @@ export class OxPropertyEditor extends LitElement {
88
90
  justify-self: end;
89
91
  align-self: center;
90
92
  }
93
+
94
+ ox-input-code,
95
+ ox-input-data {
96
+ height: 300px;
97
+ }
98
+
99
+ :host > div {
100
+ display: flex;
101
+ flex-direction: column;
102
+ gap: 3px;
103
+ }
104
+
105
+ div[data-index] {
106
+ display: flex;
107
+ min-height: 24px;
108
+ }
109
+
110
+ div[data-index] > * {
111
+ flex: 1;
112
+ }
91
113
  `
92
114
  ]
93
115
 
94
116
  @property({ type: Object }) value: any
95
117
  @property({ type: String }) type!: string
118
+ @property({ type: String, attribute: true, reflect: true }) name!: string
96
119
  @property({ type: String }) label!: string
97
120
  @property({ type: String }) placeholder?: string
98
- @property({ type: Object }) property: any
121
+ @property({ type: Object }) property?: any
122
+ @property({ type: Object }) editor?: EditorProperty
99
123
  @property({ type: Object }) host: any
124
+ @property({ type: Array }) quantifier?: [min: number, max: number] = [1, 1]
100
125
  @property({ type: Object }) observe?: (value: any) => void
101
126
 
102
127
  connectedCallback() {
@@ -105,13 +130,26 @@ export class OxPropertyEditor extends LitElement {
105
130
  this.renderRoot.addEventListener('change', this._valueChanged.bind(this))
106
131
  }
107
132
 
108
- editorTemplate(props: { [key: string]: any }) {
133
+ editorTemplate(value: any, spec: PropertySpec): TemplateResult<1> {
109
134
  return html``
110
135
  }
111
136
 
112
137
  render() {
138
+ const { value, quantifier } = this
139
+ const [min = 1, max = 1] = quantifier || [1, 1]
140
+
113
141
  return html`
114
- ${this.editorTemplate(this)}
142
+ ${max <= 1
143
+ ? this.editorTemplate(value, this)
144
+ : html`
145
+ <div ?fullwidth=${this.editor?.fullwidth}>
146
+ ${new Array(max)
147
+ .fill('')
148
+ .map(
149
+ (_, idx) => html` <div editor data-index=${idx}>${this.editorTemplate(value?.[idx], this)}</div> `
150
+ )}
151
+ </div>
152
+ `}
115
153
  ${this.label
116
154
  ? html`
117
155
  <label for="editor">
@@ -154,8 +192,19 @@ export class OxPropertyEditor extends LitElement {
154
192
 
155
193
  _valueChanged(e: Event) {
156
194
  e.stopPropagation()
157
-
158
- this.value = this.makeup((e.target as any)[this.valueProperty])
195
+ const editor = e.target as HTMLInputElement
196
+
197
+ const [min = 1, max = 1] = this.quantifier || []
198
+ const value = this.makeup((editor as any)[this.valueProperty])
199
+
200
+ if (max > 1) {
201
+ const index = Number(editor.closest('[data-index]')?.getAttribute('data-index'))
202
+ var array: any[] = this.value instanceof Array ? [...this.value] : []
203
+ array[index] = value
204
+ this.value = array
205
+ } else {
206
+ this.value = value
207
+ }
159
208
 
160
209
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
161
210
 
package/src/types.ts CHANGED
@@ -1,8 +1,14 @@
1
+ export type EditorProperty = {
2
+ fullwidth?: boolean
3
+ }
4
+
1
5
  export type PropertySpec = {
2
6
  type: string
3
7
  label: string
4
8
  name: string
5
9
  placeholder?: string
6
10
  property?: any
11
+ editor?: EditorProperty
12
+ quantifier?: [min: number, max: number]
7
13
  observe?: (value: any) => void
8
14
  }