@emuanalytics/flow-rdf-ui 4.1.0-preview.13 → 4.1.0-preview.15

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.
@@ -1,33 +1,53 @@
1
- import { html } from 'lit';
1
+ import { html, nothing } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
3
  import FlowRdfElement from '../../internal/flow-ui-rdf-element.mjs';
4
4
  import { HasSlotController } from '../../internal/slot.mjs';
5
5
  import styles from './card.styles.mjs';
6
+ import { isStringFull } from '@emuanalytics/flow-rdf-core/utils';
7
+ import { property } from 'lit/decorators.js';
6
8
 
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __decorateClass = (decorators, target, key, kind) => {
12
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
13
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
14
+ if (decorator = decorators[i])
15
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
16
+ if (kind && result)
17
+ __defProp(target, key, result);
18
+ return result;
19
+ };
7
20
  class FlowUiCard extends FlowRdfElement {
8
21
  constructor() {
9
22
  super(...arguments);
10
23
  this.hasSlotController = new HasSlotController(this, "footer", "header", "image");
24
+ this.title = "";
11
25
  }
12
26
  render() {
27
+ const hasHeader = isStringFull(this.title) ?? this.hasSlotController.test("title");
13
28
  return html`
14
29
  <div
15
30
  part="base"
16
31
  class=${classMap({
17
32
  card: true,
18
- "card--has-footer": this.hasSlotController.test("footer"),
19
- "card--has-image": this.hasSlotController.test("image"),
20
- "card--has-header": this.hasSlotController.test("header")
33
+ "card--has-header": hasHeader
21
34
  })}
35
+ title=""
22
36
  >
23
- <slot name="image" part="image" class="card__image"></slot>
24
- <slot name="header" part="header" class="card__header"></slot>
37
+ ${hasHeader ? html`
38
+ <header part="header" class="card__header">
39
+ <span part="title" class="card__title"><slot name="title">${this.title}</slot></span>
40
+ </header>
41
+ ` : nothing}
42
+
25
43
  <slot part="body" class="card__body"></slot>
26
- <slot name="footer" part="footer" class="card__footer"></slot>
27
44
  </div>
28
45
  `;
29
46
  }
30
47
  }
31
48
  FlowUiCard.styles = styles;
49
+ __decorateClass([
50
+ property({ reflect: true })
51
+ ], FlowUiCard.prototype, "title", 2);
32
52
 
33
53
  export { FlowUiCard as default };
@@ -5,6 +5,8 @@ const styles = css`
5
5
  ${componentStyles}
6
6
 
7
7
  :host {
8
+ display: block;
9
+
8
10
  --border-color: var(--flow-ui-card-border-color);
9
11
  --border-radius: var(--flow-ui-card-border-radius);
10
12
  --border-width: var(--flow-ui-card-border-width);
@@ -12,8 +14,6 @@ const styles = css`
12
14
 
13
15
  --background-color: var(--flow-ui-card-background-color);
14
16
  --color: var(--flow-ui-card-color);
15
-
16
- display: inline-block;
17
17
  }
18
18
 
19
19
  .card {
@@ -26,36 +26,9 @@ const styles = css`
26
26
  border-radius: var(--border-radius);
27
27
  }
28
28
 
29
- .card__image {
30
- display: flex;
31
- border-top-left-radius: var(--border-radius);
32
- border-top-right-radius: var(--border-radius);
33
- margin: calc(-1 * var(--border-width));
34
- overflow: hidden;
35
- }
36
-
37
- .card__image::slotted(img) {
38
- display: block;
39
- width: 100%;
40
- }
41
-
42
- .card:not(.card--has-image) .card__image {
43
- display: none;
44
- }
45
-
46
29
  .card__header {
47
- display: block;
48
- border-bottom: solid var(--border-width) var(--border-color);
49
30
  padding: calc(var(--padding) / 2) var(--padding);
50
- }
51
-
52
- .card:not(.card--has-header) .card__header {
53
- display: none;
54
- }
55
-
56
- .card:not(.card--has-image) .card__header {
57
- border-top-left-radius: var(--border-radius);
58
- border-top-right-radius: var(--border-radius);
31
+ padding-bottom: 0;
59
32
  }
60
33
 
61
34
  .card__body {
@@ -63,16 +36,6 @@ const styles = css`
63
36
  padding: var(--padding);
64
37
  }
65
38
 
66
- .card--has-footer .card__footer {
67
- display: block;
68
- border-top: solid var(--border-width) var(--border-color);
69
- padding: var(--padding);
70
- }
71
-
72
- .card:not(.card--has-footer) .card__footer {
73
- display: none;
74
- }
75
-
76
39
  /* Remove margin from first and last child of default slot */
77
40
  ::slotted(:nth-child(1 of :not([slot]))) {
78
41
  margin-top: 0;
@@ -1,10 +1,12 @@
1
1
  import { Chart } from 'chart.js';
2
- import { html } from 'lit';
2
+ import { html, nothing } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { createRef, ref } from 'lit/directives/ref.js';
5
5
  import FlowRdfElement from '../../internal/flow-ui-rdf-element.mjs';
6
6
  import { watch } from '../../internal/watch.mjs';
7
7
  import styles from './chart.styles.mjs';
8
+ import { HasSlotController } from '../../internal/slot.mjs';
9
+ import { isStringFull } from '../../internal/type-checks.mjs';
8
10
  import { initializeChartJs } from './chartjs-support.mjs';
9
11
 
10
12
  var __defProp = Object.defineProperty;
@@ -21,7 +23,9 @@ var __decorateClass = (decorators, target, key, kind) => {
21
23
  class FlowUiChart extends FlowRdfElement {
22
24
  constructor() {
23
25
  super(...arguments);
26
+ this.hasSlotController = new HasSlotController(this, "label");
24
27
  this._chartRef = createRef();
28
+ this.title = "";
25
29
  this.plugins = [];
26
30
  }
27
31
  /** The Chart.js chart instance. */
@@ -54,14 +58,26 @@ class FlowUiChart extends FlowRdfElement {
54
58
  }
55
59
  }
56
60
  render() {
61
+ const hasHeader = isStringFull(this.title) || this.hasSlotController.test("title");
57
62
  return html`
58
- <div part="base" class="chart">
59
- <canvas ${ref(this._chartRef)}></canvas>
63
+ <div part="base" class="chart" title="">
64
+ ${hasHeader ? html`
65
+ <header part="header" class="chart__header">
66
+ <span part="title" class="chart__title"><slot name="title">${this.title}</slot></span>
67
+ </header>
68
+ ` : nothing}
69
+
70
+ <div class="chart_container">
71
+ <canvas ${ref(this._chartRef)}></canvas>
72
+ </div>
60
73
  </div>
61
74
  `;
62
75
  }
63
76
  }
64
77
  FlowUiChart.styles = styles;
78
+ __decorateClass([
79
+ property({ reflect: true })
80
+ ], FlowUiChart.prototype, "title", 2);
65
81
  __decorateClass([
66
82
  property()
67
83
  ], FlowUiChart.prototype, "type", 2);
@@ -66,14 +66,33 @@ const styles = css`
66
66
 
67
67
  --dataset-stroke-color-9: var(--flow-ui-chart-stroke-color-9, hsl(292.1 88.4% 57.7%));
68
68
  --dataset-fill-color-9: var(--flow-ui-chart-fill-color-9, hsl(292.1 88.4% 57.7%));
69
+
70
+ --header-padding: var(--flow-ui-chart-header-padding, var(--flow-ui-spacing-x-small));
71
+ --header-height: var(--flow-ui-chart-header-height, var(--flow-ui-control-height-medium));
72
+ --header-font-size: var(--flow-ui-chart-header-font-size, var(--flow-ui-font-size-medium));
73
+ --header-color: var(--flow-ui-chart-header-color, var(--flow-ui-color-text));
69
74
  }
70
75
 
71
76
  .chart {
77
+ height: 100%;
72
78
  background-color: var(--background-color);
79
+ display: flex;
80
+ flex-direction: column;
81
+ }
82
+
83
+ .chart__header {
84
+ flex: 0 0 auto;
85
+ padding: var(--header-padding);
86
+ height: var(--header-height);
87
+ font-size: var(--header-font-size);
88
+ color: var(--header-color);
89
+ }
90
+
91
+ .chart_container {
92
+ flex: 1;
73
93
  position: relative;
74
94
  width: 100%;
75
95
  height: 100%;
76
- /* padding: var(--flow-ui-spacing-x-small); */
77
96
  }
78
97
  `;
79
98
 
@@ -32,7 +32,7 @@ class FlowUiDialog extends FlowRdfElement {
32
32
  this.hasSlotController = new HasSlotController(this, "footer");
33
33
  this.localize = new LocalizeController(this);
34
34
  this.open = false;
35
- this.heading = "";
35
+ this.title = "";
36
36
  this.noHeader = false;
37
37
  this.tabbed = false;
38
38
  }
@@ -162,7 +162,7 @@ class FlowUiDialog extends FlowRdfElement {
162
162
  this.syncTabbedDialog();
163
163
  }
164
164
  syncTabbedDialog() {
165
- this.heading = capitalize(this.tabGroup.activeTab?.panel) || "";
165
+ this.title = capitalize(this.tabGroup.activeTab?.panel) || "";
166
166
  }
167
167
  handleChildHide(ev) {
168
168
  ev.stopPropagation();
@@ -170,8 +170,8 @@ class FlowUiDialog extends FlowRdfElement {
170
170
  renderHeader(slot) {
171
171
  return html`
172
172
  <header slot=${ifDefined(slot)} part="header" class="dialog__header">
173
- <h2 part="heading" class="dialog__heading" id="heading">
174
- <slot name="heading">${this.heading.length > 0 ? this.heading : String.fromCharCode(65279)}</slot>
173
+ <h2 part="heading" class="dialog__title" id="heading">
174
+ <slot name="title">${this.title.length > 0 ? this.title : String.fromCharCode(65279)}</slot>
175
175
  </h2>
176
176
  <div part="header-actions" class="dialog__header-actions">
177
177
  <slot name="header-actions"></slot>
@@ -224,6 +224,7 @@ class FlowUiDialog extends FlowRdfElement {
224
224
  "dialog--open": this.open,
225
225
  "dialog--has-footer": this.hasSlotController.test("footer")
226
226
  })}
227
+ title=""
227
228
  >
228
229
  <div part="overlay" class="dialog__overlay" @click=${() => this.requestClose("overlay")} tabindex="-1"></div>
229
230
 
@@ -233,7 +234,7 @@ class FlowUiDialog extends FlowRdfElement {
233
234
  role="dialog"
234
235
  aria-modal="true"
235
236
  aria-hidden=${this.open ? "false" : "true"}
236
- aria-label=${ifDefined(this.noHeader ? this.heading : void 0)}
237
+ aria-label=${ifDefined(this.noHeader ? this.title : void 0)}
237
238
  aria-labelledby=${ifDefined(!this.noHeader ? "title" : void 0)}
238
239
  tabindex="0"
239
240
  >
@@ -261,7 +262,7 @@ __decorateClass([
261
262
  ], FlowUiDialog.prototype, "open", 2);
262
263
  __decorateClass([
263
264
  property({ reflect: true })
264
- ], FlowUiDialog.prototype, "heading", 2);
265
+ ], FlowUiDialog.prototype, "title", 2);
265
266
  __decorateClass([
266
267
  property({ attribute: "no-header", type: Boolean, reflect: true })
267
268
  ], FlowUiDialog.prototype, "noHeader", 2);
@@ -18,6 +18,7 @@ const styles = css`
18
18
  --body-spacing: 0 var(--flow-ui-spacing-x-large);
19
19
  }
20
20
 
21
+ /* Remove margins from first and last items slotted into dialog body */
21
22
  ::slotted(:nth-child(1 of :not([slot]))) {
22
23
  margin-top: 0;
23
24
  }
@@ -71,7 +72,7 @@ const styles = css`
71
72
  display: flex;
72
73
  }
73
74
 
74
- .dialog__heading {
75
+ .dialog__title {
75
76
  flex: 1 1 auto;
76
77
  font: inherit;
77
78
  font-size: var(--flow-ui-font-size-large);
@@ -79,7 +79,7 @@ class FlowUiGauge extends FlowRdfElement {
79
79
  infoDialogTemplate() {
80
80
  return html`
81
81
  <flow-ui-dialog class="gauge__info-dialog">
82
- <div slot="heading" class="gauge__info-dialog-heading">${this.headerIconTemplate()} ${this.label}</div>
82
+ <div slot="heading" class="gauge__info-dialog-heading">${this.headerIconTemplate()} ${this.title}</div>
83
83
  <slot name="info"></slot>
84
84
  <div slot="footer">
85
85
  <flow-ui-button autofocus slot="footer" variant="primary" @click=${this.hideInfoDialog}>OK</flow-ui-button>
@@ -95,12 +95,13 @@ class FlowUiGauge extends FlowRdfElement {
95
95
  class=${classMap({
96
96
  gauge: true
97
97
  })}
98
+ title=""
98
99
  >
99
100
  <div part="header" class="gauge__header">
100
101
  ${this.headerIconTemplate()}
101
- <span class="gauge__label-wrapper">
102
- <span part="label" class="gauge__label">
103
- <slot name="label">${this.label}</slot>
102
+ <span class="gauge__title-wrapper">
103
+ <span part="title" class="gauge__title">
104
+ <slot name="title">${this.title}</slot>
104
105
  </span>
105
106
  </span>
106
107
  ${hasInfo ? this.infoButtonTemplate() : nothing}
@@ -124,8 +125,8 @@ __decorateClass([
124
125
  query(".gauge__info-dialog")
125
126
  ], FlowUiGauge.prototype, "_infoDialog", 2);
126
127
  __decorateClass([
127
- property()
128
- ], FlowUiGauge.prototype, "label", 2);
128
+ property({ reflect: true })
129
+ ], FlowUiGauge.prototype, "title", 2);
129
130
  __decorateClass([
130
131
  property()
131
132
  ], FlowUiGauge.prototype, "units", 2);
@@ -56,13 +56,13 @@ const styles = css`
56
56
  }
57
57
 
58
58
  /* Wrapper needed to support text ellipsis in flex item */
59
- .gauge__label-wrapper {
59
+ .gauge__title-wrapper {
60
60
  flex: 1;
61
61
  min-width: 0;
62
62
  display: flex;
63
63
  }
64
64
 
65
- .gauge__label {
65
+ .gauge__title {
66
66
  text-overflow: ellipsis;
67
67
  white-space: nowrap;
68
68
  overflow: hidden;
@@ -82,6 +82,7 @@ class FlowUiPanelHeader extends FlowRdfElement {
82
82
  tabindex="0"
83
83
  @click=${this.handleHeaderClick}
84
84
  @keydown=${this.handleHeaderKeyDown}
85
+ title=""
85
86
  >
86
87
  <slot
87
88
  name="prefix"
@@ -91,8 +92,8 @@ class FlowUiPanelHeader extends FlowRdfElement {
91
92
  @keydown=${this.handleHeaderKeyDown}
92
93
  ></slot>
93
94
 
94
- <slot name="label" part="label" class="panel-header__label-slot">
95
- <span class="panel-header__label">${this.label}</span>
95
+ <slot name="title" part="title" class="panel-header__title-slot">
96
+ <span class="panel-header__title">${this.title}</span>
96
97
  </slot>
97
98
 
98
99
  <slot
@@ -122,8 +123,8 @@ __decorateClass([
122
123
  property({ type: Boolean, reflect: true })
123
124
  ], FlowUiPanelHeader.prototype, "closed", 2);
124
125
  __decorateClass([
125
- property()
126
- ], FlowUiPanelHeader.prototype, "label", 2);
126
+ property({ reflect: true })
127
+ ], FlowUiPanelHeader.prototype, "title", 2);
127
128
  __decorateClass([
128
129
  property({ type: Boolean, reflect: true })
129
130
  ], FlowUiPanelHeader.prototype, "fixed", 2);
@@ -33,14 +33,14 @@ const styles = css`
33
33
  color: var(--accessory-color);
34
34
  }
35
35
 
36
- .panel-header__label-slot {
36
+ .panel-header__title-slot {
37
37
  display: flex;
38
38
  align-items: center;
39
39
  flex: 1;
40
40
  min-width: 0;
41
41
  }
42
42
 
43
- .panel-header__label {
43
+ .panel-header__title {
44
44
  font-size: var(--flow-ui-panel-header-font-size);
45
45
  font-weight: var(--flow-ui-panel-header-font-weight);
46
46
  text-overflow: ellipsis;
@@ -35,8 +35,22 @@ function transformRuleSet(ruleSet, transformFn, clone = true) {
35
35
  }).filter(isRuleOrRuleset);
36
36
  return ruleSet;
37
37
  }
38
+ function countRuleSet(ruleset) {
39
+ const activeFilters = (ruleSet) => {
40
+ let count = 0;
41
+ for (const rule of ruleSet.rules) {
42
+ if (isRule(rule) && rule.field && rule.enabled) {
43
+ count += 1;
44
+ } else if (isRuleSet(rule)) {
45
+ count += activeFilters(rule);
46
+ }
47
+ }
48
+ return count;
49
+ };
50
+ return activeFilters(ruleset);
51
+ }
38
52
  const isRule = (r) => isObjectFull(r) && "field" in r;
39
53
  const isRuleSet = (r) => isObjectFull(r) && "rules" in r;
40
54
  const isRuleOrRuleset = (r) => isRule(r) || isRuleSet(r);
41
55
 
42
- export { filterRuleSet, isRule, isRuleOrRuleset, isRuleSet, renameRuleSetFields, transformRuleSet };
56
+ export { countRuleSet, filterRuleSet, isRule, isRuleOrRuleset, isRuleSet, renameRuleSetFields, transformRuleSet };