@gravitee/ui-components 3.25.3-typescript-8a53edf → 3.25.3-typescript-e7256ca
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 +3 -4
- package/src/atoms/gv-autocomplete.d.ts +104 -0
- package/src/atoms/gv-autocomplete.js +1 -461
- package/src/atoms/gv-button.d.ts +109 -0
- package/src/atoms/gv-button.js +1 -410
- package/src/atoms/gv-checkbox.d.ts +114 -0
- package/src/atoms/gv-checkbox.js +1 -187
- package/src/atoms/gv-date-picker-calendar.d.ts +190 -0
- package/src/atoms/gv-date-picker-calendar.js +1 -894
- package/src/atoms/gv-date-picker-cell.d.ts +80 -0
- package/src/atoms/gv-date-picker-cell.js +1 -190
- package/src/atoms/gv-date-picker.d.ts +194 -0
- package/src/atoms/gv-date-picker.js +1 -671
- package/src/atoms/gv-file-upload.d.ts +64 -0
- package/src/atoms/gv-file-upload.js +1 -367
- package/src/atoms/gv-icon.d.ts +26 -0
- package/src/atoms/gv-icon.js +1 -103
- package/src/atoms/gv-image.d.ts +45 -0
- package/src/atoms/gv-image.js +1 -144
- package/src/atoms/gv-input-message.d.ts +20 -0
- package/src/atoms/gv-input-message.js +1 -84
- package/src/atoms/gv-input.d.ts +246 -0
- package/src/atoms/gv-input.js +1 -561
- package/src/atoms/gv-link.d.ts +67 -0
- package/src/atoms/gv-link.js +1 -210
- package/src/atoms/gv-message.d.ts +23 -0
- package/src/atoms/gv-message.js +1 -128
- package/src/atoms/gv-metric.d.ts +32 -0
- package/src/atoms/gv-metric.js +1 -117
- package/src/atoms/gv-relative-time.d.ts +45 -0
- package/src/atoms/gv-relative-time.js +1 -156
- package/src/atoms/gv-select-native.d.ts +174 -0
- package/src/atoms/gv-select-native.js +1 -388
- package/src/atoms/gv-select.d.ts +71 -0
- package/src/atoms/gv-select.js +1 -437
- package/src/atoms/gv-spinner.d.ts +10 -0
- package/src/atoms/gv-spinner.js +1 -57
- package/src/atoms/gv-state.d.ts +50 -0
- package/src/atoms/gv-state.js +1 -130
- package/src/atoms/gv-switch.d.ts +60 -0
- package/src/atoms/gv-switch.js +1 -243
- package/src/atoms/gv-tag.d.ts +69 -0
- package/src/atoms/gv-tag.js +1 -168
- package/src/atoms/gv-text.d.ts +110 -0
- package/src/atoms/gv-text.js +1 -168
- package/src/charts/gv-chart-bar.d.ts +50 -0
- package/src/charts/gv-chart-bar.js +1 -103
- package/src/charts/gv-chart-gauge.d.ts +58 -0
- package/src/charts/gv-chart-gauge.js +1 -100
- package/src/charts/gv-chart-histogram.d.ts +48 -0
- package/src/charts/gv-chart-histogram.js +1 -83
- package/src/charts/gv-chart-line.d.ts +52 -0
- package/src/charts/gv-chart-line.js +1 -224
- package/src/charts/gv-chart-map.d.ts +50 -0
- package/src/charts/gv-chart-map.js +1 -112
- package/src/charts/gv-chart-pie.d.ts +50 -0
- package/src/charts/gv-chart-pie.js +1 -91
- package/src/index.d.ts +77 -0
- package/src/index.js +1 -77
- package/src/lib/cron-expression.d.ts +1 -0
- package/src/lib/cron-expression.js +1 -205
- package/src/lib/date.d.ts +1 -0
- package/src/lib/date.js +1 -44
- package/src/lib/events.d.ts +1 -0
- package/src/lib/events.js +1 -26
- package/src/lib/http-client-schema-form.d.ts +68 -0
- package/src/lib/http-client-schema-form.js +1 -67
- package/src/lib/http.d.ts +222 -0
- package/src/lib/http.js +1 -237
- package/src/lib/i18n.d.ts +30 -0
- package/src/lib/i18n.js +1 -103
- package/src/lib/item.d.ts +12 -0
- package/src/lib/item.js +1 -118
- package/src/lib/properties.d.ts +42 -0
- package/src/lib/properties.js +1 -189
- package/src/lib/schema-form.d.ts +5 -0
- package/src/lib/schema-form.js +1 -44
- package/src/lib/studio.d.ts +2 -0
- package/src/lib/studio.js +1 -141
- package/src/lib/style.d.ts +6 -0
- package/src/lib/style.js +1 -41
- package/src/lib/text-format.d.ts +6 -0
- package/src/lib/text-format.js +1 -69
- package/src/lib/theme.d.ts +4 -0
- package/src/lib/theme.js +1 -63
- package/src/lib/utils.d.ts +9 -0
- package/src/lib/utils.js +1 -111
- package/src/mixins/chart-element.d.ts +39 -0
- package/src/mixins/chart-element.js +1 -165
- package/src/mixins/input-element.d.ts +64 -0
- package/src/mixins/input-element.js +1 -144
- package/src/mixins/item-resource.d.ts +56 -0
- package/src/mixins/item-resource.js +1 -120
- package/src/mixins/keyboard-element.d.ts +25 -0
- package/src/mixins/keyboard-element.js +1 -69
- package/src/mixins/update-after-browser.d.ts +11 -0
- package/src/mixins/update-after-browser.js +1 -30
- package/src/mixins/with-resize-observer.d.ts +12 -0
- package/src/mixins/with-resize-observer.js +1 -68
- package/src/mixins/with-skeleton-attribute.d.ts +35 -0
- package/src/mixins/with-skeleton-attribute.js +1 -112
- package/src/molecules/gv-card-full.d.ts +78 -0
- package/src/molecules/gv-card-full.js +1 -218
- package/src/molecules/gv-card-list.d.ts +33 -0
- package/src/molecules/gv-card-list.js +1 -113
- package/src/molecules/gv-card.d.ts +65 -0
- package/src/molecules/gv-card.js +1 -133
- package/src/molecules/gv-category-list.d.ts +17 -0
- package/src/molecules/gv-category-list.js +1 -60
- package/src/molecules/gv-category.d.ts +64 -0
- package/src/molecules/gv-category.js +1 -170
- package/src/molecules/gv-code.d.ts +192 -0
- package/src/molecules/gv-code.js +1 -359
- package/src/molecules/gv-confirm.d.ts +60 -0
- package/src/molecules/gv-confirm.js +1 -188
- package/src/molecules/gv-cron-editor.d.ts +115 -0
- package/src/molecules/gv-cron-editor.js +1 -710
- package/src/molecules/gv-dropdown-menu.d.ts +28 -0
- package/src/molecules/gv-dropdown-menu.js +1 -116
- package/src/molecules/gv-expandable.d.ts +37 -0
- package/src/molecules/gv-expandable.js +1 -122
- package/src/molecules/gv-expression-language.d.ts +150 -0
- package/src/molecules/gv-expression-language.js +1 -270
- package/src/molecules/gv-identity-picture.d.ts +44 -0
- package/src/molecules/gv-identity-picture.js +1 -148
- package/src/molecules/gv-list.d.ts +123 -0
- package/src/molecules/gv-list.js +1 -227
- package/src/molecules/gv-metrics.d.ts +65 -0
- package/src/molecules/gv-metrics.js +1 -162
- package/src/molecules/gv-modal.d.ts +64 -0
- package/src/molecules/gv-modal.js +1 -213
- package/src/molecules/gv-nav.d.ts +41 -0
- package/src/molecules/gv-nav.js +1 -196
- package/src/molecules/gv-option.d.ts +65 -0
- package/src/molecules/gv-option.js +1 -242
- package/src/molecules/gv-plans.d.ts +73 -0
- package/src/molecules/gv-plans.js +1 -429
- package/src/molecules/gv-popover.d.ts +91 -0
- package/src/molecules/gv-popover.js +1 -351
- package/src/molecules/gv-promote.d.ts +108 -0
- package/src/molecules/gv-promote.js +1 -209
- package/src/molecules/gv-rating-list.d.ts +77 -0
- package/src/molecules/gv-rating-list.js +1 -365
- package/src/molecules/gv-rating.d.ts +55 -0
- package/src/molecules/gv-rating.js +1 -253
- package/src/molecules/gv-row-expandable.d.ts +8 -0
- package/src/molecules/gv-row-expandable.js +1 -45
- package/src/molecules/gv-row.d.ts +37 -0
- package/src/molecules/gv-row.js +1 -210
- package/src/molecules/gv-stats.d.ts +53 -0
- package/src/molecules/gv-stats.js +1 -121
- package/src/molecules/gv-stepper.d.ts +46 -0
- package/src/molecules/gv-stepper.js +1 -288
- package/src/molecules/gv-table.d.ts +159 -0
- package/src/molecules/gv-table.js +1 -685
- package/src/molecules/gv-tree.d.ts +44 -0
- package/src/molecules/gv-tree.js +1 -250
- package/src/organisms/gv-documentation.d.ts +52 -0
- package/src/organisms/gv-documentation.js +1 -215
- package/src/organisms/gv-header.d.ts +60 -0
- package/src/organisms/gv-header.js +1 -288
- package/src/organisms/gv-http-client.d.ts +57 -0
- package/src/organisms/gv-http-client.js +1 -275
- package/src/organisms/gv-menu.d.ts +74 -0
- package/src/organisms/gv-menu.js +1 -263
- package/src/organisms/gv-newsletter-subscription.d.ts +82 -0
- package/src/organisms/gv-newsletter-subscription.js +1 -271
- package/src/organisms/gv-pagination.d.ts +63 -0
- package/src/organisms/gv-pagination.js +1 -198
- package/src/organisms/gv-properties.d.ts +229 -0
- package/src/organisms/gv-properties.js +1 -920
- package/src/organisms/gv-resizable-views.d.ts +33 -0
- package/src/organisms/gv-resizable-views.js +1 -396
- package/src/organisms/gv-resources.d.ts +125 -0
- package/src/organisms/gv-resources.js +1 -535
- package/src/organisms/gv-schema-form-array.d.ts +55 -0
- package/src/organisms/gv-schema-form-array.js +1 -250
- package/src/organisms/gv-schema-form-control-object.d.ts +64 -0
- package/src/organisms/gv-schema-form-control-object.js +1 -154
- package/src/organisms/gv-schema-form-control.d.ts +90 -0
- package/src/organisms/gv-schema-form-control.js +1 -443
- package/src/organisms/gv-schema-form.d.ts +156 -0
- package/src/organisms/gv-schema-form.js +1 -751
- package/src/organisms/gv-tabs.d.ts +56 -0
- package/src/organisms/gv-tabs.js +1 -210
- package/src/organisms/gv-user-menu.d.ts +56 -0
- package/src/organisms/gv-user-menu.js +1 -314
- package/src/organisms/gv-vertical-menu.d.ts +28 -0
- package/src/organisms/gv-vertical-menu.js +1 -123
- package/src/policy-studio/gv-flow-step.d.ts +142 -0
- package/src/policy-studio/gv-flow-step.js +1 -464
- package/src/policy-studio/gv-flow.d.ts +89 -0
- package/src/policy-studio/gv-flow.js +1 -621
- package/src/policy-studio/gv-policy-studio-menu.d.ts +94 -0
- package/src/policy-studio/gv-policy-studio-menu.js +1 -750
- package/src/policy-studio/gv-policy-studio.d.ts +464 -0
- package/src/policy-studio/gv-policy-studio.js +1 -1842
- package/src/styles/empty.d.ts +1 -0
- package/src/styles/empty.js +1 -36
- package/src/styles/input.d.ts +1 -0
- package/src/styles/input.js +1 -263
- package/src/styles/link.d.ts +1 -0
- package/src/styles/link.js +1 -32
- package/src/styles/shapes.d.ts +2 -0
- package/src/styles/shapes.js +1 -17
- package/src/styles/skeleton.d.ts +1 -0
- package/src/styles/skeleton.js +1 -53
- package/src/styles/zoom.d.ts +1 -0
- package/src/styles/zoom.js +1 -40
- package/src/theme/gv-theme.d.ts +81 -0
- package/src/theme/gv-theme.js +1 -203
- package/wc/gv-autocomplete.d.ts +1 -0
- package/wc/gv-autocomplete.js +1 -1
- package/wc/gv-button.d.ts +1 -0
- package/wc/gv-button.js +1 -1
- package/wc/gv-card-full.d.ts +1 -0
- package/wc/gv-card-full.js +1 -1
- package/wc/gv-card-list.d.ts +1 -0
- package/wc/gv-card-list.js +1 -1
- package/wc/gv-card.d.ts +1 -0
- package/wc/gv-card.js +1 -1
- package/wc/gv-category-list.d.ts +1 -0
- package/wc/gv-category-list.js +1 -1
- package/wc/gv-category.d.ts +1 -0
- package/wc/gv-category.js +1 -1
- package/wc/gv-chart-bar.d.ts +1 -0
- package/wc/gv-chart-bar.js +1 -1
- package/wc/gv-chart-gauge.d.ts +1 -0
- package/wc/gv-chart-gauge.js +1 -1
- package/wc/gv-chart-histogram.d.ts +1 -0
- package/wc/gv-chart-histogram.js +1 -1
- package/wc/gv-chart-line.d.ts +1 -0
- package/wc/gv-chart-line.js +1 -1
- package/wc/gv-chart-map.d.ts +1 -0
- package/wc/gv-chart-map.js +1 -1
- package/wc/gv-chart-pie.d.ts +1 -0
- package/wc/gv-chart-pie.js +1 -1
- package/wc/gv-checkbox.d.ts +1 -0
- package/wc/gv-checkbox.js +1 -1
- package/wc/gv-code.d.ts +1 -0
- package/wc/gv-code.js +1 -1
- package/wc/gv-confirm.d.ts +1 -0
- package/wc/gv-confirm.js +1 -1
- package/wc/gv-cron-editor.d.ts +1 -0
- package/wc/gv-cron-editor.js +1 -1
- package/wc/gv-date-picker-calendar.d.ts +1 -0
- package/wc/gv-date-picker-calendar.js +1 -1
- package/wc/gv-date-picker-cell.d.ts +1 -0
- package/wc/gv-date-picker-cell.js +1 -1
- package/wc/gv-date-picker.d.ts +1 -0
- package/wc/gv-date-picker.js +1 -1
- package/wc/gv-documentation.d.ts +1 -0
- package/wc/gv-documentation.js +1 -1
- package/wc/gv-dropdown-menu.d.ts +1 -0
- package/wc/gv-dropdown-menu.js +1 -1
- package/wc/gv-expandable.d.ts +1 -0
- package/wc/gv-expandable.js +1 -1
- package/wc/gv-expression-language.d.ts +1 -0
- package/wc/gv-expression-language.js +1 -1
- package/wc/gv-file-upload.d.ts +1 -0
- package/wc/gv-file-upload.js +1 -1
- package/wc/gv-flow-step.d.ts +1 -0
- package/wc/gv-flow-step.js +1 -1
- package/wc/gv-flow.d.ts +1 -0
- package/wc/gv-flow.js +1 -1
- package/wc/gv-header.d.ts +1 -0
- package/wc/gv-header.js +1 -1
- package/wc/gv-http-client.d.ts +1 -0
- package/wc/gv-http-client.js +1 -1
- package/wc/gv-icon.d.ts +1 -0
- package/wc/gv-icon.js +1 -1
- package/wc/gv-identity-picture.d.ts +1 -0
- package/wc/gv-identity-picture.js +1 -1
- package/wc/gv-image.d.ts +1 -0
- package/wc/gv-image.js +1 -1
- package/wc/gv-input-message.d.ts +1 -0
- package/wc/gv-input-message.js +1 -1
- package/wc/gv-input.d.ts +1 -0
- package/wc/gv-input.js +1 -1
- package/wc/gv-link.d.ts +1 -0
- package/wc/gv-link.js +1 -1
- package/wc/gv-list.d.ts +1 -0
- package/wc/gv-list.js +1 -1
- package/wc/gv-menu.d.ts +1 -0
- package/wc/gv-menu.js +1 -1
- package/wc/gv-message.d.ts +1 -0
- package/wc/gv-message.js +1 -1
- package/wc/gv-metric.d.ts +1 -0
- package/wc/gv-metric.js +1 -1
- package/wc/gv-metrics.d.ts +1 -0
- package/wc/gv-metrics.js +1 -1
- package/wc/gv-modal.d.ts +1 -0
- package/wc/gv-modal.js +1 -1
- package/wc/gv-nav.d.ts +1 -0
- package/wc/gv-nav.js +1 -1
- package/wc/gv-newsletter-subscription.d.ts +1 -0
- package/wc/gv-newsletter-subscription.js +1 -1
- package/wc/gv-option.d.ts +1 -0
- package/wc/gv-option.js +1 -1
- package/wc/gv-pagination.d.ts +1 -0
- package/wc/gv-pagination.js +1 -1
- package/wc/gv-plans.d.ts +1 -0
- package/wc/gv-plans.js +1 -1
- package/wc/gv-policy-studio-menu.d.ts +1 -0
- package/wc/gv-policy-studio-menu.js +1 -1
- package/wc/gv-policy-studio.d.ts +1 -0
- package/wc/gv-policy-studio.js +1 -1
- package/wc/gv-popover.d.ts +1 -0
- package/wc/gv-popover.js +1 -1
- package/wc/gv-promote.d.ts +1 -0
- package/wc/gv-promote.js +1 -1
- package/wc/gv-properties.d.ts +1 -0
- package/wc/gv-properties.js +1 -1
- package/wc/gv-rating-list.d.ts +1 -0
- package/wc/gv-rating-list.js +1 -1
- package/wc/gv-rating.d.ts +1 -0
- package/wc/gv-rating.js +1 -1
- package/wc/gv-relative-time.d.ts +1 -0
- package/wc/gv-relative-time.js +1 -1
- package/wc/gv-resizable-views.d.ts +1 -0
- package/wc/gv-resizable-views.js +1 -1
- package/wc/gv-resources.d.ts +1 -0
- package/wc/gv-resources.js +1 -1
- package/wc/gv-row-expandable.d.ts +1 -0
- package/wc/gv-row-expandable.js +1 -1
- package/wc/gv-row.d.ts +1 -0
- package/wc/gv-row.js +1 -1
- package/wc/gv-schema-form-array.d.ts +1 -0
- package/wc/gv-schema-form-array.js +1 -1
- package/wc/gv-schema-form-control-object.d.ts +1 -0
- package/wc/gv-schema-form-control-object.js +1 -1
- package/wc/gv-schema-form-control.d.ts +1 -0
- package/wc/gv-schema-form-control.js +1 -1
- package/wc/gv-schema-form.d.ts +1 -0
- package/wc/gv-schema-form.js +1 -1
- package/wc/gv-select-native.d.ts +1 -0
- package/wc/gv-select-native.js +1 -1
- package/wc/gv-select.d.ts +1 -0
- package/wc/gv-select.js +1 -1
- package/wc/gv-spinner.d.ts +1 -0
- package/wc/gv-spinner.js +1 -1
- package/wc/gv-state.d.ts +1 -0
- package/wc/gv-state.js +1 -1
- package/wc/gv-stats.d.ts +1 -0
- package/wc/gv-stats.js +1 -1
- package/wc/gv-stepper.d.ts +1 -0
- package/wc/gv-stepper.js +1 -1
- package/wc/gv-switch.d.ts +1 -0
- package/wc/gv-switch.js +1 -1
- package/wc/gv-table.d.ts +1 -0
- package/wc/gv-table.js +1 -1
- package/wc/gv-tabs.d.ts +1 -0
- package/wc/gv-tabs.js +1 -1
- package/wc/gv-tag.d.ts +1 -0
- package/wc/gv-tag.js +1 -1
- package/wc/gv-text.d.ts +1 -0
- package/wc/gv-text.js +1 -1
- package/wc/gv-theme.d.ts +1 -0
- package/wc/gv-theme.js +1 -1
- package/wc/gv-tree.d.ts +1 -0
- package/wc/gv-tree.js +1 -1
- package/wc/gv-user-menu.d.ts +1 -0
- package/wc/gv-user-menu.js +1 -1
- package/wc/gv-vertical-menu.d.ts +1 -0
- package/wc/gv-vertical-menu.js +1 -1
- package/CHANGELOG.md +0 -1292
- package/LICENSE.txt +0 -202
- package/README.md +0 -195
- package/src/.eslintrc.js +0 -19
- package/src/theme/definition.json +0 -1762
|
@@ -1,685 +1 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { css, LitElement, html } from 'lit';
|
|
17
|
-
import { skeleton } from '../styles/skeleton';
|
|
18
|
-
import { empty } from '../styles/empty';
|
|
19
|
-
import { link } from '../styles/link';
|
|
20
|
-
import { classMap } from 'lit/directives/class-map';
|
|
21
|
-
import { repeat } from 'lit/directives/repeat';
|
|
22
|
-
import { dispatchCustomEvent } from '../lib/events';
|
|
23
|
-
import { getLanguage, i18n } from '../lib/i18n';
|
|
24
|
-
import { until } from 'lit/directives/until';
|
|
25
|
-
import { styleMap } from 'lit/directives/style-map';
|
|
26
|
-
import { withResizeObserver } from '../mixins/with-resize-observer';
|
|
27
|
-
import { ifDefined } from 'lit/directives/if-defined';
|
|
28
|
-
import '../atoms/gv-image';
|
|
29
|
-
import '../organisms/gv-pagination';
|
|
30
|
-
import { getCssVar } from '../lib/style';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Table component
|
|
34
|
-
*
|
|
35
|
-
* ## Details
|
|
36
|
-
* * has @theme facet
|
|
37
|
-
*
|
|
38
|
-
* @fires gv-table:select - when table row is selected
|
|
39
|
-
* @fires gv-table:mouseenter - when the pointer is entering on a table row
|
|
40
|
-
* @fires gv-table:mouseleave - when the pointer is leaving a table row
|
|
41
|
-
* @fires gv-table:sort - when the order is changed
|
|
42
|
-
*
|
|
43
|
-
* @attr {Array<any>} items - A list of items to display
|
|
44
|
-
* @attr {String} title - A title to display
|
|
45
|
-
* @attr {String} order - If defined, the table will be ordered by the field. Start with '-' to sort in desc
|
|
46
|
-
* @attr {Array<any>} options - The list of options to display
|
|
47
|
-
* @attr {Boolean} noheader - Used to hide the table header
|
|
48
|
-
* @attr {Boolean} nosort - Used to disable the click on header to sort
|
|
49
|
-
* @attr {String} rowsheight - The height of the table rows
|
|
50
|
-
* @attr {String} rowheight - The height of the table single row
|
|
51
|
-
* @attr {String} emptymessage - The empty message to display
|
|
52
|
-
* @attr {Function} format - A function to format table headers and string cells
|
|
53
|
-
* @attr {Function} compareFn - A function to define how to sort. Default function will sort selected field ignoring case
|
|
54
|
-
* @attr {Array<any>} selected - A list of selected ids of the items displayed
|
|
55
|
-
* @attr {String} total - Total of data displayed on the table (useful with in case of pagination)
|
|
56
|
-
* @attr {Boolean} skeleton - Force gv-table to be in skeleton mode
|
|
57
|
-
*
|
|
58
|
-
* @cssprop {Color} [--gv-table-selected--bgc=var(--gv-theme-color, #5a7684)] - Selected background color
|
|
59
|
-
* @cssprop {Color} [--gv-table-hover--bgc=var(--gv-theme-neutral-color-lighter, #fafafa)] - Row background color on hover
|
|
60
|
-
* @cssprop {Color} [--gv-table--bgc=var(--gv-theme-neutral-color-lightest, #ffffff)] - Background color
|
|
61
|
-
* @cssprop {Color} [--gv-table--bdc=var(--gv-theme-neutral-color-dark, #d9d9d9)] - Border color
|
|
62
|
-
* @cssprop {String} [--gv-table-header--fz=var(--gv-theme-font-size-l, 20px)] - Title font size
|
|
63
|
-
* @cssprop {Length} [--gv-table-header--p=2rem 4rem] - Title padding
|
|
64
|
-
* @cssprop {String} [--gv-table-rows--ov=auto] - Overflow on table
|
|
65
|
-
* @cssprop {Length} [--gv-table--colmg=0.2rem] - Column gap
|
|
66
|
-
* @cssprop {String} [--gv-table-row--ai=center] - Row align-items
|
|
67
|
-
* @cssprop {String} [--gv-table-row--ac=center] - Row align-content
|
|
68
|
-
* @cssprop {String} [--gv-table-cell--d=flex] - Cell display
|
|
69
|
-
*/
|
|
70
|
-
export class GvTable extends withResizeObserver(LitElement) {
|
|
71
|
-
static get properties() {
|
|
72
|
-
return {
|
|
73
|
-
items: { type: Array },
|
|
74
|
-
title: { type: String },
|
|
75
|
-
order: { type: String },
|
|
76
|
-
options: { type: Array },
|
|
77
|
-
noheader: { type: Boolean },
|
|
78
|
-
nosort: { type: Boolean },
|
|
79
|
-
rowsheight: { type: String },
|
|
80
|
-
rowheight: { type: String },
|
|
81
|
-
emptymessage: { type: String },
|
|
82
|
-
format: { type: Function },
|
|
83
|
-
compareFn: { type: Function },
|
|
84
|
-
selected: { type: Array, reflect: true },
|
|
85
|
-
total: { type: String },
|
|
86
|
-
skeleton: { type: Boolean },
|
|
87
|
-
_items: { type: Array, attribute: false },
|
|
88
|
-
_skeleton: { type: Boolean, attribute: false },
|
|
89
|
-
_error: { type: Boolean, attribute: false },
|
|
90
|
-
_empty: { type: Boolean, attribute: false },
|
|
91
|
-
_itemsProvider: { type: Array, attribute: false },
|
|
92
|
-
_page: { type: Number, attribute: false },
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static get styles() {
|
|
97
|
-
return [
|
|
98
|
-
link,
|
|
99
|
-
skeleton,
|
|
100
|
-
empty,
|
|
101
|
-
// language=CSS
|
|
102
|
-
css`
|
|
103
|
-
:host {
|
|
104
|
-
--selected--bgc: var(--gv-table-selected--bgc, var(--gv-theme-color, #5a7684));
|
|
105
|
-
--hover-bgc: var(--gv-table-hover--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));
|
|
106
|
-
--bgc: var(--gv-table--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));
|
|
107
|
-
--bdc: var(--gv-table--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9));
|
|
108
|
-
display: block;
|
|
109
|
-
height: 100%;
|
|
110
|
-
margin: 0.2rem;
|
|
111
|
-
box-sizing: border-box;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.table {
|
|
115
|
-
background-color: var(--bgc);
|
|
116
|
-
flex-direction: column;
|
|
117
|
-
height: 100%;
|
|
118
|
-
display: flex;
|
|
119
|
-
width: 100%;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.rows {
|
|
123
|
-
-ms-overflow-style: none;
|
|
124
|
-
scrollbar-width: none;
|
|
125
|
-
overflow: var(--gv-table-rows--ov, auto);
|
|
126
|
-
flex: 1;
|
|
127
|
-
height: 100%;
|
|
128
|
-
transition: height 250ms ease-in-out;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.rows::-webkit-scrollbar {
|
|
132
|
-
display: none;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
:host([w-lt-768]) .row {
|
|
136
|
-
height: 70px;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
:host([w-lt-580]) .row {
|
|
140
|
-
height: 60px;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
:host([w-lt-400]) .row {
|
|
144
|
-
height: 50px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.theader {
|
|
148
|
-
background-color: var(--gv-theme-neutral-color-lighter);
|
|
149
|
-
font-weight: bold;
|
|
150
|
-
padding: 0 0.2rem;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.row,
|
|
154
|
-
.theader {
|
|
155
|
-
align-items: var(--gv-table-row--ai, center);
|
|
156
|
-
align-content: var(--gv-table-row--ac, center);
|
|
157
|
-
border-right: solid thick transparent;
|
|
158
|
-
display: grid;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
div {
|
|
162
|
-
box-sizing: border-box;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.cell {
|
|
166
|
-
height: 100%;
|
|
167
|
-
display: var(--gv-table-cell--d, flex);
|
|
168
|
-
align-items: center;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.row:not(:last-child) {
|
|
172
|
-
box-shadow: 0 5px 3px -6px var(--bdc);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.row:hover,
|
|
176
|
-
.row.selected {
|
|
177
|
-
background-color: var(--hover-bgc);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.row.selected {
|
|
181
|
-
border-color: var(--selected--bgc);
|
|
182
|
-
box-sizing: border-box;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.header {
|
|
186
|
-
border-bottom: 1px solid var(--bdc);
|
|
187
|
-
padding: var(--gv-table-header--p, 2rem 4rem);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.title {
|
|
191
|
-
margin: 0;
|
|
192
|
-
text-transform: uppercase;
|
|
193
|
-
font-size: var(--gv-table-header--fz, var(--gv-theme-font-size-l, 20px));
|
|
194
|
-
line-height: var(--gv-table-header--fz, var(--gv-theme-font-size-l, 20px));
|
|
195
|
-
opacity: 0.6;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.title span {
|
|
199
|
-
font-weight: 600;
|
|
200
|
-
font-size: var(--gv-theme-font-size-s);
|
|
201
|
-
line-height: var(--gv-theme-font-size-s);
|
|
202
|
-
margin-left: 8px;
|
|
203
|
-
opacity: 0.7;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
gv-identity-picture {
|
|
207
|
-
height: 35px;
|
|
208
|
-
width: 35px;
|
|
209
|
-
--gv-image--of: contain;
|
|
210
|
-
margin-left: 20px;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
gv-icon {
|
|
214
|
-
transform: rotate(0deg);
|
|
215
|
-
--gv-icon--s: 18px;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
gv-icon.desc {
|
|
219
|
-
transform: rotate(180deg);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
gv-pagination {
|
|
223
|
-
align-self: flex-end;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.cell > *:not(gv-tag) {
|
|
227
|
-
margin: auto;
|
|
228
|
-
width: 100%;
|
|
229
|
-
}
|
|
230
|
-
`,
|
|
231
|
-
];
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
constructor() {
|
|
235
|
-
super();
|
|
236
|
-
this._id = new Date().getTime();
|
|
237
|
-
this.breakpoints = {
|
|
238
|
-
width: [400, 580, 768],
|
|
239
|
-
};
|
|
240
|
-
this._empty = false;
|
|
241
|
-
this.order = '';
|
|
242
|
-
this._page = 1;
|
|
243
|
-
this._itemsProvider = [];
|
|
244
|
-
this.selected = [];
|
|
245
|
-
this.compareFn = (item, item2, value) => {
|
|
246
|
-
const itemData =
|
|
247
|
-
this._getDataFromField(item, value) && this._getDataFromField(item, value).toLowerCase
|
|
248
|
-
? this._getDataFromField(item, value).toLowerCase()
|
|
249
|
-
: '';
|
|
250
|
-
const itemData2 =
|
|
251
|
-
this._getDataFromField(item2, value) && this._getDataFromField(item2, value).toLowerCase
|
|
252
|
-
? this._getDataFromField(item2, value).toLowerCase()
|
|
253
|
-
: '';
|
|
254
|
-
if (this.order.startsWith('-')) {
|
|
255
|
-
return itemData2.localeCompare(itemData);
|
|
256
|
-
} else {
|
|
257
|
-
return itemData.localeCompare(itemData2);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
this.addEventListener('gv-pagination:paginate', (e) => {
|
|
261
|
-
this._page = e.detail.page;
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
set items(items) {
|
|
266
|
-
this._skeleton = true;
|
|
267
|
-
Promise.resolve(items)
|
|
268
|
-
.then((items) => {
|
|
269
|
-
if (items) {
|
|
270
|
-
this._itemsProvider = items.map((item, index) => {
|
|
271
|
-
item._id = item.id == null ? index : item.id;
|
|
272
|
-
return item;
|
|
273
|
-
});
|
|
274
|
-
this._onSortChanged();
|
|
275
|
-
this._empty = this._itemsProvider.length === 0;
|
|
276
|
-
this._skeleton = false;
|
|
277
|
-
}
|
|
278
|
-
})
|
|
279
|
-
.catch((e) => {
|
|
280
|
-
console.error(e);
|
|
281
|
-
this._error = true;
|
|
282
|
-
this._skeleton = false;
|
|
283
|
-
this._itemsProvider = [];
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
get items() {
|
|
288
|
-
return this._itemsProvider;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
_onSortChanged(field, e) {
|
|
292
|
-
if (e) {
|
|
293
|
-
e.preventDefault();
|
|
294
|
-
}
|
|
295
|
-
if (this._itemsProvider && this.order) {
|
|
296
|
-
const desc = this.order.startsWith('-');
|
|
297
|
-
const previousOrder = desc ? this.order.substring(1) : this.order;
|
|
298
|
-
const value = field || previousOrder;
|
|
299
|
-
if (field) {
|
|
300
|
-
this.order = previousOrder === value ? (desc ? value : '-' + value) : value;
|
|
301
|
-
}
|
|
302
|
-
this._itemsProvider = this._itemsProvider.sort((item, item2) => this.compareFn(item, item2, value));
|
|
303
|
-
if (field) {
|
|
304
|
-
dispatchCustomEvent(this, 'sort', { order: this.order });
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
get _items() {
|
|
310
|
-
if (this._itemsProvider) {
|
|
311
|
-
if (this.options && this.options.paging && this.options.paging < this._itemsProvider.length) {
|
|
312
|
-
const index = (this._page - 1) * this.options.paging;
|
|
313
|
-
return [...this._itemsProvider].splice(index, this.options.paging);
|
|
314
|
-
}
|
|
315
|
-
return this._itemsProvider;
|
|
316
|
-
}
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
_getItemId(item) {
|
|
321
|
-
return item.id == null ? item._id : item.id;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
_onSelect(item, event) {
|
|
325
|
-
if (!this._skeleton && !event.target.dataset.preventSelect) {
|
|
326
|
-
if (this.options.selectable) {
|
|
327
|
-
const itemId = this._getItemId(item);
|
|
328
|
-
if (this._isSelected(item)) {
|
|
329
|
-
this.selected = this.selected.filter((id) => itemId !== id);
|
|
330
|
-
} else if (this.options.selectable === 'multi') {
|
|
331
|
-
this.selected = [...this.selected, itemId];
|
|
332
|
-
} else {
|
|
333
|
-
this.selected = [itemId];
|
|
334
|
-
}
|
|
335
|
-
dispatchCustomEvent(this, 'select', { items: this.selectedItems, options: this.options });
|
|
336
|
-
} else {
|
|
337
|
-
dispatchCustomEvent(this, 'select', { items: [item] });
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
get selectedItems() {
|
|
343
|
-
if (this.selected && this._itemsProvider) {
|
|
344
|
-
return this._itemsProvider.filter((item) => this.selected && this.selected.includes(this._getItemId(item)));
|
|
345
|
-
}
|
|
346
|
-
return [];
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
_onMouseEnter(item) {
|
|
350
|
-
if (!(this.selected && this.selected.length > 0) && !this._skeleton) {
|
|
351
|
-
dispatchCustomEvent(this, 'mouseenter', { item });
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
_onMouseLeave() {
|
|
356
|
-
if (!(this.selected && this.selected.length > 0) && !this._skeleton) {
|
|
357
|
-
dispatchCustomEvent(this, 'mouseleave');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
_renderHeader(styleGridColumns) {
|
|
362
|
-
if (this.noheader) {
|
|
363
|
-
return '';
|
|
364
|
-
} else {
|
|
365
|
-
const style = {
|
|
366
|
-
...styleGridColumns,
|
|
367
|
-
...{
|
|
368
|
-
height: this.rowheight,
|
|
369
|
-
'grid-auto-rows': this.rowheight ? null : 'minmax(80px, auto)',
|
|
370
|
-
},
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
return html` <div class=${classMap({ theader: true })} style=${styleMap(style)}>
|
|
374
|
-
${this.options && this.options.data && this._items && this._items.length
|
|
375
|
-
? repeat(
|
|
376
|
-
this.options.data,
|
|
377
|
-
(option) => option,
|
|
378
|
-
(option) => {
|
|
379
|
-
const orderValue = this.order && this.order.startsWith('-') ? this.order.substring(1) : this.order;
|
|
380
|
-
const label = this.format && option.label ? this.format(option.label) : option.label;
|
|
381
|
-
const style = typeof option.headerStyle === 'function' ? option.headerStyle(label) : option.headerStyle;
|
|
382
|
-
return html` <div style="${style || ''}">
|
|
383
|
-
${this.order && !this.nosort
|
|
384
|
-
? html`
|
|
385
|
-
<gv-button link @click="${this._onSortChanged.bind(this, option.field || option.tag)}">${until(label)}</gv-button>
|
|
386
|
-
${
|
|
387
|
-
orderValue === option.tag || (orderValue === option.field && option.type !== 'image')
|
|
388
|
-
? html` <gv-icon class=${classMap({ desc: this.order.startsWith('-') })} shape="design:triangle"></gv-icon>`
|
|
389
|
-
: ''
|
|
390
|
-
}
|
|
391
|
-
</a>`
|
|
392
|
-
: until(label)}
|
|
393
|
-
</div>`;
|
|
394
|
-
},
|
|
395
|
-
)
|
|
396
|
-
: ''}
|
|
397
|
-
</div>`;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
_renderIcon(item, itemIndex, option) {
|
|
402
|
-
const icon = typeof option.icon === 'function' ? option.icon(item) : option.icon;
|
|
403
|
-
const iconTitle = typeof option.iconTitle === 'function' ? option.iconTitle(item) : option.iconTitle;
|
|
404
|
-
if (icon) {
|
|
405
|
-
return html` <gv-icon shape="${icon}" title="${iconTitle}"></gv-icon>`;
|
|
406
|
-
}
|
|
407
|
-
return '';
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
_renderComponent(item, itemIndex, option, value, type) {
|
|
411
|
-
if (option.condition && !option.condition(item)) {
|
|
412
|
-
return '';
|
|
413
|
-
}
|
|
414
|
-
const element = document.createElement(type);
|
|
415
|
-
element.value = value;
|
|
416
|
-
if (option.attributes) {
|
|
417
|
-
Object.keys(option.attributes).forEach((attribute) => {
|
|
418
|
-
if (attribute.startsWith('on')) {
|
|
419
|
-
const event = attribute.replace('on', '').toLowerCase();
|
|
420
|
-
if (event === 'click') {
|
|
421
|
-
element.classList.add('link');
|
|
422
|
-
}
|
|
423
|
-
element.dataset.preventSelect = true;
|
|
424
|
-
element.addEventListener(event, (e) => {
|
|
425
|
-
e.stopPropagation();
|
|
426
|
-
const optionConfirm = typeof option.confirm === 'function' ? option.confirm(item) : option.confirm;
|
|
427
|
-
if (optionConfirm == null) {
|
|
428
|
-
setTimeout(() => {
|
|
429
|
-
option.attributes[attribute](item, e, element, this);
|
|
430
|
-
}, 0);
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
} else if (typeof option.attributes[attribute] === 'function') {
|
|
434
|
-
const value = option.attributes[attribute](item);
|
|
435
|
-
if (value != null) {
|
|
436
|
-
element[attribute] = value;
|
|
437
|
-
}
|
|
438
|
-
} else {
|
|
439
|
-
if (this.format && typeof option.attributes[attribute] === 'string') {
|
|
440
|
-
this.format(option.attributes[attribute]).then((t) => {
|
|
441
|
-
element[attribute] = t;
|
|
442
|
-
});
|
|
443
|
-
} else {
|
|
444
|
-
element[attribute] = option.attributes[attribute];
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
element.addEventListener('input', (event) => {
|
|
450
|
-
this._items[itemIndex][option.field] = event.target.value;
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
const optionConfirm = typeof option.confirm === 'function' ? option.confirm(item) : option.confirm;
|
|
454
|
-
|
|
455
|
-
if (optionConfirm) {
|
|
456
|
-
const confirm = document.createElement('gv-confirm');
|
|
457
|
-
if (this.format) {
|
|
458
|
-
this.format(optionConfirm.msg).then((t) => (confirm.message = t));
|
|
459
|
-
} else {
|
|
460
|
-
confirm.message = optionConfirm.msg;
|
|
461
|
-
}
|
|
462
|
-
if (optionConfirm.danger) {
|
|
463
|
-
confirm.danger = true;
|
|
464
|
-
}
|
|
465
|
-
confirm.addEventListener('click', (e) => e.stopPropagation());
|
|
466
|
-
confirm.addEventListener('gv-confirm:ok', (e) => {
|
|
467
|
-
e.stopPropagation();
|
|
468
|
-
option.attributes.onClick(item, e, element);
|
|
469
|
-
});
|
|
470
|
-
confirm.appendChild(element);
|
|
471
|
-
return confirm;
|
|
472
|
-
}
|
|
473
|
-
return element;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
_renderCell(formattedValue, option, item, itemIndex) {
|
|
477
|
-
if (option.type) {
|
|
478
|
-
if (option.type === 'image') {
|
|
479
|
-
let alt = '';
|
|
480
|
-
if (option.alt) {
|
|
481
|
-
if (typeof option.alt === 'function') {
|
|
482
|
-
alt = option.alt(item);
|
|
483
|
-
} else {
|
|
484
|
-
alt = this._getDataFromField(item, option.alt);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return this._renderImage(formattedValue, alt);
|
|
488
|
-
} else if (typeof option.type === 'function') {
|
|
489
|
-
return this._renderComponent(item, itemIndex, option, formattedValue, option.type(item));
|
|
490
|
-
} else if (option.type.startsWith('gv-')) {
|
|
491
|
-
return this._renderComponent(item, itemIndex, option, formattedValue, option.type);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return until(formattedValue);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
_getFormattedCellValue(option, item) {
|
|
498
|
-
let value = option.field ? this._getDataFromField(item, option.field) : '';
|
|
499
|
-
|
|
500
|
-
if (value) {
|
|
501
|
-
if (option.type === 'date') {
|
|
502
|
-
value = new Date(value).toLocaleDateString(getLanguage());
|
|
503
|
-
} else if (option.type === 'datetime') {
|
|
504
|
-
value = new Date(value).toLocaleString(getLanguage());
|
|
505
|
-
} else if (option.type === 'time') {
|
|
506
|
-
value = new Date(value).toLocaleTimeString(getLanguage());
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
if (option.format) {
|
|
511
|
-
value = option.format(value);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return value;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
_isSelected(item) {
|
|
518
|
-
return this.selected && this.selected.includes(this._getItemId(item));
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
_renderRows(styleGridColumns) {
|
|
522
|
-
return html` <div
|
|
523
|
-
class="rows"
|
|
524
|
-
style=${styleMap({ height: this.rowsheight, 'user-select': this.options.selectable ? 'none' : '' })}
|
|
525
|
-
@mouseleave="${this._onMouseLeave.bind(this)}"
|
|
526
|
-
>
|
|
527
|
-
${this._items && this._items.length
|
|
528
|
-
? repeat(
|
|
529
|
-
this._items,
|
|
530
|
-
(item) => item,
|
|
531
|
-
(item, itemIndex) => {
|
|
532
|
-
return html`
|
|
533
|
-
<div class=${classMap({
|
|
534
|
-
row: true,
|
|
535
|
-
skeleton: this._skeleton,
|
|
536
|
-
selected: this._isSelected(item),
|
|
537
|
-
})} style=${styleMap({
|
|
538
|
-
...styleGridColumns,
|
|
539
|
-
...{
|
|
540
|
-
height: this.rowheight,
|
|
541
|
-
'grid-auto-rows': this.rowheight ? null : 'minmax(80px, auto)',
|
|
542
|
-
cursor: this.options.selectable ? 'pointer' : '',
|
|
543
|
-
'border-color': this.options.selectable && this._isSelected(item) ? 'var(--selected--bgc)' : '',
|
|
544
|
-
'column-gap': 'var(--gv-table--colmg, 0.2rem)',
|
|
545
|
-
},
|
|
546
|
-
})}
|
|
547
|
-
@click="${this._onSelect.bind(this, item)}"
|
|
548
|
-
@mouseenter="${this._onMouseEnter.bind(this, item)}">
|
|
549
|
-
${
|
|
550
|
-
this.options && this.options.data
|
|
551
|
-
? repeat(
|
|
552
|
-
this.options.data,
|
|
553
|
-
(option) => option,
|
|
554
|
-
(option) => {
|
|
555
|
-
const style = typeof option.style === 'function' ? option.style(item) : option.style;
|
|
556
|
-
const formattedValue = this._getFormattedCellValue(option, item);
|
|
557
|
-
return html`<div class="cell" style="${ifDefined(style)}" title="${formattedValue}">
|
|
558
|
-
${this._renderCell(formattedValue, option, item, itemIndex)}${this._renderTag(option, item)}${option.icon
|
|
559
|
-
? this._renderIcon(item, itemIndex, option)
|
|
560
|
-
: ''}
|
|
561
|
-
</div> `;
|
|
562
|
-
},
|
|
563
|
-
)
|
|
564
|
-
: ''
|
|
565
|
-
}
|
|
566
|
-
</div>
|
|
567
|
-
</div>`;
|
|
568
|
-
},
|
|
569
|
-
)
|
|
570
|
-
: ''}
|
|
571
|
-
</div>`;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
_renderItems() {
|
|
575
|
-
let widthTemplate = this.options.data.map((o) => {
|
|
576
|
-
if (o.width) {
|
|
577
|
-
return o.width;
|
|
578
|
-
} else if (o.type === 'image') {
|
|
579
|
-
return '80px';
|
|
580
|
-
} else if (o.type === 'icon') {
|
|
581
|
-
return '40px';
|
|
582
|
-
}
|
|
583
|
-
return null;
|
|
584
|
-
});
|
|
585
|
-
const fixedData = widthTemplate.filter((width) => width !== null);
|
|
586
|
-
const fixedWidth = fixedData.reduce((acc, width) => {
|
|
587
|
-
return acc + parseInt(width.replace('px', ''), 10);
|
|
588
|
-
}, 0);
|
|
589
|
-
|
|
590
|
-
widthTemplate = widthTemplate.map((width) => {
|
|
591
|
-
if (width == null) {
|
|
592
|
-
const columnGap = getCssVar(this, '--gv-table--colmg', '0.2rem');
|
|
593
|
-
return `calc((100% - ( ${fixedWidth}px + ${this.options.data.length - 1} * ${columnGap} ) ) / ${
|
|
594
|
-
this.options.data.length - fixedData.length
|
|
595
|
-
})`;
|
|
596
|
-
}
|
|
597
|
-
return width;
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
const styleGridColumns = { 'grid-template-columns': widthTemplate.join(' ') };
|
|
601
|
-
return html` ${this._renderHeader(styleGridColumns)} ${this._renderRows(styleGridColumns)} ${this._renderPagination()} `;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
_renderPagination() {
|
|
605
|
-
if (this.options && this.options.paging && this._itemsProvider) {
|
|
606
|
-
const paginationData = {
|
|
607
|
-
first: 1,
|
|
608
|
-
last: this._itemsProvider.length / this.options.paging,
|
|
609
|
-
total: this._itemsProvider.length,
|
|
610
|
-
current_page: this._page,
|
|
611
|
-
total_pages: this._itemsProvider.length / this.options.paging,
|
|
612
|
-
};
|
|
613
|
-
return html`<gv-pagination .data="${paginationData}" widget="true"></gv-pagination>`;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
_getDataFromField(item, field) {
|
|
618
|
-
if (typeof field === 'function') {
|
|
619
|
-
return field(item);
|
|
620
|
-
} else {
|
|
621
|
-
return field.split('.').reduce((p, c) => p && p[c], item);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
_renderTag(option, item) {
|
|
626
|
-
if (option.tag) {
|
|
627
|
-
let tag;
|
|
628
|
-
if (typeof option.tag === 'function') {
|
|
629
|
-
tag = option.tag(item);
|
|
630
|
-
} else {
|
|
631
|
-
tag = option.format ? option.format(this._getDataFromField(item, option.tag)) : this._getDataFromField(item, option.tag);
|
|
632
|
-
}
|
|
633
|
-
if (tag) {
|
|
634
|
-
return html` <gv-tag ?skeleton="${this._skeleton}">${tag}</gv-tag>`;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return '';
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
_onImageLoaded() {
|
|
641
|
-
this._skeleton = false;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
_renderImage(picture, alt) {
|
|
645
|
-
return html`<gv-identity-picture .picture="${picture}" .display_name="${alt}"></gv-identity-picture>`;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
updated(props) {
|
|
649
|
-
this._onSortChanged();
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
render() {
|
|
653
|
-
if (this._error) {
|
|
654
|
-
return html`<div class="error">${i18n('gv-table.error')}</div>`;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
const classes = {
|
|
658
|
-
table: true,
|
|
659
|
-
skeleton: this._skeleton || this.skeleton,
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
const emptyStyle = {
|
|
663
|
-
height: this.rowsheight ? this.rowsheight : '',
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
return html`
|
|
667
|
-
<div class=${classMap(classes)} style="${styleMap({ display: this.rowsheight ? 'block' : 'flex' })}">
|
|
668
|
-
${this.title
|
|
669
|
-
? html` <div class="header">
|
|
670
|
-
<h3 class="title">
|
|
671
|
-
${this.title} ${!this._empty ? html`<span>(${this.total || (this._items && this._items.length)})</span>` : ''}
|
|
672
|
-
</h3>
|
|
673
|
-
</div>`
|
|
674
|
-
: ''}
|
|
675
|
-
${!this._empty && this.options && this.options.data
|
|
676
|
-
? this._renderItems()
|
|
677
|
-
: html` <div class="empty" style="${styleMap(emptyStyle)}">
|
|
678
|
-
${this.emptymessage ? this.emptymessage : i18n('gv-table.empty')}
|
|
679
|
-
</div>`}
|
|
680
|
-
</div>
|
|
681
|
-
`;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
window.customElements.define('gv-table', GvTable);
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.GvTable=void 0;const t=require("lit"),e=require("../styles/skeleton"),i=require("../styles/empty"),s=require("../styles/link"),r=require("lit/directives/class-map"),o=require("lit/directives/repeat"),n=require("../lib/events"),a=require("../lib/i18n"),l=require("lit/directives/until"),h=require("lit/directives/style-map"),d=require("../mixins/with-resize-observer"),g=require("lit/directives/if-defined");require("../atoms/gv-image"),require("../organisms/gv-pagination");const c=require("../lib/style");class p extends((0,d.withResizeObserver)(t.LitElement)){static get properties(){return{items:{type:Array},title:{type:String},order:{type:String},options:{type:Array},noheader:{type:Boolean},nosort:{type:Boolean},rowsheight:{type:String},rowheight:{type:String},emptymessage:{type:String},format:{type:Function},compareFn:{type:Function},selected:{type:Array,reflect:!0},total:{type:String},skeleton:{type:Boolean},_items:{type:Array,attribute:!1},_skeleton:{type:Boolean,attribute:!1},_error:{type:Boolean,attribute:!1},_empty:{type:Boolean,attribute:!1},_itemsProvider:{type:Array,attribute:!1},_page:{type:Number,attribute:!1}}}static get styles(){return[s.link,e.skeleton,i.empty,t.css`:host{--selected--bgc:var(--gv-table-selected--bgc, var(--gv-theme-color, #5a7684));--hover-bgc:var(--gv-table-hover--bgc, var(--gv-theme-neutral-color-lighter, #fafafa));--bgc:var(--gv-table--bgc, var(--gv-theme-neutral-color-lightest, #ffffff));--bdc:var(--gv-table--bdc, var(--gv-theme-neutral-color-dark, #d9d9d9));display:block;height:100%;margin:.2rem;box-sizing:border-box}.table{background-color:var(--bgc);flex-direction:column;height:100%;display:flex;width:100%}.rows{-ms-overflow-style:none;scrollbar-width:none;overflow:var(--gv-table-rows--ov,auto);flex:1;height:100%;transition:height 250ms ease-in-out}.rows::-webkit-scrollbar{display:none}:host([w-lt-768]) .row{height:70px}:host([w-lt-580]) .row{height:60px}:host([w-lt-400]) .row{height:50px}.theader{background-color:var(--gv-theme-neutral-color-lighter);font-weight:700;padding:0 .2rem}.row,.theader{align-items:var(--gv-table-row--ai,center);align-content:var(--gv-table-row--ac,center);border-right:solid thick transparent;display:grid}div{box-sizing:border-box}.cell{height:100%;display:var(--gv-table-cell--d,flex);align-items:center}.row:not(:last-child){box-shadow:0 5px 3px -6px var(--bdc)}.row.selected,.row:hover{background-color:var(--hover-bgc)}.row.selected{border-color:var(--selected--bgc);box-sizing:border-box}.header{border-bottom:1px solid var(--bdc);padding:var(--gv-table-header--p,2rem 4rem)}.title{margin:0;text-transform:uppercase;font-size:var(--gv-table-header--fz,var(--gv-theme-font-size-l,20px));line-height:var(--gv-table-header--fz,var(--gv-theme-font-size-l,20px));opacity:.6}.title span{font-weight:600;font-size:var(--gv-theme-font-size-s);line-height:var(--gv-theme-font-size-s);margin-left:8px;opacity:.7}gv-identity-picture{height:35px;width:35px;--gv-image--of:contain;margin-left:20px}gv-icon{transform:rotate(0);--gv-icon--s:18px}gv-icon.desc{transform:rotate(180deg)}gv-pagination{align-self:flex-end}.cell>:not(gv-tag){margin:auto;width:100%}`]}constructor(){super(),this._id=(new Date).getTime(),this.breakpoints={width:[400,580,768]},this._empty=!1,this.order="",this._page=1,this._itemsProvider=[],this.selected=[],this.compareFn=(t,e,i)=>{const s=this._getDataFromField(t,i)&&this._getDataFromField(t,i).toLowerCase?this._getDataFromField(t,i).toLowerCase():"",r=this._getDataFromField(e,i)&&this._getDataFromField(e,i).toLowerCase?this._getDataFromField(e,i).toLowerCase():"";return this.order.startsWith("-")?r.localeCompare(s):s.localeCompare(r)},this.addEventListener("gv-pagination:paginate",(t=>{this._page=t.detail.page}))}set items(t){this._skeleton=!0,Promise.resolve(t).then((t=>{t&&(this._itemsProvider=t.map(((t,e)=>(t._id=null==t.id?e:t.id,t))),this._onSortChanged(),this._empty=0===this._itemsProvider.length,this._skeleton=!1)})).catch((t=>{console.error(t),this._error=!0,this._skeleton=!1,this._itemsProvider=[]}))}get items(){return this._itemsProvider}_onSortChanged(t,e){if(e&&e.preventDefault(),this._itemsProvider&&this.order){const e=this.order.startsWith("-"),i=e?this.order.substring(1):this.order,s=t||i;t&&(this.order=i===s?e?s:"-"+s:s),this._itemsProvider=this._itemsProvider.sort(((t,e)=>this.compareFn(t,e,s))),t&&(0,n.dispatchCustomEvent)(this,"sort",{order:this.order})}}get _items(){if(this._itemsProvider){if(this.options&&this.options.paging&&this.options.paging<this._itemsProvider.length){const t=(this._page-1)*this.options.paging;return[...this._itemsProvider].splice(t,this.options.paging)}return this._itemsProvider}return[]}_getItemId(t){return null==t.id?t._id:t.id}_onSelect(t,e){if(!this._skeleton&&!e.target.dataset.preventSelect)if(this.options.selectable){const e=this._getItemId(t);this._isSelected(t)?this.selected=this.selected.filter((t=>e!==t)):"multi"===this.options.selectable?this.selected=[...this.selected,e]:this.selected=[e],(0,n.dispatchCustomEvent)(this,"select",{items:this.selectedItems,options:this.options})}else(0,n.dispatchCustomEvent)(this,"select",{items:[t]})}get selectedItems(){return this.selected&&this._itemsProvider?this._itemsProvider.filter((t=>this.selected&&this.selected.includes(this._getItemId(t)))):[]}_onMouseEnter(t){this.selected&&this.selected.length>0||this._skeleton||(0,n.dispatchCustomEvent)(this,"mouseenter",{item:t})}_onMouseLeave(){this.selected&&this.selected.length>0||this._skeleton||(0,n.dispatchCustomEvent)(this,"mouseleave")}_renderHeader(e){if(this.noheader)return"";{const i={...e,height:this.rowheight,"grid-auto-rows":this.rowheight?null:"minmax(80px, auto)"};return t.html`<div class="${(0,r.classMap)({theader:!0})}" style="${(0,h.styleMap)(i)}">${this.options&&this.options.data&&this._items&&this._items.length?(0,o.repeat)(this.options.data,(t=>t),(e=>{const i=this.order&&this.order.startsWith("-")?this.order.substring(1):this.order,s=this.format&&e.label?this.format(e.label):e.label,o="function"==typeof e.headerStyle?e.headerStyle(s):e.headerStyle;return t.html`<div style="${o||""}">${this.order&&!this.nosort?t.html`<gv-button link @click="${this._onSortChanged.bind(this,e.field||e.tag)}">${(0,l.until)(s)}</gv-button>${i===e.tag||i===e.field&&"image"!==e.type?t.html`<gv-icon class="${(0,r.classMap)({desc:this.order.startsWith("-")})}" shape="design:triangle"></gv-icon>`:""}`:(0,l.until)(s)}</div>`})):""}</div>`}}_renderIcon(e,i,s){const r="function"==typeof s.icon?s.icon(e):s.icon,o="function"==typeof s.iconTitle?s.iconTitle(e):s.iconTitle;return r?t.html`<gv-icon shape="${r}" title="${o}"></gv-icon>`:""}_renderComponent(t,e,i,s,r){if(i.condition&&!i.condition(t))return"";const o=document.createElement(r);o.value=s,i.attributes&&Object.keys(i.attributes).forEach((e=>{if(e.startsWith("on")){const s=e.replace("on","").toLowerCase();"click"===s&&o.classList.add("link"),o.dataset.preventSelect=!0,o.addEventListener(s,(s=>{s.stopPropagation();null==("function"==typeof i.confirm?i.confirm(t):i.confirm)&&setTimeout((()=>{i.attributes[e](t,s,o,this)}),0)}))}else if("function"==typeof i.attributes[e]){const s=i.attributes[e](t);null!=s&&(o[e]=s)}else this.format&&"string"==typeof i.attributes[e]?this.format(i.attributes[e]).then((t=>{o[e]=t})):o[e]=i.attributes[e]})),o.addEventListener("input",(t=>{this._items[e][i.field]=t.target.value}));const n="function"==typeof i.confirm?i.confirm(t):i.confirm;if(n){const e=document.createElement("gv-confirm");return this.format?this.format(n.msg).then((t=>e.message=t)):e.message=n.msg,n.danger&&(e.danger=!0),e.addEventListener("click",(t=>t.stopPropagation())),e.addEventListener("gv-confirm:ok",(e=>{e.stopPropagation(),i.attributes.onClick(t,e,o)})),e.appendChild(o),e}return o}_renderCell(t,e,i,s){if(e.type){if("image"===e.type){let s="";return e.alt&&(s="function"==typeof e.alt?e.alt(i):this._getDataFromField(i,e.alt)),this._renderImage(t,s)}if("function"==typeof e.type)return this._renderComponent(i,s,e,t,e.type(i));if(e.type.startsWith("gv-"))return this._renderComponent(i,s,e,t,e.type)}return(0,l.until)(t)}_getFormattedCellValue(t,e){let i=t.field?this._getDataFromField(e,t.field):"";return i&&("date"===t.type?i=new Date(i).toLocaleDateString((0,a.getLanguage)()):"datetime"===t.type?i=new Date(i).toLocaleString((0,a.getLanguage)()):"time"===t.type&&(i=new Date(i).toLocaleTimeString((0,a.getLanguage)()))),t.format&&(i=t.format(i)),i}_isSelected(t){return this.selected&&this.selected.includes(this._getItemId(t))}_renderRows(e){return t.html`<div class="rows" style="${(0,h.styleMap)({height:this.rowsheight,"user-select":this.options.selectable?"none":""})}" @mouseleave="${this._onMouseLeave.bind(this)}">${this._items&&this._items.length?(0,o.repeat)(this._items,(t=>t),((i,s)=>t.html`<div class="${(0,r.classMap)({row:!0,skeleton:this._skeleton,selected:this._isSelected(i)})}" style="${(0,h.styleMap)({...e,height:this.rowheight,"grid-auto-rows":this.rowheight?null:"minmax(80px, auto)",cursor:this.options.selectable?"pointer":"","border-color":this.options.selectable&&this._isSelected(i)?"var(--selected--bgc)":"","column-gap":"var(--gv-table--colmg, 0.2rem)"})}" @click="${this._onSelect.bind(this,i)}" @mouseenter="${this._onMouseEnter.bind(this,i)}">${this.options&&this.options.data?(0,o.repeat)(this.options.data,(t=>t),(e=>{const r="function"==typeof e.style?e.style(i):e.style,o=this._getFormattedCellValue(e,i);return t.html`<div class="cell" style="${(0,g.ifDefined)(r)}" title="${o}">${this._renderCell(o,e,i,s)}${this._renderTag(e,i)}${e.icon?this._renderIcon(i,s,e):""}</div>`})):""}</div>`)):""}</div>`}_renderItems(){let e=this.options.data.map((t=>t.width?t.width:"image"===t.type?"80px":"icon"===t.type?"40px":null));const i=e.filter((t=>null!==t)),s=i.reduce(((t,e)=>t+parseInt(e.replace("px",""),10)),0);e=e.map((t=>{if(null==t){const t=(0,c.getCssVar)(this,"--gv-table--colmg","0.2rem");return`calc((100% - ( ${s}px + ${this.options.data.length-1} * ${t} ) ) / ${this.options.data.length-i.length})`}return t}));const r={"grid-template-columns":e.join(" ")};return t.html`${this._renderHeader(r)} ${this._renderRows(r)} ${this._renderPagination()}`}_renderPagination(){if(this.options&&this.options.paging&&this._itemsProvider){const e={first:1,last:this._itemsProvider.length/this.options.paging,total:this._itemsProvider.length,current_page:this._page,total_pages:this._itemsProvider.length/this.options.paging};return t.html`<gv-pagination .data="${e}" widget="true"></gv-pagination>`}}_getDataFromField(t,e){return"function"==typeof e?e(t):e.split(".").reduce(((t,e)=>t&&t[e]),t)}_renderTag(e,i){if(e.tag){let s;if(s="function"==typeof e.tag?e.tag(i):e.format?e.format(this._getDataFromField(i,e.tag)):this._getDataFromField(i,e.tag),s)return t.html`<gv-tag ?skeleton="${this._skeleton}">${s}</gv-tag>`}return""}_onImageLoaded(){this._skeleton=!1}_renderImage(e,i){return t.html`<gv-identity-picture .picture="${e}" .display_name="${i}"></gv-identity-picture>`}updated(t){this._onSortChanged()}render(){if(this._error)return t.html`<div class="error">${(0,a.i18n)("gv-table.error")}</div>`;const e={table:!0,skeleton:this._skeleton||this.skeleton},i={height:this.rowsheight?this.rowsheight:""};return t.html`<div class="${(0,r.classMap)(e)}" style="${(0,h.styleMap)({display:this.rowsheight?"block":"flex"})}">${this.title?t.html`<div class="header"><h3 class="title">${this.title} ${this._empty?"":t.html`<span>(${this.total||this._items&&this._items.length})</span>`}</h3></div>`:""} ${!this._empty&&this.options&&this.options.data?this._renderItems():t.html`<div class="empty" style="${(0,h.styleMap)(i)}">${this.emptymessage?this.emptymessage:(0,a.i18n)("gv-table.empty")}</div>`}</div>`}}exports.GvTable=p,window.customElements.define("gv-table",p);
|