@verii/components-organizations-registrar 1.0.0-pre.1756096826 → 1.0.0-pre.1756224043

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.
Files changed (131) hide show
  1. package/dist/chunks/{ConsentProvider.DIG3atk-.js → ConsentProvider.6M2ucqXH.js} +3 -3
  2. package/dist/chunks/ConsentProvider.6M2ucqXH.js.map +1 -0
  3. package/dist/chunks/{ConsentProvider.DTG51XMy.js → ConsentProvider.Bbc0preP.js} +2 -2
  4. package/dist/chunks/ConsentProvider.Bbc0preP.js.map +1 -0
  5. package/dist/chunks/{CreateOrganization.utils.C5C_r3Zp.js → CreateOrganizationUtils.C5C_r3Zp.js} +1 -1
  6. package/dist/chunks/CreateOrganizationUtils.C5C_r3Zp.js.map +1 -0
  7. package/dist/chunks/{CreateOrganization.utils.8cSBFSYF.js → CreateOrganizationUtils.Xq78HHkP.js} +7 -7
  8. package/dist/chunks/CreateOrganizationUtils.Xq78HHkP.js.map +1 -0
  9. package/dist/chunks/{CustomAppBar.DuFQqld7.js → CustomAppBar.BOlNFosS.js} +5 -7
  10. package/dist/chunks/CustomAppBar.BOlNFosS.js.map +1 -0
  11. package/dist/chunks/{CustomAppBar.BfQvuTHz.js → CustomAppBar.DaXLAwPh.js} +4 -6
  12. package/dist/chunks/CustomAppBar.DaXLAwPh.js.map +1 -0
  13. package/dist/chunks/{LinkedInRegistrationInput.C-qzrR-S.js → LinkedInRegistrationInput.CmYmSJoq.js} +8 -5
  14. package/dist/chunks/LinkedInRegistrationInput.CmYmSJoq.js.map +1 -0
  15. package/dist/chunks/{LinkedInRegistrationInput.DKRMHYRh.js → LinkedInRegistrationInput.gnYgP1Hf.js} +11 -8
  16. package/dist/chunks/LinkedInRegistrationInput.gnYgP1Hf.js.map +1 -0
  17. package/dist/chunks/{Loading.UJl_3_cf.js → Loading.Bcm3xNJU.js} +2 -3
  18. package/dist/chunks/Loading.Bcm3xNJU.js.map +1 -0
  19. package/dist/chunks/{Loading.DYBk0Ktb.js → Loading.cGHE59CV.js} +2 -3
  20. package/dist/chunks/Loading.cGHE59CV.js.map +1 -0
  21. package/dist/chunks/{MainLayout.CWFkijrE.js → MainLayout.BzfaZs8j.js} +2 -2
  22. package/dist/chunks/{MainLayout.CWFkijrE.js.map → MainLayout.BzfaZs8j.js.map} +1 -1
  23. package/dist/chunks/{MainLayout.6Hq5XQ-L.js → MainLayout.V-ymVxxR.js} +3 -3
  24. package/dist/chunks/{MainLayout.6Hq5XQ-L.js.map → MainLayout.V-ymVxxR.js.map} +1 -1
  25. package/dist/chunks/{OrganizationAvatar.BEwRZ9tC.js → OrganizationAvatar.BXW4diDT.js} +2 -2
  26. package/dist/chunks/{OrganizationAvatar.BEwRZ9tC.js.map → OrganizationAvatar.BXW4diDT.js.map} +1 -1
  27. package/dist/chunks/{OrganizationAvatar.lWcXtbM6.js → OrganizationAvatar.Dgg5VSPI.js} +2 -2
  28. package/dist/chunks/{OrganizationAvatar.lWcXtbM6.js.map → OrganizationAvatar.Dgg5VSPI.js.map} +1 -1
  29. package/dist/chunks/{ServicesEdit.BUAbbXgV.js → ServicesEdit.BnnqC203.js} +3 -3
  30. package/dist/chunks/ServicesEdit.BnnqC203.js.map +1 -0
  31. package/dist/chunks/{ServicesEdit.CrtEcP_7.js → ServicesEdit.DDgjS5kU.js} +2 -2
  32. package/dist/chunks/ServicesEdit.DDgjS5kU.js.map +1 -0
  33. package/dist/chunks/{SetInvitationService.BUZqAilX.js → SetInvitationService.PxAGwk-I.js} +11 -11
  34. package/dist/chunks/SetInvitationService.PxAGwk-I.js.map +1 -0
  35. package/dist/chunks/{SetInvitationService.B0ezxTzf.js → SetInvitationService.ZT5lP003.js} +5 -5
  36. package/dist/chunks/SetInvitationService.ZT5lP003.js.map +1 -0
  37. package/dist/chunks/TermsAndConditionsPdf.Ba8-5Hcm.js.map +1 -1
  38. package/dist/chunks/TermsAndConditionsPdf.ewC7N9Vy.js.map +1 -1
  39. package/dist/chunks/{CreateOrganization.C2Kf44eJ.js → ValidateTextInput.D5kgjulG.js} +328 -14
  40. package/dist/chunks/ValidateTextInput.D5kgjulG.js.map +1 -0
  41. package/dist/chunks/{CreateOrganization.A11-a_8R.js → ValidateTextInput.DEBaVB1L.js} +356 -42
  42. package/dist/chunks/ValidateTextInput.DEBaVB1L.js.map +1 -0
  43. package/dist/chunks/{index.DZOVpocw.js → index.CYCWawJT.js} +6 -6
  44. package/dist/chunks/index.CYCWawJT.js.map +1 -0
  45. package/dist/chunks/{index.DmM8ShwP.js → index.Cmn4FlUL.js} +5 -5
  46. package/dist/chunks/index.Cmn4FlUL.js.map +1 -0
  47. package/dist/chunks/{index.DlFajFTS.js → index.DIizFYFZ.js} +3 -3
  48. package/dist/chunks/index.DIizFYFZ.js.map +1 -0
  49. package/dist/chunks/{index.ZAmuSdK1.js → index.DIur8MCO.js} +4 -4
  50. package/dist/chunks/index.DIur8MCO.js.map +1 -0
  51. package/dist/chunks/{index.Ch4ynES2.js → index.DMWKdmxs.js} +4 -5
  52. package/dist/chunks/index.DMWKdmxs.js.map +1 -0
  53. package/dist/chunks/{index.Dir1xwV4.js → index.DND10PiY.js} +5 -6
  54. package/dist/chunks/index.DND10PiY.js.map +1 -0
  55. package/dist/chunks/{index.Cpod3Il3.js → index.YjnxLFjk.js} +3 -3
  56. package/dist/chunks/index.YjnxLFjk.js.map +1 -0
  57. package/dist/chunks/index.iexmV4Mr.js.map +1 -1
  58. package/dist/chunks/remoteDataProvider.BCiFSYnk.js.map +1 -1
  59. package/dist/chunks/remoteDataProvider.gtTXA1-g.js.map +1 -1
  60. package/dist/chunks/useIsIssuingInspection.C76mY_wb.js.map +1 -1
  61. package/dist/chunks/useIsIssuingInspection.DavhBs5B.js.map +1 -1
  62. package/dist/components/AppBar.cjs +1 -1
  63. package/dist/components/AppBar.js +1 -1
  64. package/dist/components/common.cjs +3 -3
  65. package/dist/components/common.js +3 -3
  66. package/dist/components/invitations.cjs +1 -1
  67. package/dist/components/invitations.js +1 -1
  68. package/dist/components/organizations.cjs +12 -301
  69. package/dist/components/organizations.cjs.map +1 -1
  70. package/dist/components/organizations.js +10 -299
  71. package/dist/components/organizations.js.map +1 -1
  72. package/dist/components/services.cjs +1 -1
  73. package/dist/components/services.js +1 -1
  74. package/dist/components.cjs +2 -2
  75. package/dist/components.js +2 -2
  76. package/dist/index.cjs +3 -3
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.js +3 -3
  79. package/dist/index.js.map +1 -1
  80. package/dist/layouts.cjs +1 -1
  81. package/dist/layouts.js +1 -1
  82. package/dist/pages/individuals.cjs +4 -4
  83. package/dist/pages/individuals.cjs.map +1 -1
  84. package/dist/pages/individuals.js +5 -5
  85. package/dist/pages/individuals.js.map +1 -1
  86. package/dist/pages/invitations.cjs +11 -12
  87. package/dist/pages/invitations.cjs.map +1 -1
  88. package/dist/pages/invitations.js +9 -10
  89. package/dist/pages/invitations.js.map +1 -1
  90. package/dist/pages/organizations.cjs +74 -75
  91. package/dist/pages/organizations.cjs.map +1 -1
  92. package/dist/pages/organizations.js +10 -11
  93. package/dist/pages/organizations.js.map +1 -1
  94. package/dist/pages/services.cjs +6 -6
  95. package/dist/pages/services.cjs.map +1 -1
  96. package/dist/pages/services.js +5 -5
  97. package/dist/pages/services.js.map +1 -1
  98. package/dist/pages.cjs +1 -1
  99. package/dist/pages.cjs.map +1 -1
  100. package/dist/pages.js +1 -1
  101. package/dist/pages.js.map +1 -1
  102. package/package.json +12 -9
  103. package/setup-tests.js +31 -0
  104. package/dist/chunks/ConsentProvider.DIG3atk-.js.map +0 -1
  105. package/dist/chunks/ConsentProvider.DTG51XMy.js.map +0 -1
  106. package/dist/chunks/CreateOrganization.A11-a_8R.js.map +0 -1
  107. package/dist/chunks/CreateOrganization.C2Kf44eJ.js.map +0 -1
  108. package/dist/chunks/CreateOrganization.utils.8cSBFSYF.js.map +0 -1
  109. package/dist/chunks/CreateOrganization.utils.C5C_r3Zp.js.map +0 -1
  110. package/dist/chunks/CustomAppBar.BfQvuTHz.js.map +0 -1
  111. package/dist/chunks/CustomAppBar.DuFQqld7.js.map +0 -1
  112. package/dist/chunks/LinkedInRegistrationInput.C-qzrR-S.js.map +0 -1
  113. package/dist/chunks/LinkedInRegistrationInput.DKRMHYRh.js.map +0 -1
  114. package/dist/chunks/Loading.DYBk0Ktb.js.map +0 -1
  115. package/dist/chunks/Loading.UJl_3_cf.js.map +0 -1
  116. package/dist/chunks/OrganisationSubmitButton.D32qynh9.js +0 -40
  117. package/dist/chunks/OrganisationSubmitButton.D32qynh9.js.map +0 -1
  118. package/dist/chunks/OrganisationSubmitButton.D3w1nG1X.js +0 -41
  119. package/dist/chunks/OrganisationSubmitButton.D3w1nG1X.js.map +0 -1
  120. package/dist/chunks/ServicesEdit.BUAbbXgV.js.map +0 -1
  121. package/dist/chunks/ServicesEdit.CrtEcP_7.js.map +0 -1
  122. package/dist/chunks/SetInvitationService.B0ezxTzf.js.map +0 -1
  123. package/dist/chunks/SetInvitationService.BUZqAilX.js.map +0 -1
  124. package/dist/chunks/index.Ch4ynES2.js.map +0 -1
  125. package/dist/chunks/index.Cpod3Il3.js.map +0 -1
  126. package/dist/chunks/index.DZOVpocw.js.map +0 -1
  127. package/dist/chunks/index.Dir1xwV4.js.map +0 -1
  128. package/dist/chunks/index.DlFajFTS.js.map +0 -1
  129. package/dist/chunks/index.DmM8ShwP.js.map +0 -1
  130. package/dist/chunks/index.ZAmuSdK1.js.map +0 -1
  131. package/jest.config.cjs +0 -29
@@ -1,304 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const React = require("react");
5
- const material = require("@mui/material");
6
- const reactAdmin = require("react-admin");
7
- const reactHookForm = require("react-hook-form");
8
- const parse = require("autosuggest-highlight/parse");
9
- const match = require("autosuggest-highlight/match");
10
- const AddIcon = require("@mui/icons-material/Add");
11
- const PropTypes = require("prop-types");
12
- const remoteDataProvider = require("../chunks/remoteDataProvider.BCiFSYnk.js");
13
- const CreateOrganization = require("../chunks/CreateOrganization.A11-a_8R.js");
14
- const CreateOrganization_utils = require("../chunks/CreateOrganization.utils.C5C_r3Zp.js");
15
- const OrganisationSubmitButton = require("../chunks/OrganisationSubmitButton.D32qynh9.js");
16
- const index = require("../chunks/index.iexmV4Mr.js");
17
- const useDebounce = (value, delay) => {
18
- const [debouncedValue, setDebouncedValue] = React.useState(value);
19
- React.useEffect(() => {
20
- const timer = setTimeout(() => setDebouncedValue(value), delay);
21
- return () => {
22
- clearTimeout(timer);
23
- };
24
- }, [value, delay]);
25
- return debouncedValue;
26
- };
27
- const DID_START = "did:";
28
- const ERRORS = {
29
- DID_NOT_FOUND: "DID not found",
30
- REQUIRED: "Required"
31
- };
32
- const AutoCompleteOrganizationName = ({ defaultValue }) => {
33
- const form = reactHookForm.useFormContext();
34
- const [value, setValue] = React.useState(defaultValue);
35
- const [text, setText] = React.useState(defaultValue?.name || "");
36
- const [options, setOptions] = React.useState([]);
37
- const [isOpen, setIsOpen] = React.useState(false);
38
- const [loading, setLoading] = React.useState(false);
39
- const [error, setError] = React.useState("");
40
- const dataProvider = reactAdmin.useDataProvider();
41
- const debouncedText = useDebounce(text, 500);
42
- const theme = material.useTheme();
43
- const [stopSearch, setStopSearch] = React.useState(false);
44
- form.register("org.name", { required: true });
45
- React.useEffect(() => {
46
- form.setValue("org", value, { shouldValidate: true });
47
- }, [form, value]);
48
- React.useEffect(() => {
49
- const searchProfiles = async () => {
50
- if (stopSearch) {
51
- return;
52
- }
53
- setLoading(true);
54
- try {
55
- if (debouncedText.includes(DID_START)) {
56
- const result2 = await dataProvider.getOne(remoteDataProvider.dataResources.VERIFIED_PROFILE, {
57
- id: debouncedText
58
- });
59
- setError("");
60
- setText(result2.data.credentialSubject.name);
61
- setValue(result2.data.credentialSubject);
62
- setIsOpen(false);
63
- return;
64
- }
65
- if (!debouncedText) {
66
- setOptions([]);
67
- return;
68
- }
69
- const result = await dataProvider.getList(remoteDataProvider.dataResources.SEARCH_PROFILES, {
70
- search: debouncedText
71
- });
72
- setOptions(result.data.slice(0, 5));
73
- } catch {
74
- setOptions([]);
75
- if (debouncedText.includes(DID_START)) {
76
- setError(ERRORS.DID_NOT_FOUND);
77
- }
78
- } finally {
79
- setLoading(false);
80
- }
81
- };
82
- if (debouncedText) {
83
- searchProfiles();
84
- }
85
- }, [dataProvider, debouncedText, stopSearch]);
86
- React.useEffect(() => {
87
- if (!isOpen) {
88
- setOptions([]);
89
- }
90
- }, [isOpen]);
91
- const handleChangeText = React.useCallback((event) => {
92
- setText(event?.target?.value);
93
- setValue({ name: event?.target?.value });
94
- }, []);
95
- const handleBlur = React.useCallback(() => {
96
- if (!text) {
97
- setValue(null);
98
- setError(ERRORS.REQUIRED);
99
- }
100
- if (text && !options.length) {
101
- setValue({ name: text });
102
- }
103
- }, [options, text]);
104
- const handleFocus = React.useCallback(() => {
105
- setError("");
106
- }, []);
107
- const handleStopSearch = React.useCallback(() => {
108
- setStopSearch(true);
109
- setOptions([]);
110
- setTimeout(() => {
111
- setStopSearch(false);
112
- }, 1e4);
113
- }, []);
114
- return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { marginBottom: 5, children: [
115
- /* @__PURE__ */ jsxRuntime.jsx(
116
- material.Autocomplete,
117
- {
118
- fullWidth: true,
119
- options: text?.length && !loading ? options : [],
120
- inputValue: text || "",
121
- open: isOpen,
122
- onOpen: () => setIsOpen(true),
123
- onClose: () => setIsOpen(false),
124
- onInputChange: handleChangeText,
125
- getOptionLabel: (params) => params?.name?.toString(),
126
- getOptionKey: (params) => params.id,
127
- loading,
128
- freeSolo: true,
129
- disableClearable: true,
130
- blurOnSelect: true,
131
- value,
132
- filterOptions: (x) => x,
133
- onChange: (_event, newValue) => {
134
- if (typeof newValue === "string") {
135
- setText(text);
136
- setValue({ name: text });
137
- setOptions([]);
138
- return;
139
- }
140
- setValue(newValue);
141
- setText(newValue.name);
142
- },
143
- renderOption: (props, option, { inputValue }) => {
144
- const matches = match(option.name, inputValue, { insideWords: true });
145
- const parts = parse(option.name, matches);
146
- const isLastItem = props["data-option-index"] === options.length - 1;
147
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
148
- /* @__PURE__ */ jsxRuntime.jsx("li", { ...props, style: isLastItem ? styles.lastItem : styles.item, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
149
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: parts.map((part, index2) => /* @__PURE__ */ jsxRuntime.jsx(
150
- material.Typography,
151
- {
152
- style: { fontWeight: part.highlight ? 700 : 400 },
153
- variant: "pl",
154
- children: part.text
155
- },
156
- index2
157
- )) }),
158
- /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "ps", color: theme.palette.secondary.light, children: option.id })
159
- ] }) }),
160
- isLastItem ? /* @__PURE__ */ jsxRuntime.jsxs(
161
- material.Button,
162
- {
163
- variant: "outlined",
164
- color: "secondary",
165
- onClick: handleStopSearch,
166
- sx: styles.inviteButton,
167
- children: [
168
- /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { sx: styles.plus }),
169
- "Invite New Organization"
170
- ]
171
- }
172
- ) : null
173
- ] });
174
- },
175
- renderInput: (params) => /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { style: styles.inputBox, children: [
176
- /* @__PURE__ */ jsxRuntime.jsx(
177
- material.TextField,
178
- {
179
- label: "Legal Name",
180
- ...params,
181
- value: params.inputProps.value.name,
182
- onBlur: handleBlur,
183
- onFocus: handleFocus,
184
- error
185
- }
186
- ),
187
- value?.id ? /* @__PURE__ */ jsxRuntime.jsx(
188
- material.Typography,
189
- {
190
- style: styles.did,
191
- variant: "ps",
192
- color: theme.palette.secondary.light,
193
- sx: styles.inviteButton,
194
- children: value.id
195
- }
196
- ) : null
197
- ] })
198
- }
199
- ),
200
- error ? /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "ps", color: theme.palette.error.light, children: error }) : null
201
- ] });
202
- };
203
- AutoCompleteOrganizationName.propTypes = {
204
- // eslint-disable-next-line react/forbid-prop-types
205
- defaultValue: PropTypes.object
206
- };
207
- const styles = {
208
- inputBox: { position: "relative" },
209
- item: {
210
- padding: "8px 12px",
211
- borderBottomWidth: "1px",
212
- borderBottomStyle: "solid",
213
- borderBottomColor: "#D1D4D8"
214
- },
215
- lastItem: {
216
- padding: "8px 12px"
217
- },
218
- did: {
219
- position: "absolute",
220
- left: "0px",
221
- bottom: "-12px"
222
- },
223
- inviteButton: {
224
- color: (theme) => theme.customColors.grey2,
225
- marginBottom: "16px",
226
- marginLeft: "12px",
227
- marginTop: "16px",
228
- fontSize: "12px"
229
- },
230
- plus: {
231
- width: "16px",
232
- height: "16px",
233
- marginRight: "6px"
234
- }
235
- };
236
- const ValidateTextInput = ({ source, resource, ...props }) => {
237
- const { debounce: debounceTime = 250, ...rest } = props;
238
- const errorobj = { message: " " };
239
- const dataProvider = reactAdmin.useDataProvider();
240
- const [isError, setIsError] = React.useState(false);
241
- const timeout = React.useRef(null);
242
- const validateSecureUrl = [
243
- reactAdmin.regex(index.secureUrlRegexp, (res) => {
244
- setIsError(false);
245
- return res ? "Secure webhook should be a HTTPS URL" : void 0;
246
- }),
247
- reactAdmin.maxLength(1024)
248
- ];
249
- const debouncedValidation = async (value) => {
250
- clearTimeout(timeout.current);
251
- if (!value) {
252
- setIsError(false);
253
- return void 0;
254
- }
255
- return new Promise((resolve) => {
256
- timeout.current = setTimeout(async () => {
257
- const { data } = await dataProvider.create(resource, { data: { secureWebhookUrl: value } });
258
- if (data && data.status === 400) {
259
- setIsError(true);
260
- resolve(errorobj);
261
- } else {
262
- resolve(void 0);
263
- setIsError(false);
264
- }
265
- }, debounceTime);
266
- });
267
- };
268
- const validate = [...validateSecureUrl, debouncedValidation];
269
- return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: sx.constainer, children: [
270
- /* @__PURE__ */ jsxRuntime.jsx(reactAdmin.TextInput, { source, validate, ...rest }),
271
- isError && /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "caption", component: "div", sx: sx.errorMessage, children: index.ERRORS.secureWebHook })
272
- ] });
273
- };
274
- const sx = {
275
- constainer: {
276
- width: "100%",
277
- position: "relative"
278
- },
279
- errorMessage: {
280
- color: "primary.main",
281
- mt: 0,
282
- mb: 0.5,
283
- ml: 1.5
284
- }
285
- };
286
- ValidateTextInput.propTypes = {
287
- source: PropTypes.string,
288
- resource: PropTypes.string,
289
- errortext: PropTypes.string,
290
- // eslint-disable-next-line react/forbid-prop-types
291
- validate: PropTypes.array,
292
- debounce: PropTypes.number
293
- };
294
- exports.CreateInvitationForOrganization = CreateOrganization.CreateInvitationForOrganization;
295
- exports.CreateOrganisation = CreateOrganization.CreateOrganization;
296
- exports.validateEmail = CreateOrganization_utils.validateEmail;
297
- exports.validateName = CreateOrganization_utils.validateName;
298
- exports.validateServiceEndpoint = CreateOrganization_utils.validateServiceEndpoint;
299
- exports.validateWebsite = CreateOrganization_utils.validateWebsite;
300
- exports.validateWebsiteStrict = CreateOrganization_utils.validateWebsiteStrict;
301
- exports.OrganisationSubmitButton = OrganisationSubmitButton.OrganizationSubmitButton;
302
- exports.AutoCompleteOrganizationName = AutoCompleteOrganizationName;
303
- exports.ValidateTextInput = ValidateTextInput;
3
+ const ValidateTextInput = require("../chunks/ValidateTextInput.DEBaVB1L.js");
4
+ const CreateOrganizationUtils = require("../chunks/CreateOrganizationUtils.C5C_r3Zp.js");
5
+ exports.AutoCompleteOrganizationName = ValidateTextInput.AutoCompleteOrganizationName;
6
+ exports.CreateInvitationForOrganization = ValidateTextInput.CreateInvitationForOrganization;
7
+ exports.CreateOrganisation = ValidateTextInput.CreateOrganization;
8
+ exports.OrganizationSubmitButton = ValidateTextInput.OrganizationSubmitButton;
9
+ exports.ValidateTextInput = ValidateTextInput.ValidateTextInput;
10
+ exports.validateEmail = CreateOrganizationUtils.validateEmail;
11
+ exports.validateName = CreateOrganizationUtils.validateName;
12
+ exports.validateServiceEndpoint = CreateOrganizationUtils.validateServiceEndpoint;
13
+ exports.validateWebsite = CreateOrganizationUtils.validateWebsite;
14
+ exports.validateWebsiteStrict = CreateOrganizationUtils.validateWebsiteStrict;
304
15
  //# sourceMappingURL=organizations.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.cjs","sources":["../../src/utils/hooks/useDebounceValue.js","../../src/components/organizations/AutoCompleteOrganizationName.jsx","../../src/components/organizations/ValidateTextInput.jsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst useDebounce = (value, delay) => {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const timer = setTimeout(() => setDebouncedValue(value), delay || 500);\n\n return () => {\n clearTimeout(timer);\n };\n }, [value, delay]);\n\n return debouncedValue;\n};\n\nexport default useDebounce;\n","import { useCallback, useState, useEffect } from 'react';\nimport { Box, Autocomplete, Typography, useTheme, TextField, Button } from '@mui/material';\nimport { useDataProvider } from 'react-admin';\nimport { useFormContext } from 'react-hook-form';\nimport parse from 'autosuggest-highlight/parse';\nimport match from 'autosuggest-highlight/match';\nimport AddIcon from '@mui/icons-material/Add';\nimport PropTypes from 'prop-types';\nimport { dataResources } from '../../utils/remoteDataProvider';\nimport useDebounce from '../../utils/hooks/useDebounceValue';\n\nconst DID_START = 'did:';\nconst ERRORS = {\n DID_NOT_FOUND: 'DID not found',\n REQUIRED: 'Required',\n};\n\nconst AutoCompleteOrganizationName = ({ defaultValue }) => {\n const form = useFormContext();\n const [value, setValue] = useState(defaultValue);\n const [text, setText] = useState(defaultValue?.name || '');\n const [options, setOptions] = useState([]);\n const [isOpen, setIsOpen] = useState(false);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState('');\n const dataProvider = useDataProvider();\n const debouncedText = useDebounce(text, 500);\n const theme = useTheme();\n const [stopSearch, setStopSearch] = useState(false);\n\n form.register('org.name', { required: true });\n\n useEffect(() => {\n form.setValue('org', value, { shouldValidate: true });\n }, [form, value]);\n\n useEffect(() => {\n const searchProfiles = async () => {\n if (stopSearch) {\n return;\n }\n\n setLoading(true);\n try {\n if (debouncedText.includes(DID_START)) {\n const result = await dataProvider.getOne(dataResources.VERIFIED_PROFILE, {\n id: debouncedText,\n });\n setError('');\n setText(result.data.credentialSubject.name);\n setValue(result.data.credentialSubject);\n setIsOpen(false);\n return;\n }\n\n if (!debouncedText) {\n setOptions([]);\n\n return;\n }\n\n const result = await dataProvider.getList(dataResources.SEARCH_PROFILES, {\n search: debouncedText,\n });\n\n setOptions(result.data.slice(0, 5));\n } catch {\n setOptions([]);\n\n if (debouncedText.includes(DID_START)) {\n setError(ERRORS.DID_NOT_FOUND);\n }\n } finally {\n setLoading(false);\n }\n };\n\n if (debouncedText) {\n searchProfiles();\n }\n }, [dataProvider, debouncedText, stopSearch]);\n\n useEffect(() => {\n if (!isOpen) {\n setOptions([]);\n }\n }, [isOpen]);\n\n const handleChangeText = useCallback((event) => {\n setText(event?.target?.value);\n setValue({ name: event?.target?.value });\n }, []);\n\n const handleBlur = useCallback(() => {\n if (!text) {\n setValue(null);\n setError(ERRORS.REQUIRED);\n }\n\n if (text && !options.length) {\n setValue({ name: text });\n }\n }, [options, text]);\n\n const handleFocus = useCallback(() => {\n setError('');\n }, []);\n\n const handleStopSearch = useCallback(() => {\n setStopSearch(true);\n setOptions([]);\n\n setTimeout(() => {\n setStopSearch(false);\n }, 10000);\n }, []);\n\n return (\n <Box marginBottom={5}>\n <Autocomplete\n fullWidth\n options={text?.length && !loading ? options : []}\n inputValue={text || ''}\n open={isOpen}\n onOpen={() => setIsOpen(true)}\n onClose={() => setIsOpen(false)}\n onInputChange={handleChangeText}\n getOptionLabel={(params) => params?.name?.toString()}\n getOptionKey={(params) => params.id}\n loading={loading}\n freeSolo\n disableClearable\n blurOnSelect\n value={value}\n filterOptions={(x) => x}\n onChange={(_event, newValue) => {\n if (typeof newValue === 'string') {\n setText(text);\n setValue({ name: text });\n setOptions([]);\n\n return;\n }\n\n setValue(newValue);\n setText(newValue.name);\n }}\n renderOption={(props, option, { inputValue }) => {\n const matches = match(option.name, inputValue, { insideWords: true });\n const parts = parse(option.name, matches);\n // eslint-disable-next-line react/prop-types\n const isLastItem = props['data-option-index'] === options.length - 1;\n\n return (\n <>\n <li {...props} style={isLastItem ? styles.lastItem : styles.item}>\n <div>\n <div>\n {parts.map((part, index) => (\n <Typography\n /* eslint-disable-next-line react/no-array-index-key */\n key={index}\n style={{ fontWeight: part.highlight ? 700 : 400 }}\n variant=\"pl\"\n >\n {part.text}\n </Typography>\n ))}\n </div>\n <Typography variant=\"ps\" color={theme.palette.secondary.light}>\n {option.id}\n </Typography>\n </div>\n </li>\n\n {isLastItem ? (\n <Button\n variant=\"outlined\"\n color=\"secondary\"\n onClick={handleStopSearch}\n sx={styles.inviteButton}\n >\n <AddIcon sx={styles.plus} />\n Invite New Organization\n </Button>\n ) : null}\n </>\n );\n }}\n renderInput={(params) => (\n <Box style={styles.inputBox}>\n <TextField\n label=\"Legal Name\"\n {...params}\n value={params.inputProps.value.name}\n onBlur={handleBlur}\n onFocus={handleFocus}\n error={error}\n />\n {value?.id ? (\n <Typography\n style={styles.did}\n variant=\"ps\"\n color={theme.palette.secondary.light}\n sx={styles.inviteButton}\n >\n {value.id}\n </Typography>\n ) : null}\n </Box>\n )}\n />\n {error ? (\n <Typography variant=\"ps\" color={theme.palette.error.light}>\n {error}\n </Typography>\n ) : null}\n </Box>\n );\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nAutoCompleteOrganizationName.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n defaultValue: PropTypes.object,\n};\n\nconst styles = {\n inputBox: { position: 'relative' },\n item: {\n padding: '8px 12px',\n borderBottomWidth: '1px',\n borderBottomStyle: 'solid',\n borderBottomColor: '#D1D4D8',\n },\n lastItem: {\n padding: '8px 12px',\n },\n did: {\n position: 'absolute',\n left: '0px',\n bottom: '-12px',\n },\n inviteButton: {\n color: (theme) => theme.customColors.grey2,\n marginBottom: '16px',\n marginLeft: '12px',\n marginTop: '16px',\n fontSize: '12px',\n },\n plus: {\n width: '16px',\n height: '16px',\n marginRight: '6px',\n },\n};\n\nexport default AutoCompleteOrganizationName;\n","/**\n * Copyright 2023 Velocity Team\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useDataProvider, TextInput, regex, maxLength } from 'react-admin';\nimport PropTypes from 'prop-types';\nimport { useRef, useState } from 'react';\nimport { Typography, Box } from '@mui/material';\nimport { secureUrlRegexp, ERRORS } from '../../utils/index.jsx';\n\nconst ValidateTextInput = ({ source, resource, ...props }) => {\n const { debounce: debounceTime = 250, ...rest } = props;\n const errorobj = { message: ' ' };\n const dataProvider = useDataProvider();\n const [isError, setIsError] = useState(false);\n\n const timeout = useRef(null);\n\n const validateSecureUrl = [\n regex(secureUrlRegexp, (res) => {\n setIsError(false);\n return res ? 'Secure webhook should be a HTTPS URL' : undefined;\n }),\n maxLength(1024),\n ];\n\n const debouncedValidation = async (value) => {\n clearTimeout(timeout.current);\n\n if (!value) {\n setIsError(false);\n return undefined;\n }\n\n return new Promise((resolve) => {\n // eslint-disable-next-line better-mutation/no-mutation\n timeout.current = setTimeout(async () => {\n const { data } = await dataProvider.create(resource, { data: { secureWebhookUrl: value } });\n if (data && data.status === 400) {\n setIsError(true);\n resolve(errorobj);\n } else {\n resolve(undefined);\n setIsError(false);\n }\n }, debounceTime);\n });\n };\n\n const validate = [...validateSecureUrl, debouncedValidation];\n\n return (\n <Box sx={sx.constainer}>\n <TextInput source={source} validate={validate} {...rest} />\n {isError && (\n <Typography variant=\"caption\" component=\"div\" sx={sx.errorMessage}>\n {ERRORS.secureWebHook}\n </Typography>\n )}\n </Box>\n );\n};\n\nexport default ValidateTextInput;\n\nconst sx = {\n constainer: {\n width: '100%',\n position: 'relative',\n },\n errorMessage: {\n color: 'primary.main',\n mt: 0,\n mb: 0.5,\n ml: 1.5,\n },\n};\n\n// eslint-disable-next-line better-mutation/no-mutation\nValidateTextInput.propTypes = {\n source: PropTypes.string,\n resource: PropTypes.string,\n errortext: PropTypes.string,\n // eslint-disable-next-line react/forbid-prop-types\n validate: PropTypes.array,\n debounce: PropTypes.number,\n};\n"],"names":["useState","useEffect","useFormContext","useDataProvider","useTheme","result","dataResources","useCallback","jsxs","Box","jsx","Autocomplete","Fragment","index","Typography","Button","TextField","useRef","regex","secureUrlRegexp","maxLength","TextInput","ERRORS"],"mappings":";;;;;;;;;;;;;;;;AAEA,MAAM,cAAc,CAAC,OAAO,UAAU;AACpC,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,MAAAA,SAAS,KAAK;AAE1DC,QAAAA,UAAU,MAAM;AACd,UAAM,QAAQ,WAAW,MAAM,kBAAkB,KAAK,GAAG,KAAY;AAErE,WAAO,MAAM;AACX,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,OAAO,KAAK,CAAC;AAEjB,SAAO;AACT;ACHA,MAAM,YAAY;AAClB,MAAM,SAAS;AAAA,EACb,eAAe;AAAA,EACf,UAAU;AACZ;AAEA,MAAM,+BAA+B,CAAC,EAAE,mBAAmB;AACzD,QAAM,OAAOC,cAAAA,eAAA;AACb,QAAM,CAAC,OAAO,QAAQ,IAAIF,MAAAA,SAAS,YAAY;AAC/C,QAAM,CAAC,MAAM,OAAO,IAAIA,MAAAA,SAAS,cAAc,QAAQ,EAAE;AACzD,QAAM,CAAC,SAAS,UAAU,IAAIA,MAAAA,SAAS,CAAA,CAAE;AACzC,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAAS,KAAK;AAC1C,QAAM,CAAC,SAAS,UAAU,IAAIA,MAAAA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,SAAAA,KAAA,EAAI,IAAI,GAAG,YACV,UAAA;AAAA,IAAAC,2BAAAA,IAACW,WAAAA,WAAA,EAAU,QAAgB,UAAqB,GAAG,KAAA,CAAM;AAAA,IACxD,WACCX,2BAAAA,IAACI,SAAAA,YAAA,EAAW,SAAQ,WAAU,WAAU,OAAM,IAAI,GAAG,cAClD,UAAAQ,MAAAA,OAAO,cAAA,CACV;AAAA,EAAA,GAEJ;AAEJ;AAIA,MAAM,KAAK;AAAA,EACT,YAAY;AAAA,IACV,OAAO;AAAA,IACP,UAAU;AAAA,EAAA;AAAA,EAEZ,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EAAA;AAER;AAGA,kBAAkB,YAAY;AAAA,EAC5B,QAAQ,UAAU;AAAA,EAClB,UAAU,UAAU;AAAA,EACpB,WAAW,UAAU;AAAA;AAAA,EAErB,UAAU,UAAU;AAAA,EACpB,UAAU,UAAU;AACtB;;;;;;;;;;;"}
1
+ {"version":3,"file":"organizations.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -1,304 +1,15 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect, useCallback, useRef } from "react";
3
- import { useTheme, Box, Autocomplete, TextField, Typography, Button } from "@mui/material";
4
- import { useDataProvider, regex, maxLength, TextInput } from "react-admin";
5
- import { useFormContext } from "react-hook-form";
6
- import parse from "autosuggest-highlight/parse";
7
- import match from "autosuggest-highlight/match";
8
- import AddIcon from "@mui/icons-material/Add";
9
- import PropTypes from "prop-types";
10
- import { d as dataResources } from "../chunks/remoteDataProvider.gtTXA1-g.js";
11
- import { C, a } from "../chunks/CreateOrganization.C2Kf44eJ.js";
12
- import { c, v, d, a as a2, b } from "../chunks/CreateOrganization.utils.8cSBFSYF.js";
13
- import { O } from "../chunks/OrganisationSubmitButton.D3w1nG1X.js";
14
- import { s as secureUrlRegexp, E as ERRORS$1 } from "../chunks/index.ZAmuSdK1.js";
15
- const useDebounce = (value, delay) => {
16
- const [debouncedValue, setDebouncedValue] = useState(value);
17
- useEffect(() => {
18
- const timer = setTimeout(() => setDebouncedValue(value), delay);
19
- return () => {
20
- clearTimeout(timer);
21
- };
22
- }, [value, delay]);
23
- return debouncedValue;
24
- };
25
- const DID_START = "did:";
26
- const ERRORS = {
27
- DID_NOT_FOUND: "DID not found",
28
- REQUIRED: "Required"
29
- };
30
- const AutoCompleteOrganizationName = ({ defaultValue }) => {
31
- const form = useFormContext();
32
- const [value, setValue] = useState(defaultValue);
33
- const [text, setText] = useState(defaultValue?.name || "");
34
- const [options, setOptions] = useState([]);
35
- const [isOpen, setIsOpen] = useState(false);
36
- const [loading, setLoading] = useState(false);
37
- const [error, setError] = useState("");
38
- const dataProvider = useDataProvider();
39
- const debouncedText = useDebounce(text, 500);
40
- const theme = useTheme();
41
- const [stopSearch, setStopSearch] = useState(false);
42
- form.register("org.name", { required: true });
43
- useEffect(() => {
44
- form.setValue("org", value, { shouldValidate: true });
45
- }, [form, value]);
46
- useEffect(() => {
47
- const searchProfiles = async () => {
48
- if (stopSearch) {
49
- return;
50
- }
51
- setLoading(true);
52
- try {
53
- if (debouncedText.includes(DID_START)) {
54
- const result2 = await dataProvider.getOne(dataResources.VERIFIED_PROFILE, {
55
- id: debouncedText
56
- });
57
- setError("");
58
- setText(result2.data.credentialSubject.name);
59
- setValue(result2.data.credentialSubject);
60
- setIsOpen(false);
61
- return;
62
- }
63
- if (!debouncedText) {
64
- setOptions([]);
65
- return;
66
- }
67
- const result = await dataProvider.getList(dataResources.SEARCH_PROFILES, {
68
- search: debouncedText
69
- });
70
- setOptions(result.data.slice(0, 5));
71
- } catch {
72
- setOptions([]);
73
- if (debouncedText.includes(DID_START)) {
74
- setError(ERRORS.DID_NOT_FOUND);
75
- }
76
- } finally {
77
- setLoading(false);
78
- }
79
- };
80
- if (debouncedText) {
81
- searchProfiles();
82
- }
83
- }, [dataProvider, debouncedText, stopSearch]);
84
- useEffect(() => {
85
- if (!isOpen) {
86
- setOptions([]);
87
- }
88
- }, [isOpen]);
89
- const handleChangeText = useCallback((event) => {
90
- setText(event?.target?.value);
91
- setValue({ name: event?.target?.value });
92
- }, []);
93
- const handleBlur = useCallback(() => {
94
- if (!text) {
95
- setValue(null);
96
- setError(ERRORS.REQUIRED);
97
- }
98
- if (text && !options.length) {
99
- setValue({ name: text });
100
- }
101
- }, [options, text]);
102
- const handleFocus = useCallback(() => {
103
- setError("");
104
- }, []);
105
- const handleStopSearch = useCallback(() => {
106
- setStopSearch(true);
107
- setOptions([]);
108
- setTimeout(() => {
109
- setStopSearch(false);
110
- }, 1e4);
111
- }, []);
112
- return /* @__PURE__ */ jsxs(Box, { marginBottom: 5, children: [
113
- /* @__PURE__ */ jsx(
114
- Autocomplete,
115
- {
116
- fullWidth: true,
117
- options: text?.length && !loading ? options : [],
118
- inputValue: text || "",
119
- open: isOpen,
120
- onOpen: () => setIsOpen(true),
121
- onClose: () => setIsOpen(false),
122
- onInputChange: handleChangeText,
123
- getOptionLabel: (params) => params?.name?.toString(),
124
- getOptionKey: (params) => params.id,
125
- loading,
126
- freeSolo: true,
127
- disableClearable: true,
128
- blurOnSelect: true,
129
- value,
130
- filterOptions: (x) => x,
131
- onChange: (_event, newValue) => {
132
- if (typeof newValue === "string") {
133
- setText(text);
134
- setValue({ name: text });
135
- setOptions([]);
136
- return;
137
- }
138
- setValue(newValue);
139
- setText(newValue.name);
140
- },
141
- renderOption: (props, option, { inputValue }) => {
142
- const matches = match(option.name, inputValue, { insideWords: true });
143
- const parts = parse(option.name, matches);
144
- const isLastItem = props["data-option-index"] === options.length - 1;
145
- return /* @__PURE__ */ jsxs(Fragment, { children: [
146
- /* @__PURE__ */ jsx("li", { ...props, style: isLastItem ? styles.lastItem : styles.item, children: /* @__PURE__ */ jsxs("div", { children: [
147
- /* @__PURE__ */ jsx("div", { children: parts.map((part, index) => /* @__PURE__ */ jsx(
148
- Typography,
149
- {
150
- style: { fontWeight: part.highlight ? 700 : 400 },
151
- variant: "pl",
152
- children: part.text
153
- },
154
- index
155
- )) }),
156
- /* @__PURE__ */ jsx(Typography, { variant: "ps", color: theme.palette.secondary.light, children: option.id })
157
- ] }) }),
158
- isLastItem ? /* @__PURE__ */ jsxs(
159
- Button,
160
- {
161
- variant: "outlined",
162
- color: "secondary",
163
- onClick: handleStopSearch,
164
- sx: styles.inviteButton,
165
- children: [
166
- /* @__PURE__ */ jsx(AddIcon, { sx: styles.plus }),
167
- "Invite New Organization"
168
- ]
169
- }
170
- ) : null
171
- ] });
172
- },
173
- renderInput: (params) => /* @__PURE__ */ jsxs(Box, { style: styles.inputBox, children: [
174
- /* @__PURE__ */ jsx(
175
- TextField,
176
- {
177
- label: "Legal Name",
178
- ...params,
179
- value: params.inputProps.value.name,
180
- onBlur: handleBlur,
181
- onFocus: handleFocus,
182
- error
183
- }
184
- ),
185
- value?.id ? /* @__PURE__ */ jsx(
186
- Typography,
187
- {
188
- style: styles.did,
189
- variant: "ps",
190
- color: theme.palette.secondary.light,
191
- sx: styles.inviteButton,
192
- children: value.id
193
- }
194
- ) : null
195
- ] })
196
- }
197
- ),
198
- error ? /* @__PURE__ */ jsx(Typography, { variant: "ps", color: theme.palette.error.light, children: error }) : null
199
- ] });
200
- };
201
- AutoCompleteOrganizationName.propTypes = {
202
- // eslint-disable-next-line react/forbid-prop-types
203
- defaultValue: PropTypes.object
204
- };
205
- const styles = {
206
- inputBox: { position: "relative" },
207
- item: {
208
- padding: "8px 12px",
209
- borderBottomWidth: "1px",
210
- borderBottomStyle: "solid",
211
- borderBottomColor: "#D1D4D8"
212
- },
213
- lastItem: {
214
- padding: "8px 12px"
215
- },
216
- did: {
217
- position: "absolute",
218
- left: "0px",
219
- bottom: "-12px"
220
- },
221
- inviteButton: {
222
- color: (theme) => theme.customColors.grey2,
223
- marginBottom: "16px",
224
- marginLeft: "12px",
225
- marginTop: "16px",
226
- fontSize: "12px"
227
- },
228
- plus: {
229
- width: "16px",
230
- height: "16px",
231
- marginRight: "6px"
232
- }
233
- };
234
- const ValidateTextInput = ({ source, resource, ...props }) => {
235
- const { debounce: debounceTime = 250, ...rest } = props;
236
- const errorobj = { message: " " };
237
- const dataProvider = useDataProvider();
238
- const [isError, setIsError] = useState(false);
239
- const timeout = useRef(null);
240
- const validateSecureUrl = [
241
- regex(secureUrlRegexp, (res) => {
242
- setIsError(false);
243
- return res ? "Secure webhook should be a HTTPS URL" : void 0;
244
- }),
245
- maxLength(1024)
246
- ];
247
- const debouncedValidation = async (value) => {
248
- clearTimeout(timeout.current);
249
- if (!value) {
250
- setIsError(false);
251
- return void 0;
252
- }
253
- return new Promise((resolve) => {
254
- timeout.current = setTimeout(async () => {
255
- const { data } = await dataProvider.create(resource, { data: { secureWebhookUrl: value } });
256
- if (data && data.status === 400) {
257
- setIsError(true);
258
- resolve(errorobj);
259
- } else {
260
- resolve(void 0);
261
- setIsError(false);
262
- }
263
- }, debounceTime);
264
- });
265
- };
266
- const validate = [...validateSecureUrl, debouncedValidation];
267
- return /* @__PURE__ */ jsxs(Box, { sx: sx.constainer, children: [
268
- /* @__PURE__ */ jsx(TextInput, { source, validate, ...rest }),
269
- isError && /* @__PURE__ */ jsx(Typography, { variant: "caption", component: "div", sx: sx.errorMessage, children: ERRORS$1.secureWebHook })
270
- ] });
271
- };
272
- const sx = {
273
- constainer: {
274
- width: "100%",
275
- position: "relative"
276
- },
277
- errorMessage: {
278
- color: "primary.main",
279
- mt: 0,
280
- mb: 0.5,
281
- ml: 1.5
282
- }
283
- };
284
- ValidateTextInput.propTypes = {
285
- source: PropTypes.string,
286
- resource: PropTypes.string,
287
- errortext: PropTypes.string,
288
- // eslint-disable-next-line react/forbid-prop-types
289
- validate: PropTypes.array,
290
- debounce: PropTypes.number
291
- };
1
+ import { A, C, a, O, V } from "../chunks/ValidateTextInput.D5kgjulG.js";
2
+ import { d, b, c, v, a as a2 } from "../chunks/CreateOrganizationUtils.Xq78HHkP.js";
292
3
  export {
293
- AutoCompleteOrganizationName,
4
+ A as AutoCompleteOrganizationName,
294
5
  C as CreateInvitationForOrganization,
295
6
  a as CreateOrganisation,
296
- O as OrganisationSubmitButton,
297
- ValidateTextInput,
298
- c as validateEmail,
299
- v as validateName,
300
- d as validateServiceEndpoint,
301
- a2 as validateWebsite,
302
- b as validateWebsiteStrict
7
+ O as OrganizationSubmitButton,
8
+ V as ValidateTextInput,
9
+ d as validateEmail,
10
+ b as validateName,
11
+ c as validateServiceEndpoint,
12
+ v as validateWebsite,
13
+ a2 as validateWebsiteStrict
303
14
  };
304
15
  //# sourceMappingURL=organizations.js.map