@jahia/javascript-modules-library 0.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 +201 -0
- package/README.md +35 -0
- package/core/index.js +1 -0
- package/core/server/components/AbsoluteArea.js +1 -0
- package/core/server/components/AddContentButtons.js +1 -0
- package/core/server/components/AddResources.js +1 -0
- package/core/server/components/Area.js +1 -0
- package/core/server/components/index.js +1 -0
- package/core/server/components/render/HydrateInBrowser.js +1 -0
- package/core/server/components/render/Render.js +1 -0
- package/core/server/components/render/RenderInBrowser.js +1 -0
- package/core/server/components/render/index.js +1 -0
- package/core/server/components/render/internal/InBrowser.js +1 -0
- package/core/server/framework/defineJahiaComponent.js +1 -0
- package/core/server/framework/index.js +1 -0
- package/core/server/framework/register.js +1 -0
- package/core/server/hooks/index.js +1 -0
- package/core/server/hooks/useGQLQuery.js +1 -0
- package/core/server/hooks/useJCRQuery.js +1 -0
- package/core/server/hooks/useServerContext.js +1 -0
- package/core/server/hooks/useUrlBuilder.js +1 -0
- package/core/server/index.js +1 -0
- package/core/server/utils/index.js +1 -0
- package/core/server/utils/jcr/getChildNodes.js +1 -0
- package/core/server/utils/jcr/getNodeFromPathOrId.js +1 -0
- package/core/server/utils/jcr/getNodeProps.js +1 -0
- package/core/server/utils/jcr/getNodesByJCRQuery.js +1 -0
- package/core/server/utils/jcr/index.js +1 -0
- package/core/server/utils/urlBuilder/index.js +1 -0
- package/core/server/utils/urlBuilder/urlBuilder.js +1 -0
- package/index.js +1 -0
- package/nav/index.js +1 -0
- package/nav/server/index.js +1 -0
- package/nav/server/navBuilder/index.js +1 -0
- package/nav/server/navBuilder/navBuilder.js +24 -0
- package/package.json +60 -0
- package/types/@jahia/javascript-modules-library-private.d.ts +60 -0
- package/types/core/index.d.ts +1 -0
- package/types/core/server/components/AbsoluteArea.d.ts +29 -0
- package/types/core/server/components/AddContentButtons.d.ts +13 -0
- package/types/core/server/components/AddResources.d.ts +31 -0
- package/types/core/server/components/Area.d.ts +27 -0
- package/types/core/server/components/index.d.ts +5 -0
- package/types/core/server/components/render/HydrateInBrowser.d.ts +13 -0
- package/types/core/server/components/render/Render.d.ts +23 -0
- package/types/core/server/components/render/RenderInBrowser.d.ts +13 -0
- package/types/core/server/components/render/index.d.ts +3 -0
- package/types/core/server/components/render/internal/InBrowser.d.ts +8 -0
- package/types/core/server/framework/defineJahiaComponent.d.ts +41 -0
- package/types/core/server/framework/index.d.ts +2 -0
- package/types/core/server/framework/register.d.ts +7 -0
- package/types/core/server/hooks/index.d.ts +4 -0
- package/types/core/server/hooks/useGQLQuery.d.ts +5 -0
- package/types/core/server/hooks/useJCRQuery.d.ts +3 -0
- package/types/core/server/hooks/useServerContext.d.ts +14 -0
- package/types/core/server/hooks/useUrlBuilder.d.ts +31 -0
- package/types/core/server/index.d.ts +4 -0
- package/types/core/server/utils/index.d.ts +2 -0
- package/types/core/server/utils/jcr/getChildNodes.d.ts +9 -0
- package/types/core/server/utils/jcr/getNodeFromPathOrId.d.ts +12 -0
- package/types/core/server/utils/jcr/getNodeProps.d.ts +7 -0
- package/types/core/server/utils/jcr/getNodesByJCRQuery.d.ts +9 -0
- package/types/core/server/utils/jcr/index.d.ts +4 -0
- package/types/core/server/utils/urlBuilder/index.d.ts +1 -0
- package/types/core/server/utils/urlBuilder/urlBuilder.d.ts +27 -0
- package/types/globals.d.ts +11 -0
- package/types/index.d.ts +19 -0
- package/types/java.io.d.ts +694 -0
- package/types/java.net.d.ts +190 -0
- package/types/java.security.d.ts +27 -0
- package/types/java.util.d.ts +1536 -0
- package/types/javax.jcr.d.ts +1250 -0
- package/types/javax.servlet.d.ts +426 -0
- package/types/javax.servlet.http.d.ts +1431 -0
- package/types/nav/index.d.ts +1 -0
- package/types/nav/server/index.d.ts +1 -0
- package/types/nav/server/navBuilder/index.d.ts +1 -0
- package/types/nav/server/navBuilder/navBuilder.d.ts +78 -0
- package/types/org.jahia.modules.npm.modules.engine.js.server.d.ts +292 -0
- package/types/org.jahia.services.content.d.ts +1463 -0
- package/types/org.jahia.services.content.decorator.d.ts +92 -0
- package/types/org.jahia.services.query.d.ts +35 -0
- package/types/org.jahia.services.render.d.ts +168 -0
- package/types/org.jahia.services.usermanager.d.ts +85 -0
- package/types/org.osgi.framework.d.ts +1004 -0
- package/types/server.d.ts +27 -0
- package/types/servercontext.d.ts +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# javascript-modules-library
|
|
2
|
+
Javascript Library for NPM Javascript Module Engine
|
|
3
|
+
|
|
4
|
+
## Generated types
|
|
5
|
+
|
|
6
|
+
This library contains types generated from Java source code. The types are generated using a tool called java-ts-bind
|
|
7
|
+
that was forked here : https://github.com/Jahia/java-ts-bind/tree/finer-excludes . You don't need to checkout this
|
|
8
|
+
repository as the scripts will automatically do that for you but we mention it in case you need to make modifications
|
|
9
|
+
to it.
|
|
10
|
+
|
|
11
|
+
By default, the generated types are committed in this project, but if you need to rebuild/update them, you can do so by
|
|
12
|
+
using the following steps:
|
|
13
|
+
|
|
14
|
+
1. Change to the project directory :
|
|
15
|
+
|
|
16
|
+
`cd types/generated`
|
|
17
|
+
|
|
18
|
+
2. Launch the script that will clone the java-ts-bind repository and build it from source code (it has never been released) :
|
|
19
|
+
|
|
20
|
+
`./build.sh`
|
|
21
|
+
|
|
22
|
+
3. Update the classes and methods declared in [types/generated/package.json](types/generated/package.json) in case you added/removed classes or methods.
|
|
23
|
+
|
|
24
|
+
4. Launch the script that will download all the required source code and JARs for the type generation and that will
|
|
25
|
+
also compile the source to generated the required symbols JARs. Then it will generate the types, and finally apply
|
|
26
|
+
some post-processing to the generated types to make usable :
|
|
27
|
+
|
|
28
|
+
`./generate.sh`
|
|
29
|
+
|
|
30
|
+
Note that the generation will take some time on the initial build as it needs to download all the required source code
|
|
31
|
+
and JARs, and build the projects from the source code.
|
|
32
|
+
|
|
33
|
+
Once completed, the generated types will be in the following directory :
|
|
34
|
+
|
|
35
|
+
types/generated/build/types
|
package/core/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{useServerContext}from"../hooks/useServerContext";import{server}from"@jahia/javascript-modules-library-private";export function AbsoluteArea({name:e,areaView:r,allowedTypes:t,numberOfItems:a,subNodesView:o,path:s,editable:n=!0,level:i,areaType:l="jnt:contentList",limitedAbsoluteAreaEdit:m,parameters:d}){const{renderContext:u}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.renderAbsoluteArea({name:e,areaView:r,allowedTypes:t,numberOfItems:a,subNodesView:o,path:s,editable:n,level:i,areaType:l,limitedAbsoluteAreaEdit:m,parameters:d},u)}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{server}from"@jahia/javascript-modules-library-private";import{useServerContext}from"../hooks/useServerContext";export function AddContentButtons({nodeTypes:e,childName:t="*",editCheck:r=!1}){const{renderContext:n,currentResource:o}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.createContentButtons(t,e,r,n,o)}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{useServerContext}from"../hooks";import{server}from"@jahia/javascript-modules-library-private";export function AddResources({...e}){const{renderContext:r}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.addResources(e,r)}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{useServerContext}from"../hooks/useServerContext";import{server}from"@jahia/javascript-modules-library-private";export function Area({name:e,areaView:r,allowedTypes:a,numberOfItems:t,subNodesView:n,path:o,editable:s=!0,areaAsSubNode:m,areaType:i="jnt:contentList",parameters:d}){const{renderContext:p}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.renderArea({name:e,areaView:r,allowedTypes:a,numberOfItems:t,subNodesView:n,path:o,editable:s,areaAsSubNode:m,areaType:i,parameters:d},p)}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./AddContentButtons";export*from"./AddResources";export*from"./Area";export*from"./AbsoluteArea";export*from"./render";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import InBrowser from"./internal/InBrowser";export function HydrateInBrowser({child:r,props:e}){return React.createElement(InBrowser,{preRender:!0,child:r,props:e,dataKey:"data-reacthydrate"})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{server}from"@jahia/javascript-modules-library-private";import{useServerContext}from"../../hooks/useServerContext";export function Render({content:e,node:r,path:t,editable:n=!0,advanceRenderingConfig:a,templateType:o,view:i,parameters:d}){const{renderContext:p,currentResource:c}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.render({content:e,node:r,path:t,editable:n,advanceRenderingConfig:a,templateType:o,view:i,parameters:d},p,c)}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import InBrowser from"./internal/InBrowser";export function RenderInBrowser({child:r,props:e}){return React.createElement(InBrowser,{preRender:!1,child:r,props:e,dataKey:"data-reactrender"})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./Render";export*from"./HydrateInBrowser";export*from"./RenderInBrowser";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import{useServerContext}from"../../../hooks/useServerContext";import{AddResources}from"../../AddResources";import{buildUrl}from"../../../utils/urlBuilder";import{I18nextProvider}from"react-i18next";import i18n from"i18next";const getClientI18nStoreScript=(e,t)=>{const r=i18n.getResourceBundle(e,t);if(r){const n={};return n[e]={},n[e][t]=r,`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n if(!window.__APPSHELL_INIT_DATA__.initialI18nStore) {\n window.__APPSHELL_INIT_DATA__.initialI18nStore = [];\n }\n window.__APPSHELL_INIT_DATA__.initialI18nStore.push(${JSON.stringify(n)});\n <\/script>`}},getAppShellInitData=e=>`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n window.__APPSHELL_INIT_DATA__.moduleBaseUrl = '${e}';\n <\/script>`;function InBrowser({child:e,props:t,dataKey:r,preRender:n}){const{bundleKey:i,currentResource:o,renderContext:a}=useServerContext(),s=o.getLocale().getLanguage(),c=getAppShellInitData(buildUrl({value:"/modules"},a,o)),l=getClientI18nStoreScript(s,i),_=buildUrl({value:"/modules/"+i+"/javascript/client/remote.js"},a,o),d=buildUrl({value:"/modules/javascript-modules-engine/javascript/apps/reactAppShell.js"},a,o),p={};return p[r]=encodeURIComponent(JSON.stringify({name:e.name,lang:s,bundle:i,props:t||{}})),React.createElement(React.Fragment,null,React.createElement("div",{...p},n&&React.createElement(I18nextProvider,{i18n:i18n},React.createElement(e,{...t}))),l&&React.createElement(AddResources,{key:`i18n_initialStore_${i}`,insert:!0,inlineResource:l}),React.createElement(AddResources,{key:"npm-engine-appShellInitData",insert:!0,inlineResource:c}),React.createElement(AddResources,{insert:!0,type:"javascript",targetTag:"body",resources:_}),React.createElement(AddResources,{type:"javascript",targetTag:"body",resources:d}))}export default InBrowser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function defineJahiaComponent(n){return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./register";export*from"./defineJahiaComponent";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{server}from"@jahia/javascript-modules-library-private";export function registerJahiaComponents(e){if(!bundle)return void console.error("registerJahiaComponents: bundle is not available, make sure you are using this function inside the initialization of the bundle");const n=bundle.getSymbolicName(),o=server.registry.get("view","react");Object.keys(e).forEach((t=>{let i;const r=e[t].jahiaComponent;if(!r||!r.nodeType||!r.componentType)return void console.warn(`registerJahiaComponents(bundle=${n}: Missing mandatory property nodeType and/or componentType, skipping component name=${r.name} nodeType=${r.nodeType} id=${r.id} registration`);i={name:"default",templateType:"html",component:null};let a=r.id;delete r.id,i.component=e[t];const p={...i,...r};a||(a=`${n}_${p.componentType}_${p.nodeType}_${p.name}`),server.registry.add("view",a,o,p)}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./useGQLQuery";export*from"./useJCRQuery";export*from"./useServerContext";export*from"./useUrlBuilder";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useServerContext}from"./useServerContext";import{server}from"@jahia/javascript-modules-library-private";export const useGQLQuery=({query:e,variables:r,operationName:t})=>{const{renderContext:o}=useServerContext();return server.gql.executeQuerySync({query:e,variables:r,operationName:t,renderContext:o})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useServerContext}from"./useServerContext";import{getNodesByJCRQuery}from"../utils/jcr";export const useJCRQuery=({query:e})=>{const{renderContext:r}=useServerContext();return getNodesByJCRQuery(r.getMainResource().getNode().getSession(),e,-1,0)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React,{useContext}from"react";const ServerContext=React.createContext({});export function useServerContext(){return useContext(ServerContext)}export function ServerContextProvider({renderContext:e,currentResource:r,currentNode:t,mainNode:n,bundleKey:o,children:c}){return React.createElement(ServerContext.Provider,{value:{renderContext:e,currentResource:r,currentNode:t,mainNode:n,bundleKey:o}},c)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useServerContext}from"./useServerContext";import{buildUrl as originalBuildUrl}from"../utils/urlBuilder";export function useUrlBuilder(){const{renderContext:e,currentResource:r}=useServerContext(),t=({nodePath:t,extension:a,language:l,mode:n,parameters:o})=>originalBuildUrl({path:t,extension:a,language:l,mode:n,parameters:o},e,r);return{buildStaticUrl:({assetPath:t,moduleName:a=e?.getURLGenerator()?.getCurrentModule(),parameters:l})=>{let n=a+"/static"+(t?.startsWith("/")?"":"/")+t;return originalBuildUrl({value:n,parameters:l},e,r)},buildNodeUrl:t,buildHtmlFragmentUrl:({nodePath:e,language:r,mode:a,parameters:l})=>t({nodePath:e,extension:".html.ajax",language:r,mode:a,parameters:l})}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./components";export*from"./framework";export*from"./hooks";export*from"./utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./jcr";export*from"./urlBuilder";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getChildNodes(e,o,t=0,n=void 0){let r=[];if(!e||!o)return console.warn("Missing one or more mandatory parameters (node, limit) to getChildNodes"),r;const s=e.getNodes();let i=0;for(;s.hasNext();){const e=s.nextNode();if(i<t)n&&!n(e)||i++;else if((!n||n(e))&&(r.push(e),o>0&&r.length===o))break}return r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getNodeFromPathOrId(e,t){return e.identifier?t.getNodeByIdentifier(e.identifier):e.path?t.getNode(e.path):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const STRING=1,LONG=3,DOUBLE=4,DATE=5,BOOLEAN=6,NAME=7,PATH=8,REFERENCE=9,WEAKREFERENCE=10,URI=11,DECIMAL=12,extractProp=(e,t)=>{if(e.hasProperty(t)){const r=e.getProperty(t);if(r.isMultiple()){const t=r.getValues(),o=[];for(const s of t)o.push(extractPropValue(e.getSession(),s,r.getType()));return o}return extractPropValue(e.getSession(),r.getValue(),r.getType())}},extractPropValue=(e,t,r)=>{switch(r){case 1:case 5:case 7:case 8:case 11:case 12:return t.getString();case 3:return t.getLong();case 4:return t.getDouble();case 6:return t.getBoolean();case 9:case 10:try{return e.getNodeByIdentifier(t.getString())}catch(e){return}default:return}};export function getNodeProps(e,t){let r={};if(e&&t&&t.length>0)for(const o of t)e.hasProperty(o)&&(r[o]=extractProp(e,o));return r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getNodesByJCRQuery(e,t,r,o=0){let s=[];if(!e||!t||!r)return console.warn("Missing one or more mandatory parameters (session, query, limit) to getNodesByJCRQuery"),s;const n=e.getWorkspace().getQueryManager().createQuery(t,"JCR-SQL2");r>0&&n.setLimit(r),o&&o>0&&n.setOffset(o);const a=n.execute().getNodes();for(;a.hasNext();)s.push(a.nextNode());return s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./getChildNodes";export*from"./getNodeFromPathOrId";export*from"./getNodeProps";export*from"./getNodesByJCRQuery";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./urlBuilder";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getNodeFromPathOrId}from"../jcr/getNodeFromPathOrId";import{server}from"@jahia/javascript-modules-library-private";const absoluteUrlRegExp=/^(?:[a-z+]+:)?\/\//i,finalizeUrl=(e,r)=>absoluteUrlRegExp.test(e)?e:(e=e.startsWith("/")?r.getRequest().getContextPath()+e:e,r.getResponse().encodeURL(e));function appendParameters(e,r){const t=e.includes("?")?"&":"?";return`${e}${t}${Object.keys(r).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(r[e])}`)).join("&")}`}export function initUrlBuilder(){server.registry.add("urlBuilder","nt:file",{priority:1,buildURL:({jcrNode:e,mode:r,currentResource:t})=>"/files/"+(r?"edit"===r||"preview"===r?"default":"live":t.getWorkspace())+server.render.escapePath(e.getCanonicalPath())}),server.registry.add("urlBuilder","*",{priority:0,buildURL:({jcrNode:e,mode:r,language:t,extension:a,renderContext:n,currentResource:o})=>{let i,l;if(r)switch(r){case"edit":l="/cms/edit",i="default";break;case"preview":l="/cms/render",i="default";break;default:l="/cms/render",i="live"}else l=n.getServletPath(),i=o.getWorkspace();return l+"/"+i+"/"+(t||o.getLocale().toString())+server.render.escapePath(e.getPath())+(a||".html")}})}export function buildUrl(e,r,t){let a;if(e.path){let n;try{n=getNodeFromPathOrId({path:e.path},t.getNode().getSession())}catch(r){return console.warn(`Unable to find node for path: ${e.path}\n Replacing by #`),"#"}if(n){const o=server.registry.find({type:"urlBuilder"},"priority");for(const i of o)if("*"===i.key||n.isNodeType(i.key)){a=i.buildURL({jcrNode:n,mode:e.mode,language:e.language,extension:e.extension,renderContext:r,currentResource:t});break}}}else{if(!e.value)return console.warn("Missing parameter to build url, please provide either a content path using 'path' parameter, or a prebuild valid url using 'value' parameter\n replacing by #"),"#";a=e.value}return a?(e.parameters&&"[object Object]"===Object.prototype.toString.call(e.parameters)&&(a=appendParameters(a,e.parameters)),finalizeUrl(a,r)):(console.warn(`Unable to build url for: ${JSON.stringify(e)}\n Replacing by #`),"#")}
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./core";export*from"./nav";
|
package/nav/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./server";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./navBuilder";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./navBuilder";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{server}from"@jahia/javascript-modules-library-private";import{print}from"graphql";import gql from"graphql-tag";const getPageAncestors=(e,t,r)=>{const n=server.gql.executeQuerySync({query:print(gql`
|
|
2
|
+
query ($workspace: Workspace!, $path: String!, $types: [String]!){
|
|
3
|
+
jcr(workspace: $workspace) {
|
|
4
|
+
nodeByPath(path: $path) {
|
|
5
|
+
ancestors(fieldFilter: {filters:[{fieldName:"isNodeType", value:"true"}]}) {
|
|
6
|
+
path
|
|
7
|
+
isNodeType(type: {types: $types})
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`),variables:{workspace:e,path:t,types:r}});return n.data?n.data.jcr.nodeByPath.ancestors:[]},getMenuItemsChildren=(e,t,r)=>{const n=server.gql.executeQuerySync({query:print(gql`
|
|
13
|
+
query childrenOfType($workspace: Workspace!, $path: String!, $types: [String]!){
|
|
14
|
+
jcr(workspace: $workspace) {
|
|
15
|
+
nodeByPath(path: $path) {
|
|
16
|
+
children(typesFilter: {types:$types}) {
|
|
17
|
+
nodes {
|
|
18
|
+
path
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`),variables:{workspace:e,path:t,types:r}});return n.data?n.data.jcr.nodeByPath.children.nodes:[]},getBaseNode=(e,t,r)=>{const n=t.getMainResource().getNode(),a=getPageAncestors(r,n.getPath(),["jnt:page"]);if(!e||"home"===e)return t.getSite().getHome();if("currentPage"===e){if(t.getMainResource().getNode().isNodeType("jnt:page"))return n;if(a.length>0)return n.getSession().getNode(a.slice(-1)[0].path)}return n},buildMenu=(e,t,r,n)=>{let a=[];if(e){const s=e.getSession();n||(n=getMenuItemsChildren(r.workspace,e.getPath(),["jmix:navMenuItem"]));for(let e=0;e<n.length;e++){const o={},i=n[e].path,p=s.getNode(i),c=r.mainResourceNode.getPath()===i||r.mainResourceNode.getPath().startsWith(i+"/");let g=!1,u=!1,d=!0;if(p.isNodeType("jmix:nodeReference")){r.currentResource.getDependencies().add(p.getPropertyAsString("j:node"));const e=p.getProperty("j:node").getNode();e?g=r.mainResourceNode.getPath()===e.getPath():(g=!1,u=!0)}else g=r.mainResourceNode.getPath()===p.getPath();if(p.hasProperty["j:displayInMenuName"]&&(d=!1,p.getProperty("j:displayInMenuName").getValues().forEach((e=>{d=d||e.getString()===r.menuName}))),!u&&d&&(r.startLevelValue<t||c)){if(t<r.maxDepth){const e=getMenuItemsChildren(r.workspace,p.getPath(),["jmix:navMenuItem"]);e.length>0&&(o.children=buildMenu(p,t+1,r,e))}r.startLevelValue<t&&(r.currentResource.getDependencies().add(p.getCanonicalPath()),o.render=server.render.render({path:p.getPath(),view:r.menuEntryView||"menuElement"},r.renderContext,r.currentResource)),o.node=p,o.inPath=c,o.selected=g,o.level=t}a.push(o)}}return a};export function buildNavMenu(e,t,r,n,a,s){const o=a.isLiveMode()?"LIVE":"EDIT";return buildMenu(getBaseNode(t,a,o),1,{renderContext:a,mainResourceNode:a.getMainResource().getNode(),currentResource:s,workspace:o,menuName:s.getNode().getName(),startLevelValue:n,maxDepth:e,menuEntryView:r})}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jahia/javascript-modules-library",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "types/index.d.ts",
|
|
6
|
+
"repository": "git@github.com:Jahia/javascript-modules.git",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"types:copy": "mkdir -p dist/types && ncp types/manual dist/types && ncp types/generated/build/types dist/types",
|
|
10
|
+
"build:development": "run types:copy && tsc && node generate-index",
|
|
11
|
+
"build:production": "run build:development && run minify",
|
|
12
|
+
"build": "run build:production",
|
|
13
|
+
"minify": "node minify",
|
|
14
|
+
"doc": "typedoc",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"lint": "eslint --ext js,jsx,json,ts .",
|
|
17
|
+
"lint:fix": "eslint --ext js,jsx,json,ts --fix .",
|
|
18
|
+
"prepack": "echo 'Please run 'mvn package' to create the tgz so the Maven version can be injected in the package.json' && exit 1"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"graphql": "^16.0.1",
|
|
25
|
+
"graphql-tag": "^2.12.6",
|
|
26
|
+
"i18next": "^23.10.1",
|
|
27
|
+
"prop-types": "^15.8.1",
|
|
28
|
+
"react": "^18.2.0",
|
|
29
|
+
"react-i18next": "^14.1.0"
|
|
30
|
+
},
|
|
31
|
+
"resolutions": {
|
|
32
|
+
"minimist": "^1.2.6",
|
|
33
|
+
"set-getter": "^0.1.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/cli": "^7.23.4",
|
|
37
|
+
"@babel/core": "^7.23.7",
|
|
38
|
+
"@babel/preset-env": "^7.23.8",
|
|
39
|
+
"@babel/preset-react": "^7.23.3",
|
|
40
|
+
"@jahia/eslint-config": "^2.1.2",
|
|
41
|
+
"@types/node-fetch": "^2.6.11",
|
|
42
|
+
"@types/react": "^18.2.48",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
|
44
|
+
"@typescript-eslint/parser": "^4.29.3",
|
|
45
|
+
"babel-loader": "^9.1.3",
|
|
46
|
+
"babel-plugin-transform-react-jsx": "^6.24.1",
|
|
47
|
+
"eslint": "^7.32.0",
|
|
48
|
+
"eslint-plugin-cypress": "^2.11.3",
|
|
49
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
50
|
+
"eslint-plugin-json": "^3.1.0",
|
|
51
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
52
|
+
"eslint-plugin-react": "^7.32.2",
|
|
53
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
54
|
+
"ncp": "^2.0.0",
|
|
55
|
+
"terser": "^5.36.0",
|
|
56
|
+
"typedoc": "^0.25.13",
|
|
57
|
+
"typescript": "^4.3.5"
|
|
58
|
+
},
|
|
59
|
+
"packageManager": "yarn@4.5.0"
|
|
60
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {ConfigHelper, GQLHelper, OSGiHelper, RegistryHelper, RenderHelper} from 'org.jahia.modules.npm.modules.engine.js.server';
|
|
2
|
+
import {JCRNodeWrapper} from 'org.jahia.services.content';
|
|
3
|
+
import {Resource, RenderContext} from 'org.jahia.services.render';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This module is used for internal compilation of the project. It should not be used directly in your code.
|
|
7
|
+
*/
|
|
8
|
+
declare module '@jahia/javascript-modules-library-private' {
|
|
9
|
+
/**
|
|
10
|
+
* A set of helpers that provide common functionality provided by Jahia for Javascript server-side rendering
|
|
11
|
+
*/
|
|
12
|
+
export const server: {
|
|
13
|
+
/**
|
|
14
|
+
* This helper provides access to OSGi configuration
|
|
15
|
+
*/
|
|
16
|
+
config: ConfigHelper,
|
|
17
|
+
/**
|
|
18
|
+
* This helper provides access Jahia's GraphQL API, to execute queries and mutations
|
|
19
|
+
*/
|
|
20
|
+
gql: GQLHelper,
|
|
21
|
+
/**
|
|
22
|
+
* This helper provides access to OSGi bundle for resource loading and service access
|
|
23
|
+
*/
|
|
24
|
+
osgi: OSGiHelper,
|
|
25
|
+
/**
|
|
26
|
+
* This helper provides access to Jahia's registry API, to register new UI objects or retrieving existing ones
|
|
27
|
+
*/
|
|
28
|
+
registry: RegistryHelper,
|
|
29
|
+
/**
|
|
30
|
+
* This helper provides rendering functions such as registering page resources, adding cache dependencies or rendering components
|
|
31
|
+
*/
|
|
32
|
+
render: RenderHelper
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A context object that gives access to the underlying Jahia Java objects that are part of the current rendering context
|
|
37
|
+
*/
|
|
38
|
+
export interface ServerContext {
|
|
39
|
+
/**
|
|
40
|
+
* Jahia's rendering context, it provides access to all kinds of context information, such as the current request, response, user, mode, mainResource and more
|
|
41
|
+
*/
|
|
42
|
+
renderContext : RenderContext;
|
|
43
|
+
/**
|
|
44
|
+
* The current resource being rendered, which is a combination of the current node and its template/view information
|
|
45
|
+
*/
|
|
46
|
+
currentResource : Resource;
|
|
47
|
+
/**
|
|
48
|
+
* The current JCR node being rendered
|
|
49
|
+
*/
|
|
50
|
+
currentNode : JCRNodeWrapper;
|
|
51
|
+
/**
|
|
52
|
+
* The main JCR node being rendered, which is the root node of the current page
|
|
53
|
+
*/
|
|
54
|
+
mainNode : JCRNodeWrapper;
|
|
55
|
+
/**
|
|
56
|
+
* The OSGi bundle key of the current module being rendered
|
|
57
|
+
*/
|
|
58
|
+
bundleKey : string;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./server";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an absolute area in which editors may insert content objects.
|
|
3
|
+
* @param {object} props The React properties for the component.
|
|
4
|
+
* @param {string} [props.name] The name of the area.
|
|
5
|
+
* @param {string} [props.areaView] The view to use for the area.
|
|
6
|
+
* @param {string[]} [props.allowedTypes] The allowed types for the area.
|
|
7
|
+
* @param {number} [props.numberOfItems] The number of items to display in the area.
|
|
8
|
+
* @param {string} [props.subNodesView] The view to use for the subnodes.
|
|
9
|
+
* @param {string} [props.path] Relative (to the current node) or absolute path to the node to include
|
|
10
|
+
* @param {boolean} [props.editable] Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
|
|
11
|
+
* @param {number} [props.level] Ancestor level for absolute area - 0 is Home page, 1 first sub-pages, ...
|
|
12
|
+
* @param {string} [props.areaType] Content type to be used to create the area (by default jnt:contentList)
|
|
13
|
+
* @param {boolean} [props.limitedAbsoluteAreaEdit] Is the absolute area editable everywhere or only on the page containing its node.
|
|
14
|
+
* @param {object} [props.parameters] the parameters to pass to the absolute area
|
|
15
|
+
* @returns {JSX.Element} The AbsoluteArea component
|
|
16
|
+
*/
|
|
17
|
+
export function AbsoluteArea({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, level, areaType, limitedAbsoluteAreaEdit, parameters }: {
|
|
18
|
+
name?: string;
|
|
19
|
+
areaView?: string;
|
|
20
|
+
allowedTypes?: string[];
|
|
21
|
+
numberOfItems?: number;
|
|
22
|
+
subNodesView?: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
editable?: boolean;
|
|
25
|
+
level?: number;
|
|
26
|
+
areaType?: string;
|
|
27
|
+
limitedAbsoluteAreaEdit?: boolean;
|
|
28
|
+
parameters?: object;
|
|
29
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates add content buttons for a content object
|
|
3
|
+
* @param {object} properties The React properties for the component.
|
|
4
|
+
* @param {string} [properties.nodeTypes] The node types to add.
|
|
5
|
+
* @param {string} [properties.childName='*'] The child name.
|
|
6
|
+
* @param {boolean} [properties.editCheck=false] If true, the edit check will be performed.
|
|
7
|
+
* @returns {JSX.Element} The add content buttons.
|
|
8
|
+
*/
|
|
9
|
+
export function AddContentButtons({ nodeTypes, childName, editCheck }: {
|
|
10
|
+
nodeTypes?: string;
|
|
11
|
+
childName?: string;
|
|
12
|
+
editCheck?: boolean;
|
|
13
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a resources to the head tag of the HTML page.
|
|
3
|
+
* @param {object} props - The properties for the component.
|
|
4
|
+
* @param {boolean} [props.insert] - If true, the resource will be inserted into the document. Typically used for on-demand loading of resources.
|
|
5
|
+
* @param {boolean} [props.async] - If true, the resource will be loaded asynchronously. For scripts, this means the script will be executed as soon as it's available, without blocking the rest of the page.
|
|
6
|
+
* @param {boolean} [props.defer] - If true, the resource will be deferred, i.e., loaded after the document has been parsed. For scripts, this means the script will not be executed until after the page has loaded.
|
|
7
|
+
* @param {string} [props.type] - The type of the resource. This could be 'javascript' for .js files, 'css' for .css files, etc.
|
|
8
|
+
* @param {string} [props.resources] - The path to the resource file, relative to the module.
|
|
9
|
+
* @param {string} [props.inlineResource] - Inline HTML that markup will be considered as resource.
|
|
10
|
+
* @param {string} [props.title] - The title of the resource. This is typically not used for scripts or stylesheets, but may be used for other types of resources.
|
|
11
|
+
* @param {string} [props.key] - A unique key for the resource. This could be used to prevent duplicate resources from being added to the document.
|
|
12
|
+
* @param {string} [props.targetTag] - The HTML tag where the resource should be added. This could be 'head' for resources that should be added to the <head> tag, 'body' for resources that should be added to the <body> tag, etc.
|
|
13
|
+
* @param {string} [props.rel] - The relationship of the resource to the document. This is typically 'stylesheet' for CSS files.
|
|
14
|
+
* @param {string} [props.media] - The media for which the resource is intended. This is typically used for CSS files, with values like 'screen', 'print', etc.
|
|
15
|
+
* @param {string} [props.condition] - A condition that must be met for the resource to be loaded. This could be used for conditional comments in IE, for example.
|
|
16
|
+
* @returns {JSX.Element} A React element that renders a script or link tag.
|
|
17
|
+
*/
|
|
18
|
+
export function AddResources({ ...props }: {
|
|
19
|
+
insert?: boolean;
|
|
20
|
+
async?: boolean;
|
|
21
|
+
defer?: boolean;
|
|
22
|
+
type?: string;
|
|
23
|
+
resources?: string;
|
|
24
|
+
inlineResource?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
key?: string;
|
|
27
|
+
targetTag?: string;
|
|
28
|
+
rel?: string;
|
|
29
|
+
media?: string;
|
|
30
|
+
condition?: string;
|
|
31
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an area in which editors may insert content objects.
|
|
3
|
+
* @param {object} props The React properties for the component.
|
|
4
|
+
* @param {string} [props.name] The name of the area.
|
|
5
|
+
* @param {string} [props.areaView] The view to use for the area.
|
|
6
|
+
* @param {string[]} [props.allowedTypes] The allowed types for the area.
|
|
7
|
+
* @param {number} [props.numberOfItems] The number of items to display in the area.
|
|
8
|
+
* @param {string} [props.subNodesView] The view to use for the subnodes.
|
|
9
|
+
* @param {string} [props.path] Relative (to the current node) or absolute path to the node to include
|
|
10
|
+
* @param {boolean} [props.editable] Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
|
|
11
|
+
* @param {boolean} [props.areaAsSubNode] Allows area to be stored as a subnode
|
|
12
|
+
* @param {string} [props.areaType] Content type to be used to create the area (by default jnt:contentList)
|
|
13
|
+
* @param {object} [props.parameters] the parameters to pass to the area
|
|
14
|
+
* @returns {JSX.Element} The Area component
|
|
15
|
+
*/
|
|
16
|
+
export function Area({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, areaAsSubNode, areaType, parameters }: {
|
|
17
|
+
name?: string;
|
|
18
|
+
areaView?: string;
|
|
19
|
+
allowedTypes?: string[];
|
|
20
|
+
numberOfItems?: number;
|
|
21
|
+
subNodesView?: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
editable?: boolean;
|
|
24
|
+
areaAsSubNode?: boolean;
|
|
25
|
+
areaType?: string;
|
|
26
|
+
parameters?: object;
|
|
27
|
+
}): JSX.Element;
|