@progressive-development/pd-forms 0.0.55 → 0.0.56

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.0.55",
6
+ "version": "0.0.56",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
package/src/PdBaseUi.js CHANGED
@@ -4,12 +4,13 @@
4
4
  */
5
5
 
6
6
  import { LitElement } from 'lit';
7
+ import { updateWhenLocaleChanges } from '@lit/localize';
7
8
 
8
9
  export class PdBaseUI extends LitElement {
9
10
 
10
- static get properties() {
11
- return {
12
- };
13
- }
11
+ constructor() {
12
+ super();
13
+ updateWhenLocaleChanges(this);
14
+ }
14
15
 
15
16
  }
@@ -3,9 +3,12 @@
3
3
  * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
4
4
  */
5
5
 
6
- import { LitElement, html, css } from 'lit';
7
- import {msg, updateWhenLocaleChanges} from '@lit/localize';
6
+ import { html, css } from 'lit';
7
+ import { msg } from '@lit/localize';
8
8
 
9
+ import { PdBaseUI } from './PdBaseUi.js';
10
+
11
+ import { setLocale } from './localization.js';
9
12
 
10
13
  /**
11
14
  * An example element.
@@ -13,7 +16,7 @@ import {msg, updateWhenLocaleChanges} from '@lit/localize';
13
16
  * @slot - This element has a slot
14
17
  * @csspart button - The button
15
18
  */
16
- export class PdFormContainer extends LitElement {
19
+ export class PdFormContainer extends PdBaseUI {
17
20
 
18
21
  static get styles() {
19
22
  return css`
@@ -37,13 +40,15 @@ export class PdFormContainer extends LitElement {
37
40
 
38
41
  static get properties() {
39
42
  return {
40
- requiredFieldInfo: { type: Boolean}
43
+ requiredFieldInfo: { type: Boolean},
44
+ locale: { type: String }
41
45
  };
42
46
  }
43
47
 
44
- constructor() {
45
- super();
46
- updateWhenLocaleChanges(this);
48
+ updated(changedProperties) {
49
+ if (changedProperties.has("locale") && this.locale) {
50
+ setLocale(this.locale);
51
+ }
47
52
  }
48
53
 
49
54
  firstUpdated() {
package/src/PdFormRow.js CHANGED
@@ -3,7 +3,9 @@
3
3
  * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
4
4
  */
5
5
 
6
- import {LitElement, html, css} from 'lit';
6
+ import { html, css } from 'lit';
7
+
8
+ import { PdBaseUI } from './PdBaseUi.js';
7
9
 
8
10
  /**
9
11
  * An example element.
@@ -11,7 +13,7 @@ import {LitElement, html, css} from 'lit';
11
13
  * @slot - This element has a slot
12
14
  * @csspart button - The button
13
15
  */
14
- export class PdFormRow extends LitElement {
16
+ export class PdFormRow extends PdBaseUI {
15
17
 
16
18
  static get styles() {
17
19
  return css`
@@ -5,5 +5,5 @@ import {sourceLocale, targetLocales} from './generated/locale-codes.js';
5
5
  export const {getLocale, setLocale} = configureLocalization({
6
6
  sourceLocale,
7
7
  targetLocales,
8
- loadLocale: (locale) => import(`/locale/${locale}.js`),
8
+ loadLocale: (locale) => import(`./generated/locale/${locale}.js`),
9
9
  });
@@ -82,7 +82,7 @@ return html`
82
82
  <h3>Defaults Inputs with labels</h3>
83
83
  <div
84
84
  style="display: flex; justify-content: space-between; max-width: 800px"
85
- >
85
+ >
86
86
  <pd-select
87
87
  id="testId1"
88
88
  ?gradient="${gradient}"
@@ -100,8 +100,8 @@ return html`
100
100
  ?gradient="${gradient}"
101
101
  style="${style}"
102
102
  label="Input Area Label"
103
- ></pd-input-area>
104
- </div>
103
+ ></pd-input-area>
104
+ </div>
105
105
 
106
106
  <div
107
107
  style="display: flex; justify-content: space-between; max-width: 800px"
@@ -12,10 +12,10 @@ export default {
12
12
  function Template() {
13
13
  return html`
14
14
  <h3>Mit Forms</h3>
15
- <pd-form-container>
15
+ <pd-form-container id="testFormContainerId" locale="be">
16
16
  <pd-form-row>
17
- <pd-input class="quarter2" id="test1Id" label="Label 1"></pd-input>
18
- <pd-input class="quarter2" id="test2Id" label="Label 2"></pd-input>
17
+ <pd-input class="quarter2" id="test1Id" label="Label 1" required></pd-input>
18
+ <pd-input class="quarter2" id="test2Id" label="Label 2" required></pd-input>
19
19
  </pd-form-row>
20
20
  <pd-form-row>
21
21
  <pd-input class="quarter4" id="test3Id" label="Label 3"></pd-input>
@@ -43,6 +43,17 @@ function Template() {
43
43
  <pd-input class="quarter2" id="test15Id" label="Label 6"></pd-input>
44
44
  </pd-form-row>
45
45
  </pd-form-container>
46
+
47
+ <h2>Test Validation</h2>
48
+ <button
49
+ @click="${() => {
50
+ document.getElementById('testFormContainerId').dispatchEvent(
51
+ new CustomEvent("validate-form", {detail: {errorMap: new Map()}})
52
+ );
53
+ }}"
54
+ >
55
+ Test Validate
56
+ </button>
46
57
  `;
47
58
  }
48
59