@nocobase/plugin-custom-variables 2.0.3
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 +99 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/AddVariableButton.d.ts +7 -0
- package/dist/client/DrawerDescription.d.ts +10 -0
- package/dist/client/EditBadge.d.ts +11 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.js +10 -0
- package/dist/client/useCustomVariablesOptions.d.ts +5 -0
- package/dist/client/variableInitializer.d.ts +8 -0
- package/dist/externalVersion.js +22 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/de-DE.json +36 -0
- package/dist/locale/en-US.json +36 -0
- package/dist/locale/es-ES.json +36 -0
- package/dist/locale/fr-FR.json +36 -0
- package/dist/locale/hu-HU.json +36 -0
- package/dist/locale/id-ID.json +36 -0
- package/dist/locale/index.d.ts +1 -0
- package/dist/locale/index.js +36 -0
- package/dist/locale/it-IT.json +36 -0
- package/dist/locale/ja-JP.json +36 -0
- package/dist/locale/ko-KR.json +36 -0
- package/dist/locale/nl-NL.json +36 -0
- package/dist/locale/pt-BR.json +36 -0
- package/dist/locale/ru-RU.json +36 -0
- package/dist/locale/tr-TR.json +36 -0
- package/dist/locale/uk-UA.json +36 -0
- package/dist/locale/vi-VN.json +36 -0
- package/dist/locale/zh-CN.json +36 -0
- package/dist/locale/zh-TW.json +36 -0
- package/dist/server/collections/customVariables.d.ts +10 -0
- package/dist/server/collections/customVariables.js +116 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.js +124 -0
- package/dist/server/parseFilter.d.ts +1 -0
- package/dist/server/parseFilter.js +44 -0
- package/package.json +29 -0
- package/server.d.ts +2 -0
- package/server.js +1 -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,99 @@
|
|
|
1
|
+
# NocoBase
|
|
2
|
+
|
|
3
|
+
<video width="100%" controls>
|
|
4
|
+
<source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
|
|
5
|
+
</video>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
9
|
+
<a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability-first, open-source no-code platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
## What is NocoBase
|
|
13
|
+
|
|
14
|
+
NocoBase is the most extensible AI-powered no-code platform.
|
|
15
|
+
Total control. Infinite extensibility. AI collaboration.
|
|
16
|
+
Enable your team to adapt quickly and cut costs dramatically.
|
|
17
|
+
No years of development. No millions wasted.
|
|
18
|
+
Deploy NocoBase in minutes — and take control of everything.
|
|
19
|
+
|
|
20
|
+
Homepage:
|
|
21
|
+
https://www.nocobase.com/
|
|
22
|
+
|
|
23
|
+
Online Demo:
|
|
24
|
+
https://demo.nocobase.com/new
|
|
25
|
+
|
|
26
|
+
Documents:
|
|
27
|
+
https://docs.nocobase.com/
|
|
28
|
+
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
31
|
+
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
34
|
+
|
|
35
|
+
## Release Notes
|
|
36
|
+
|
|
37
|
+
Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
|
|
38
|
+
|
|
39
|
+
## Distinctive features
|
|
40
|
+
|
|
41
|
+
### 1. Data model-driven, not form/table–driven
|
|
42
|
+
|
|
43
|
+
Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
|
|
44
|
+
|
|
45
|
+
- UI and data structure are fully decoupled
|
|
46
|
+
- Multiple blocks and actions can be created for the same table or record in any quantity or form
|
|
47
|
+
- Supports the main database, external databases, and third-party APIs as data sources
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. AI employees, integrated into your business systems
|
|
52
|
+
Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
|
|
53
|
+
|
|
54
|
+
- Define AI employees for roles such as translator, analyst, researcher, or assistant
|
|
55
|
+
- Seamless AI–human collaboration in interfaces and workflows
|
|
56
|
+
- Ensure AI usage is secure, transparent, and customizable for your business needs
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
### 3. What you see is what you get, incredibly easy to use
|
|
61
|
+
|
|
62
|
+
While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
|
|
63
|
+
|
|
64
|
+
- One-click switch between usage mode and configuration mode
|
|
65
|
+
- Pages serve as a canvas to arrange blocks and actions, similar to Notion
|
|
66
|
+
- Configuration mode is designed for ordinary users, not just programmers
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
### 4. Everything is a plugin, designed for extension
|
|
71
|
+
Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
|
|
72
|
+
|
|
73
|
+
- All functionalities are plugins, similar to WordPress
|
|
74
|
+
- Plugins are ready to use upon installation
|
|
75
|
+
- Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
NocoBase supports three installation methods:
|
|
82
|
+
|
|
83
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
|
84
|
+
|
|
85
|
+
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
|
86
|
+
|
|
87
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
|
88
|
+
|
|
89
|
+
The business code of the project is completely independent and supports low-code development.
|
|
90
|
+
|
|
91
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
|
|
92
|
+
|
|
93
|
+
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
|
94
|
+
|
|
95
|
+
## How NocoBase works
|
|
96
|
+
|
|
97
|
+
<video width="100%" controls>
|
|
98
|
+
<source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
|
|
99
|
+
</video>
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare function DrawerDescription(props: any): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This program is offered under a commercial license.
|
|
7
|
+
* For more information, see <https://www.nocobase.com/agreement>
|
|
8
|
+
*/
|
|
9
|
+
import { FC } from 'react';
|
|
10
|
+
declare const EditBadge: FC;
|
|
11
|
+
export default EditBadge;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This program is offered under a commercial license.
|
|
7
|
+
* For more information, see <https://www.nocobase.com/agreement>
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from '@nocobase/client';
|
|
10
|
+
declare class PluginCustomVariablesClient extends Plugin {
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default PluginCustomVariablesClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-i18next"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-custom-variables",["react","react-i18next","@nocobase/client","@formily/react","@nocobase/utils/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-custom-variables"]=t(require("react"),require("react-i18next"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-custom-variables"]=t(e.react,e["react-i18next"],e["@nocobase/client"],e["@formily/react"],e["@nocobase/utils/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o,a,i){return function(){"use strict";var l={482:function(e){e.exports=a},505:function(e){e.exports=r},772:function(e){e.exports=n},584:function(e){e.exports=o},721:function(e){e.exports=i},156:function(t){t.exports=e},238:function(e){e.exports=t}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return l[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return!function(){u.r(s),u.d(s,{default:function(){return J}});var e=u(772),t=u(584),n=u(156),r=u.n(n),o=(0,n.createContext)({onSuccess:function(){}}),a=function(t){var n=(0,e.useToken)().token,a=(0,e.useSchemaInitializerRender)("customVariables:addVariable").render;return r().createElement(o.Provider,{value:{onSuccess:t.onSuccess||function(){}}},a({style:{borderRadius:n.borderRadius}}))},i=u(238),l="custom-variables";function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var p=function(){var t,o=(0,i.useTranslation)(l).t,a=(0,e.useCurrentRoute)(),u=(0,e.useNocoBaseRoutes)().updateRoute,s=(0,n.useMemo)(function(){return{type:"object",title:o("Edit badge"),properties:{count:{title:o("Badge"),"x-decorator":"FormItem","x-decorator-props":{tooltip:o("You can enter numbers, text, variables, aggregation variables, expressions, etc.")},"x-component":function(t){var n=(0,e.useVariableOptions)({});return r().createElement(e.Variable.TextArea,f(c({},t),{scope:n}))},description:r().createElement("span",null,o("Syntax references: "),r().createElement("a",{href:"https://docs.nocobase.com/handbook/calculation-engines/formula",target:"_blank",rel:"noreferrer"},"Formula.js"))},color:{title:o("Background color"),"x-decorator":"FormItem","x-component":"ColorPicker","x-component-props":{}},textColor:{title:o("Text color"),"x-decorator":"FormItem","x-component":"ColorPicker","x-component-props":{}},size:{title:o("Size"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:o("Default"),value:"default"},{label:o("Small"),value:"small"}],default:"default"},overflowCount:{title:o("Max number"),"x-decorator":"FormItem","x-decorator-props":{tooltip:o("Maximum number to display when the badge is a number")},"x-component":"InputNumber",default:99},showZero:{title:o("Show zero"),"x-decorator":"FormItem","x-decorator-props":{tooltip:o("Whether to show the badge when it is a number and the number is 0")},"x-component":"Checkbox",default:!1}}}},[o]),p=(0,n.useMemo)(function(){var e;return null==(e=a.options)?void 0:e.badge},[null==(t=a.options)?void 0:t.badge]),d=(0,n.useCallback)(function(e){if(void 0!==a.id){var t;u(a.id,{options:f(c({},a.options),{badge:f(c({},null==(t=a.options)?void 0:t.badge,e),{count:null==e.count||""===e.count?void 0:e.count})})})}},[a.id,a.options,u]);return r().createElement(e.SchemaSettingsModalItem,{title:o("Edit badge"),eventKey:"edit-badge",schema:s,initialValues:p,onSubmit:d})},d=u(721),m=u(482),b=u(505);function v(){var e,t,n=(e=["\n margin-bottom: 1.5em;\n padding: 1em;\n background-color: ",";\n\n > *:last-child {\n margin-bottom: 0;\n }\n\n dl {\n display: flex;\n align-items: baseline;\n\n dt {\n color: ",";\n &:after {\n content: ':';\n margin-right: 0.5em;\n }\n }\n }\n\n p {\n color: ",";\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return v=function(){return n},n}var y=(0,e.createStyles)(function(e){var t=e.css,n=e.token;return{container:t(v(),n.colorFillAlter,n.colorText,n.colorTextDescription)}});function h(t){var n=t.label,o=t.title,a=t.icon,i=t.description,l=y().styles;return r().createElement("div",{className:(0,e.cx)(l.container,t.className)},r().createElement("dl",null,r().createElement("dt",null,n),r().createElement("dd",null,r().createElement(d.Tag,{icon:a,style:{background:"none"}},o))),i?r().createElement("p",null,i):null)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function O(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){x(a,r,o,i,l,"next",e)}function l(e){x(a,r,o,i,l,"throw",e)}i(void 0)})}}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function C(){var e,t,n=(e=["\n position: relative;\n width: 100%;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return C=function(){return n},n}function P(t){var n=t.value,o=t.onChange,a=t.renderSchemaComponent;return r().createElement(e.VariableInput,{value:n,onChange:o,renderSchemaComponent:a})}function I(){return!0}var k=(0,b.observer)(function(t){var n,o,a=t.filter,i=w(t,["filter"]),l=(0,e.useCompile)(),c=(0,e.useCollectionManager_deprecated)().getCollectionFields,u=(0,b.useForm)().values,s=E((0,e.parseCollectionName)(null==u?void 0:u.collection),2),f=s[0],p=c(s[1],f);return r().createElement(d.Select,(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){S(e,t,n[t])})}return e}({popupMatchSelectWidth:!1},i),o=o={options:p.filter(void 0===a?I:a).map(function(e){var t;return{label:l(null==(t=e.uiSchema)?void 0:t.title),value:e.name}})},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n))},{displayName:"FieldsSelect"}),A=function(n,a){var i;return{type:"object",properties:S({},a,{"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{zIndex:9999},type:"void",title:{create:'{{t("Add aggregate variable", { ns: "'.concat(l,'" })}}'),update:'{{t("Edit aggregate variable", { ns: "'.concat(l,'" })}}')}[a],properties:{description:{type:"void","x-component":h,"x-component-props":{label:'{{t("Variable type", { ns: "'.concat(l,'" })}}'),title:'{{t("Aggregate", { ns: "'.concat(l,'" })}}'),icon:r().createElement(m.BarChartOutlined,null),description:'{{t("Create an aggregate variable that performs statistical calculations (COUNT, SUM, AVG, MIN, MAX) on data from a specific collection. You can apply filters to narrow down the data scope and optionally use distinct values for counting operations.", { ns: "'.concat(l,'" })}}')}},variableTitle:{type:"string",title:'{{t("Variable name", { ns: "'.concat(l,'" })}}'),"x-decorator":"FormItem","x-component":"Input",required:!0,default:null==n?void 0:n.label},aggregator:{type:"string",title:'{{t("Aggregator function", { ns: "'.concat(l,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:"COUNT",value:"count"},{label:"SUM",value:"sum"},{label:"AVG",value:"avg"},{label:"MIN",value:"min"},{label:"MAX",value:"max"}],required:!0,default:(null==n?void 0:n.options.aggregator)||"count"},collectionField:{type:"void","x-decorator":"SchemaComponentContext.Provider","x-decorator-props":{value:{designable:!1}},"x-component":"Grid",properties:{row:{type:"void","x-component":"Grid.Row",properties:{target:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-component-props":{dataSourceFilter:function(e){return"main"===e.key||e.options.isDBInstance}},title:'{{t("Data of collection", { ns: "'.concat(l,'" })}}'),"x-reactions":[{target:"params.field",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"params.filter",effects:["onFieldValueChange"],fulfill:{state:{value:null}}}],default:null==n?void 0:n.options.collection}}},field:{type:"void","x-component":"Grid.Col",properties:{"params.field":{type:"string",title:'{{t("Field to aggregate", { ns: "'.concat(l,'" })}}'),"x-decorator":"FormItem","x-component":k,"x-component-props":{filter:function(e){return!e.hidden&&e.interface&&!["belongsTo","hasOne","hasMany","belongsToMany"].includes(e.type)}},required:!0,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],default:null==n?void 0:n.options.params.field}}}}}}},params:{type:"object",properties:{distinct:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-content":'{{t("Distinct", { ns: "'.concat(l,'" })}}'),"x-reactions":[{dependencies:["collection","aggregator"],fulfill:{state:{visible:'{{!!$deps[0] && ["count"].includes($deps[1])}}'}}}],default:null==n?void 0:n.options.params.distinct},filter:{type:"object",title:'{{t("Filter")}}',"x-decorator":"FormItem","x-component":"Filter","x-use-component-props":function(){var t=(0,b.useForm)().values,n=E((0,e.parseCollectionName)(null==t?void 0:t.collection),2),r=n[0],o=n[1];return{options:(0,e.useCollectionFilterOptions)(o,r),className:(0,e.css)(C())}},"x-component-props":{dynamicComponent:P},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}],default:null==n?void 0:n.options.params.filter}}},precision:{type:"number",title:'{{t("Result precision", { ns: "'.concat(l,'" })}}'),description:'{{t("Number of decimal places for query result.", { ns: "'.concat(l,'" })}}'),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,max:14,step:1,precision:0},default:null!=(i=null==n?void 0:n.options.precision)?i:2},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:function(){var t=(0,e.useActionContext)().setVisible,n=(0,b.useForm)();return{run:function(){return O(function(){return j(this,function(e){switch(e.label){case 0:return t(!1),[4,n.reset()];case 1:return e.sent(),[2]}})})()}}}}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:function(){var i=(0,e.useActionContext)().setVisible,l=(0,b.useForm)(),c=(0,e.useVariableScopeInfo)().getVariableScopeInfo,u=(0,e.useAPIClient)(),s=r().useContext(o).onSuccess;return{run:function(){return O(function(){var e,r,o,f;return j(this,function(p){switch(p.label){case 0:return[4,l.submit()];case 1:if(p.sent(),r=(e=l.values).variableTitle,o=w(e,["variableTitle"]),!(f=c()).scopeId)throw Error("Scope info not found");if("update"!==a)return[3,3];return[4,u.request({url:"customVariables:update",method:"POST",params:{filterByTk:n.name},data:{label:r,options:o}})];case 2:p.sent(),p.label=3;case 3:if("create"!==a)return[3,5];return[4,u.request({url:"customVariables:create",method:"POST",data:{name:(0,t.uid)(),label:r,declaredAt:f.scopeId,type:"aggregate",options:o}})];case 4:p.sent(),p.label=5;case 5:return[4,l.reset()];case 6:return p.sent(),i(!1),null==s||s(),[2]}})})()}}}}}}}}})}},V=new e.SchemaInitializer({name:"customVariables:addVariable",title:'{{t("Add variable", { ns: "'.concat(l,'" })}}'),icon:"PlusOutlined",items:[{name:"aggregateVariable",title:'{{t("Aggregate variable", { ns: "'.concat(l,'" })}}'),Component:function(){var t=E(r().useState(!1),2),n=t[0],o=t[1],a=(0,i.useTranslation)(l).t;return r().createElement(r().Fragment,null,r().createElement(e.SchemaInitializerItem,{title:a("Aggregate variable"),onClick:function(){o(!0)}}),r().createElement(e.ActionContextProvider,{value:{visible:n,setVisible:o}},r().createElement(e.SchemaComponentContext.Provider,{value:{designable:!1}},r().createElement(e.SchemaComponent,{schema:A(void 0,"create")}))))}}]}),T=function(t){var n=t.visible,o=t.setVisible,a=t.initialValues;return r().createElement(e.ActionContextProvider,{value:{visible:n,setVisible:o}},r().createElement(e.SchemaComponentContext.Provider,{value:{designable:!1}},r().createElement(e.SchemaComponent,{schema:A(a,"update")})))};function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function q(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){M(a,r,o,i,l,"next",e)}function l(e){M(a,r,o,i,l,"throw",e)}i(void 0)})}}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return F(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var R=function(t){var o=D((0,n.useState)(!1),2),a=o[0],c=o[1],u=(0,i.useTranslation)(l).t,s=(0,e.useToken)().token,f=(0,n.useRef)(a);return(0,n.useEffect)(function(){!a&&f.current&&t.refresh(),f.current=a},[a,t.refresh]),r().createElement(r().Fragment,null,r().createElement("div",{onClick:function(e){c(!0)}},r().createElement(m.EditOutlined,null),r().createElement("span",{style:{marginLeft:s.marginXS}},u("Edit"))),r().createElement(T,{visible:a,setVisible:c,initialValues:t.variable}))},B=function(t){var n,o=(0,e.useAPIClient)(),a=(0,i.useTranslation)(l).t,c=[{key:"edit",label:r().createElement(R,{variable:t.variable,refresh:t.refresh})},{key:"delete",label:a("Delete"),icon:r().createElement(m.DeleteOutlined,null),onClick:(n=q(function(e){return N(this,function(n){return e.domEvent,d.Modal.confirm({title:a("Delete Variable"),content:a('Are you sure you want to delete "{{label}}" variable?',{label:t.variable.label}),okText:a("Yes"),cancelText:a("No"),onOk:q(function(){return N(this,function(e){switch(e.label){case 0:return[4,o.request({url:"customVariables:destroy",method:"POST",params:{filterByTk:t.variable.name}})];case 1:return e.sent(),t.refresh(),[2]}})})}),[2]})}),function(e){return n.apply(this,arguments)})}];return r().createElement("div",{style:{paddingLeft:"8px",cursor:"pointer",opacity:+!t.hidden},onClick:function(e){e.stopPropagation()}},r().createElement(d.Dropdown,{menu:{items:c}},r().createElement(m.EllipsisOutlined,null)))},_=function(t){var o=D((0,n.useState)(!1),2),a=o[0],i=o[1];return(0,e.useFlag)().isInXButton?r().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},onMouseEnter:function(){return i(!0)},onMouseLeave:function(){return i(!1)}},r().createElement("span",null,t.value),r().createElement(B,{variable:t.variable,hidden:!a,refresh:t.refresh})):r().createElement(r().Fragment,null,t.value)},$=function(){var t=D((0,n.useState)([]),2),o=t[0],a=t[1],i=(0,e.useAPIClient)(),l=(0,e.useVariableScopeInfo)().getVariableScopeInfo,c=D((0,n.useState)(!1),2),u=c[0],s=c[1],f=(0,n.useCallback)(function(){var e=l().scopeId;e&&(s(!0),i.request({url:"customVariables:list",method:"GET",params:{filter:{declaredAt:e}}}).then(function(e){a(e.data.data.map(function(e){return{label:r().createElement(_,{value:e.label,variable:e,refresh:f}),value:e.name}})),s(!1)}).catch(function(e){console.error("Error fetching custom variables:",e),a([]),s(!1)}))},[l]);return(0,n.useEffect)(function(){f()},[f]),{options:o,loading:u,refresh:f}};function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function G(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function L(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){G(a,r,o,i,l,"next",e)}function l(e){G(a,r,o,i,l,"throw",e)}i(void 0)})}}function U(e,t,n){return(U=Z()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&X(o,n.prototype),o}).apply(null,arguments)}function W(e){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t){return(X=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Y(e,t){if(e){if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return z(e,t)}}function K(e){var t="function"==typeof Map?new Map:void 0;return(K=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return U(e,arguments,W(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),X(n,e)})(e)}function Z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Z=function(){return!!e})()}function H(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var J=function(o){var c;if("function"!=typeof o&&null!==o)throw TypeError("Super expression must either be null or a function");function u(){var e,t;if(!(this instanceof u))throw TypeError("Cannot call a class as a function");return e=u,t=arguments,e=W(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,Z()?Reflect.construct(e,t||[],W(this).constructor):e.apply(this,t))}return u.prototype=Object.create(o&&o.prototype,{constructor:{value:u,writable:!0,configurable:!0}}),o&&X(u,o),c=[{key:"load",value:function(){var o=this;return L(function(){return H(this,function(c){return o.app.schemaInitializerManager.add(V),o.app.schemaSettingsManager.addItem("menuSettings:menuItem","badge",{Component:p,sort:401}),o.app.schemaSettingsManager.addItem("PageTabSettings","badge",{Component:p,sort:201}),o.app.apiClient.axios.interceptors.response.use(function(e){var t=e.config.url.split("?")[0];return o.app.eventBus.dispatchEvent(new CustomEvent("collection:".concat(t))),e}),o.app.registerVariable({name:"$customVariables",useOption:function(){var e=$(),t=e.options,o=e.refresh,c=e.loading,u=(0,i.useTranslation)(l).t,s=(0,n.useMemo)(function(){return{label:u("Custom Variables"),value:"$customVariables",children:((function(e){if(Array.isArray(e))return z(e)})(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||Y(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([{label:r().createElement(a,{onSuccess:o}),disabled:!0,value:"none"}])}},[t,o]);return(0,n.useMemo)(function(){return{option:s,visible:!c}},[s,c])},useCtx:function(){var o,a,i=(0,e.useAPIClient)(),l=(0,e.useApp)(),c=(0,e.useLocalVariablesWithoutCustomVariable)(),u=(0,e.useVariables)(),s=(o=r().useState(0),function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(o,2)||Y(o,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=s[0],p=s[1],d=r().useRef(new Set),m=(0,n.useCallback)(function(){p(function(e){return e+1})},[]),b=(0,n.useCallback)((a=L(function(n){var r,o;return H(this,function(a){switch(a.label){case 0:return r={},(0,t.flatten)(n,{breakOn:function(e){var t=e.key;return t.startsWith("$")&&"$and"!==t&&"$or"!==t},transformValue:function(t){if(!(0,e.isVariable)(t))return t;var n=null==u?void 0:u.parseVariable(t,c).then(function(e){return e.value});return r[t]=n,n}}),[4,Promise.all((o=Object.keys(r)).map(function(e){return r[e]}))];case 1:return a.sent().forEach(function(e,t){r[o[t]]=e}),[2,r]}})}),function(e){return a.apply(this,arguments)}),[c,null==u?void 0:u.parseVariable]);return(0,n.useEffect)(function(){return function(){d.current.forEach(function(e){l.eventBus.removeEventListener(e,m)})}},[]),(0,n.useMemo)(function(){var e;return e=L(function(e){var t,n,r,o,a,c,u;return H(this,function(s){switch(s.label){case 0:return n=e.variableName.replace("$customVariables.",""),[4,i.request({url:"customVariables:get?filter[name]=".concat(n),method:"GET"})];case 1:if(!(null==(r=s.sent())||null==(t=r.data)?void 0:t.data))throw Error('Custom variable "'.concat(n,'" not found. It may have been deleted.'));return[4,b((o=r.data.data).options.params.filter)];case 2:return a=s.sent(),c=["collection:".concat(o.options.collection,":create"),"collection:".concat(o.options.collection,":update"),"collection:".concat(o.options.collection,":destroy")],d.current.forEach(function(e){l.eventBus.removeEventListener(e,m)}),c.forEach(function(e){d.current.add(e),l.eventBus.addEventListener(e,m)}),[4,i.request({url:"customVariables:parse?name=".concat(n),method:"POST",data:{filterCtx:a}})];case 3:return[2,null==(u=s.sent().data)?void 0:u.data]}})}),function(t){return e.apply(this,arguments)}},[f])}}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(u.prototype,c),u}(K(e.Plugin))}(),s}()});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SchemaInitializer } from '@nocobase/client';
|
|
2
|
+
import React, { FC } from 'react';
|
|
3
|
+
export declare const variableInitializer: SchemaInitializer<import("antd").ButtonProps, {}>;
|
|
4
|
+
export declare const VariableEditor: FC<{
|
|
5
|
+
visible: boolean;
|
|
6
|
+
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
|
+
initialValues: any;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
"react": "18.2.0",
|
|
12
|
+
"@nocobase/client": "2.0.3",
|
|
13
|
+
"antd": "5.24.2",
|
|
14
|
+
"@formily/react": "2.3.7",
|
|
15
|
+
"react-i18next": "11.18.6",
|
|
16
|
+
"@nocobase/utils": "2.0.3",
|
|
17
|
+
"@ant-design/icons": "5.6.1",
|
|
18
|
+
"@nocobase/server": "2.0.3",
|
|
19
|
+
"mathjs": "15.1.0",
|
|
20
|
+
"@nocobase/data-source-manager": "2.0.3",
|
|
21
|
+
"@nocobase/database": "2.0.3"
|
|
22
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This program is offered under a commercial license.
|
|
7
|
+
* For more information, see <https://www.nocobase.com/agreement>
|
|
8
|
+
*/
|
|
9
|
+
export * from './server';
|
|
10
|
+
export { default } from './server';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
default: () => import_server.default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
44
|
+
var import_server = __toESM(require("./server"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
...require("./server")
|
|
48
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Add aggregate variable": "Add aggregate variable",
|
|
3
|
+
"Add variable": "Add variable",
|
|
4
|
+
"Aggregate": "Aggregate",
|
|
5
|
+
"Aggregate variable": "Aggregate variable",
|
|
6
|
+
"Aggregator function": "Aggregator function",
|
|
7
|
+
"Are you sure you want to delete \"{{label}}\" variable?": "Are you sure you want to delete \"{{label}}\" variable?",
|
|
8
|
+
"Background color": "Background color",
|
|
9
|
+
"Badge": "Badge",
|
|
10
|
+
"Create an aggregate variable that performs statistical calculations (COUNT, SUM, AVG, MIN, MAX) on data from a specific collection. You can apply filters to narrow down the data scope and optionally use distinct values for counting operations.": "Create an aggregate variable that performs statistical calculations (COUNT, SUM, AVG, MIN, MAX) on data from a specific collection. You can apply filters to narrow down the data scope and optionally use distinct values for counting operations.",
|
|
11
|
+
"Custom Variables": "Custom Variables",
|
|
12
|
+
"Data of collection": "Data of collection",
|
|
13
|
+
"Default": "Default",
|
|
14
|
+
"Delete": "Delete",
|
|
15
|
+
"Delete Variable": "Delete Variable",
|
|
16
|
+
"Distinct": "Distinct",
|
|
17
|
+
"Edit": "Edit",
|
|
18
|
+
"Edit aggregate variable": "Edit aggregate variable",
|
|
19
|
+
"Edit badge": "Edit badge",
|
|
20
|
+
"Field to aggregate": "Field to aggregate",
|
|
21
|
+
"Max number": "Max number",
|
|
22
|
+
"Maximum number to display when the badge is a number": "Maximum number to display when the badge is a number",
|
|
23
|
+
"No": "No",
|
|
24
|
+
"Number of decimal places for query result.": "Number of decimal places for query result.",
|
|
25
|
+
"Result precision": "Result precision",
|
|
26
|
+
"Show zero": "Show zero",
|
|
27
|
+
"Size": "Size",
|
|
28
|
+
"Small": "Small",
|
|
29
|
+
"Syntax references: ": "Syntax references: ",
|
|
30
|
+
"Text color": "Text color",
|
|
31
|
+
"Variable name": "Variable name",
|
|
32
|
+
"Variable type": "Variable type",
|
|
33
|
+
"Whether to show the badge when it is a number and the number is 0": "Whether to show the badge when it is a number and the number is 0",
|
|
34
|
+
"Yes": "Yes",
|
|
35
|
+
"You can enter numbers, text, variables, aggregation variables, expressions, etc.": "You can enter numbers, text, variables, aggregation variables, expressions, etc."
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Add aggregate variable": "Add aggregate variable",
|
|
3
|
+
"Add variable": "Add variable",
|
|
4
|
+
"Aggregate": "Aggregate",
|
|
5
|
+
"Aggregate variable": "Aggregate variable",
|
|
6
|
+
"Aggregator function": "Aggregator function",
|
|
7
|
+
"Are you sure you want to delete \"{{label}}\" variable?": "Are you sure you want to delete \"{{label}}\" variable?",
|
|
8
|
+
"Background color": "Background color",
|
|
9
|
+
"Badge": "Badge",
|
|
10
|
+
"Create an aggregate variable that performs statistical calculations (COUNT, SUM, AVG, MIN, MAX) on data from a specific collection. You can apply filters to narrow down the data scope and optionally use distinct values for counting operations.": "Create an aggregate variable that performs statistical calculations (COUNT, SUM, AVG, MIN, MAX) on data from a specific collection. You can apply filters to narrow down the data scope and optionally use distinct values for counting operations.",
|
|
11
|
+
"Custom Variables": "Custom Variables",
|
|
12
|
+
"Data of collection": "Data of collection",
|
|
13
|
+
"Default": "Default",
|
|
14
|
+
"Delete": "Delete",
|
|
15
|
+
"Delete Variable": "Delete Variable",
|
|
16
|
+
"Distinct": "Distinct",
|
|
17
|
+
"Edit": "Edit",
|
|
18
|
+
"Edit aggregate variable": "Edit aggregate variable",
|
|
19
|
+
"Edit badge": "Edit badge",
|
|
20
|
+
"Field to aggregate": "Field to aggregate",
|
|
21
|
+
"Max number": "Max number",
|
|
22
|
+
"Maximum number to display when the badge is a number": "Maximum number to display when the badge is a number",
|
|
23
|
+
"No": "No",
|
|
24
|
+
"Number of decimal places for query result.": "Number of decimal places for query result.",
|
|
25
|
+
"Result precision": "Result precision",
|
|
26
|
+
"Show zero": "Show zero",
|
|
27
|
+
"Size": "Size",
|
|
28
|
+
"Small": "Small",
|
|
29
|
+
"Syntax references: ": "Syntax references: ",
|
|
30
|
+
"Text color": "Text color",
|
|
31
|
+
"Variable name": "Variable name",
|
|
32
|
+
"Variable type": "Variable type",
|
|
33
|
+
"Whether to show the badge when it is a number and the number is 0": "Whether to show the badge when it is a number and the number is 0",
|
|
34
|
+
"Yes": "Yes",
|
|
35
|
+
"You can enter numbers, text, variables, aggregation variables, expressions, etc.": "You can enter numbers, text, variables, aggregation variables, expressions, etc."
|
|
36
|
+
}
|