@postnord/pn-marketweb-components 2.3.6 → 2.3.9
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/cjs/loader.cjs.js +1 -1
- package/cjs/pn-animated-tile.cjs.entry.js +2 -2
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +9 -0
- package/cjs/pn-multi-formfield.cjs.entry.js +253 -0
- package/collection/collection-manifest.json +1 -1
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.css +54 -20
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.js +2 -2
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.stories.js +25 -1
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +2 -2
- package/collection/components/layout-components/pn-marketweb-siteheader/translations.js +9 -0
- package/collection/components/layout-components/pn-multi-formfield/multi-formfield.stories.js +55 -0
- package/collection/components/layout-components/pn-multi-formfield/pn-multi-formfield.css +4 -0
- package/collection/components/layout-components/pn-multi-formfield/pn-multi-formfield.js +267 -0
- package/collection/components/layout-components/pn-multi-formfield/types.js +1 -0
- package/custom-elements/index.d.ts +4 -4
- package/custom-elements/index.js +312 -83
- package/esm/loader.js +1 -1
- package/esm/pn-animated-tile.entry.js +2 -2
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-marketweb-siteheader.entry.js +9 -0
- package/esm/pn-multi-formfield.entry.js +249 -0
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-animated-tile.entry.js +1 -1
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/esm-es5/pn-multi-formfield.entry.js +1 -0
- package/package.json +2 -1
- package/pn-market-web-components/p-070f1309.system.entry.js +1 -0
- package/pn-market-web-components/p-397514bc.system.entry.js +1 -0
- package/pn-market-web-components/p-468025b2.system.entry.js +1 -0
- package/pn-market-web-components/p-5776275b.entry.js +1 -0
- package/pn-market-web-components/p-67887512.system.js +1 -1
- package/pn-market-web-components/p-93d454ea.entry.js +1 -0
- package/pn-market-web-components/p-96e6d92c.entry.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/layout-components/pn-marketweb-siteheader/translations.d.ts +9 -0
- package/types/components/layout-components/pn-multi-formfield/pn-multi-formfield.d.ts +36 -0
- package/types/components/layout-components/pn-multi-formfield/types.d.ts +4 -0
- package/types/components.d.ts +17 -9
- package/cjs/pn-multi-input.cjs.entry.js +0 -32
- package/collection/components/layout-components/pn-multi-input/multi-input.stories.js +0 -22
- package/collection/components/layout-components/pn-multi-input/pn-multi-input.css +0 -0
- package/collection/components/layout-components/pn-multi-input/pn-multi-input.js +0 -31
- package/esm/pn-multi-input.entry.js +0 -28
- package/esm-es5/pn-multi-input.entry.js +0 -1
- package/pn-market-web-components/p-7cab2106.system.entry.js +0 -1
- package/pn-market-web-components/p-803088a3.entry.js +0 -1
- package/pn-market-web-components/p-97aafcf4.entry.js +0 -1
- package/pn-market-web-components/p-b66743b3.system.entry.js +0 -1
- package/pn-market-web-components/p-d74172bc.entry.js +0 -1
- package/pn-market-web-components/p-efe598a8.system.entry.js +0 -1
- package/types/components/layout-components/pn-multi-input/pn-multi-input.d.ts +0 -8
|
@@ -19,28 +19,32 @@ pn-animated-tile [slot=side-b] {
|
|
|
19
19
|
left: 0;
|
|
20
20
|
width: 100%;
|
|
21
21
|
height: 100%;
|
|
22
|
-
padding: 2.4rem;
|
|
23
22
|
}
|
|
24
23
|
pn-animated-tile [slot=side-a] {
|
|
24
|
+
padding: 0;
|
|
25
25
|
opacity: 1;
|
|
26
26
|
}
|
|
27
27
|
pn-animated-tile [slot=side-b] {
|
|
28
|
+
padding: 2.4rem 2.4rem 7rem 2.4rem;
|
|
28
29
|
opacity: 0;
|
|
29
30
|
transform: translateY(50px);
|
|
30
31
|
}
|
|
31
32
|
pn-animated-tile .pn-animated-tile__toggle {
|
|
32
33
|
position: absolute;
|
|
33
|
-
bottom:
|
|
34
|
-
right:
|
|
35
|
-
padding: 2.4rem;
|
|
36
|
-
}
|
|
37
|
-
pn-animated-tile .pn-animated-tile__toggle pn-icon {
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
border-radius: 50%;
|
|
34
|
+
bottom: 2.4rem;
|
|
35
|
+
right: 2.4rem;
|
|
40
36
|
padding: 0.8rem;
|
|
41
|
-
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
border: none;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
pn-animated-tile .pn-animated-tile__toggle:hover {
|
|
42
|
+
background-color: #e9e6e5;
|
|
43
|
+
}
|
|
44
|
+
pn-animated-tile .pn-animated-tile__toggle:hover pn-icon {
|
|
45
|
+
background-color: #e9e6e5;
|
|
42
46
|
}
|
|
43
|
-
pn-animated-tile
|
|
47
|
+
pn-animated-tile .button-tooltip {
|
|
44
48
|
display: none;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -75,52 +79,82 @@ pn-animated-tile pn-icon .button-tooltip {
|
|
|
75
79
|
[data-cat-theme=white] .pn-animated-tile__container {
|
|
76
80
|
background-color: #FFFFFF;
|
|
77
81
|
}
|
|
78
|
-
[data-cat-theme=white] .pn-animated-tile__toggle
|
|
82
|
+
[data-cat-theme=white] .pn-animated-tile__toggle {
|
|
79
83
|
background-color: #FFFFFF;
|
|
80
84
|
}
|
|
81
|
-
[data-cat-theme=white] .pn-animated-tile__toggle
|
|
85
|
+
[data-cat-theme=white] .pn-animated-tile__toggle pn-icon {
|
|
86
|
+
background-color: #FFFFFF;
|
|
87
|
+
}
|
|
88
|
+
[data-cat-theme=white] .pn-animated-tile__toggle pn-icon svg > path {
|
|
82
89
|
fill: #00A0D6;
|
|
83
90
|
}
|
|
91
|
+
[data-cat-theme=white] .pn-animated-tile__toggle:focus, [data-cat-theme=white] .pn-animated-tile__toggle:focus-visible {
|
|
92
|
+
outline-color: #00A0D6;
|
|
93
|
+
}
|
|
84
94
|
|
|
85
95
|
[data-cat-theme=coral400] .pn-animated-tile__container {
|
|
86
96
|
background-color: #F06365;
|
|
87
97
|
}
|
|
88
|
-
[data-cat-theme=coral400] .pn-animated-tile__toggle
|
|
98
|
+
[data-cat-theme=coral400] .pn-animated-tile__toggle {
|
|
89
99
|
background-color: #FFFFFF;
|
|
90
100
|
}
|
|
91
|
-
[data-cat-theme=coral400] .pn-animated-tile__toggle
|
|
101
|
+
[data-cat-theme=coral400] .pn-animated-tile__toggle pn-icon {
|
|
102
|
+
background-color: #FFFFFF;
|
|
103
|
+
}
|
|
104
|
+
[data-cat-theme=coral400] .pn-animated-tile__toggle pn-icon svg > path {
|
|
92
105
|
fill: #F06365;
|
|
93
106
|
}
|
|
107
|
+
[data-cat-theme=coral400] .pn-animated-tile__toggle:focus, [data-cat-theme=coral400] .pn-animated-tile__toggle:focus-visible {
|
|
108
|
+
outline-color: #F06365;
|
|
109
|
+
}
|
|
94
110
|
|
|
95
111
|
[data-cat-theme=private] .pn-animated-tile__container {
|
|
96
112
|
background-color: #00A0D6;
|
|
97
113
|
}
|
|
98
|
-
[data-cat-theme=private] .pn-animated-tile__toggle
|
|
114
|
+
[data-cat-theme=private] .pn-animated-tile__toggle {
|
|
99
115
|
background-color: #FFFFFF;
|
|
100
116
|
}
|
|
101
|
-
[data-cat-theme=private] .pn-animated-tile__toggle
|
|
117
|
+
[data-cat-theme=private] .pn-animated-tile__toggle pn-icon {
|
|
118
|
+
background-color: #FFFFFF;
|
|
119
|
+
}
|
|
120
|
+
[data-cat-theme=private] .pn-animated-tile__toggle pn-icon svg > path {
|
|
102
121
|
fill: #00A0D6;
|
|
103
122
|
}
|
|
123
|
+
[data-cat-theme=private] .pn-animated-tile__toggle:focus, [data-cat-theme=private] .pn-animated-tile__toggle:focus-visible {
|
|
124
|
+
outline-color: #00A0D6;
|
|
125
|
+
}
|
|
104
126
|
|
|
105
127
|
[data-cat-theme=business] .pn-animated-tile__container {
|
|
106
128
|
background-color: #0D234B;
|
|
107
129
|
}
|
|
108
|
-
[data-cat-theme=business] .pn-animated-tile__toggle
|
|
130
|
+
[data-cat-theme=business] .pn-animated-tile__toggle {
|
|
109
131
|
background-color: #FFFFFF;
|
|
110
132
|
}
|
|
111
|
-
[data-cat-theme=business] .pn-animated-tile__toggle
|
|
133
|
+
[data-cat-theme=business] .pn-animated-tile__toggle pn-icon {
|
|
134
|
+
background-color: #FFFFFF;
|
|
135
|
+
}
|
|
136
|
+
[data-cat-theme=business] .pn-animated-tile__toggle pn-icon svg > path {
|
|
112
137
|
fill: #0D234B;
|
|
113
138
|
}
|
|
139
|
+
[data-cat-theme=business] .pn-animated-tile__toggle:focus, [data-cat-theme=business] .pn-animated-tile__toggle:focus-visible {
|
|
140
|
+
outline-color: #0D234B;
|
|
141
|
+
}
|
|
114
142
|
|
|
115
143
|
[data-cat-theme=hybrid] .pn-animated-tile__container {
|
|
116
144
|
background-color: #e9e6e5;
|
|
117
145
|
}
|
|
118
|
-
[data-cat-theme=hybrid] .pn-animated-tile__toggle
|
|
146
|
+
[data-cat-theme=hybrid] .pn-animated-tile__toggle {
|
|
119
147
|
background-color: #FFFFFF;
|
|
120
148
|
}
|
|
121
|
-
[data-cat-theme=hybrid] .pn-animated-tile__toggle
|
|
149
|
+
[data-cat-theme=hybrid] .pn-animated-tile__toggle pn-icon {
|
|
150
|
+
background-color: #FFFFFF;
|
|
151
|
+
}
|
|
152
|
+
[data-cat-theme=hybrid] .pn-animated-tile__toggle pn-icon svg > path {
|
|
122
153
|
fill: #005D92;
|
|
123
154
|
}
|
|
155
|
+
[data-cat-theme=hybrid] .pn-animated-tile__toggle:focus, [data-cat-theme=hybrid] .pn-animated-tile__toggle:focus-visible {
|
|
156
|
+
outline-color: #005D92;
|
|
157
|
+
}
|
|
124
158
|
|
|
125
159
|
[data-cat-firstpage-only=true] [slot=side-b],
|
|
126
160
|
[data-cat-firstpage-only=true] .pn-animated-tile__toggle {
|
|
@@ -19,8 +19,8 @@ export class PnAnimatedTile {
|
|
|
19
19
|
h("div", { class: `pn-animated-tile__content cat-animate ${this.transitionClassName}` },
|
|
20
20
|
h("slot", { name: "side-a" }),
|
|
21
21
|
h("slot", { name: "side-b" })),
|
|
22
|
-
h("
|
|
23
|
-
h("pn-icon", { symbol: "plus"
|
|
22
|
+
h("button", { class: `pn-animated-tile__toggle cat-animate toggle ${this.animateIcon}`, onClick: this.onClickHandler },
|
|
23
|
+
h("pn-icon", { symbol: "plus" })))));
|
|
24
24
|
}
|
|
25
25
|
static get is() { return "pn-animated-tile"; }
|
|
26
26
|
static get originalStyleUrls() { return {
|
|
@@ -30,7 +30,7 @@ const FlipDefault = args => {
|
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
32
|
<div slot="side-b">
|
|
33
|
-
<div style="display:flex; flex-direction:column; justify-content:center;">
|
|
33
|
+
<div style="display:flex; flex-direction:column; justify-content:center; overflow-y:scroll; height:100%;">
|
|
34
34
|
<h2 style="color:#FFF; padding:0 0.8rem">Heading</h2>
|
|
35
35
|
<p style="color:#FFF; padding:0 0.8rem">
|
|
36
36
|
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
@@ -51,6 +51,30 @@ const FlipDefault = args => {
|
|
|
51
51
|
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
52
52
|
Vivamus porta non ex vitae mollis.
|
|
53
53
|
|
|
54
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
55
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
56
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
57
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
58
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
59
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
60
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
61
|
+
Vivamus porta non ex vitae mollis.
|
|
62
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
63
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
64
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
65
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
66
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
67
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
68
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
69
|
+
Vivamus porta non ex vitae mollis.
|
|
70
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
71
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
72
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
73
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
74
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
75
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
76
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
77
|
+
Vivamus porta non ex vitae mollis.
|
|
54
78
|
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
55
79
|
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
56
80
|
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
@@ -449,8 +449,8 @@ const BusinessUserLoggedInTemplate = ({ ...args }) => {
|
|
|
449
449
|
|
|
450
450
|
export const BusinessUserLoggedIn = BusinessUserLoggedInTemplate.bind({});
|
|
451
451
|
BusinessUserLoggedIn.args = {
|
|
452
|
-
market: '
|
|
453
|
-
language: '
|
|
452
|
+
market: 'com',
|
|
453
|
+
language: 'zh',
|
|
454
454
|
endpoint: 'https://com-integration.postnord.com',
|
|
455
455
|
name: 'custom user name',
|
|
456
456
|
loggedin: true,
|
|
@@ -71,4 +71,13 @@ export const translations = {
|
|
|
71
71
|
unifiedLoginButton: 'Anmeldung',
|
|
72
72
|
unifiedMyPagesButton: 'Meine Seiten',
|
|
73
73
|
},
|
|
74
|
+
zh: {
|
|
75
|
+
searchlabel: '搜索',
|
|
76
|
+
searchplaceholder: '搜索',
|
|
77
|
+
searchbuttontext: '搜索',
|
|
78
|
+
menuHomeButton: '主页',
|
|
79
|
+
menuGoBackButton: '回去',
|
|
80
|
+
mainMenuButton: '选择菜单',
|
|
81
|
+
menuStartButton: '开始',
|
|
82
|
+
},
|
|
74
83
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import readme from "./readme.md";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Input/Multi-FormField",
|
|
5
|
+
parameters: {
|
|
6
|
+
notes: readme,
|
|
7
|
+
},
|
|
8
|
+
argTypes: {
|
|
9
|
+
formFieldClassName: "",
|
|
10
|
+
formFieldOuterParentClassName: "",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template = ({ ...args }) => {
|
|
15
|
+
return `
|
|
16
|
+
<pn-multi-formfield
|
|
17
|
+
formfieldclassname=${args.formFieldClassName}
|
|
18
|
+
formfieldouterparentclassname=${args.formFieldOuterParentClassName}
|
|
19
|
+
>
|
|
20
|
+
<div class="formelement">
|
|
21
|
+
<div>
|
|
22
|
+
<label class="Form__Element__Caption" for="e4752967-52ef-4315-88e7-acefd54667bd">Text</label>
|
|
23
|
+
<input
|
|
24
|
+
type="text"
|
|
25
|
+
name="__field_91506"
|
|
26
|
+
id="e4752967-52ef-4315-88e7-acefd54667bd"
|
|
27
|
+
class="FormTextbox__Input form-control"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="formelement">
|
|
32
|
+
<div>
|
|
33
|
+
<label class="form-group-text form-label" for="0e58dbc8-ef3b-4647-85e6-1d24483e8fe9">Selection</label>
|
|
34
|
+
<select
|
|
35
|
+
class="form-control native-select"
|
|
36
|
+
name="__field_90429"
|
|
37
|
+
id="0e58dbc8-ef3b-4647-85e6-1d24483e8fe9"
|
|
38
|
+
data-f-datainput=""
|
|
39
|
+
>
|
|
40
|
+
<option disabled="disabled" selected='"selected"' value="">-- Choose an option --</option>
|
|
41
|
+
<option value="All" data-f-datainput="">All</option>
|
|
42
|
+
<option value="Legoland" data-f-datainput="">Legoland</option>
|
|
43
|
+
</select>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<textarea type="text" class="hiddenValue" cols="70" rows="10"></textarea>
|
|
47
|
+
</pn-multi-formfield>
|
|
48
|
+
`;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Primary = Template.bind({});
|
|
52
|
+
Primary.args = {
|
|
53
|
+
formFieldClassName: "form-control",
|
|
54
|
+
formFieldOuterParentClassName: "formelement",
|
|
55
|
+
};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Component, Element, Host, h, State, Prop, Event } from "@stencil/core";
|
|
2
|
+
import { debounce } from "debounce";
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
4
|
+
export class PnMultiFormField {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.containerElm = null;
|
|
7
|
+
this.slotElm = null;
|
|
8
|
+
this.formFields = null;
|
|
9
|
+
this.formFieldTypes = ["input", "textarea", "select"];
|
|
10
|
+
this.additionalRowStartIndex = 2;
|
|
11
|
+
this.formRow = [];
|
|
12
|
+
this.formValues = [];
|
|
13
|
+
this.elementToCopy = null;
|
|
14
|
+
this.fieldsPerRowCount = 0;
|
|
15
|
+
this.newRowStartIndex = 2;
|
|
16
|
+
this.originalLabelNames = [];
|
|
17
|
+
this.value = [];
|
|
18
|
+
this.formFieldClassName = "form-control";
|
|
19
|
+
this.formFieldOuterParentClassName = "formelement";
|
|
20
|
+
this.formFieldEvent = (e) => {
|
|
21
|
+
if (e.target.matches(`.${this.formFieldClassName}`)) {
|
|
22
|
+
["change", "keyup"].forEach((eventName) => {
|
|
23
|
+
const debouncedAddValue = debounce(this.updateValues.bind(this, e.target), 1000);
|
|
24
|
+
e.target.addEventListener(eventName, debouncedAddValue);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
generateUniqueId() {
|
|
30
|
+
return uuidv4();
|
|
31
|
+
}
|
|
32
|
+
componentDidLoad() {
|
|
33
|
+
this.init();
|
|
34
|
+
}
|
|
35
|
+
async init() {
|
|
36
|
+
this.addEventHandlers();
|
|
37
|
+
this.setDefaultValues();
|
|
38
|
+
}
|
|
39
|
+
addEventHandlers() {
|
|
40
|
+
this.hostElement.addEventListener("click", this.formFieldEvent);
|
|
41
|
+
}
|
|
42
|
+
setDefaultValues() {
|
|
43
|
+
var _a;
|
|
44
|
+
const labelElms = (_a = this.containerElm) === null || _a === void 0 ? void 0 : _a.querySelectorAll("label");
|
|
45
|
+
if (labelElms) {
|
|
46
|
+
this.fieldsPerRowCount = labelElms.length;
|
|
47
|
+
this.originalLabelNames = [...labelElms].map((label) => label.innerHTML);
|
|
48
|
+
const emptyValues = this.originalLabelNames.map((label) => {
|
|
49
|
+
const obj = { Name: label, Value: "" };
|
|
50
|
+
return obj;
|
|
51
|
+
});
|
|
52
|
+
this.formValues = [...emptyValues];
|
|
53
|
+
this.setHiddenValue();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
setHiddenValue() {
|
|
57
|
+
var _a;
|
|
58
|
+
const hiddenField = (_a = this.hostElement) === null || _a === void 0 ? void 0 : _a.querySelector(".hiddenValue");
|
|
59
|
+
if (hiddenField) {
|
|
60
|
+
hiddenField.value = JSON.stringify(this.formValues);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
updateValues(field, e) {
|
|
64
|
+
var _a;
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const slotElm = field.closest(".pn-multi-formfield-slot");
|
|
67
|
+
const isSlotParent = !!slotElm;
|
|
68
|
+
let containerElm = isSlotParent ? slotElm : field.closest(".generated-parent");
|
|
69
|
+
if (containerElm) {
|
|
70
|
+
const formFields = (_a = [...containerElm === null || containerElm === void 0 ? void 0 : containerElm.querySelectorAll(`.${this.formFieldClassName}`)]) === null || _a === void 0 ? void 0 : _a.filter((x) => this.formFieldTypes.includes(x.nodeName.toLowerCase()));
|
|
71
|
+
formFields === null || formFields === void 0 ? void 0 : formFields.map((elm) => {
|
|
72
|
+
const fieldElm = elm;
|
|
73
|
+
const closestLabelElm = fieldElm.closest("div").querySelector("label");
|
|
74
|
+
const label = (closestLabelElm === null || closestLabelElm === void 0 ? void 0 : closestLabelElm.dataset.label) || (closestLabelElm === null || closestLabelElm === void 0 ? void 0 : closestLabelElm.innerHTML);
|
|
75
|
+
const newItem = { Name: label, Value: fieldElm.value };
|
|
76
|
+
this.setFormValues(newItem);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
this.setHiddenValue();
|
|
80
|
+
}
|
|
81
|
+
setFormValues(obj) {
|
|
82
|
+
const item = this.formValues.find((item) => item.Name === obj.Name);
|
|
83
|
+
if (item === undefined) {
|
|
84
|
+
this.formValues.push(obj);
|
|
85
|
+
}
|
|
86
|
+
if (item !== undefined) {
|
|
87
|
+
item.Value = obj.Value;
|
|
88
|
+
}
|
|
89
|
+
this.formValues = [...this.formValues];
|
|
90
|
+
this.value = this.formValues;
|
|
91
|
+
this.changed.emit(this.formValues);
|
|
92
|
+
}
|
|
93
|
+
addRow(e) {
|
|
94
|
+
if (e.type === "click") {
|
|
95
|
+
this.addFormElements();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
addFormElements() {
|
|
99
|
+
if (!this.elementToCopy) {
|
|
100
|
+
const elm = this.hostElement.querySelector(".pn-multi-formfield");
|
|
101
|
+
const clone = elm.cloneNode(true);
|
|
102
|
+
this.elementToCopy = clone;
|
|
103
|
+
}
|
|
104
|
+
const setFormElements = [
|
|
105
|
+
...this.elementToCopy.querySelectorAll(`.${this.formFieldOuterParentClassName}`),
|
|
106
|
+
].map((elm) => {
|
|
107
|
+
const labelElm = elm.querySelector("label");
|
|
108
|
+
const fieldElm = elm.querySelector(`.${this.formFieldClassName}`);
|
|
109
|
+
const newId = this.generateUniqueId();
|
|
110
|
+
labelElm.dataset.label = `${labelElm.innerText} ${this.newRowStartIndex}`;
|
|
111
|
+
labelElm.setAttribute("for", newId);
|
|
112
|
+
fieldElm.setAttribute("id", newId);
|
|
113
|
+
fieldElm.setAttribute("name", `__${newId}`);
|
|
114
|
+
return elm;
|
|
115
|
+
});
|
|
116
|
+
this.newRowStartIndex++;
|
|
117
|
+
const parentId = this.generateUniqueId();
|
|
118
|
+
const parentElm = document.createElement("div");
|
|
119
|
+
parentElm.setAttribute("id", parentId);
|
|
120
|
+
parentElm.setAttribute("class", "generated-parent");
|
|
121
|
+
setFormElements.map((clone) => {
|
|
122
|
+
parentElm.innerHTML += clone.innerHTML;
|
|
123
|
+
});
|
|
124
|
+
parentElm.appendChild(this.createDeleteButton());
|
|
125
|
+
this.containerElm.appendChild(parentElm);
|
|
126
|
+
}
|
|
127
|
+
createDeleteButton() {
|
|
128
|
+
const buttonElm = document.createElement("pn-button");
|
|
129
|
+
buttonElm.onclick = (e) => this.deleteRow(e);
|
|
130
|
+
buttonElm.setAttribute("icon-only", "true");
|
|
131
|
+
buttonElm.setAttribute("icon", "minus");
|
|
132
|
+
buttonElm.setAttribute("appearance", "warning");
|
|
133
|
+
buttonElm.appendChild(document.createTextNode(`X`));
|
|
134
|
+
return buttonElm;
|
|
135
|
+
}
|
|
136
|
+
deleteRow(e) {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
const targetElm = e.currentTarget;
|
|
139
|
+
const parentElm = targetElm.parentElement;
|
|
140
|
+
const allFieldElms = parentElm.querySelectorAll(`.${this.formFieldClassName}`);
|
|
141
|
+
allFieldElms.forEach((elm) => {
|
|
142
|
+
elm.remove();
|
|
143
|
+
});
|
|
144
|
+
parentElm.remove();
|
|
145
|
+
this.newRowStartIndex--;
|
|
146
|
+
this.formValues = [...this.formValues.slice(0, this.fieldsPerRowCount)];
|
|
147
|
+
const allGeneratedElms = [...this.containerElm.querySelectorAll(".generated-parent")];
|
|
148
|
+
allGeneratedElms.map((elm, index) => {
|
|
149
|
+
const allLabelElms = [...elm.querySelectorAll("label")];
|
|
150
|
+
allLabelElms.map((labelElm) => {
|
|
151
|
+
const labelParts = this.getLabelParts(labelElm.dataset.label);
|
|
152
|
+
labelElm.dataset.label = this.getLabelName(labelParts[0], index);
|
|
153
|
+
const associatedField = labelElm.parentElement.querySelector(`.${this.formFieldClassName}`);
|
|
154
|
+
const updateItem = { Name: labelElm.dataset.label, Value: associatedField.value };
|
|
155
|
+
this.setFormValues(updateItem);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
this.setHiddenValue();
|
|
159
|
+
}
|
|
160
|
+
getLabelParts(label) {
|
|
161
|
+
const part1 = label.substring(0, label.lastIndexOf(" "));
|
|
162
|
+
const part2 = label.substring(label.lastIndexOf(" ") + 1);
|
|
163
|
+
const parts = [part1, part2];
|
|
164
|
+
return parts;
|
|
165
|
+
}
|
|
166
|
+
getLabelName(name, index) {
|
|
167
|
+
return `${name} ${index + this.additionalRowStartIndex}`;
|
|
168
|
+
}
|
|
169
|
+
render() {
|
|
170
|
+
return (h(Host, null,
|
|
171
|
+
h("div", { ref: (el) => (this.containerElm = el), class: "pn-multi-formfield" },
|
|
172
|
+
h("div", { ref: (el) => (this.slotElm = el), class: "pn-multi-formfield-slot" },
|
|
173
|
+
h("slot", null))),
|
|
174
|
+
h("pn-button", { "icon-only": "true", "aria-label": "Add", icon: "plus", onClick: (e) => this.addRow(e) }, "+")));
|
|
175
|
+
}
|
|
176
|
+
static get is() { return "pn-multi-formfield"; }
|
|
177
|
+
static get originalStyleUrls() { return {
|
|
178
|
+
"$": ["pn-multi-formfield.scss"]
|
|
179
|
+
}; }
|
|
180
|
+
static get styleUrls() { return {
|
|
181
|
+
"$": ["pn-multi-formfield.css"]
|
|
182
|
+
}; }
|
|
183
|
+
static get properties() { return {
|
|
184
|
+
"value": {
|
|
185
|
+
"type": "unknown",
|
|
186
|
+
"mutable": true,
|
|
187
|
+
"complexType": {
|
|
188
|
+
"original": "FormValue[]",
|
|
189
|
+
"resolved": "FormValue[]",
|
|
190
|
+
"references": {
|
|
191
|
+
"FormValue": {
|
|
192
|
+
"location": "import",
|
|
193
|
+
"path": "./types"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"required": false,
|
|
198
|
+
"optional": false,
|
|
199
|
+
"docs": {
|
|
200
|
+
"tags": [],
|
|
201
|
+
"text": ""
|
|
202
|
+
},
|
|
203
|
+
"defaultValue": "[]"
|
|
204
|
+
},
|
|
205
|
+
"formFieldClassName": {
|
|
206
|
+
"type": "string",
|
|
207
|
+
"mutable": false,
|
|
208
|
+
"complexType": {
|
|
209
|
+
"original": "string",
|
|
210
|
+
"resolved": "string",
|
|
211
|
+
"references": {}
|
|
212
|
+
},
|
|
213
|
+
"required": false,
|
|
214
|
+
"optional": false,
|
|
215
|
+
"docs": {
|
|
216
|
+
"tags": [],
|
|
217
|
+
"text": ""
|
|
218
|
+
},
|
|
219
|
+
"attribute": "form-field-class-name",
|
|
220
|
+
"reflect": false,
|
|
221
|
+
"defaultValue": "\"form-control\""
|
|
222
|
+
},
|
|
223
|
+
"formFieldOuterParentClassName": {
|
|
224
|
+
"type": "string",
|
|
225
|
+
"mutable": false,
|
|
226
|
+
"complexType": {
|
|
227
|
+
"original": "string",
|
|
228
|
+
"resolved": "string",
|
|
229
|
+
"references": {}
|
|
230
|
+
},
|
|
231
|
+
"required": false,
|
|
232
|
+
"optional": false,
|
|
233
|
+
"docs": {
|
|
234
|
+
"tags": [],
|
|
235
|
+
"text": ""
|
|
236
|
+
},
|
|
237
|
+
"attribute": "form-field-outer-parent-class-name",
|
|
238
|
+
"reflect": false,
|
|
239
|
+
"defaultValue": "\"formelement\""
|
|
240
|
+
}
|
|
241
|
+
}; }
|
|
242
|
+
static get states() { return {
|
|
243
|
+
"formRow": {},
|
|
244
|
+
"formValues": {},
|
|
245
|
+
"elementToCopy": {},
|
|
246
|
+
"fieldsPerRowCount": {},
|
|
247
|
+
"newRowStartIndex": {},
|
|
248
|
+
"originalLabelNames": {}
|
|
249
|
+
}; }
|
|
250
|
+
static get events() { return [{
|
|
251
|
+
"method": "changed",
|
|
252
|
+
"name": "changed",
|
|
253
|
+
"bubbles": true,
|
|
254
|
+
"cancelable": true,
|
|
255
|
+
"composed": true,
|
|
256
|
+
"docs": {
|
|
257
|
+
"tags": [],
|
|
258
|
+
"text": ""
|
|
259
|
+
},
|
|
260
|
+
"complexType": {
|
|
261
|
+
"original": "any",
|
|
262
|
+
"resolved": "any",
|
|
263
|
+
"references": {}
|
|
264
|
+
}
|
|
265
|
+
}]; }
|
|
266
|
+
static get elementRef() { return "hostElement"; }
|
|
267
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -200,10 +200,10 @@ export const PnMarketwebSiteheaderUnifiedLogin: {
|
|
|
200
200
|
new (): PnMarketwebSiteheaderUnifiedLogin;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
interface
|
|
204
|
-
export const
|
|
205
|
-
prototype:
|
|
206
|
-
new ():
|
|
203
|
+
interface PnMultiFormfield extends Components.PnMultiFormfield, HTMLElement {}
|
|
204
|
+
export const PnMultiFormfield: {
|
|
205
|
+
prototype: PnMultiFormfield;
|
|
206
|
+
new (): PnMultiFormfield;
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
interface PnParcelTracker extends Components.PnParcelTracker, HTMLElement {}
|