@operato/input 2.0.0-beta.24 → 2.0.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/input",
3
3
  "description": "Webcomponents for input following open-wc recommendations",
4
4
  "author": "heartyoh@hatiolab.com",
5
- "version": "2.0.0-beta.24",
5
+ "version": "2.0.0-beta.26",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "license": "MIT",
@@ -203,11 +203,12 @@
203
203
  "@codemirror/state": "^6.3.3",
204
204
  "@codemirror/theme-one-dark": "^6.1.2",
205
205
  "@codemirror/view": "^6.22.1",
206
+ "@ctrl/tinycolor": "^4.1.0",
206
207
  "@lit/localize": "^0.12.1",
207
208
  "@material/web": "^1.5.0",
208
209
  "@operato/color-picker": "^2.0.0-beta.23",
209
- "@operato/i18n": "^2.0.0-beta.23",
210
- "@operato/popup": "^2.0.0-beta.24",
210
+ "@operato/i18n": "^2.0.0-beta.26",
211
+ "@operato/popup": "^2.0.0-beta.26",
211
212
  "@operato/styles": "^2.0.0-beta.23",
212
213
  "@operato/utils": "^2.0.0-beta.23",
213
214
  "@polymer/paper-dropdown-menu": "^3.2.0",
@@ -253,5 +254,5 @@
253
254
  "prettier --write"
254
255
  ]
255
256
  },
256
- "gitHead": "f9c8a5a062f3ba213cd0f146cabf54369f7b1c1e"
257
+ "gitHead": "7985e734b326247f804b6e0a7ef00154db31f0bb"
257
258
  }
@@ -40,7 +40,7 @@ export class OxCheckbox extends OxFormField {
40
40
  }
41
41
 
42
42
  :host([checked]) .checkbox {
43
- background-color: var(--ox-checkbox-checked-background-color, var(--md-sys-color-primary));
43
+ background-color: var(--ox-checkbox-checked-background-color, var(--md-sys-color-surface-tint));
44
44
  }
45
45
 
46
46
  path {
@@ -61,11 +61,12 @@ export class OxCheckbox extends OxFormField {
61
61
  }
62
62
 
63
63
  .label {
64
- color: var(--ox-checkbox-label-color, var(--md-sys-color-on-surface-variant));
65
- font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
64
+ color: var(--ox-checkbox-label-color, var(--md-sys-color-on-primary-container));
65
+ font-size: var(--md-sys-typescale-label-medium-size, 1rem);
66
66
  line-height: var(--md-sys-typescale-label-medium-line-height, 1rem);
67
67
  }
68
68
  :host([checked]) .label {
69
+ color:var(ox-checkbox-label-checked-color, var(--md-sys-color-primary));
69
70
  font-weight: 700;
70
71
  }
71
72
  `
@@ -7,6 +7,7 @@ import '@material/web/icon/icon.js'
7
7
 
8
8
  import { css, html } from 'lit'
9
9
  import { customElement, property, query, queryAll } from 'lit/decorators.js'
10
+ import { random as randomColor, TinyColor } from '@ctrl/tinycolor'
10
11
 
11
12
  import { OxFormField } from './ox-form-field.js'
12
13
  import { OxInputColor } from './ox-input-color.js'
@@ -38,29 +39,32 @@ export class OxInputMultipleColors extends OxFormField {
38
39
  grid-gap: var(--spacing-medium);
39
40
  align-items: center;
40
41
  justify-content: left;
41
- margin-bottom: var(--margin-narrow);
42
+ margin-bottom: var(--spacing-tiny, 2px);
42
43
  }
43
44
 
44
45
  ox-input-color {
45
46
  width: 100%;
46
47
  }
47
48
 
49
+ md-icon {
50
+ pointer-events: none;
51
+ }
52
+
48
53
  button {
49
54
  height: 100%;
50
55
  border: var(--button-border);
51
- border-radius: var(--border-radius);
52
- background-color: var(--button-background-color);
56
+ border-radius: 0;
57
+ background-color: transparent;
53
58
  line-height: 0.8;
54
- color: var(--button-color);
59
+ color: var(--md-sys-color-on-surface);
55
60
  cursor: pointer;
56
61
  }
57
62
 
58
- button:focus,
59
63
  button:hover,
60
64
  button:active {
61
65
  border: var(--button-activ-border);
62
- background-color: var(--button-background-focus-color);
63
- color: var(--md-sys-color-primary-container);
66
+ background-color: var(--md-sys-color-on-primary);
67
+ color: var(--md-sys-color-primary);
64
68
  }
65
69
  `
66
70
 
@@ -79,7 +83,7 @@ export class OxInputMultipleColors extends OxFormField {
79
83
  ${(this.value || []).map(
80
84
  (item, index) => html`
81
85
  <div>
82
- <button @click=${() => this._appendEditorColor()} data-index=${index} ?disabled=${this.disabled}>
86
+ <button @tap=${(e: Event) => this._appendEditorColor(e)} data-index=${index} ?disabled=${this.disabled}>
83
87
  <md-icon>add</md-icon>
84
88
  </button>
85
89
  <ox-input-color .value=${item} ?disabled=${this.disabled}> </ox-input-color>
@@ -87,7 +91,7 @@ export class OxInputMultipleColors extends OxFormField {
87
91
  ${(this.value || []).length > 1
88
92
  ? html`
89
93
  <button
90
- @click=${(e: Event) => this._removeEditorColor(e)}
94
+ @tap=${(e: Event) => this._removeEditorColor(e)}
91
95
  data-index=${index}
92
96
  ?disabled=${this.disabled}
93
97
  >
@@ -106,8 +110,11 @@ export class OxInputMultipleColors extends OxFormField {
106
110
  this.value = Array.from(this.colors).map(color => color.value!)
107
111
  }
108
112
 
109
- _appendEditorColor() {
110
- this.value = [...this.value, 'black']
113
+ _appendEditorColor(e: Event) {
114
+ const idx = Number((e.target as HTMLElement).getAttribute('data-index'))
115
+ const hue = this.value[idx] || '#fff'
116
+ this.value.splice(idx + 1, 0, randomColor({ hue }).toRgbString())
117
+ this.value = [...this.value]
111
118
 
112
119
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
113
120
  }
@@ -115,8 +122,11 @@ export class OxInputMultipleColors extends OxFormField {
115
122
  _removeEditorColor(e: Event) {
116
123
  var values = []
117
124
  for (var i = 0; i < this.value.length; i++) {
118
- if (i == Number((e.target as HTMLElement).dataset.index)) continue
119
- else values.push(this.value[i])
125
+ if (i == Number((e.target as HTMLElement).getAttribute('data-index'))) {
126
+ continue
127
+ } else {
128
+ values.push(this.value[i])
129
+ }
120
130
  }
121
131
 
122
132
  this.value = values