@sitecore-jss/sitecore-jss-react 16.0.0-canary.8 → 16.0.1
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/LICENSE.txt +202 -202
- package/README.md +6 -6
- package/dist/components/File.js +4 -1
- package/dist/components/Image.js +21 -11
- package/dist/components/Link.js +10 -3
- package/dist/components/Placeholder.js +9 -2
- package/dist/components/PlaceholderCommon.js +20 -15
- package/dist/components/SitecoreContext.js +4 -3
- package/dist/components/VisitorIdentification.js +1 -1
- package/dist/enhancers/withComponentFactory.js +3 -0
- package/dist/enhancers/withPlaceholder.js +8 -2
- package/dist/enhancers/withSitecoreContext.js +6 -2
- package/dist/utils.js +5 -1
- package/package.json +15 -14
- package/types/components/Date.d.ts +2 -2
- package/types/components/File.d.ts +3 -2
- package/types/components/Image.d.ts +4 -5
- package/types/components/Link.d.ts +5 -1
- package/types/components/Placeholder.d.ts +3 -3
- package/types/components/PlaceholderCommon.d.ts +26 -12
- package/types/components/RichText.d.ts +1 -1
- package/types/components/SitecoreContext.d.ts +9 -9
- package/types/components/Text.d.ts +1 -1
- package/types/enhancers/withComponentFactory.d.ts +3 -0
- package/types/enhancers/withExperienceEditorChromes.d.ts +1 -1
- package/types/enhancers/withPlaceholder.d.ts +5 -1
- package/types/enhancers/withSitecoreContext.d.ts +9 -5
- package/types/index.d.ts +1 -1
- package/types/utils.d.ts +9 -1
package/LICENSE.txt
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright [yyyy] [name of copyright owner]
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Sitecore JavaScript Services for React
|
|
2
|
-
|
|
3
|
-
This module is provided as a part of Sitecore JavaScript Services. It contains React components and integration for JSS.
|
|
4
|
-
|
|
5
|
-
Consult the [Sitecore JSS documentation](https://jss.sitecore.net) for further details.
|
|
6
|
-
|
|
1
|
+
# Sitecore JavaScript Services for React
|
|
2
|
+
|
|
3
|
+
This module is provided as a part of Sitecore JavaScript Services. It contains React components and integration for JSS.
|
|
4
|
+
|
|
5
|
+
Consult the [Sitecore JSS documentation](https://jss.sitecore.net) for further details.
|
|
6
|
+
|
package/dist/components/File.js
CHANGED
|
@@ -37,7 +37,9 @@ exports.File = function (_a) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
// handle link directly on field for forgetful devs
|
|
40
|
-
var file = dynamicField.src
|
|
40
|
+
var file = (dynamicField.src
|
|
41
|
+
? field
|
|
42
|
+
: dynamicField.value);
|
|
41
43
|
if (!file) {
|
|
42
44
|
return null;
|
|
43
45
|
}
|
|
@@ -56,5 +58,6 @@ exports.File.propTypes = {
|
|
|
56
58
|
value: prop_types_1.default.object,
|
|
57
59
|
}),
|
|
58
60
|
]).isRequired,
|
|
61
|
+
children: prop_types_1.default.node,
|
|
59
62
|
};
|
|
60
63
|
exports.File.displayName = 'File';
|
package/dist/components/Image.js
CHANGED
|
@@ -63,28 +63,32 @@ exports.Image = function (_a) {
|
|
|
63
63
|
media = field;
|
|
64
64
|
}
|
|
65
65
|
var dynamicMedia = media;
|
|
66
|
-
if (!media ||
|
|
66
|
+
if (!media ||
|
|
67
|
+
(!dynamicMedia.editable && !dynamicMedia.value && !dynamicMedia.src)) {
|
|
67
68
|
return null;
|
|
68
69
|
}
|
|
70
|
+
var imageField = dynamicMedia;
|
|
69
71
|
// we likely have an experience editor value, should be a string
|
|
70
|
-
if (editable &&
|
|
71
|
-
var foundImg = sitecore_jss_1.mediaApi.findEditorImageTag(
|
|
72
|
+
if (editable && imageField.editable) {
|
|
73
|
+
var foundImg = sitecore_jss_1.mediaApi.findEditorImageTag(imageField.editable);
|
|
72
74
|
if (!foundImg) {
|
|
73
|
-
return getEditableWrapper(
|
|
75
|
+
return getEditableWrapper(imageField.editable);
|
|
74
76
|
}
|
|
75
77
|
var foundImgProps = utils_1.convertAttributesToReactProps(foundImg.attrs);
|
|
76
78
|
// Note: otherProps may override values from foundImgProps, e.g. `style`, `className` prop
|
|
77
79
|
// We do not attempt to merge.
|
|
78
80
|
var imgAttrs = getImageAttrs(__assign(__assign({}, foundImgProps), otherProps), imageParams, mediaUrlPrefix);
|
|
79
81
|
if (!imgAttrs) {
|
|
80
|
-
return getEditableWrapper(
|
|
82
|
+
return getEditableWrapper(imageField.editable);
|
|
81
83
|
}
|
|
82
84
|
var imgHtml = server_1.default.renderToStaticMarkup(react_1.default.createElement("img", __assign({}, imgAttrs)));
|
|
83
|
-
var editableMarkup =
|
|
85
|
+
var editableMarkup = imageField.editable.replace(foundImg.imgTag, imgHtml);
|
|
84
86
|
return getEditableWrapper(editableMarkup);
|
|
85
87
|
}
|
|
86
88
|
// some wise-guy/gal is passing in a 'raw' image object value
|
|
87
|
-
var img = dynamicMedia.src
|
|
89
|
+
var img = dynamicMedia.src
|
|
90
|
+
? media
|
|
91
|
+
: dynamicMedia.value;
|
|
88
92
|
if (!img) {
|
|
89
93
|
return null;
|
|
90
94
|
}
|
|
@@ -104,12 +108,18 @@ exports.Image.propTypes = {
|
|
|
104
108
|
editable: prop_types_1.default.string,
|
|
105
109
|
}),
|
|
106
110
|
]),
|
|
111
|
+
field: prop_types_1.default.oneOfType([
|
|
112
|
+
prop_types_1.default.shape({
|
|
113
|
+
src: prop_types_1.default.string,
|
|
114
|
+
}),
|
|
115
|
+
prop_types_1.default.shape({
|
|
116
|
+
value: prop_types_1.default.object,
|
|
117
|
+
editable: prop_types_1.default.string,
|
|
118
|
+
}),
|
|
119
|
+
]),
|
|
107
120
|
editable: prop_types_1.default.bool,
|
|
108
121
|
mediaUrlPrefix: prop_types_1.default.instanceOf(RegExp),
|
|
109
|
-
imageParams: prop_types_1.default.objectOf(prop_types_1.default.oneOfType([
|
|
110
|
-
prop_types_1.default.number.isRequired,
|
|
111
|
-
prop_types_1.default.string.isRequired
|
|
112
|
-
]).isRequired)
|
|
122
|
+
imageParams: prop_types_1.default.objectOf(prop_types_1.default.oneOfType([prop_types_1.default.number.isRequired, prop_types_1.default.string.isRequired]).isRequired),
|
|
113
123
|
};
|
|
114
124
|
exports.Image.defaultProps = {
|
|
115
125
|
editable: true,
|
package/dist/components/Link.js
CHANGED
|
@@ -30,7 +30,10 @@ var prop_types_1 = __importDefault(require("prop-types"));
|
|
|
30
30
|
exports.Link = function (_a) {
|
|
31
31
|
var field = _a.field, editable = _a.editable, children = _a.children, showLinkTextWithChildrenPresent = _a.showLinkTextWithChildrenPresent, otherProps = __rest(_a, ["field", "editable", "children", "showLinkTextWithChildrenPresent"]);
|
|
32
32
|
var dynamicField = field;
|
|
33
|
-
if (!field ||
|
|
33
|
+
if (!field ||
|
|
34
|
+
(!dynamicField.editableFirstPart &&
|
|
35
|
+
!dynamicField.value &&
|
|
36
|
+
!dynamicField.href)) {
|
|
34
37
|
return null;
|
|
35
38
|
}
|
|
36
39
|
var resultTags = [];
|
|
@@ -52,7 +55,9 @@ exports.Link = function (_a) {
|
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
// handle link directly on field for forgetful devs
|
|
55
|
-
var link = dynamicField.href
|
|
58
|
+
var link = dynamicField.href
|
|
59
|
+
? field
|
|
60
|
+
: dynamicField.value;
|
|
56
61
|
if (!link) {
|
|
57
62
|
return null;
|
|
58
63
|
}
|
|
@@ -66,7 +71,7 @@ exports.Link = function (_a) {
|
|
|
66
71
|
// information disclosure attack prevention keeps target blank site from getting ref to window.opener
|
|
67
72
|
anchorAttrs.rel = 'noopener noreferrer';
|
|
68
73
|
}
|
|
69
|
-
var linkText = showLinkTextWithChildrenPresent || !children ?
|
|
74
|
+
var linkText = showLinkTextWithChildrenPresent || !children ? link.text || link.href : null;
|
|
70
75
|
resultTags.push(react_1.default.createElement('a', __assign(__assign(__assign({}, anchorAttrs), otherProps), { key: 'link' }), linkText, children));
|
|
71
76
|
return react_1.default.createElement(react_1.default.Fragment, null, resultTags);
|
|
72
77
|
};
|
|
@@ -82,6 +87,8 @@ exports.LinkPropTypes = {
|
|
|
82
87
|
}),
|
|
83
88
|
]).isRequired,
|
|
84
89
|
editable: prop_types_1.default.bool,
|
|
90
|
+
children: prop_types_1.default.node,
|
|
91
|
+
showLinkTextWithChildrenPresent: prop_types_1.default.bool,
|
|
85
92
|
};
|
|
86
93
|
exports.Link.propTypes = exports.LinkPropTypes;
|
|
87
94
|
exports.Link.defaultProps = {
|
|
@@ -30,8 +30,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
var react_1 = __importDefault(require("react"));
|
|
31
31
|
var PlaceholderCommon_1 = require("./PlaceholderCommon");
|
|
32
32
|
var withComponentFactory_1 = require("../enhancers/withComponentFactory");
|
|
33
|
+
/**
|
|
34
|
+
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
35
|
+
*/
|
|
33
36
|
function isRawRendering(rendering) {
|
|
34
|
-
return !rendering.componentName &&
|
|
37
|
+
return (!rendering.componentName &&
|
|
38
|
+
rendering.name !== undefined);
|
|
35
39
|
}
|
|
36
40
|
var PlaceholderComponent = /** @class */ (function (_super) {
|
|
37
41
|
__extends(PlaceholderComponent, _super);
|
|
@@ -53,7 +57,10 @@ var PlaceholderComponent = /** @class */ (function (_super) {
|
|
|
53
57
|
var renderingData = childProps.rendering;
|
|
54
58
|
var placeholderData = PlaceholderCommon_1.PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, this.props.name);
|
|
55
59
|
var components = this.getComponentsForRenderingData(placeholderData);
|
|
56
|
-
if (this.props.renderEmpty &&
|
|
60
|
+
if (this.props.renderEmpty &&
|
|
61
|
+
placeholderData.every(function (rendering) {
|
|
62
|
+
return isRawRendering(rendering);
|
|
63
|
+
})) {
|
|
57
64
|
return this.props.renderEmpty(components);
|
|
58
65
|
}
|
|
59
66
|
else if (this.props.render) {
|
|
@@ -79,23 +79,28 @@ var PlaceholderCommon = /** @class */ (function (_super) {
|
|
|
79
79
|
PlaceholderCommon.prototype.getComponentsForRenderingData = function (placeholderData) {
|
|
80
80
|
var _this = this;
|
|
81
81
|
var _a = this.props, name = _a.name, placeholderFields = _a.fields, placeholderParams = _a.params, missingComponentComponent = _a.missingComponentComponent, placeholderProps = __rest(_a, ["name", "fields", "params", "missingComponentComponent"]);
|
|
82
|
-
return placeholderData
|
|
83
|
-
|
|
82
|
+
return placeholderData
|
|
83
|
+
.map(function (rendering, index) {
|
|
84
|
+
var key = rendering.uid
|
|
85
|
+
? rendering.uid
|
|
86
|
+
: "component-" + index;
|
|
84
87
|
var commonProps = { key: key };
|
|
85
88
|
// if the element is not a 'component rendering', render it 'raw'
|
|
86
|
-
if (!rendering.componentName &&
|
|
89
|
+
if (!rendering.componentName &&
|
|
90
|
+
rendering.name) {
|
|
87
91
|
return _this.createRawElement(rendering, commonProps);
|
|
88
92
|
}
|
|
89
|
-
var
|
|
93
|
+
var componentRendering = rendering;
|
|
94
|
+
var component = _this.getComponentForRendering(componentRendering);
|
|
90
95
|
if (!component) {
|
|
91
|
-
console.error("Placeholder " + name + " contains unknown component " +
|
|
96
|
+
console.error("Placeholder " + name + " contains unknown component " + componentRendering.componentName + ". Ensure that a React component exists for it, and that it is registered in your componentFactory.js.");
|
|
92
97
|
component = (missingComponentComponent !== null && missingComponentComponent !== void 0 ? missingComponentComponent : MissingComponent_1.MissingComponent);
|
|
93
98
|
}
|
|
94
|
-
var finalProps = __assign(__assign(__assign(__assign(__assign({}, commonProps), placeholderProps), ((placeholderFields ||
|
|
95
|
-
fields: __assign(__assign({}, placeholderFields),
|
|
96
|
-
})), ((placeholderParams ||
|
|
97
|
-
params: __assign(__assign({}, placeholderParams),
|
|
98
|
-
})), { rendering:
|
|
99
|
+
var finalProps = __assign(__assign(__assign(__assign(__assign({}, commonProps), placeholderProps), ((placeholderFields || componentRendering.fields) && {
|
|
100
|
+
fields: __assign(__assign({}, placeholderFields), componentRendering.fields),
|
|
101
|
+
})), ((placeholderParams || componentRendering.params) && {
|
|
102
|
+
params: __assign(__assign({}, placeholderParams), componentRendering.params),
|
|
103
|
+
})), { rendering: componentRendering });
|
|
99
104
|
return react_1.default.createElement(component, finalProps);
|
|
100
105
|
})
|
|
101
106
|
.filter(function (element) { return element; }); // remove nulls
|
|
@@ -121,7 +126,7 @@ var PlaceholderCommon = /** @class */ (function (_super) {
|
|
|
121
126
|
/* Since we can't set the "key" attribute via React, stash it
|
|
122
127
|
* so we can set in the DOM after render.
|
|
123
128
|
*/
|
|
124
|
-
if (attributes && attributes.chrometype === 'placeholder') {
|
|
129
|
+
if (!Array.isArray(attributes) && attributes && attributes.chrometype === 'placeholder') {
|
|
125
130
|
props.phkey = elem.attributes.key; // props that get rendered as dom attribute names need to be lowercase, otherwise React complains.
|
|
126
131
|
props.ref = this.addRef; // only need ref for placeholder containers, trying to add it to other components (e.g. stateless components) may result in a warning.
|
|
127
132
|
}
|
|
@@ -147,20 +152,20 @@ var PlaceholderCommon = /** @class */ (function (_super) {
|
|
|
147
152
|
PlaceholderCommon.propTypes = {
|
|
148
153
|
rendering: prop_types_1.default.oneOfType([
|
|
149
154
|
prop_types_1.default.object,
|
|
150
|
-
prop_types_1.default.object
|
|
155
|
+
prop_types_1.default.object,
|
|
151
156
|
]).isRequired,
|
|
152
157
|
fields: prop_types_1.default.objectOf(prop_types_1.default.oneOfType([
|
|
153
158
|
prop_types_1.default.object,
|
|
154
|
-
prop_types_1.default.object
|
|
159
|
+
prop_types_1.default.object,
|
|
155
160
|
]).isRequired),
|
|
156
161
|
params: prop_types_1.default.objectOf(prop_types_1.default.string.isRequired),
|
|
157
162
|
missingComponentComponent: prop_types_1.default.oneOfType([
|
|
158
163
|
prop_types_1.default.object,
|
|
159
|
-
prop_types_1.default.func
|
|
164
|
+
prop_types_1.default.func,
|
|
160
165
|
]),
|
|
161
166
|
errorComponent: prop_types_1.default.oneOfType([
|
|
162
167
|
prop_types_1.default.object,
|
|
163
|
-
prop_types_1.default.
|
|
168
|
+
prop_types_1.default.func,
|
|
164
169
|
]),
|
|
165
170
|
};
|
|
166
171
|
return PlaceholderCommon;
|
|
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
19
20
|
var react_1 = __importDefault(require("react"));
|
|
20
21
|
var prop_types_1 = __importDefault(require("prop-types"));
|
|
21
22
|
exports.SitecoreContextReactContext = react_1.default.createContext({});
|
|
@@ -26,7 +27,7 @@ var SitecoreContext = /** @class */ (function (_super) {
|
|
|
26
27
|
var _this = _super.call(this, props) || this;
|
|
27
28
|
_this.setContext = function (value) {
|
|
28
29
|
_this.setState({
|
|
29
|
-
context: value
|
|
30
|
+
context: value,
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
33
|
var context = {
|
|
@@ -40,7 +41,7 @@ var SitecoreContext = /** @class */ (function (_super) {
|
|
|
40
41
|
}
|
|
41
42
|
_this.state = {
|
|
42
43
|
context: context,
|
|
43
|
-
setContext: _this.setContext
|
|
44
|
+
setContext: _this.setContext,
|
|
44
45
|
};
|
|
45
46
|
return _this;
|
|
46
47
|
}
|
|
@@ -51,7 +52,7 @@ var SitecoreContext = /** @class */ (function (_super) {
|
|
|
51
52
|
SitecoreContext.propTypes = {
|
|
52
53
|
children: prop_types_1.default.any.isRequired,
|
|
53
54
|
componentFactory: prop_types_1.default.func,
|
|
54
|
-
context: prop_types_1.default.any
|
|
55
|
+
context: prop_types_1.default.any,
|
|
55
56
|
};
|
|
56
57
|
SitecoreContext.displayName = 'SitecoreContext';
|
|
57
58
|
return SitecoreContext;
|
|
@@ -13,7 +13,7 @@ var VIComponent = function (_a) {
|
|
|
13
13
|
}
|
|
14
14
|
emittedVI = true;
|
|
15
15
|
var script = document.createElement('script');
|
|
16
|
-
script.src =
|
|
16
|
+
script.src = '/layouts/system/VisitorIdentification.js';
|
|
17
17
|
script.type = 'text/javascript';
|
|
18
18
|
var meta = document.createElement('meta');
|
|
19
19
|
meta.name = 'VIcurrentDateTime';
|
|
@@ -16,6 +16,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var react_1 = __importDefault(require("react"));
|
|
18
18
|
var SitecoreContext_1 = require("../components/SitecoreContext");
|
|
19
|
+
/**
|
|
20
|
+
* @param {React.ComponentClass<T> | React.SFC<T>} Component
|
|
21
|
+
*/
|
|
19
22
|
function withComponentFactory(Component) {
|
|
20
23
|
return function WithComponentFactory(props) {
|
|
21
24
|
return (react_1.default.createElement(SitecoreContext_1.ComponentFactoryReactContext.Consumer, null, function (context) { return react_1.default.createElement(Component, __assign({}, props, { componentFactory: props.componentFactory || context })); }));
|
|
@@ -30,7 +30,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
var react_1 = __importDefault(require("react"));
|
|
31
31
|
var PlaceholderCommon_1 = require("../components/PlaceholderCommon");
|
|
32
32
|
var withComponentFactory_1 = require("./withComponentFactory");
|
|
33
|
+
/**
|
|
34
|
+
* @param {WithPlaceholderSpec} placeholders
|
|
35
|
+
* @param {WithPlaceholderOptions} [options]
|
|
36
|
+
*/
|
|
33
37
|
function withPlaceholder(placeholders, options) {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
39
|
return function (WrappedComponent) {
|
|
35
40
|
var WithPlaceholder = /** @class */ (function (_super) {
|
|
36
41
|
__extends(WithPlaceholder, _super);
|
|
@@ -57,10 +62,11 @@ function withPlaceholder(placeholders, options) {
|
|
|
57
62
|
? options.resolvePlaceholderDataFromProps(childProps)
|
|
58
63
|
: childProps.rendering;
|
|
59
64
|
var definitelyArrayPlacholders = !Array.isArray(placeholders)
|
|
60
|
-
? [placeholders]
|
|
65
|
+
? [placeholders]
|
|
66
|
+
: placeholders;
|
|
61
67
|
definitelyArrayPlacholders.forEach(function (placeholder) {
|
|
62
68
|
var placeholderData;
|
|
63
|
-
if (placeholder.placeholder && placeholder.prop) {
|
|
69
|
+
if (typeof placeholder !== 'string' && placeholder.placeholder && placeholder.prop) {
|
|
64
70
|
placeholderData = PlaceholderCommon_1.PlaceholderCommon.getPlaceholderDataFromRenderingData(renderingData, placeholder.placeholder);
|
|
65
71
|
if (placeholderData) {
|
|
66
72
|
childProps[placeholder.prop] = _this.getComponentsForRenderingData(placeholderData);
|
|
@@ -16,6 +16,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var react_1 = __importDefault(require("react"));
|
|
18
18
|
var SitecoreContext_1 = require("../components/SitecoreContext");
|
|
19
|
+
/**
|
|
20
|
+
* @param {WithSitecoreContextOptions} [options]
|
|
21
|
+
*/
|
|
19
22
|
function withSitecoreContext(options) {
|
|
20
23
|
return function withSitecoreContextHoc(Component) {
|
|
21
24
|
return function WithSitecoreContext(props) {
|
|
@@ -33,7 +36,7 @@ exports.withSitecoreContext = withSitecoreContext;
|
|
|
33
36
|
*
|
|
34
37
|
* @see https://jss.sitecore.com/docs/techniques/extending-layout-service/layoutservice-extending-context
|
|
35
38
|
*
|
|
36
|
-
* @param {WithSitecoreContextOptions} [options]
|
|
39
|
+
* @param {WithSitecoreContextOptions} [options] hook options
|
|
37
40
|
*
|
|
38
41
|
* @example
|
|
39
42
|
* const EditMode = () => {
|
|
@@ -47,6 +50,7 @@ exports.withSitecoreContext = withSitecoreContext;
|
|
|
47
50
|
* const onClick = () => updateSitecoreContext({ pageEditing: true });
|
|
48
51
|
* return <span onClick={onClick}>Edit Mode is {sitecoreContext.pageEditing ? 'active' : 'inactive'}</span>
|
|
49
52
|
* }
|
|
53
|
+
* @returns {Object} { sitecoreContext, updateSitecoreContext }
|
|
50
54
|
*/
|
|
51
55
|
function useSitecoreContext(options) {
|
|
52
56
|
var _a;
|
|
@@ -54,7 +58,7 @@ function useSitecoreContext(options) {
|
|
|
54
58
|
var updatable = (_a = options) === null || _a === void 0 ? void 0 : _a.updatable;
|
|
55
59
|
return {
|
|
56
60
|
sitecoreContext: reactContext.context,
|
|
57
|
-
updateSitecoreContext: updatable ? reactContext.setContext : undefined
|
|
61
|
+
updateSitecoreContext: updatable ? reactContext.setContext : undefined,
|
|
58
62
|
};
|
|
59
63
|
}
|
|
60
64
|
exports.useSitecoreContext = useSitecoreContext;
|
package/dist/utils.js
CHANGED
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var style_attr_1 = require("style-attr");
|
|
4
4
|
// https://stackoverflow.com/a/10426674/9324
|
|
5
5
|
exports.convertKebabCasetoCamelCase = function (str) {
|
|
6
|
-
return str.replace(/^.|-./g, function (letter, index) {
|
|
6
|
+
return str.replace(/^.|-./g, function (letter, index) {
|
|
7
|
+
return index === 0 ? letter.toLowerCase() : letter.substr(1).toUpperCase();
|
|
8
|
+
});
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
11
|
* https://facebook.github.io/react/docs/dom-elements.html
|
|
10
12
|
* We are only concerned with style at the moment, which needs to be converted from string to object to satisfy React.
|
|
11
13
|
* We don't need to convert any other attributes (that we know of), because the placeholder renders them "as-is" by using the special "is" React prop.
|
|
12
14
|
* For whatever reason though, the "style" prop is still validated as needing to be an object when using the "is" prop, which is why we need to convert from string to object.
|
|
15
|
+
* @param {string} [style] style
|
|
16
|
+
* @returns {Array} converted attributes
|
|
13
17
|
*/
|
|
14
18
|
exports.convertStyleAttribute = function (style) {
|
|
15
19
|
if (style === void 0) { style = ''; }
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run clean && tsc",
|
|
7
7
|
"clean": "del-cli dist types",
|
|
8
|
-
"lint": "
|
|
8
|
+
"lint": "eslint ./src/**/*.tsx ./src/**/*.ts",
|
|
9
9
|
"test": "mocha --require ts-node/register --require ./src/tests/shim.ts ./src/tests/jsdom-setup.ts ./src/tests/enzyme-setup.ts \"./src/**/*.test.ts\" \"./src/**/*.test.tsx\"",
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
|
-
"coverage": "nyc
|
|
11
|
+
"coverage": "nyc npm test"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=8.1"
|
|
@@ -27,40 +27,41 @@
|
|
|
27
27
|
"@types/chai-spies": "^1.0.1",
|
|
28
28
|
"@types/chai-string": "^1.4.2",
|
|
29
29
|
"@types/enzyme": "^3.10.3",
|
|
30
|
-
"@types/enzyme-adapter-react-16": "^1.0.5",
|
|
31
30
|
"@types/mocha": "^5.2.7",
|
|
32
31
|
"@types/node": "12.7.5",
|
|
33
32
|
"@types/prop-types": "^15.7.2",
|
|
34
|
-
"@types/react": "
|
|
35
|
-
"@types/react-dom": "^
|
|
33
|
+
"@types/react": "^17.0.0",
|
|
34
|
+
"@types/react-dom": "^17.0.0",
|
|
36
35
|
"@types/url-parse": "^1.4.3",
|
|
36
|
+
"@wojtekmaj/enzyme-adapter-react-17": "^0.4.1",
|
|
37
37
|
"chai": "^4.2.0",
|
|
38
38
|
"chai-spies": "^1.0.0",
|
|
39
39
|
"chai-string": "^1.5.0",
|
|
40
40
|
"del-cli": "^3.0.1",
|
|
41
41
|
"enzyme": "^3.10.0",
|
|
42
|
-
"
|
|
42
|
+
"eslint": "^7.15.0",
|
|
43
|
+
"eslint-plugin-react": "^7.21.5",
|
|
43
44
|
"jsdom": "^15.1.1",
|
|
44
45
|
"mocha": "^8.1.3",
|
|
45
|
-
"
|
|
46
|
-
"react
|
|
46
|
+
"nyc": "^15.1.0",
|
|
47
|
+
"react": "^17.0.1",
|
|
48
|
+
"react-dom": "^17.0.1",
|
|
47
49
|
"react-test-renderer": "^16.9.0",
|
|
48
50
|
"sinon": "^7.4.2",
|
|
49
51
|
"ts-node": "^8.3.0",
|
|
50
|
-
"tslint-react": "^4.0.0",
|
|
51
52
|
"typescript": "3.7.5",
|
|
52
53
|
"url-parse": "^1.4.7"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"react": "^
|
|
56
|
-
"react-dom": "^
|
|
56
|
+
"react": "^17.0.1",
|
|
57
|
+
"react-dom": "^17.0.1"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@sitecore-jss/sitecore-jss": "^16.0.
|
|
60
|
+
"@sitecore-jss/sitecore-jss": "^16.0.1",
|
|
60
61
|
"prop-types": "^15.7.2",
|
|
61
62
|
"style-attr": "^1.3.0"
|
|
62
63
|
},
|
|
63
64
|
"description": "",
|
|
64
65
|
"types": "types/index.d.ts",
|
|
65
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "29ff3559b0c3d263ba4c84a3cfab4f1b980d9272"
|
|
66
67
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface DateFieldProps {
|
|
3
3
|
/** The date field data. */
|
|
4
|
+
[htmlAttributes: string]: unknown;
|
|
4
5
|
field: {
|
|
5
6
|
value?: string;
|
|
6
7
|
editable?: string;
|
|
@@ -15,7 +16,6 @@ export interface DateFieldProps {
|
|
|
15
16
|
* @default true
|
|
16
17
|
*/
|
|
17
18
|
editable?: boolean;
|
|
18
|
-
render?: (date: Date | null) => React.ComponentClass<
|
|
19
|
-
[htmlAttributes: string]: any;
|
|
19
|
+
render?: (date: Date | null) => React.ComponentClass<unknown> | React.FunctionComponent<unknown> | React.ReactNode;
|
|
20
20
|
}
|
|
21
21
|
export declare const DateField: React.SFC<DateFieldProps>;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface FileFieldValue {
|
|
3
|
+
[propName: string]: unknown;
|
|
3
4
|
src?: string;
|
|
4
5
|
title?: string;
|
|
5
6
|
displayName?: string;
|
|
6
|
-
[propName: string]: any;
|
|
7
7
|
}
|
|
8
8
|
export interface FileField {
|
|
9
9
|
value: FileFieldValue;
|
|
10
10
|
}
|
|
11
11
|
export interface FileProps {
|
|
12
|
+
[attributeName: string]: unknown;
|
|
12
13
|
/** The file field data. */
|
|
13
14
|
field: FileFieldValue | FileField;
|
|
14
15
|
/** HTML attributes that will be appended to the rendered <a /> tag. */
|
|
15
|
-
|
|
16
|
+
children?: React.ReactNode;
|
|
16
17
|
}
|
|
17
18
|
export declare const File: React.SFC<FileProps>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ImageFieldValue {
|
|
3
|
+
[attributeName: string]: unknown;
|
|
3
4
|
src?: string;
|
|
4
|
-
/** HTML attributes that will be appended to the rendered <img /> tag. */
|
|
5
|
-
[attributeName: string]: any;
|
|
6
5
|
}
|
|
7
6
|
export interface ImageField {
|
|
8
7
|
value?: ImageFieldValue;
|
|
9
8
|
editable?: string;
|
|
10
9
|
}
|
|
11
10
|
export interface ImageSizeParameters {
|
|
11
|
+
[attr: string]: string | number | undefined;
|
|
12
12
|
/** Fixed width of the image */
|
|
13
13
|
w?: number;
|
|
14
14
|
/** Fixed height of the image */
|
|
@@ -25,6 +25,7 @@ export interface ImageSizeParameters {
|
|
|
25
25
|
sc?: number;
|
|
26
26
|
}
|
|
27
27
|
export interface ImageProps {
|
|
28
|
+
[attributeName: string]: unknown;
|
|
28
29
|
/**
|
|
29
30
|
* The image field data.
|
|
30
31
|
* @deprecated use field property instead
|
|
@@ -44,7 +45,7 @@ export interface ImageProps {
|
|
|
44
45
|
imageParams?: {
|
|
45
46
|
[paramName: string]: string | number;
|
|
46
47
|
};
|
|
47
|
-
srcSet?:
|
|
48
|
+
srcSet?: ImageSizeParameters[];
|
|
48
49
|
/**
|
|
49
50
|
* Custom regexp that finds media URL prefix that will be replaced by `/-/jssmedia` or `/~/jssmedia`.
|
|
50
51
|
* @example
|
|
@@ -53,7 +54,5 @@ export interface ImageProps {
|
|
|
53
54
|
* /~assets/website -> /~/jssmedia/website
|
|
54
55
|
*/
|
|
55
56
|
mediaUrlPrefix?: RegExp;
|
|
56
|
-
/** HTML attributes that will be appended to the rendered <img /> tag. */
|
|
57
|
-
[attributeName: string]: any;
|
|
58
57
|
}
|
|
59
58
|
export declare const Image: React.SFC<ImageProps>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export interface LinkFieldValue {
|
|
4
|
+
[attributeName: string]: unknown;
|
|
4
5
|
href?: string;
|
|
5
6
|
className?: string;
|
|
7
|
+
class?: string;
|
|
6
8
|
title?: string;
|
|
7
9
|
target?: string;
|
|
8
|
-
|
|
10
|
+
text?: string;
|
|
9
11
|
}
|
|
10
12
|
export interface LinkField {
|
|
11
13
|
value: LinkFieldValue;
|
|
@@ -37,4 +39,6 @@ export declare const LinkPropTypes: {
|
|
|
37
39
|
editableLastPart: PropTypes.Requireable<string>;
|
|
38
40
|
}>>;
|
|
39
41
|
editable: PropTypes.Requireable<boolean>;
|
|
42
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
43
|
+
showLinkTextWithChildrenPresent: PropTypes.Requireable<boolean>;
|
|
40
44
|
};
|
|
@@ -6,16 +6,16 @@ export interface PlaceholderComponentProps extends PlaceholderProps {
|
|
|
6
6
|
* Render props function that is called when the placeholder contains no content components.
|
|
7
7
|
* Can be used to wrap the Sitecore EE empty placeholder markup in something that's visually correct
|
|
8
8
|
*/
|
|
9
|
-
renderEmpty?: (components: React.ReactNode[]) => React.ComponentClass<
|
|
9
|
+
renderEmpty?: (components: React.ReactNode[]) => React.ComponentClass<unknown> | React.SFC<unknown> | React.ReactNode;
|
|
10
10
|
/**
|
|
11
11
|
* Render props function that enables control over the rendering of the components in the placeholder.
|
|
12
12
|
* Useful for techniques like wrapping each child in a wrapper component.
|
|
13
13
|
*/
|
|
14
|
-
render?: (components: React.ReactNode[], data: (ComponentRendering | HtmlElementRendering)[], props: PlaceholderProps) => React.ComponentClass<
|
|
14
|
+
render?: (components: React.ReactNode[], data: (ComponentRendering | HtmlElementRendering)[], props: PlaceholderProps) => React.ComponentClass<unknown> | React.SFC<unknown> | React.ReactNode;
|
|
15
15
|
/**
|
|
16
16
|
* Render props function that is called for each non-system component added to the placeholder.
|
|
17
17
|
* Mutually exclusive with `render`. System components added during Experience Editor are automatically rendered as-is.
|
|
18
18
|
*/
|
|
19
|
-
renderEach?: (component: React.ReactNode, index: number) => React.ComponentClass<
|
|
19
|
+
renderEach?: (component: React.ReactNode, index: number) => React.ComponentClass<unknown> | React.SFC<unknown> | React.ReactNode;
|
|
20
20
|
}
|
|
21
21
|
export declare const Placeholder: (props: PlaceholderComponentProps) => JSX.Element;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ComponentFactory } from '../components/sharedTypes';
|
|
4
4
|
import { ComponentRendering, RouteData, Field, Item, HtmlElementRendering } from '@sitecore-jss/sitecore-jss';
|
|
5
|
+
declare type ErrorComponentProps = {
|
|
6
|
+
[prop: string]: unknown;
|
|
7
|
+
};
|
|
5
8
|
export interface PlaceholderProps {
|
|
9
|
+
[key: string]: unknown;
|
|
6
10
|
/** Name of the placeholder to render. */
|
|
7
11
|
name: string;
|
|
8
12
|
/** Rendering data to be used when rendering the placeholder. */
|
|
@@ -30,13 +34,12 @@ export interface PlaceholderProps {
|
|
|
30
34
|
* A component that is rendered in place of any components that are in this placeholder,
|
|
31
35
|
* but do not have a definition in the componentFactory (i.e. don't have a React implementation)
|
|
32
36
|
*/
|
|
33
|
-
missingComponentComponent?: React.ComponentClass<
|
|
37
|
+
missingComponentComponent?: React.ComponentClass<unknown> | React.FC<unknown>;
|
|
34
38
|
/**
|
|
35
39
|
* A component that is rendered in place of the placeholder when an error occurs rendering
|
|
36
40
|
* the placeholder
|
|
37
41
|
*/
|
|
38
|
-
errorComponent?: React.ComponentClass<
|
|
39
|
-
[key: string]: any;
|
|
42
|
+
errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
|
|
40
43
|
}
|
|
41
44
|
export declare class PlaceholderCommon<T extends PlaceholderProps> extends React.Component<T> {
|
|
42
45
|
static propTypes: {
|
|
@@ -47,23 +50,34 @@ export declare class PlaceholderCommon<T extends PlaceholderProps> extends React
|
|
|
47
50
|
params: PropTypes.Requireable<{
|
|
48
51
|
[x: string]: string;
|
|
49
52
|
}>;
|
|
50
|
-
missingComponentComponent: PropTypes.Requireable<React.ComponentClass<
|
|
51
|
-
errorComponent: PropTypes.Requireable<React.ComponentClass<
|
|
53
|
+
missingComponentComponent: PropTypes.Requireable<React.ComponentClass<unknown, any> | React.FC<unknown>>;
|
|
54
|
+
errorComponent: PropTypes.Requireable<React.ComponentClass<unknown, any> | React.FC<unknown>>;
|
|
52
55
|
};
|
|
53
|
-
nodeRefs:
|
|
56
|
+
nodeRefs: Element[];
|
|
54
57
|
state: Readonly<{
|
|
55
58
|
error?: Error;
|
|
56
59
|
}>;
|
|
57
|
-
static getPlaceholderDataFromRenderingData(rendering: ComponentRendering | RouteData, name: string): (ComponentRendering | HtmlElementRendering)[];
|
|
58
60
|
constructor(props: T);
|
|
61
|
+
static getPlaceholderDataFromRenderingData(rendering: ComponentRendering | RouteData, name: string): (ComponentRendering | HtmlElementRendering)[];
|
|
59
62
|
componentDidMount(): void;
|
|
60
63
|
componentDidUpdate(): void;
|
|
61
64
|
componentDidCatch(error: Error): void;
|
|
62
|
-
getComponentsForRenderingData(placeholderData: (ComponentRendering | HtmlElementRendering)[]): (React.
|
|
65
|
+
getComponentsForRenderingData(placeholderData: (ComponentRendering | HtmlElementRendering)[]): (React.ReactElement<{
|
|
66
|
+
[attr: string]: unknown;
|
|
67
|
+
}, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null)[];
|
|
63
68
|
getComponentForRendering(renderingDefinition: {
|
|
64
69
|
componentName: string;
|
|
65
|
-
}):
|
|
66
|
-
addRef(nodeRef:
|
|
67
|
-
createRawElement(elem:
|
|
70
|
+
}): ComponentType | null;
|
|
71
|
+
addRef(nodeRef: Element): void;
|
|
72
|
+
createRawElement(elem: HtmlElementRendering, baseProps: {
|
|
73
|
+
key?: string;
|
|
74
|
+
}): React.ReactElement<{
|
|
75
|
+
[attr: string]: unknown;
|
|
76
|
+
key?: string | undefined;
|
|
77
|
+
dangerouslySetInnerHTML: {
|
|
78
|
+
__html: string | null;
|
|
79
|
+
};
|
|
80
|
+
}, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null;
|
|
68
81
|
updateKeyAttributes(): void;
|
|
69
82
|
}
|
|
83
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export interface RichTextProps {
|
|
4
|
+
[htmlAttributes: string]: unknown;
|
|
4
5
|
/** The rich text field data. */
|
|
5
6
|
field?: {
|
|
6
7
|
value?: string;
|
|
@@ -17,7 +18,6 @@ export interface RichTextProps {
|
|
|
17
18
|
* @default true
|
|
18
19
|
*/
|
|
19
20
|
editable?: boolean;
|
|
20
|
-
[htmlAttributes: string]: any;
|
|
21
21
|
}
|
|
22
22
|
export declare const RichText: React.SFC<RichTextProps>;
|
|
23
23
|
export declare const RichTextPropTypes: {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ComponentFactory } from './sharedTypes';
|
|
4
|
-
export interface SitecoreContextProps {
|
|
4
|
+
export interface SitecoreContextProps<ContextType = any> {
|
|
5
5
|
componentFactory: ComponentFactory;
|
|
6
|
-
context?:
|
|
6
|
+
context?: ContextType;
|
|
7
7
|
}
|
|
8
|
-
export interface SitecoreContextState {
|
|
9
|
-
setContext: (value:
|
|
10
|
-
context:
|
|
8
|
+
export interface SitecoreContextState<ContextType = any> {
|
|
9
|
+
setContext: (value: ContextType) => void;
|
|
10
|
+
context: ContextType;
|
|
11
11
|
}
|
|
12
|
-
export declare const SitecoreContextReactContext: React.Context<SitecoreContextState
|
|
12
|
+
export declare const SitecoreContextReactContext: React.Context<SitecoreContextState<any>>;
|
|
13
13
|
export declare const ComponentFactoryReactContext: React.Context<ComponentFactory>;
|
|
14
|
-
export declare class SitecoreContext extends React.Component<SitecoreContextProps
|
|
14
|
+
export declare class SitecoreContext<ContextType = any> extends React.Component<SitecoreContextProps<ContextType>, SitecoreContextState<ContextType>> {
|
|
15
15
|
static propTypes: {
|
|
16
16
|
children: PropTypes.Validator<any>;
|
|
17
17
|
componentFactory: PropTypes.Requireable<(...args: any[]) => any>;
|
|
18
18
|
context: PropTypes.Requireable<any>;
|
|
19
19
|
};
|
|
20
20
|
static displayName: string;
|
|
21
|
-
constructor(props: SitecoreContextProps);
|
|
22
|
-
setContext: (value:
|
|
21
|
+
constructor(props: SitecoreContextProps<ContextType>);
|
|
22
|
+
setContext: (value: ContextType) => void;
|
|
23
23
|
render(): JSX.Element;
|
|
24
24
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
export interface TextProps {
|
|
3
|
+
[htmlAttributes: string]: unknown;
|
|
3
4
|
/** The text field data. */
|
|
4
5
|
field?: {
|
|
5
6
|
value?: string;
|
|
@@ -19,6 +20,5 @@ export interface TextProps {
|
|
|
19
20
|
* If false, HTML-encoding of the field value is disabled and the value is rendered as-is.
|
|
20
21
|
*/
|
|
21
22
|
encode?: boolean;
|
|
22
|
-
[htmlAttributes: string]: any;
|
|
23
23
|
}
|
|
24
24
|
export declare const Text: FunctionComponent<TextProps>;
|
|
@@ -3,4 +3,7 @@ import { ComponentFactory } from '../components/sharedTypes';
|
|
|
3
3
|
export interface ComponentFactoryProps {
|
|
4
4
|
componentFactory?: ComponentFactory;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* @param {React.ComponentClass<T> | React.SFC<T>} Component
|
|
8
|
+
*/
|
|
6
9
|
export declare function withComponentFactory<T extends ComponentFactoryProps>(Component: React.ComponentClass<T> | React.SFC<T>): (props: T) => JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const withExperienceEditorChromes: (WrappedComponent: React.ComponentClass<
|
|
2
|
+
export declare const withExperienceEditorChromes: (WrappedComponent: React.ComponentClass<unknown, any> | React.SFC<unknown>) => React.ComponentClass<{}, any>;
|
|
@@ -8,7 +8,7 @@ export interface WithPlaceholderOptions {
|
|
|
8
8
|
* However, if your component data is in a different prop, like say 'route' in a sample app,
|
|
9
9
|
* this lets you map that.
|
|
10
10
|
*/
|
|
11
|
-
resolvePlaceholderDataFromProps?: (props:
|
|
11
|
+
resolvePlaceholderDataFromProps?: (props: unknown) => ComponentRendering | RouteData;
|
|
12
12
|
/**
|
|
13
13
|
* Function to alter the placeholder props from within the HOC. Enables the props to be
|
|
14
14
|
* transformed before being used by the placeholder/HOC, for example to customize the
|
|
@@ -27,4 +27,8 @@ export interface PlaceholderToPropMapping {
|
|
|
27
27
|
prop: string;
|
|
28
28
|
}
|
|
29
29
|
export declare type WithPlaceholderSpec = (string | PlaceholderToPropMapping) | (string | PlaceholderToPropMapping)[];
|
|
30
|
+
/**
|
|
31
|
+
* @param {WithPlaceholderSpec} placeholders
|
|
32
|
+
* @param {WithPlaceholderOptions} [options]
|
|
33
|
+
*/
|
|
30
34
|
export declare function withPlaceholder(placeholders: WithPlaceholderSpec, options?: WithPlaceholderOptions): (WrappedComponent: React.ComponentClass<any, any> | React.SFC<any>) => (props: PlaceholderProps) => JSX.Element;
|
|
@@ -3,13 +3,16 @@ export interface WithSitecoreContextOptions {
|
|
|
3
3
|
updatable?: boolean;
|
|
4
4
|
}
|
|
5
5
|
export interface WithSitecoreContextProps {
|
|
6
|
-
sitecoreContext:
|
|
7
|
-
updateSitecoreContext?: ((value:
|
|
6
|
+
sitecoreContext: unknown;
|
|
7
|
+
updateSitecoreContext?: ((value: unknown) => void) | false;
|
|
8
8
|
}
|
|
9
9
|
export interface ComponentConsumerProps extends WithSitecoreContextProps {
|
|
10
10
|
children?: ReactNode;
|
|
11
11
|
}
|
|
12
12
|
export declare type WithSitecoreContextHocProps<ComponentProps> = Pick<ComponentProps, Exclude<keyof ComponentProps, keyof WithSitecoreContextProps>>;
|
|
13
|
+
/**
|
|
14
|
+
* @param {WithSitecoreContextOptions} [options]
|
|
15
|
+
*/
|
|
13
16
|
export declare function withSitecoreContext(options?: WithSitecoreContextOptions): <ComponentProps extends ComponentConsumerProps>(Component: React.ComponentType<ComponentProps>) => (props: Pick<ComponentProps, Exclude<keyof ComponentProps, "sitecoreContext" | "updateSitecoreContext">>) => JSX.Element;
|
|
14
17
|
/**
|
|
15
18
|
* This hook grants acсess to the current SiteCore page context
|
|
@@ -20,7 +23,7 @@ export declare function withSitecoreContext(options?: WithSitecoreContextOptions
|
|
|
20
23
|
*
|
|
21
24
|
* @see https://jss.sitecore.com/docs/techniques/extending-layout-service/layoutservice-extending-context
|
|
22
25
|
*
|
|
23
|
-
* @param {WithSitecoreContextOptions} [options]
|
|
26
|
+
* @param {WithSitecoreContextOptions} [options] hook options
|
|
24
27
|
*
|
|
25
28
|
* @example
|
|
26
29
|
* const EditMode = () => {
|
|
@@ -34,8 +37,9 @@ export declare function withSitecoreContext(options?: WithSitecoreContextOptions
|
|
|
34
37
|
* const onClick = () => updateSitecoreContext({ pageEditing: true });
|
|
35
38
|
* return <span onClick={onClick}>Edit Mode is {sitecoreContext.pageEditing ? 'active' : 'inactive'}</span>
|
|
36
39
|
* }
|
|
40
|
+
* @returns {Object} { sitecoreContext, updateSitecoreContext }
|
|
37
41
|
*/
|
|
38
|
-
export declare function useSitecoreContext(options?: WithSitecoreContextOptions): {
|
|
39
|
-
sitecoreContext:
|
|
42
|
+
export declare function useSitecoreContext<Context>(options?: WithSitecoreContextOptions): {
|
|
43
|
+
sitecoreContext: Context;
|
|
40
44
|
updateSitecoreContext: ((value: any) => void) | undefined;
|
|
41
45
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { DateField } from './components/Date';
|
|
|
8
8
|
export { Link, LinkField, LinkFieldValue, LinkProps, LinkPropTypes } from './components/Link';
|
|
9
9
|
export { File, FileField } from './components/File';
|
|
10
10
|
export { VisitorIdentification } from './components/VisitorIdentification';
|
|
11
|
-
export { SitecoreContext, SitecoreContextState, SitecoreContextReactContext } from './components/SitecoreContext';
|
|
11
|
+
export { SitecoreContext, SitecoreContextState, SitecoreContextReactContext, } from './components/SitecoreContext';
|
|
12
12
|
export { withSitecoreContext, useSitecoreContext } from './enhancers/withSitecoreContext';
|
|
13
13
|
export { withExperienceEditorChromes } from './enhancers/withExperienceEditorChromes';
|
|
14
14
|
export { withPlaceholder } from './enhancers/withPlaceholder';
|
package/types/utils.d.ts
CHANGED
|
@@ -4,6 +4,14 @@ export declare const convertKebabCasetoCamelCase: (str: string) => string;
|
|
|
4
4
|
* We are only concerned with style at the moment, which needs to be converted from string to object to satisfy React.
|
|
5
5
|
* We don't need to convert any other attributes (that we know of), because the placeholder renders them "as-is" by using the special "is" React prop.
|
|
6
6
|
* For whatever reason though, the "style" prop is still validated as needing to be an object when using the "is" prop, which is why we need to convert from string to object.
|
|
7
|
+
* @param {string} [style] style
|
|
8
|
+
* @returns {Array} converted attributes
|
|
7
9
|
*/
|
|
8
10
|
export declare const convertStyleAttribute: (style?: string) => {};
|
|
9
|
-
export declare const convertAttributesToReactProps: (attributes:
|
|
11
|
+
export declare const convertAttributesToReactProps: (attributes: {
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
style?: string | undefined;
|
|
14
|
+
class?: string | undefined;
|
|
15
|
+
} | null) => [] | {
|
|
16
|
+
[attr: string]: unknown;
|
|
17
|
+
};
|