@operato/data-grist 2.0.0-alpha.59 → 2.0.0-alpha.60
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 +9 -0
- package/dist/src/filters/filters-form.js +21 -21
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/stories/accumulator.stories.js +107 -109
- package/dist/stories/accumulator.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/filters/filters-form.ts +45 -45
- package/stories/accumulator.stories.ts +108 -114
@@ -128,7 +128,7 @@ export class FiltersForm extends LitElement {
|
|
128
128
|
|
129
129
|
const grist = this.closest('ox-grist') as DataGrist
|
130
130
|
|
131
|
-
this.value = (grist
|
131
|
+
this.value = (grist?.filters || []).map(filter => {
|
132
132
|
return {
|
133
133
|
...filter,
|
134
134
|
value: this.buildDefaultValue(filter!.operator, filter!.value)
|
@@ -172,8 +172,8 @@ export class FiltersForm extends LitElement {
|
|
172
172
|
filterLabel !== undefined
|
173
173
|
? filterLabel
|
174
174
|
: typeof label === 'object' && label.renderer
|
175
|
-
|
176
|
-
|
175
|
+
? label.renderer(column)
|
176
|
+
: header.renderer(column) || name
|
177
177
|
|
178
178
|
const idx = operator === 'between' ? 1 : 0
|
179
179
|
const renderer = getFilterRenderer(
|
@@ -194,48 +194,48 @@ export class FiltersForm extends LitElement {
|
|
194
194
|
><span>${labelText}</span> ${renderer(column, value, this)}
|
195
195
|
</label> `
|
196
196
|
: type !== 'select' && !labelText
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
197
|
+
? renderer(column, value, this)
|
198
|
+
: operator === 'in'
|
199
|
+
? html`
|
200
|
+
<ox-select
|
201
|
+
name=${name}
|
202
|
+
placeholder=${labelText}
|
203
|
+
.value=${value}
|
204
|
+
@change=${(e: CustomEvent) =>
|
205
|
+
e.target?.dispatchEvent(
|
206
|
+
new CustomEvent('filter-change', {
|
207
|
+
detail: {
|
208
|
+
name,
|
209
|
+
operator,
|
210
|
+
value: e.detail
|
211
|
+
}
|
212
|
+
})
|
213
|
+
)}
|
214
|
+
>
|
215
|
+
<ox-popup-list multiple attr-selected="checked" with-search>
|
216
|
+
${renderer(column, value, this)}
|
217
|
+
</ox-popup-list>
|
218
|
+
</ox-select>
|
219
|
+
`
|
220
|
+
: html`
|
221
|
+
<ox-select
|
222
|
+
name=${name}
|
223
|
+
placeholder=${labelText}
|
224
|
+
.value=${value}
|
225
|
+
@change=${(e: CustomEvent) =>
|
226
|
+
e.target?.dispatchEvent(
|
227
|
+
new CustomEvent('filter-change', {
|
228
|
+
detail: {
|
229
|
+
name,
|
230
|
+
operator,
|
231
|
+
value: e.detail
|
232
|
+
}
|
233
|
+
})
|
234
|
+
)}
|
235
|
+
>
|
236
|
+
<ox-popup-list with-search> ${renderer(column, value, this)} </ox-popup-list>
|
237
|
+
</ox-select>
|
238
|
+
`
|
239
239
|
})}
|
240
240
|
</form>
|
241
241
|
`
|
@@ -103,7 +103,8 @@ const config = {
|
|
103
103
|
header: 'accval',
|
104
104
|
record: {
|
105
105
|
editable: true,
|
106
|
-
align: 'right'
|
106
|
+
align: 'right',
|
107
|
+
defaultValue: 100
|
107
108
|
},
|
108
109
|
accumulator: 'avg',
|
109
110
|
// accumulator: {
|
@@ -200,137 +201,130 @@ interface ArgTypes {
|
|
200
201
|
fetchHandler: object
|
201
202
|
}
|
202
203
|
|
203
|
-
const Template: Story<ArgTypes> = ({
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
}: ArgTypes) => html` <link
|
209
|
-
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
|
210
|
-
rel="stylesheet"
|
211
|
-
/>
|
212
|
-
<link href="/themes/app-theme.css" rel="stylesheet" />
|
213
|
-
<link href="/themes/oops-theme.css" rel="stylesheet" />
|
214
|
-
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
215
|
-
|
216
|
-
<style>
|
217
|
-
ox-grist {
|
218
|
-
height: 600px;
|
219
|
-
}
|
220
|
-
|
221
|
-
[slot='headroom'] {
|
222
|
-
display: flex;
|
223
|
-
flex-direction: row;
|
224
|
-
align-items: center;
|
225
|
-
padding: var(--padding-default) var(--padding-wide);
|
226
|
-
background-color: var(--theme-white-color);
|
227
|
-
box-shadow: var(--box-shadow);
|
204
|
+
const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive = false, fetchHandler }: ArgTypes) =>
|
205
|
+
html` <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
206
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
207
|
+
<link href="/themes/oops-theme.css" rel="stylesheet" />
|
208
|
+
<link href="/themes/grist-theme.css" rel="stylesheet" />
|
228
209
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
--mdc-icon-size: 18px;
|
234
|
-
}
|
235
|
-
#sorters {
|
236
|
-
margin-left: auto;
|
237
|
-
margin-right: var(--margin-default);
|
238
|
-
padding-left: var(--padding-narrow);
|
239
|
-
border-bottom: var(--border-dark-color);
|
240
|
-
position: relative;
|
241
|
-
color: var(--secondary-color);
|
242
|
-
font-size: var(--fontsize-default);
|
243
|
-
user-select: none;
|
244
|
-
}
|
210
|
+
<style>
|
211
|
+
ox-grist {
|
212
|
+
height: 600px;
|
213
|
+
}
|
245
214
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
215
|
+
[slot='headroom'] {
|
216
|
+
display: flex;
|
217
|
+
flex-direction: row;
|
218
|
+
align-items: center;
|
219
|
+
padding: var(--padding-default) var(--padding-wide);
|
220
|
+
background-color: var(--theme-white-color);
|
221
|
+
box-shadow: var(--box-shadow);
|
250
222
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
223
|
+
--mdc-icon-size: 24px;
|
224
|
+
}
|
225
|
+
#sorters mwc-icon,
|
226
|
+
#modes mwc-icon {
|
227
|
+
--mdc-icon-size: 18px;
|
228
|
+
}
|
229
|
+
#sorters {
|
230
|
+
margin-left: auto;
|
231
|
+
margin-right: var(--margin-default);
|
232
|
+
padding-left: var(--padding-narrow);
|
233
|
+
border-bottom: var(--border-dark-color);
|
234
|
+
position: relative;
|
235
|
+
color: var(--secondary-color);
|
236
|
+
font-size: var(--fontsize-default);
|
237
|
+
user-select: none;
|
238
|
+
}
|
257
239
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
color: var(--secondary-text-color);
|
263
|
-
cursor: default;
|
264
|
-
}
|
240
|
+
#sorters > * {
|
241
|
+
padding: var(--padding-narrow);
|
242
|
+
vertical-align: middle;
|
243
|
+
}
|
265
244
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
245
|
+
#modes > * {
|
246
|
+
padding: var(--padding-narrow);
|
247
|
+
opacity: 0.5;
|
248
|
+
color: var(--primary-text-color);
|
249
|
+
cursor: pointer;
|
250
|
+
}
|
270
251
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
252
|
+
#modes > mwc-icon[active] {
|
253
|
+
border-radius: 9px;
|
254
|
+
background-color: rgba(var(--primary-color-rgb), 0.05);
|
255
|
+
opacity: 1;
|
256
|
+
color: var(--secondary-text-color);
|
257
|
+
cursor: default;
|
258
|
+
}
|
275
259
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
padding: 5px;
|
281
|
-
width: 36px;
|
282
|
-
height: 36px;
|
283
|
-
cursor: pointer;
|
284
|
-
}
|
260
|
+
#modes > mwc-icon:hover {
|
261
|
+
opacity: 1;
|
262
|
+
color: var(--secondary-text-color);
|
263
|
+
}
|
285
264
|
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
265
|
+
#add {
|
266
|
+
width: 50px;
|
267
|
+
text-align: right;
|
268
|
+
}
|
290
269
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
270
|
+
#add button {
|
271
|
+
background-color: var(--primary-color);
|
272
|
+
border: 0;
|
273
|
+
border-radius: 50%;
|
274
|
+
padding: 5px;
|
275
|
+
width: 36px;
|
276
|
+
height: 36px;
|
277
|
+
cursor: pointer;
|
278
|
+
}
|
295
279
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
}
|
280
|
+
#add button:hover {
|
281
|
+
background-color: var(--focus-background-color);
|
282
|
+
box-shadow: var(--box-shadow);
|
283
|
+
}
|
301
284
|
|
302
|
-
|
303
|
-
|
304
|
-
|
285
|
+
#add button mwc-icon {
|
286
|
+
font-size: 2em;
|
287
|
+
color: var(--theme-white-color);
|
288
|
+
}
|
305
289
|
|
306
|
-
@media only screen and (max-width: 460px) {
|
307
290
|
#filters {
|
308
|
-
|
291
|
+
display: flex;
|
292
|
+
justify-content: center;
|
293
|
+
align-items: center;
|
309
294
|
}
|
310
295
|
|
311
|
-
#
|
312
|
-
|
296
|
+
#filters * {
|
297
|
+
margin-right: var(--margin-default);
|
313
298
|
}
|
314
|
-
}
|
315
|
-
</style>
|
316
299
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
?url-params-sensitive=${urlParamsSensitive}
|
322
|
-
@filters-change=${(e: Event) => console.log('filters', (e.target as any).filters)}
|
323
|
-
>
|
324
|
-
<div slot="headroom">
|
325
|
-
<div id="filters">
|
326
|
-
<ox-filters-form autofocus></ox-filters-form>
|
327
|
-
</div>
|
300
|
+
@media only screen and (max-width: 460px) {
|
301
|
+
#filters {
|
302
|
+
flex-direction: column;
|
303
|
+
}
|
328
304
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
305
|
+
#modes {
|
306
|
+
display: none;
|
307
|
+
}
|
308
|
+
}
|
309
|
+
</style>
|
310
|
+
|
311
|
+
<ox-grist
|
312
|
+
mode="GRID"
|
313
|
+
.config=${config}
|
314
|
+
.fetchHandler=${fetchHandler}
|
315
|
+
?url-params-sensitive=${urlParamsSensitive}
|
316
|
+
@filters-change=${(e: Event) => console.log('filters', (e.target as any).filters)}
|
317
|
+
>
|
318
|
+
<div slot="headroom">
|
319
|
+
<div id="filters">
|
320
|
+
<ox-filters-form autofocus></ox-filters-form>
|
321
|
+
</div>
|
322
|
+
|
323
|
+
<ox-record-creator id="add" light-popup>
|
324
|
+
<button><mwc-icon>add</mwc-icon></button>
|
325
|
+
</ox-record-creator>
|
326
|
+
</div>
|
327
|
+
</ox-grist>`
|
334
328
|
|
335
329
|
export const Regular = Template.bind({})
|
336
330
|
Regular.args = {
|