@progressive-development/pd-forms 0.1.35 → 0.1.36

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent pd-forms following open-wc recommendations",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.1.35",
6
+ "version": "0.1.36",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -0,0 +1,3 @@
1
+ import { PdHoverBox } from './src/PdHoverBox.js';
2
+
3
+ window.customElements.define('pd-hover-box', PdHoverBox);
@@ -34,6 +34,8 @@ import { PdBaseUI } from './PdBaseUi.js';
34
34
 
35
35
  import { SharedInputStyles } from './shared-input-styles.js';
36
36
 
37
+ import '../pd-hover-box.js';
38
+
37
39
  /**
38
40
  * Available input types.
39
41
  * Each input elemt set it's own type during constructor call.
@@ -230,9 +232,16 @@ import { SharedInputStyles } from './shared-input-styles.js';
230
232
  return html`
231
233
  <div class="label-header">
232
234
  <label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}${additionalValue ? html` - <b>${additionalValue}</b>` : ''}</label>
233
- ${this.helperTxt ? html`<pd-icon title="${this.helperTxt}" icon="helpIcon" activeIcon></pd-icon>` : ""}
235
+ ${this.helperTxt ? html`
236
+
237
+ <pd-hover-box>
238
+ <pd-icon slot="small-view" icon="helpIcon" activeIcon></pd-icon>
239
+ <p slot="extended-view">${this.helperTxt}</p>
240
+ </pd-hover-box>
241
+
242
+ ` : ""}
234
243
  </div>
235
244
  `;
236
245
  }
237
246
 
238
- }
247
+ }
@@ -0,0 +1,108 @@
1
+ /* eslint-disable lit-a11y/click-events-have-key-events */
2
+ /**
3
+ * @license
4
+ * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
5
+ *
6
+ * Lit element container for pd input elements.
7
+ *
8
+ * Used to:
9
+ * - Automatically validation of form content
10
+ * - Success/NotReady information for form-container
11
+ */
12
+
13
+ import { html, css } from 'lit';
14
+ import { PdBaseUI } from './PdBaseUi.js';
15
+
16
+ /**
17
+ * An example element.
18
+ *
19
+ * @slot - This element has a slot
20
+ * @csspart button - The button
21
+ */
22
+ export class PdHoverBox extends PdBaseUI {
23
+
24
+ static get properties() {
25
+ return {
26
+ _visible: { type: Boolean, state: true},
27
+ };
28
+ }
29
+
30
+ static get styles() {
31
+ return [
32
+ PdBaseUI.styles,
33
+ css`
34
+
35
+ :host {
36
+
37
+ }
38
+
39
+ .hover-box {
40
+ position: relative;
41
+ }
42
+
43
+ .small-view {
44
+
45
+ }
46
+
47
+ .extended-view {
48
+ position: absolute;
49
+ z-index: 100;
50
+ right: -3px;
51
+ top: -3px;
52
+ background-color: var(--pd-hover-box-bg-col, var(--pd-default-dark-col));
53
+ visibility: hidden; /* Hidden by default */
54
+ opacity: 0;
55
+ border: 1px solid var(--pd-hover-box-border-col, var(--pd-default-col));
56
+ color: var(--pd-hover-box-font-col, white);
57
+ text-align: center;
58
+ padding: 5px;
59
+
60
+ min-width: 160px;
61
+ max-width: 400px;
62
+
63
+ transition: opacity 0.2s ease-in;
64
+ }
65
+
66
+ `];
67
+ }
68
+
69
+ render() {
70
+ return html`
71
+ <div class="hover-box">
72
+
73
+ <div class="small-view" @click="${this._activateInfo}">
74
+ <slot name="small-view"></slot>
75
+ </div>
76
+
77
+ <div id="extendedViewId" class="extended-view">
78
+ <slot name="extended-view"></slot>
79
+ </div>
80
+
81
+ </div>
82
+ `;
83
+ }
84
+
85
+ // eslint-disable-next-line class-methods-use-this
86
+ _activateInfo(e) {
87
+ const modal = this.shadowRoot.getElementById('extendedViewId');
88
+ modal.style.visibility = 'visible';
89
+ modal.style.opacity = '1';
90
+ this.addEventListener('click', this._clickHandler);
91
+ e.stopPropagation();
92
+
93
+ // Nachteil: Wird immer bei jedem Click nach erstmaligem aktvieren ausgeführt. Der Code unten
94
+ // aber nur bei KLick auf das Fenster, daher zunächst so belassen.
95
+ // Nachtrag: Allerdings geht es nicht für mehrere Hilfetexte gleichzeitig. Zunächst zurückgenommen.
96
+ /* window.onclick = () => {
97
+ modal.style.display = "none";
98
+ }; */
99
+ }
100
+
101
+ _clickHandler() {
102
+ this.removeEventListener('click', PdHoverBox._clickHandler);
103
+ const modal = this.shadowRoot.getElementById('extendedViewId');
104
+ modal.style.visibility = 'hidden';
105
+ modal.style.opacity = '0';
106
+ }
107
+
108
+ }
@@ -46,7 +46,18 @@ function Template() {
46
46
  <pd-range id="range5060Id"
47
47
  class="quarter4"
48
48
  label="50er/60er"
49
- helperTxt="Hier steht ein Hilfstext"
49
+ helperTxt="Hier steht ein Hilfstext."
50
+ required
51
+ max="4"
52
+ value="0"
53
+ .optionValueMapper="${OPTIONS_GENRE}">
54
+ </pd-range>
55
+ </pd-form-row>
56
+ <pd-form-row>
57
+ <pd-range id="range5060Id"
58
+ class="quarter4"
59
+ label="50er/60er"
60
+ helperTxt="Hier steht ein Hilfstext, oder aber auch ein etwas längeres Element. Mit mehr als nur etwas Text. Man weiß es nicht genaut"
50
61
  required
51
62
  max="4"
52
63
  value="0"