@operato/input 2.0.0-beta.9 → 7.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +210 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/locale/localization.d.ts +2 -2
- package/dist/src/ox-checkbox.js +4 -8
- package/dist/src/ox-checkbox.js.map +1 -1
- package/dist/src/ox-input-barcode.js +15 -11
- package/dist/src/ox-input-barcode.js.map +1 -1
- package/dist/src/ox-input-multiple-colors.d.ts +1 -1
- package/dist/src/ox-input-multiple-colors.js +22 -13
- package/dist/src/ox-input-multiple-colors.js.map +1 -1
- package/dist/src/ox-input-search.d.ts +0 -1
- package/dist/src/ox-input-search.js +2 -5
- package/dist/src/ox-input-search.js.map +1 -1
- package/dist/src/ox-input-table-column-config.d.ts +21 -0
- package/dist/src/ox-input-table-column-config.js +202 -0
- package/dist/src/ox-input-table-column-config.js.map +1 -0
- package/dist/src/ox-select.js +1 -14
- package/dist/src/ox-select.js.map +1 -1
- package/dist/stories/ox-input-search.stories.d.ts +0 -1
- package/dist/stories/ox-input-search.stories.js +2 -1
- package/dist/stories/ox-input-search.stories.js.map +1 -1
- package/dist/stories/ox-input-table-column-config.stories.d.ts +34 -0
- package/dist/stories/ox-input-table-column-config.stories.js +99 -0
- package/dist/stories/ox-input-table-column-config.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -9
- package/src/index.ts +2 -0
- package/src/ox-checkbox.ts +4 -8
- package/src/ox-input-barcode.ts +14 -12
- package/src/ox-input-multiple-colors.ts +23 -13
- package/src/ox-input-search.ts +2 -2
- package/src/ox-input-table-column-config.ts +211 -0
- package/src/ox-select.ts +1 -16
- package/stories/ox-input-search.stories.ts +2 -1
- package/stories/ox-input-table-column-config.stories.ts +120 -0
- package/themes/grist-theme.css +1 -3
package/package.json
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
"name": "@operato/input",
|
3
3
|
"description": "Webcomponents for input following open-wc recommendations",
|
4
4
|
"author": "heartyoh@hatiolab.com",
|
5
|
-
"version": "
|
5
|
+
"version": "7.0.0-rc.10",
|
6
6
|
"main": "dist/src/index.js",
|
7
7
|
"module": "dist/src/index.js",
|
8
8
|
"license": "MIT",
|
9
|
+
"operato": true,
|
9
10
|
"publishConfig": {
|
10
11
|
"access": "public",
|
11
12
|
"@operato:registry": "https://registry.npmjs.org"
|
@@ -17,6 +18,7 @@
|
|
17
18
|
},
|
18
19
|
"exports": {
|
19
20
|
".": "./dist/src/index.js",
|
21
|
+
"./package.json": "./package.json",
|
20
22
|
"./ox-form-field.js": "./dist/src/ox-form-field.js",
|
21
23
|
"./ox-checkbox.js": "./dist/src/ox-checkbox.js",
|
22
24
|
"./ox-buttons-radio.js": "./dist/src/ox-buttons-radio.js",
|
@@ -54,7 +56,8 @@
|
|
54
56
|
"./ox-input-hashtags.js": "./dist/src/ox-input-hashtags.js",
|
55
57
|
"./ox-input-mass-fraction.js": "./dist/src/ox-input-mass-fraction.js",
|
56
58
|
"./ox-input-textarea.js": "./dist/src/ox-input-textarea.js",
|
57
|
-
"./ox-input-direction.js": "./dist/src/ox-input-direction.js"
|
59
|
+
"./ox-input-direction.js": "./dist/src/ox-input-direction.js",
|
60
|
+
"./ox-input-table-column-config.js": "./dist/src/ox-input-table-column-config.js"
|
58
61
|
},
|
59
62
|
"typesVersions": {
|
60
63
|
"*": {
|
@@ -171,6 +174,9 @@
|
|
171
174
|
],
|
172
175
|
"./ox-input-direction.js": [
|
173
176
|
"./dist/src/ox-input-direction.d.ts"
|
177
|
+
],
|
178
|
+
"./ox-input-table-column-config.js": [
|
179
|
+
"./dist/src/ox-input-table-column-config.d.ts"
|
174
180
|
]
|
175
181
|
}
|
176
182
|
},
|
@@ -197,13 +203,14 @@
|
|
197
203
|
"@codemirror/state": "^6.3.3",
|
198
204
|
"@codemirror/theme-one-dark": "^6.1.2",
|
199
205
|
"@codemirror/view": "^6.22.1",
|
206
|
+
"@ctrl/tinycolor": "^4.1.0",
|
200
207
|
"@lit/localize": "^0.12.1",
|
201
|
-
"@material/web": "^1.
|
202
|
-
"@operato/color-picker": "^
|
203
|
-
"@operato/i18n": "^
|
204
|
-
"@operato/popup": "^
|
205
|
-
"@operato/styles": "^
|
206
|
-
"@operato/utils": "^
|
208
|
+
"@material/web": "^1.5.0",
|
209
|
+
"@operato/color-picker": "^7.0.0-rc.0",
|
210
|
+
"@operato/i18n": "^7.0.0-rc.0",
|
211
|
+
"@operato/popup": "^7.0.0-rc.10",
|
212
|
+
"@operato/styles": "^7.0.0-rc.10",
|
213
|
+
"@operato/utils": "^7.0.0-rc.8",
|
207
214
|
"@polymer/paper-dropdown-menu": "^3.2.0",
|
208
215
|
"@polymer/paper-item": "^3.0.1",
|
209
216
|
"@thebespokepixel/es-tinycolor": "^3.1.0",
|
@@ -247,5 +254,5 @@
|
|
247
254
|
"prettier --write"
|
248
255
|
]
|
249
256
|
},
|
250
|
-
"gitHead": "
|
257
|
+
"gitHead": "96efe00ae617394f5a4fee901be5e20323ff7e57"
|
251
258
|
}
|
package/src/index.ts
CHANGED
package/src/ox-checkbox.ts
CHANGED
@@ -39,12 +39,8 @@ export class OxCheckbox extends OxFormField {
|
|
39
39
|
justify-content: center;
|
40
40
|
}
|
41
41
|
|
42
|
-
:host([indeterminate]) .checkbox {
|
43
|
-
background-color: var(--ox-checkbox-unchecked-background-color, var(--md-ref-palette-primary80));
|
44
|
-
}
|
45
|
-
|
46
42
|
:host([checked]) .checkbox {
|
47
|
-
background-color: var(--ox-checkbox-checked-background-color, var(--md-
|
43
|
+
background-color: var(--ox-checkbox-checked-background-color, var(--md-sys-color-surface-tint));
|
48
44
|
}
|
49
45
|
|
50
46
|
path {
|
@@ -52,7 +48,6 @@ export class OxCheckbox extends OxFormField {
|
|
52
48
|
}
|
53
49
|
|
54
50
|
:host([indeterminate]) line {
|
55
|
-
fill: var(--ox-checkbox-intermidiate-color, var(--md-sys-color-on-surface-variant));
|
56
51
|
stroke: var(--ox-checkbox-intermidiate-color, var(--md-sys-color-outline));
|
57
52
|
}
|
58
53
|
|
@@ -66,11 +61,12 @@ export class OxCheckbox extends OxFormField {
|
|
66
61
|
}
|
67
62
|
|
68
63
|
.label {
|
69
|
-
color: var(--ox-checkbox-label-color, var(--md-sys-color-on-
|
70
|
-
font-size: var(--md-sys-typescale-label-
|
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);
|
71
66
|
line-height: var(--md-sys-typescale-label-medium-line-height, 1rem);
|
72
67
|
}
|
73
68
|
:host([checked]) .label {
|
69
|
+
color:var(ox-checkbox-label-checked-color, var(--md-sys-color-primary));
|
74
70
|
font-weight: 700;
|
75
71
|
}
|
76
72
|
`
|
package/src/ox-input-barcode.ts
CHANGED
@@ -48,6 +48,8 @@ export class OxInputBarcode extends OxFormField {
|
|
48
48
|
display: flex;
|
49
49
|
align-items: center;
|
50
50
|
border: none;
|
51
|
+
background-color: transparent;
|
52
|
+
height: var(--ox-input-height, var(--form-element-height-medium));
|
51
53
|
}
|
52
54
|
|
53
55
|
* {
|
@@ -61,17 +63,16 @@ export class OxInputBarcode extends OxFormField {
|
|
61
63
|
input {
|
62
64
|
flex: 1;
|
63
65
|
width: 10px; /* intentionally width set */
|
66
|
+
border: var(--ox-input-border, 1px solid var(--md-sys-color-outline));
|
67
|
+
border-radius: var(--ox-input-radius, var(--md-sys-shape-corner-small));
|
68
|
+
background-color: var(--ox-input-background-color, var(--md-sys-color-on-primary));
|
69
|
+
color: var(--ox-input-color, var(--md-sys-color-on-primary-container));
|
70
|
+
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
71
|
+
|
64
72
|
box-sizing: border-box;
|
65
|
-
padding: 0 var(--spacing-small);
|
66
73
|
padding-right: 35px;
|
67
|
-
height: var(--form-element-height-medium);
|
68
|
-
border: 1px solid var(--md-sys-color-outline);
|
69
|
-
border-radius: var(--md-sys-shape-corner-small);
|
70
|
-
|
71
|
-
background-color: var(--md-sys-color-on-primary);
|
72
|
-
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
73
|
-
color: var(--md-sys-color-on-primary-container);
|
74
74
|
}
|
75
|
+
|
75
76
|
input:focus {
|
76
77
|
outline: none;
|
77
78
|
border-color: var(--md-sys-color-secondary-fixed-dim);
|
@@ -81,7 +82,7 @@ export class OxInputBarcode extends OxFormField {
|
|
81
82
|
display: block;
|
82
83
|
position: relative;
|
83
84
|
margin-left: -35px;
|
84
|
-
width:
|
85
|
+
width: 35px;
|
85
86
|
border: none;
|
86
87
|
background: var(--barcodescan-input-button-icon) no-repeat center center;
|
87
88
|
}
|
@@ -96,7 +97,7 @@ export class OxInputBarcode extends OxFormField {
|
|
96
97
|
* Indicates whether barcode scanning is enabled.
|
97
98
|
* @property {Boolean} scannable
|
98
99
|
*/
|
99
|
-
@property({ type: Boolean }) scannable?: boolean
|
100
|
+
@property({ type: Boolean, attribute: true }) scannable?: boolean
|
100
101
|
|
101
102
|
/**
|
102
103
|
* If true, the "Enter" key press event is not fired after scanning a barcode.
|
@@ -132,8 +133,6 @@ export class OxInputBarcode extends OxFormField {
|
|
132
133
|
connectedCallback() {
|
133
134
|
super.connectedCallback()
|
134
135
|
|
135
|
-
this.scannable = false
|
136
|
-
|
137
136
|
if (navigator.mediaDevices) {
|
138
137
|
;(async () => {
|
139
138
|
try {
|
@@ -143,9 +142,12 @@ export class OxInputBarcode extends OxFormField {
|
|
143
142
|
this.scannable = true
|
144
143
|
}
|
145
144
|
} catch (e) {
|
145
|
+
this.scannable = false
|
146
146
|
console.warn('this device not support camera for barcode scan', e)
|
147
147
|
}
|
148
148
|
})()
|
149
|
+
} else {
|
150
|
+
this.scannable = false
|
149
151
|
}
|
150
152
|
}
|
151
153
|
|
@@ -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(--
|
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:
|
52
|
-
background-color:
|
56
|
+
border-radius: 0;
|
57
|
+
background-color: transparent;
|
53
58
|
line-height: 0.8;
|
54
|
-
color: var(--
|
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(--
|
63
|
-
color: var(--md-sys-color-primary
|
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 @
|
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
|
-
@
|
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
|
-
|
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).
|
119
|
-
|
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
|
package/src/ox-input-search.ts
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
import '@material/web/icon/icon.js'
|
6
6
|
|
7
|
-
import debounce from 'lodash-es/debounce'
|
7
|
+
// import debounce from 'lodash-es/debounce'
|
8
8
|
import { css, html } from 'lit'
|
9
9
|
import { customElement, property, query } from 'lit/decorators.js'
|
10
10
|
|
@@ -50,7 +50,7 @@ export class OxInputSearch extends OxFormField {
|
|
50
50
|
|
51
51
|
@query('input') input!: HTMLInputElement
|
52
52
|
|
53
|
-
private dispatchChangeEventDebouncer = debounce((value: string) => this.dispatchChangeEvent(value), 100)
|
53
|
+
// private dispatchChangeEventDebouncer = debounce((value: string) => this.dispatchChangeEvent(value), 100)
|
54
54
|
|
55
55
|
render() {
|
56
56
|
return html`
|
@@ -0,0 +1,211 @@
|
|
1
|
+
import { css, html } from 'lit'
|
2
|
+
import { customElement, property } from 'lit/decorators.js'
|
3
|
+
import { OxFormField } from './ox-form-field'
|
4
|
+
import '@material/web/icon/icon.js'
|
5
|
+
|
6
|
+
export interface ColumnConfig {
|
7
|
+
name: string
|
8
|
+
label: string
|
9
|
+
visible: boolean
|
10
|
+
width: number
|
11
|
+
order: number
|
12
|
+
}
|
13
|
+
|
14
|
+
@customElement('ox-input-table-column-config')
|
15
|
+
export class OxInputTableColumnConfig extends OxFormField {
|
16
|
+
static styles = [
|
17
|
+
css`
|
18
|
+
:host {
|
19
|
+
display: block;
|
20
|
+
padding: 4px;
|
21
|
+
border: 1px solid var(--ox-input-table-column-config-border-color, var(--md-sys-color-on-surface));
|
22
|
+
background-color: var(--ox-input-table-column-config-background-color, var(--md-sys-color-surface));
|
23
|
+
color: var(--ox-input-table-column-config-color, var(--md-sys-color-on-surface));
|
24
|
+
}
|
25
|
+
|
26
|
+
table {
|
27
|
+
width: auto;
|
28
|
+
border-collapse: collapse;
|
29
|
+
font-size: 12px;
|
30
|
+
border: 0;
|
31
|
+
}
|
32
|
+
|
33
|
+
tr {
|
34
|
+
border-bottom: 1px solid var(--ox-input-table-column-config-border-color, var(--md-sys-color-on-surface));
|
35
|
+
}
|
36
|
+
|
37
|
+
th,
|
38
|
+
td {
|
39
|
+
padding: 0 var(--spacing-small, 2px);
|
40
|
+
text-align: left;
|
41
|
+
}
|
42
|
+
|
43
|
+
th {
|
44
|
+
text-transform: capitalize;
|
45
|
+
text-align: center;
|
46
|
+
background-color: var(
|
47
|
+
--ox-input-table-column-config-header-background-color,
|
48
|
+
var(--md-sys-color-secondary-container)
|
49
|
+
);
|
50
|
+
color: var(--ox-input-table-column-config-header-background-color, var(--md-sys-color-on-secondary-container));
|
51
|
+
white-space: nowrap;
|
52
|
+
}
|
53
|
+
|
54
|
+
th *,
|
55
|
+
td * {
|
56
|
+
vertical-align: middle;
|
57
|
+
}
|
58
|
+
|
59
|
+
td[width] {
|
60
|
+
width: 60px;
|
61
|
+
text-align: right;
|
62
|
+
}
|
63
|
+
|
64
|
+
input {
|
65
|
+
font-size: 12px;
|
66
|
+
padding: 0;
|
67
|
+
margin: 0;
|
68
|
+
border: none;
|
69
|
+
width: 100%;
|
70
|
+
box-sizing: border-box;
|
71
|
+
outline: none;
|
72
|
+
background-color: var(--ox-input-table-column-config-input-background-color, var(--md-sys-color-surface));
|
73
|
+
color: var(--ox-input-table-column-config-input-color, var(--md-sys-color-on-surface));
|
74
|
+
}
|
75
|
+
|
76
|
+
input[type='number'] {
|
77
|
+
text-align: right;
|
78
|
+
}
|
79
|
+
|
80
|
+
md-icon {
|
81
|
+
cursor: pointer;
|
82
|
+
padding: 0;
|
83
|
+
margin: 0;
|
84
|
+
border: none;
|
85
|
+
background: none;
|
86
|
+
|
87
|
+
--md-icon-size: 16px;
|
88
|
+
}
|
89
|
+
|
90
|
+
md-icon[disabled] {
|
91
|
+
cursor: not-allowed;
|
92
|
+
color: var(--ox-input-table-column-config-disabled-color, var(--md-sys-color-surface-variant, #ccc));
|
93
|
+
}
|
94
|
+
`
|
95
|
+
]
|
96
|
+
|
97
|
+
@property({ type: Array }) value: ColumnConfig[] = []
|
98
|
+
|
99
|
+
render() {
|
100
|
+
console.log('this.value', this.value)
|
101
|
+
return html`
|
102
|
+
<table>
|
103
|
+
<thead>
|
104
|
+
<tr>
|
105
|
+
<th></th>
|
106
|
+
<th>name</th>
|
107
|
+
<th>label</th>
|
108
|
+
<th>width</th>
|
109
|
+
<th></th>
|
110
|
+
</tr>
|
111
|
+
</thead>
|
112
|
+
<tbody>
|
113
|
+
${(this.value || []).map(
|
114
|
+
(col, index) => html`
|
115
|
+
<tr name=${col.name}>
|
116
|
+
<td>
|
117
|
+
<input
|
118
|
+
type="checkbox"
|
119
|
+
.checked=${col.visible}
|
120
|
+
@change=${(e: Event) => this._updateVisibility(e, index)}
|
121
|
+
/>
|
122
|
+
</td>
|
123
|
+
<td name>${col.name}</td>
|
124
|
+
<td>
|
125
|
+
<input type="text" .value=${col.label} @input=${(e: Event) => this._updateLabel(e, index)} />
|
126
|
+
</td>
|
127
|
+
<td width>
|
128
|
+
<input
|
129
|
+
type="number"
|
130
|
+
.value=${String(col.width)}
|
131
|
+
@input=${(e: Event) => this._updateWidth(e, index)}
|
132
|
+
/>
|
133
|
+
</td>
|
134
|
+
<td buttons>
|
135
|
+
<md-icon class="icon-button" @click=${() => this._moveUp(index)} ?disabled=${index === 0}>
|
136
|
+
arrow_upward
|
137
|
+
</md-icon>
|
138
|
+
<md-icon
|
139
|
+
class="icon-button"
|
140
|
+
@click=${() => this._moveDown(index)}
|
141
|
+
?disabled=${index === this.value.length - 1}
|
142
|
+
>
|
143
|
+
arrow_downward
|
144
|
+
</md-icon>
|
145
|
+
</td>
|
146
|
+
</tr>
|
147
|
+
`
|
148
|
+
)}
|
149
|
+
</tbody>
|
150
|
+
</table>
|
151
|
+
`
|
152
|
+
}
|
153
|
+
|
154
|
+
private _updateVisibility(event: Event, index: number) {
|
155
|
+
const target = event.target as HTMLInputElement
|
156
|
+
this.value[index].visible = target.checked
|
157
|
+
this.requestUpdate()
|
158
|
+
this._notifyChange()
|
159
|
+
}
|
160
|
+
|
161
|
+
private _updateLabel(event: Event, index: number) {
|
162
|
+
const target = event.target as HTMLInputElement
|
163
|
+
this.value[index].label = target.value
|
164
|
+
this.requestUpdate()
|
165
|
+
this._notifyChange()
|
166
|
+
}
|
167
|
+
|
168
|
+
private _updateWidth(event: Event, index: number) {
|
169
|
+
const target = event.target as HTMLInputElement
|
170
|
+
this.value[index].width = target.valueAsNumber
|
171
|
+
this.requestUpdate()
|
172
|
+
this._notifyChange()
|
173
|
+
}
|
174
|
+
|
175
|
+
private _moveUp(index: number) {
|
176
|
+
if (index === 0) return
|
177
|
+
const temp = this.value[index]
|
178
|
+
this.value[index] = this.value[index - 1]
|
179
|
+
this.value[index - 1] = temp
|
180
|
+
this._updateOrder()
|
181
|
+
this.requestUpdate()
|
182
|
+
this._notifyChange()
|
183
|
+
}
|
184
|
+
|
185
|
+
private _moveDown(index: number) {
|
186
|
+
if (index === this.value.length - 1) return
|
187
|
+
const temp = this.value[index]
|
188
|
+
this.value[index] = this.value[index + 1]
|
189
|
+
this.value[index + 1] = temp
|
190
|
+
this._updateOrder()
|
191
|
+
this.requestUpdate()
|
192
|
+
this._notifyChange()
|
193
|
+
}
|
194
|
+
|
195
|
+
private _updateOrder() {
|
196
|
+
this.value = this.value.map((col, index) => ({
|
197
|
+
...col,
|
198
|
+
order: index + 1
|
199
|
+
}))
|
200
|
+
}
|
201
|
+
|
202
|
+
private _notifyChange() {
|
203
|
+
this.dispatchEvent(
|
204
|
+
new CustomEvent('change', {
|
205
|
+
detail: this.value,
|
206
|
+
bubbles: true,
|
207
|
+
composed: true
|
208
|
+
})
|
209
|
+
)
|
210
|
+
}
|
211
|
+
}
|
package/src/ox-select.ts
CHANGED
@@ -10,27 +10,12 @@ import { css, html, render, PropertyValues, nothing } from 'lit'
|
|
10
10
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
11
11
|
|
12
12
|
import { OxPopupList } from '@operato/popup'
|
13
|
-
import { TooltipStyles } from '@operato/styles'
|
14
|
-
import { detectOverflow } from '@operato/utils'
|
15
13
|
|
16
14
|
import { OxFormField } from './ox-form-field.js'
|
17
15
|
|
18
|
-
function onmouseover(e: Event) {
|
19
|
-
const element = e.target as HTMLSpanElement
|
20
|
-
if (detectOverflow(element)) {
|
21
|
-
element.setAttribute('data-tooltip', element.textContent!)
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
function onmouseout(e: Event) {
|
26
|
-
const element = e.target as HTMLSpanElement
|
27
|
-
element.removeAttribute('data-tooltip')
|
28
|
-
}
|
29
|
-
|
30
16
|
@customElement('ox-select')
|
31
17
|
export class OxSelect extends OxFormField {
|
32
18
|
static styles = [
|
33
|
-
TooltipStyles,
|
34
19
|
css`
|
35
20
|
:host {
|
36
21
|
display: block;
|
@@ -98,7 +83,7 @@ export class OxSelect extends OxFormField {
|
|
98
83
|
|
99
84
|
return html`
|
100
85
|
<div @click=${this.expand}>
|
101
|
-
<span
|
86
|
+
<span data-reactive-tooltip>${label}</span>
|
102
87
|
<md-icon>expand_more</md-icon>
|
103
88
|
</div>
|
104
89
|
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import '../src/ox-input-table-column-config.js'
|
2
|
+
|
3
|
+
import { html, TemplateResult } from 'lit'
|
4
|
+
import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'
|
5
|
+
|
6
|
+
export default {
|
7
|
+
title: 'ox-input-table-column-config',
|
8
|
+
component: 'ox-input-table-column-config',
|
9
|
+
argTypes: {
|
10
|
+
name: { control: 'text' },
|
11
|
+
value: { control: 'object' },
|
12
|
+
disabled: { control: 'boolean' },
|
13
|
+
theme: { control: 'select', options: ['light', 'dark'] }
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
interface Story<T> {
|
18
|
+
(args: T): TemplateResult
|
19
|
+
args?: Partial<T>
|
20
|
+
argTypes?: Record<string, unknown>
|
21
|
+
}
|
22
|
+
|
23
|
+
interface ArgTypes {
|
24
|
+
name?: string
|
25
|
+
value?: object
|
26
|
+
disabled?: boolean
|
27
|
+
theme?: string
|
28
|
+
}
|
29
|
+
|
30
|
+
const Template: Story<ArgTypes> = ({
|
31
|
+
name = 'table-column-config',
|
32
|
+
value = {},
|
33
|
+
disabled,
|
34
|
+
theme = 'light'
|
35
|
+
}: ArgTypes) => html`
|
36
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
|
37
|
+
|
38
|
+
<link href="/themes/light.css" rel="stylesheet" />
|
39
|
+
<link href="/themes/dark.css" rel="stylesheet" />
|
40
|
+
<link href="/themes/spacing.css" rel="stylesheet" />
|
41
|
+
|
42
|
+
<link
|
43
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
44
|
+
rel="stylesheet"
|
45
|
+
/>
|
46
|
+
<link
|
47
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
48
|
+
rel="stylesheet"
|
49
|
+
/>
|
50
|
+
<link
|
51
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
52
|
+
rel="stylesheet"
|
53
|
+
/>
|
54
|
+
|
55
|
+
<style>
|
56
|
+
${MDTypeScaleStyles.cssText}
|
57
|
+
</style>
|
58
|
+
|
59
|
+
<style>
|
60
|
+
.container {
|
61
|
+
height: 500px;
|
62
|
+
text-align: center;
|
63
|
+
padding: 20px;
|
64
|
+
|
65
|
+
background-color: var(--md-sys-color-primary-container);
|
66
|
+
color: var(--md-sys-color-on-primary-container);
|
67
|
+
}
|
68
|
+
</style>
|
69
|
+
|
70
|
+
<script>
|
71
|
+
document.body.classList.add('${theme}')
|
72
|
+
</script>
|
73
|
+
|
74
|
+
<div class="container md-typescale-body-large-prominent">
|
75
|
+
<ox-input-table-column-config
|
76
|
+
@change=${(e: Event) => {
|
77
|
+
console.log((e.target as HTMLInputElement).value)
|
78
|
+
}}
|
79
|
+
name=${name}
|
80
|
+
.value=${value}
|
81
|
+
?disabled=${disabled}
|
82
|
+
>
|
83
|
+
</ox-input-table-column-config>
|
84
|
+
</div>
|
85
|
+
`
|
86
|
+
|
87
|
+
export const Regular = Template.bind({})
|
88
|
+
Regular.args = {
|
89
|
+
name: 'table-column-config',
|
90
|
+
value: [
|
91
|
+
{
|
92
|
+
name: 'section',
|
93
|
+
label: 'Section',
|
94
|
+
visible: true,
|
95
|
+
width: 100,
|
96
|
+
order: 1
|
97
|
+
},
|
98
|
+
{
|
99
|
+
name: 'title',
|
100
|
+
label: 'Title',
|
101
|
+
visible: true,
|
102
|
+
width: 110,
|
103
|
+
order: 2
|
104
|
+
},
|
105
|
+
{
|
106
|
+
name: 'startDate',
|
107
|
+
label: 'Start Date',
|
108
|
+
visible: true,
|
109
|
+
width: 150,
|
110
|
+
order: 3
|
111
|
+
},
|
112
|
+
{
|
113
|
+
name: 'endDate',
|
114
|
+
label: 'End Date',
|
115
|
+
visible: true,
|
116
|
+
width: 200,
|
117
|
+
order: 4
|
118
|
+
}
|
119
|
+
]
|
120
|
+
}
|