@operato/form 2.0.0-alpha.8 → 2.0.0-alpha.85
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 +112 -0
- package/demo/index.html +14 -3
- package/dist/src/components/ox-custom-input.d.ts +1 -1
- package/dist/src/components/ox-custom-select.d.ts +1 -1
- package/dist/src/components/ox-file-uploader.d.ts +1 -1
- package/dist/src/components/ox-file-uploader.js +7 -7
- package/dist/src/components/ox-file-uploader.js.map +1 -1
- package/dist/src/components/ox-form-paginator.d.ts +1 -1
- package/dist/src/components/ox-search-form.d.ts +2 -2
- package/dist/src/components/ox-search-form.js +36 -36
- package/dist/src/components/ox-search-form.js.map +1 -1
- package/dist/src/filters/filter-checkbox.d.ts +1 -1
- package/dist/src/filters/filter-checkbox.js +4 -2
- package/dist/src/filters/filter-checkbox.js.map +1 -1
- package/dist/src/filters/filter-input-barcode.d.ts +1 -1
- package/dist/src/filters/filter-input-barcode.js.map +1 -1
- package/dist/src/filters/filter-input.d.ts +1 -1
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.d.ts +1 -1
- package/dist/src/filters/filter-range-date.js +14 -3
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.d.ts +1 -1
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/filters/filter-select.d.ts +1 -1
- package/dist/src/filters/filter-select.js.map +1 -1
- package/dist/src/filters/filter-styles.js +35 -28
- package/dist/src/filters/filter-styles.js.map +1 -1
- package/dist/src/filters/index.d.ts +1 -1
- package/dist/src/filters/index.js +1 -1
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/filters/ox-filters-form-base.d.ts +5 -8
- package/dist/src/filters/ox-filters-form-base.js +92 -69
- package/dist/src/filters/ox-filters-form-base.js.map +1 -1
- package/dist/src/filters/registry.d.ts +1 -1
- package/dist/src/filters/registry.js.map +1 -1
- package/dist/src/{filters/types.d.ts → types.d.ts} +10 -0
- package/dist/src/types.js.map +1 -0
- package/dist/stories/{ox-filter-form-barcode.stories.js → ox-filters-form-barcode.stories.js} +14 -6
- package/dist/stories/ox-filters-form-barcode.stories.js.map +1 -0
- package/dist/stories/{ox-filter-form-base.stories.d.ts → ox-filters-form-base.stories.d.ts} +3 -2
- package/dist/stories/ox-filters-form-base.stories.js +133 -0
- package/dist/stories/ox-filters-form-base.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/components/ox-file-uploader.ts +7 -7
- package/src/components/ox-search-form.ts +83 -83
- package/src/filters/filter-checkbox.ts +5 -3
- package/src/filters/filter-input-barcode.ts +1 -1
- package/src/filters/filter-input.ts +1 -1
- package/src/filters/filter-range-date.ts +21 -6
- package/src/filters/filter-range-number.ts +1 -1
- package/src/filters/filter-select.ts +1 -1
- package/src/filters/filter-styles.ts +35 -28
- package/src/filters/index.ts +1 -1
- package/src/filters/ox-filters-form-base.ts +100 -71
- package/src/filters/registry.ts +1 -1
- package/src/{filters/types.ts → types.ts} +13 -0
- package/stories/{ox-filter-form-barcode.stories.ts → ox-filters-form-barcode.stories.ts} +13 -5
- package/stories/ox-filters-form-base.stories.ts +150 -0
- package/themes/form-theme.css +1 -1
- package/dist/src/filters/types.js.map +0 -1
- package/dist/stories/ox-filter-form-barcode.stories.js.map +0 -1
- package/dist/stories/ox-filter-form-base.stories.js +0 -82
- package/dist/stories/ox-filter-form-base.stories.js.map +0 -1
- package/stories/ox-filter-form-base.stories.ts +0 -97
- /package/dist/src/{filters/types.js → types.js} +0 -0
- /package/dist/stories/{ox-filter-form-barcode.stories.d.ts → ox-filters-form-barcode.stories.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '@material/
|
|
1
|
+
import '@material/web/icon/icon.js'
|
|
2
2
|
import './ox-custom-input.js'
|
|
3
3
|
import './ox-custom-select.js'
|
|
4
4
|
|
|
@@ -83,68 +83,68 @@ export class SearchForm extends LitElement {
|
|
|
83
83
|
</select>
|
|
84
84
|
`
|
|
85
85
|
: field.type === 'checkbox'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
? html`
|
|
87
|
+
<input
|
|
88
|
+
id="ckbx_${field.name}"
|
|
89
|
+
type="checkbox"
|
|
90
|
+
?checked="${field.value}"
|
|
91
|
+
.name=${field.name}
|
|
92
|
+
?hidden=${field.hidden}
|
|
93
|
+
@click=${(e: MouseEvent) => {
|
|
94
|
+
const checkbox = e.currentTarget as HTMLInputElement & { _value: any }
|
|
95
|
+
if (checkbox.hasAttribute('indeterminate')) {
|
|
96
|
+
const values = [undefined, 'on', 'off']
|
|
97
|
+
const currentValue = checkbox._value
|
|
98
|
+
const newValue =
|
|
99
|
+
values.indexOf(currentValue) + 1 > values.length - 1
|
|
100
|
+
? values[0]
|
|
101
|
+
: values[values.indexOf(currentValue) + 1]
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
if (newValue === 'on') {
|
|
104
|
+
checkbox.checked = true
|
|
105
|
+
} else if (newValue === 'off') {
|
|
106
|
+
checkbox.checked = false
|
|
107
|
+
} else {
|
|
108
|
+
checkbox.indeterminate = true
|
|
109
|
+
}
|
|
110
|
+
checkbox._value = newValue
|
|
109
111
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
/>
|
|
142
|
-
`}
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
<label for="ckbx_${field.name}" ?hidden=${field.hidden}
|
|
115
|
+
>${field.label || field.name || field.id}</label
|
|
116
|
+
>
|
|
117
|
+
`
|
|
118
|
+
: field.type === 'object'
|
|
119
|
+
? html`
|
|
120
|
+
<label ?hidden=${field.hidden}>${field.label || field.name || field.id}</label>
|
|
121
|
+
<input
|
|
122
|
+
.type=${field.type}
|
|
123
|
+
.value=${field.value || ''}
|
|
124
|
+
.name=${field.name}
|
|
125
|
+
.field=${field.field}
|
|
126
|
+
.queryName=${field.queryName}
|
|
127
|
+
.placeholder=${field.placeholder || ''}
|
|
128
|
+
?hidden=${field.hidden}
|
|
129
|
+
?autofocus=${!field.hidden && 0 === autofocusConsumed++}
|
|
130
|
+
/>
|
|
131
|
+
`
|
|
132
|
+
: html`
|
|
133
|
+
<label ?hidden=${field.hidden}>${field.label || field.name || field.id}</label>
|
|
134
|
+
<input
|
|
135
|
+
.type=${field.type}
|
|
136
|
+
.value=${field.value || ''}
|
|
137
|
+
.name=${field.name}
|
|
138
|
+
.placeholder=${field.placeholder || ''}
|
|
139
|
+
?hidden=${field.hidden}
|
|
140
|
+
?autofocus=${!field.hidden && 0 === autofocusConsumed++}
|
|
141
|
+
/>
|
|
142
|
+
`}
|
|
143
143
|
`
|
|
144
144
|
)}
|
|
145
145
|
${this.hideSearchButton || false
|
|
146
146
|
? ``
|
|
147
|
-
: html`<
|
|
147
|
+
: html`<md-icon @click=${(e: MouseEvent) => this.submit()} search>search</md-icon>`}
|
|
148
148
|
</form>
|
|
149
149
|
`
|
|
150
150
|
}
|
|
@@ -224,14 +224,14 @@ export class SearchForm extends LitElement {
|
|
|
224
224
|
field.type === 'text'
|
|
225
225
|
? value
|
|
226
226
|
: field.type === 'checkbox'
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
? field.hasAttribute('indeterminate')
|
|
228
|
+
? field._value === 'on'
|
|
229
|
+
? true
|
|
230
|
+
: false
|
|
231
|
+
: (field as HTMLInputElement).checked
|
|
232
|
+
: field.type === 'number'
|
|
233
|
+
? parseFloat(value)
|
|
234
|
+
: value,
|
|
235
235
|
operator
|
|
236
236
|
}
|
|
237
237
|
})
|
|
@@ -257,16 +257,16 @@ export class SearchForm extends LitElement {
|
|
|
257
257
|
field.type === 'text' && field.getAttribute('type') === 'object'
|
|
258
258
|
? await this._getResourceIds(field)
|
|
259
259
|
: field.type === 'text'
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
? value
|
|
261
|
+
: field.type === 'checkbox'
|
|
262
|
+
? field.hasAttribute('indeterminate')
|
|
263
|
+
? field._value === 'on'
|
|
264
|
+
? true
|
|
265
|
+
: false
|
|
266
|
+
: (field as HTMLInputElement).checked
|
|
267
|
+
: field.type === 'number'
|
|
268
|
+
? parseFloat(value)
|
|
269
|
+
: value,
|
|
270
270
|
relation: field.type === 'text' && field.getAttribute('type') === 'object'
|
|
271
271
|
}
|
|
272
272
|
return filter
|
|
@@ -285,14 +285,14 @@ export class SearchForm extends LitElement {
|
|
|
285
285
|
query: gql`
|
|
286
286
|
query {
|
|
287
287
|
fetch: ${queryName}(${buildArgs({
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
filters: [
|
|
289
|
+
{
|
|
290
|
+
name: field,
|
|
291
|
+
operator: 'i_like',
|
|
292
|
+
value: `%${value}%`
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
})}) {
|
|
296
296
|
items {
|
|
297
297
|
id
|
|
298
298
|
}
|
|
@@ -2,10 +2,10 @@ import '@operato/input/ox-checkbox.js'
|
|
|
2
2
|
|
|
3
3
|
import { html } from 'lit-html'
|
|
4
4
|
|
|
5
|
-
import { FilterSelectRenderer } from '
|
|
5
|
+
import { FilterSelectRenderer } from '../types.js'
|
|
6
6
|
|
|
7
7
|
export const FilterCheckbox: FilterSelectRenderer = (filter, value, owner) => {
|
|
8
|
-
const { name } = filter
|
|
8
|
+
const { name, label } = filter
|
|
9
9
|
|
|
10
10
|
return html`
|
|
11
11
|
<ox-checkbox
|
|
@@ -13,6 +13,7 @@ export const FilterCheckbox: FilterSelectRenderer = (filter, value, owner) => {
|
|
|
13
13
|
?checked=${value}
|
|
14
14
|
indeterminatable
|
|
15
15
|
?indeterminate=${value === undefined}
|
|
16
|
+
left-label
|
|
16
17
|
@change=${(e: CustomEvent) => {
|
|
17
18
|
;(e.target as HTMLElement).dispatchEvent(
|
|
18
19
|
new CustomEvent('filter-change', {
|
|
@@ -26,6 +27,7 @@ export const FilterCheckbox: FilterSelectRenderer = (filter, value, owner) => {
|
|
|
26
27
|
})
|
|
27
28
|
)
|
|
28
29
|
}}
|
|
29
|
-
|
|
30
|
+
><label><span>${label}</span></label></ox-checkbox
|
|
31
|
+
>
|
|
30
32
|
`
|
|
31
33
|
}
|
|
@@ -2,7 +2,7 @@ import '@operato/input/ox-input-barcode.js'
|
|
|
2
2
|
|
|
3
3
|
import { html } from 'lit-html'
|
|
4
4
|
|
|
5
|
-
import { FilterSelectRenderer } from '
|
|
5
|
+
import { FilterSelectRenderer } from '../types.js'
|
|
6
6
|
|
|
7
7
|
export const FilterInputBarcode: FilterSelectRenderer = (filter, value, owner) => {
|
|
8
8
|
const { name, type } = filter
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { html } from 'lit-html'
|
|
2
2
|
|
|
3
|
-
import { FilterSelectRenderer } from '
|
|
3
|
+
import { FilterSelectRenderer } from '../types.js'
|
|
4
|
+
|
|
5
|
+
function formatDate(type: string, date: Date) {
|
|
6
|
+
var year = date.getFullYear()
|
|
7
|
+
var month = ('0' + (date.getMonth() + 1)).slice(-2)
|
|
8
|
+
var day = ('0' + date.getDate()).slice(-2)
|
|
9
|
+
var hours = ('0' + date.getHours()).slice(-2)
|
|
10
|
+
var minutes = ('0' + date.getMinutes()).slice(-2)
|
|
11
|
+
|
|
12
|
+
var formatDate = year + '-' + month + '-' + day
|
|
13
|
+
|
|
14
|
+
return type == 'date' ? formatDate : formatDate + 'T' + hours + ':' + minutes
|
|
15
|
+
}
|
|
4
16
|
|
|
5
17
|
export const FilterRangeDate: FilterSelectRenderer = (filter, value, owner) => {
|
|
6
18
|
var { name, type, operator } = filter
|
|
7
|
-
|
|
19
|
+
var [from, to] = value instanceof Array ? value : []
|
|
8
20
|
|
|
9
21
|
if (type === 'datetime') {
|
|
10
22
|
type = 'datetime-local'
|
|
11
23
|
}
|
|
12
24
|
|
|
25
|
+
from = formatDate(type, new Date(from))
|
|
26
|
+
to = formatDate(type, new Date(to))
|
|
27
|
+
|
|
13
28
|
return html`
|
|
14
29
|
<input
|
|
15
30
|
name=${name}
|
|
16
|
-
type=${type}
|
|
17
|
-
|
|
31
|
+
type=${type as 'date' | 'datetime-local'}
|
|
32
|
+
value=${from}
|
|
18
33
|
from
|
|
19
34
|
@keyup=${(e: KeyboardEvent) => {
|
|
20
35
|
if (e.key !== 'Enter') {
|
|
@@ -38,8 +53,8 @@ export const FilterRangeDate: FilterSelectRenderer = (filter, value, owner) => {
|
|
|
38
53
|
~
|
|
39
54
|
<input
|
|
40
55
|
name=${name}
|
|
41
|
-
type=${type}
|
|
42
|
-
|
|
56
|
+
type=${type as 'date' | 'datetime-local'}
|
|
57
|
+
value=${to}
|
|
43
58
|
to
|
|
44
59
|
@keyup=${(e: KeyboardEvent) => {
|
|
45
60
|
if (e.key !== 'Enter') {
|
|
@@ -2,7 +2,7 @@ import '@operato/input/ox-checkbox.js'
|
|
|
2
2
|
|
|
3
3
|
import { html } from 'lit-html'
|
|
4
4
|
|
|
5
|
-
import { FilterSelectRenderer } from '
|
|
5
|
+
import { FilterSelectRenderer } from '../types.js'
|
|
6
6
|
|
|
7
7
|
export const FilterSelect: FilterSelectRenderer = (filter, value, owner) => {
|
|
8
8
|
/* value는 filters-form이나 grid-header에서 처리되므로 이 곳에서는 무시한다. */
|
|
@@ -2,56 +2,65 @@ import { css } from 'lit'
|
|
|
2
2
|
|
|
3
3
|
export const FilterStyles = css`
|
|
4
4
|
:host {
|
|
5
|
-
--ox-input-placeholder-color: var(--primary-color);
|
|
6
|
-
|
|
7
|
-
--ox-input-
|
|
8
|
-
--ox-input-border: 1px solid
|
|
9
|
-
--ox-input-
|
|
10
|
-
--ox-input-
|
|
11
|
-
--ox-input-
|
|
12
|
-
--ox-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
--ox-filters-form-
|
|
16
|
-
--ox-filters-
|
|
17
|
-
|
|
5
|
+
--ox-filters-input-placeholder-color: var(--input-placeholder-color, var(--primary-color));
|
|
6
|
+
|
|
7
|
+
--ox-filters-input-border: var(--input-border, 1px solid rgba(0, 0, 0, 0.2));
|
|
8
|
+
--ox-filters-input-focus-border: var(--input-focus-border, 1px solid var(--primary-color));
|
|
9
|
+
--ox-filters-input-font: var(--input-font, normal 14px var(--theme-font));
|
|
10
|
+
--ox-filters-input-color: var(--input-color, var(--primary-text-color));
|
|
11
|
+
--ox-filters-input-focus-color: var(--input-focus-color, var(--primary-color));
|
|
12
|
+
--ox-filters-label-font: var(--label-font, normal 14px var(--theme-font));
|
|
13
|
+
--ox-filters-label-color: var(--label-color, var(--primary-text-color));
|
|
14
|
+
|
|
15
|
+
--ox-filters-form-gap: var(--input-gap-vertical, 8px) var(--input-gap-horizontal, 16px);
|
|
16
|
+
--ox-filters-input-padding: var(--input-padding, 6px 2px);
|
|
17
|
+
|
|
18
|
+
--ox-select-padding: var(--ox-filters-input-padding);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
label {
|
|
21
|
-
font: var(--ox-filters-
|
|
22
|
-
color: var(--ox-filters-
|
|
22
|
+
font: var(--ox-filters-label-font);
|
|
23
|
+
color: var(--ox-filters-label-color);
|
|
23
24
|
}
|
|
25
|
+
|
|
24
26
|
span {
|
|
25
|
-
margin-right: var(--margin-narrow);
|
|
26
27
|
text-transform: capitalize;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
input::placeholder {
|
|
30
|
-
color: var(--ox-input-placeholder-color);
|
|
31
|
+
color: var(--ox-filters-input-placeholder-color);
|
|
31
32
|
opacity: 0.6;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
input {
|
|
36
|
+
padding: var(--ox-filters-input-padding);
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
ox-select,
|
|
35
40
|
input {
|
|
36
|
-
padding: var(--input-padding);
|
|
37
41
|
border: none;
|
|
38
|
-
border-bottom: var(--ox-input-border);
|
|
39
|
-
font: var(--ox-input-font);
|
|
40
|
-
color: var(--ox-input-color);
|
|
42
|
+
border-bottom: var(--ox-filters-input-border);
|
|
43
|
+
font: var(--ox-filters-input-font);
|
|
44
|
+
color: var(--ox-filters-input-color);
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
ox-select:focus,
|
|
44
48
|
input:focus {
|
|
45
49
|
outline: none;
|
|
46
|
-
border-bottom: var(--ox-input-focus-border);
|
|
47
|
-
color: var(--
|
|
50
|
+
border-bottom: var(--ox-filters-input-focus-border);
|
|
51
|
+
color: var(--ox-filters-input-focus-color);
|
|
48
52
|
}
|
|
53
|
+
|
|
49
54
|
ox-select {
|
|
50
|
-
|
|
55
|
+
min-width: 90px;
|
|
56
|
+
max-width: 170px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ox-input-search {
|
|
60
|
+
max-width: 150px;
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
input[type='number'] {
|
|
54
|
-
padding-right: var(--padding-narrow);
|
|
55
64
|
max-width: 90px;
|
|
56
65
|
}
|
|
57
66
|
|
|
@@ -59,15 +68,13 @@ export const FilterStyles = css`
|
|
|
59
68
|
input[type*='time'],
|
|
60
69
|
input[type='week'],
|
|
61
70
|
input[type='month'] {
|
|
62
|
-
padding: 8px var(--padding-narrow) 8px var(--padding-default);
|
|
63
71
|
max-width: 170px;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
@media only screen and (max-width: 460px) {
|
|
67
75
|
:host {
|
|
68
76
|
--ox-filters-form-label-font: bold 13px var(--theme-font);
|
|
69
|
-
--ox-input-font: normal 16px var(--theme-font);
|
|
70
|
-
--ox-filters-form-gap: var(--margin-narrow);
|
|
77
|
+
--ox-filters-input-font: normal 16px var(--theme-font);
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
input[from],
|
package/src/filters/index.ts
CHANGED