@postnord/pn-marketweb-components 2.3.5 → 2.3.8
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/index-9066c0d0.js +61 -0
- package/cjs/loader.cjs.js +1 -1
- package/cjs/pn-animated-tile.cjs.entry.js +35 -0
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-multi-formfield.cjs.entry.js +253 -0
- package/cjs/pn-spotlight.cjs.entry.js +3 -58
- package/collection/collection-manifest.json +3 -1
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.css +162 -0
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.js +42 -0
- package/collection/components/animation/pn-animated-tile/pn-animated-tile.stories.js +93 -0
- package/collection/components/animation/{pn-scroll.stories.js → pn-scroll/pn-scroll.stories.js} +1 -1
- 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 +12 -0
- package/custom-elements/index.js +435 -158
- package/esm/index-45541632.js +59 -0
- package/esm/loader.js +1 -1
- package/esm/pn-animated-tile.entry.js +31 -0
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-multi-formfield.entry.js +249 -0
- package/esm/pn-spotlight.entry.js +2 -57
- package/esm-es5/index-45541632.js +7 -0
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-animated-tile.entry.js +1 -0
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-multi-formfield.entry.js +1 -0
- package/esm-es5/pn-spotlight.entry.js +1 -7
- package/package.json +2 -1
- package/pn-market-web-components/p-070f1309.system.entry.js +1 -0
- package/pn-market-web-components/p-3e668a3f.system.js +7 -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-5e43ccf2.js +7 -0
- package/pn-market-web-components/p-67887512.system.js +1 -1
- package/pn-market-web-components/p-8e890ab1.system.entry.js +1 -0
- package/pn-market-web-components/p-96e6d92c.entry.js +1 -0
- package/pn-market-web-components/p-f82c5d08.entry.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/animation/pn-animated-tile/pn-animated-tile.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 +34 -0
- package/pn-market-web-components/p-27559a76.system.entry.js +0 -7
- package/pn-market-web-components/p-ac66c9ff.entry.js +0 -7
- /package/collection/components/animation/{pn-scroll.css → pn-scroll/pn-scroll.css} +0 -0
- /package/collection/components/animation/{pn-scroll.js → pn-scroll/pn-scroll.js} +0 -0
- /package/types/components/animation/{pn-scroll.d.ts → pn-scroll/pn-scroll.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
|
-
"./components/animation/pn-
|
|
3
|
+
"./components/animation/pn-animated-tile/pn-animated-tile.js",
|
|
4
|
+
"./components/animation/pn-scroll/pn-scroll.js",
|
|
4
5
|
"./components/cards/pn-quote-card/pn-quote-card.js",
|
|
5
6
|
"./components/cards/pn-quote-card/pn-line-shape/pn-line-shape.js",
|
|
6
7
|
"./components/cards/pn-teaser-card/pn-teaser-card.js",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"./components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-search.js",
|
|
30
31
|
"./components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-unified-login.js",
|
|
31
32
|
"./components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js",
|
|
33
|
+
"./components/layout-components/pn-multi-formfield/pn-multi-formfield.js",
|
|
32
34
|
"./components/minor/pn-titletag/pn-titletag.js",
|
|
33
35
|
"./components/navigation/pn-language-selector/pn-language-selector-option.js",
|
|
34
36
|
"./components/navigation/pn-language-selector/pn-language-selector.js",
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
pn-animated-tile .pn-animated-tile__container {
|
|
2
|
+
position: relative;
|
|
3
|
+
border-radius: 2.4rem;
|
|
4
|
+
height: 56rem;
|
|
5
|
+
cursor: default;
|
|
6
|
+
}
|
|
7
|
+
pn-animated-tile .pn-animated-tile__content {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
height: 100%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
}
|
|
14
|
+
pn-animated-tile [slot=side-a],
|
|
15
|
+
pn-animated-tile [slot=side-b] {
|
|
16
|
+
position: absolute;
|
|
17
|
+
align-self: stretch;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
}
|
|
23
|
+
pn-animated-tile [slot=side-a] {
|
|
24
|
+
padding: 0;
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
27
|
+
pn-animated-tile [slot=side-b] {
|
|
28
|
+
padding: 2.4rem 2.4rem 7rem 2.4rem;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
transform: translateY(50px);
|
|
31
|
+
}
|
|
32
|
+
pn-animated-tile .pn-animated-tile__toggle {
|
|
33
|
+
position: absolute;
|
|
34
|
+
bottom: 2.4rem;
|
|
35
|
+
right: 2.4rem;
|
|
36
|
+
padding: 0.8rem;
|
|
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;
|
|
46
|
+
}
|
|
47
|
+
pn-animated-tile .button-tooltip {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.cat-animate [slot=side-a],
|
|
52
|
+
.cat-animate [slot=side-b] {
|
|
53
|
+
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out 0.2s;
|
|
54
|
+
}
|
|
55
|
+
.cat-animate.fade [slot=side-a] {
|
|
56
|
+
opacity: 0;
|
|
57
|
+
}
|
|
58
|
+
.cat-animate.fade [slot=side-b] {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
transform: translateY(0);
|
|
61
|
+
transition-delay: 0.5s;
|
|
62
|
+
}
|
|
63
|
+
.cat-animate.fade--reversed [slot=side-a] {
|
|
64
|
+
opacity: 1;
|
|
65
|
+
transition-delay: 0.5s;
|
|
66
|
+
}
|
|
67
|
+
.cat-animate.fade--reversed [slot=side-b] {
|
|
68
|
+
opacity: 0;
|
|
69
|
+
transform: translateY(50px);
|
|
70
|
+
}
|
|
71
|
+
.cat-animate.toggle pn-icon {
|
|
72
|
+
transition: transform 0.45s ease-in-out;
|
|
73
|
+
transition-delay: 0.5s;
|
|
74
|
+
}
|
|
75
|
+
.cat-animate.toggle.animate pn-icon {
|
|
76
|
+
transform: rotate(45deg);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-cat-theme=white] .pn-animated-tile__container {
|
|
80
|
+
background-color: #FFFFFF;
|
|
81
|
+
}
|
|
82
|
+
[data-cat-theme=white] .pn-animated-tile__toggle {
|
|
83
|
+
background-color: #FFFFFF;
|
|
84
|
+
}
|
|
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 {
|
|
89
|
+
fill: #00A0D6;
|
|
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
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-cat-theme=coral400] .pn-animated-tile__container {
|
|
96
|
+
background-color: #F06365;
|
|
97
|
+
}
|
|
98
|
+
[data-cat-theme=coral400] .pn-animated-tile__toggle {
|
|
99
|
+
background-color: #FFFFFF;
|
|
100
|
+
}
|
|
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 {
|
|
105
|
+
fill: #F06365;
|
|
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
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-cat-theme=private] .pn-animated-tile__container {
|
|
112
|
+
background-color: #00A0D6;
|
|
113
|
+
}
|
|
114
|
+
[data-cat-theme=private] .pn-animated-tile__toggle {
|
|
115
|
+
background-color: #FFFFFF;
|
|
116
|
+
}
|
|
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 {
|
|
121
|
+
fill: #00A0D6;
|
|
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
|
+
}
|
|
126
|
+
|
|
127
|
+
[data-cat-theme=business] .pn-animated-tile__container {
|
|
128
|
+
background-color: #0D234B;
|
|
129
|
+
}
|
|
130
|
+
[data-cat-theme=business] .pn-animated-tile__toggle {
|
|
131
|
+
background-color: #FFFFFF;
|
|
132
|
+
}
|
|
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 {
|
|
137
|
+
fill: #0D234B;
|
|
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
|
+
}
|
|
142
|
+
|
|
143
|
+
[data-cat-theme=hybrid] .pn-animated-tile__container {
|
|
144
|
+
background-color: #e9e6e5;
|
|
145
|
+
}
|
|
146
|
+
[data-cat-theme=hybrid] .pn-animated-tile__toggle {
|
|
147
|
+
background-color: #FFFFFF;
|
|
148
|
+
}
|
|
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 {
|
|
153
|
+
fill: #005D92;
|
|
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
|
+
}
|
|
158
|
+
|
|
159
|
+
[data-cat-firstpage-only=true] [slot=side-b],
|
|
160
|
+
[data-cat-firstpage-only=true] .pn-animated-tile__toggle {
|
|
161
|
+
display: none;
|
|
162
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { Component, Element, h, Host, State, Watch } from '@stencil/core';
|
|
3
|
+
export class PnAnimatedTile {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.toggled = false;
|
|
6
|
+
this.transitionClassName = '';
|
|
7
|
+
this.animateIcon = '';
|
|
8
|
+
this.onClickHandler = () => {
|
|
9
|
+
this.toggled = !this.toggled;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
onToggledHandler() {
|
|
13
|
+
this.transitionClassName = classNames({ 'fade': this.toggled, 'fade--reversed': !this.toggled });
|
|
14
|
+
this.animateIcon = classNames({ 'animate': this.toggled, '': !this.toggled });
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return (h(Host, null,
|
|
18
|
+
h("div", { class: "pn-animated-tile__container" },
|
|
19
|
+
h("div", { class: `pn-animated-tile__content cat-animate ${this.transitionClassName}` },
|
|
20
|
+
h("slot", { name: "side-a" }),
|
|
21
|
+
h("slot", { name: "side-b" })),
|
|
22
|
+
h("button", { class: `pn-animated-tile__toggle cat-animate toggle ${this.animateIcon}`, onClick: this.onClickHandler },
|
|
23
|
+
h("pn-icon", { symbol: "plus" })))));
|
|
24
|
+
}
|
|
25
|
+
static get is() { return "pn-animated-tile"; }
|
|
26
|
+
static get originalStyleUrls() { return {
|
|
27
|
+
"$": ["pn-animated-tile.scss"]
|
|
28
|
+
}; }
|
|
29
|
+
static get styleUrls() { return {
|
|
30
|
+
"$": ["pn-animated-tile.css"]
|
|
31
|
+
}; }
|
|
32
|
+
static get states() { return {
|
|
33
|
+
"toggled": {},
|
|
34
|
+
"transitionClassName": {},
|
|
35
|
+
"animateIcon": {}
|
|
36
|
+
}; }
|
|
37
|
+
static get elementRef() { return "hostElement"; }
|
|
38
|
+
static get watchers() { return [{
|
|
39
|
+
"propName": "toggled",
|
|
40
|
+
"methodName": "onToggledHandler"
|
|
41
|
+
}]; }
|
|
42
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import readme from './readme.md';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Animation/Flip',
|
|
5
|
+
parameters: {
|
|
6
|
+
notes: readme,
|
|
7
|
+
layout: 'fullscreen',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const FlipDefault = args => {
|
|
12
|
+
return `
|
|
13
|
+
<div style="width:100%; display:flex; flex-direction:row; gap:16px;">
|
|
14
|
+
<div style="width:33%">
|
|
15
|
+
<pn-animated-tile data-cat-theme="private" data-cat-firstpage-only="true">
|
|
16
|
+
<div slot="side-a">
|
|
17
|
+
<div style="width:100%;height:100%; display: flex;justify-content: flex-end;align-items: center;">
|
|
18
|
+
<h2 style="color:#fff; font-size:7.2rem; text-align:right;">No <span style="display:block;color:#00A0D6; border-radius:0.4rem; background-color:#fff; padding: 0 0.8rem">side-b</span></h2>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<div slot="side-b"></div>
|
|
22
|
+
</pn-animated-tile>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div style="width:33%">
|
|
26
|
+
<pn-animated-tile data-cat-theme="business" data-cat-firstpage-only="false">
|
|
27
|
+
<div slot="side-a">
|
|
28
|
+
<div style="width:100%;height:100%; display: flex;justify-content: center;align-items: center;">
|
|
29
|
+
<h2 style="color:#FFF; font-size:7.2rem; text-align:right;">Track <span style="color:#F06365; border-radius:0.4rem; background-color:#005D92; padding: 0 0.8rem">shipments</span></h2>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div slot="side-b">
|
|
33
|
+
<div style="display:flex; flex-direction:column; justify-content:center;">
|
|
34
|
+
<h2 style="color:#FFF; padding:0 0.8rem">Heading</h2>
|
|
35
|
+
<p style="color:#FFF; padding:0 0.8rem">
|
|
36
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
37
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
38
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
39
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
40
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
41
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
42
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
43
|
+
Vivamus porta non ex vitae mollis.
|
|
44
|
+
|
|
45
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
46
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
47
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
48
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
49
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
50
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
51
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
52
|
+
Vivamus porta non ex vitae mollis.
|
|
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
|
+
</p>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</pn-animated-tile>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div style="width:33%">
|
|
69
|
+
<pn-animated-tile data-cat-theme="hybrid">
|
|
70
|
+
<div slot="side-a"></div>
|
|
71
|
+
<div slot="side-b">
|
|
72
|
+
<div style="display:flex; flex-direction:column; justify-content:center; height:100%;">
|
|
73
|
+
<h2 style="color:#2D2013; padding:0 0.8rem">Heading</h2>
|
|
74
|
+
<p style="color:#2D2013; padding:0 0.8rem">
|
|
75
|
+
Nam interdum urna ipsum, a volutpat tortor iaculis non.
|
|
76
|
+
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae;
|
|
77
|
+
Integer sed tortor a justo fermentum sodales. Cras sed posuere lorem, sit amet porttitor neque.
|
|
78
|
+
Nunc tincidunt, tellus eget dapibus dapibus, ligula lorem imperdiet nunc, non aliquet dolor metus id justo.
|
|
79
|
+
Vivamus tempus lacus eu mi convallis, et auctor sapien bibendum.
|
|
80
|
+
Donec non lacus mi. Nulla feugiat, sem quis accumsan aliquet, purus purus tincidunt nisi, a iaculis dolor neque non turpis. In quis nisi turpis.
|
|
81
|
+
Sed sit amet volutpat risus. Praesent arcu dolor, auctor a dictum in, egestas vel augue. Nunc molestie pulvinar mi a convallis.
|
|
82
|
+
Vivamus porta non ex vitae mollis.
|
|
83
|
+
</p>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</pn-animated-tile>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const Flip = FlipDefault.bind({});
|
|
93
|
+
Flip.args = {};
|
|
@@ -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 {};
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import type { Components, JSX } from "../types/components";
|
|
4
4
|
|
|
5
|
+
interface PnAnimatedTile extends Components.PnAnimatedTile, HTMLElement {}
|
|
6
|
+
export const PnAnimatedTile: {
|
|
7
|
+
prototype: PnAnimatedTile;
|
|
8
|
+
new (): PnAnimatedTile;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
interface PnBonusProgressbar extends Components.PnBonusProgressbar, HTMLElement {}
|
|
6
12
|
export const PnBonusProgressbar: {
|
|
7
13
|
prototype: PnBonusProgressbar;
|
|
@@ -194,6 +200,12 @@ export const PnMarketwebSiteheaderUnifiedLogin: {
|
|
|
194
200
|
new (): PnMarketwebSiteheaderUnifiedLogin;
|
|
195
201
|
};
|
|
196
202
|
|
|
203
|
+
interface PnMultiFormfield extends Components.PnMultiFormfield, HTMLElement {}
|
|
204
|
+
export const PnMultiFormfield: {
|
|
205
|
+
prototype: PnMultiFormfield;
|
|
206
|
+
new (): PnMultiFormfield;
|
|
207
|
+
};
|
|
208
|
+
|
|
197
209
|
interface PnParcelTracker extends Components.PnParcelTracker, HTMLElement {}
|
|
198
210
|
export const PnParcelTracker: {
|
|
199
211
|
prototype: PnParcelTracker;
|