@dropins/storefront-company-management 1.0.0-beta2 → 1.0.0-beta21
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/api/allowCompanyRegistration/allowCompanyRegistration.d.ts +18 -0
- package/api/allowCompanyRegistration/graphql/allowCompanyRegistration.graphql.d.ts +18 -0
- package/api/allowCompanyRegistration/index.d.ts +18 -0
- package/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.d.ts +4 -0
- package/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.d.ts +18 -0
- package/api/checkCompanyCreditEnabled/index.d.ts +18 -0
- package/api/companyEnabled/companyEnabled.d.ts +18 -0
- package/api/companyEnabled/graphql/companyEnabled.graphql.d.ts +18 -0
- package/api/{checkIsCompanyEnabled → companyEnabled}/index.d.ts +1 -1
- package/api/companyRoles/createCompanyRole.d.ts +7 -0
- package/api/companyRoles/deleteCompanyRole.d.ts +7 -0
- package/api/companyRoles/getCompanyAclResources.d.ts +7 -0
- package/api/companyRoles/getCompanyRole.d.ts +8 -0
- package/api/companyRoles/getCompanyRoles.d.ts +8 -0
- package/api/companyRoles/graphql/fragments.d.ts +18 -0
- package/api/companyRoles/graphql/index.d.ts +20 -0
- package/api/companyRoles/graphql/mutations.d.ts +20 -0
- package/api/companyRoles/graphql/queries.d.ts +21 -0
- package/api/companyRoles/index.d.ts +27 -0
- package/api/companyRoles/isCompanyRoleNameAvailable.d.ts +7 -0
- package/api/companyRoles/updateCompanyRole.d.ts +7 -0
- package/api/companyRoles/utils.d.ts +11 -0
- package/api/createCompany/createCompany.d.ts +39 -0
- package/api/createCompany/graphql/createCompany.graphql.d.ts +18 -0
- package/api/createCompany/index.d.ts +18 -0
- package/api/createCompanyTeam/createCompanyTeam.d.ts +11 -0
- package/api/createCompanyTeam/graphql/createCompanyTeam.graphql.d.ts +18 -0
- package/api/createCompanyTeam/index.d.ts +18 -0
- package/api/createCompanyUser/createCompanyUser.d.ts +9 -0
- package/api/createCompanyUser/graphql/createCompanyUser.graphql.d.ts +18 -0
- package/api/createCompanyUser/index.d.ts +18 -0
- package/api/deleteCompanyTeam/deleteCompanyTeam.d.ts +9 -0
- package/api/deleteCompanyTeam/graphql/deleteCompanyTeam.graphql.d.ts +18 -0
- package/api/deleteCompanyTeam/index.d.ts +18 -0
- package/api/deleteCompanyUser/deleteCompanyUser.d.ts +10 -0
- package/api/deleteCompanyUser/graphql/deleteCompanyUser.graphql.d.ts +18 -0
- package/api/deleteCompanyUser/index.d.ts +18 -0
- package/api/fetchUserPermissions/fetchUserPermissions.d.ts +11 -0
- package/api/{getCompany → fetchUserPermissions}/graphql/getCustomerRole.graphql.d.ts +1 -1
- package/api/fetchUserPermissions/index.d.ts +18 -0
- package/api/getCompany/getCompany.d.ts +9 -3
- package/api/getCompanyCredit/getCompanyCredit.d.ts +4 -0
- package/api/getCompanyCredit/graphql/getCompanyCredit.graphql.d.ts +18 -0
- package/api/getCompanyCredit/index.d.ts +18 -0
- package/api/getCompanyCreditHistory/getCompanyCreditHistory.d.ts +5 -0
- package/api/getCompanyCreditHistory/graphql/getCompanyCreditHistory.graphql.d.ts +18 -0
- package/api/getCompanyCreditHistory/index.d.ts +19 -0
- package/api/getCompanyStructure/getCompanyStructure.d.ts +10 -0
- package/api/getCompanyStructure/graphql/getCompanyStructure.graphql.d.ts +18 -0
- package/api/getCompanyStructure/index.d.ts +18 -0
- package/api/getCompanyTeam/getCompanyTeam.d.ts +11 -0
- package/api/getCompanyTeam/graphql/getCompanyTeam.graphql.d.ts +18 -0
- package/api/getCompanyTeam/index.d.ts +18 -0
- package/api/getCompanyUser/getCompanyUser.d.ts +9 -0
- package/api/getCompanyUser/graphql/getCompanyUser.graphql.d.ts +18 -0
- package/api/getCompanyUser/index.d.ts +18 -0
- package/api/getCompanyUsers/getCompanyUsers.d.ts +12 -0
- package/api/getCompanyUsers/graphql/companyUsers.graphql.d.ts +18 -0
- package/api/getCompanyUsers/index.d.ts +18 -0
- package/api/getCustomerCompany/getCustomerCompany.d.ts +12 -0
- package/api/getCustomerCompany/graphql/getCustomerCompanyInfo.graphql.d.ts +18 -0
- package/api/getCustomerCompany/index.d.ts +18 -0
- package/api/getStoreConfig/getStoreConfig.d.ts +6 -0
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +18 -0
- package/api/getStoreConfig/index.d.ts +18 -0
- package/api/graphql/buildCompanyQueries.d.ts +9 -0
- package/api/index.d.ts +26 -2
- package/api/initialize/initialize.d.ts +2 -20
- package/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.d.ts +18 -0
- package/api/isCompanyAdmin/index.d.ts +18 -0
- package/api/isCompanyAdmin/isCompanyAdmin.d.ts +22 -0
- package/api/isCompanyUser/graphql/isCompanyUser.graphql.d.ts +18 -0
- package/api/isCompanyUser/index.d.ts +18 -0
- package/api/isCompanyUser/isCompanyUser.d.ts +22 -0
- package/api/isCompanyUserEmailAvailable/graphql/isCompanyUserEmailAvailable.graphql.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/index.d.ts +18 -0
- package/api/isCompanyUserEmailAvailable/isCompanyUserEmailAvailable.d.ts +7 -0
- package/api/updateCompanyStructure/graphql/updateCompanyStructure.graphql.d.ts +18 -0
- package/api/updateCompanyStructure/index.d.ts +18 -0
- package/api/updateCompanyStructure/updateCompanyStructure.d.ts +11 -0
- package/api/updateCompanyTeam/graphql/updateCompanyTeam.graphql.d.ts +18 -0
- package/api/updateCompanyTeam/index.d.ts +18 -0
- package/api/updateCompanyTeam/updateCompanyTeam.d.ts +11 -0
- package/api/updateCompanyUser/graphql/updateCompanyUser.graphql.d.ts +18 -0
- package/api/updateCompanyUser/index.d.ts +18 -0
- package/api/updateCompanyUser/updateCompanyUser.d.ts +9 -0
- package/api/updateCompanyUserStatus/graphql/updateCompanyUserStatus.graphql.d.ts +18 -0
- package/api/updateCompanyUserStatus/index.d.ts +18 -0
- package/api/updateCompanyUserStatus/updateCompanyUserStatus.d.ts +11 -0
- package/api.js +22 -1
- package/api.js.map +1 -1
- package/chunks/CompanyLoaders.js +4 -0
- package/chunks/CompanyLoaders.js.map +1 -0
- package/chunks/CompanyUserForm.js +4 -0
- package/chunks/CompanyUserForm.js.map +1 -0
- package/chunks/Tree.js +4 -0
- package/chunks/Tree.js.map +1 -0
- package/chunks/acdl.js +4 -0
- package/chunks/acdl.js.map +1 -0
- package/chunks/company-permissions.js +4 -0
- package/chunks/company-permissions.js.map +1 -0
- package/chunks/fetch-error.js +4 -0
- package/chunks/fetch-error.js.map +1 -0
- package/chunks/fetchUserPermissions.js +34 -0
- package/chunks/fetchUserPermissions.js.map +1 -0
- package/chunks/getCompanyCreditHistory.js +68 -0
- package/chunks/getCompanyCreditHistory.js.map +1 -0
- package/chunks/getCustomerCompany.js +26 -0
- package/chunks/getCustomerCompany.js.map +1 -0
- package/chunks/isCompanyRoleNameAvailable.js +121 -0
- package/chunks/isCompanyRoleNameAvailable.js.map +1 -0
- package/chunks/isCompanyUser.js +21 -0
- package/chunks/isCompanyUser.js.map +1 -0
- package/chunks/network-error.js +4 -0
- package/chunks/network-error.js.map +1 -0
- package/chunks/transform-store-config.js +44 -0
- package/chunks/transform-store-config.js.map +1 -0
- package/chunks/updateCompany.js +70 -0
- package/chunks/updateCompany.js.map +1 -0
- package/chunks/updateCompanyTeam.js +42 -0
- package/chunks/updateCompanyTeam.js.map +1 -0
- package/chunks/updateCompanyUser.js +37 -0
- package/chunks/updateCompanyUser.js.map +1 -0
- package/chunks/updateCompanyUserStatus.js +39 -0
- package/chunks/updateCompanyUserStatus.js.map +1 -0
- package/chunks/useCompanyContextListener.js +4 -0
- package/chunks/useCompanyContextListener.js.map +1 -0
- package/chunks/useCompanyRoles.js +4 -0
- package/chunks/useCompanyRoles.js.map +1 -0
- package/chunks/useCustomerCompanyInfo.js +4 -0
- package/chunks/useCustomerCompanyInfo.js.map +1 -0
- package/chunks/useInLineAlert.js +4 -0
- package/chunks/useInLineAlert.js.map +1 -0
- package/chunks/useUserPermissions.js +4 -0
- package/chunks/useUserPermissions.js.map +1 -0
- package/chunks/validateCompanyEmail.js +29 -0
- package/chunks/validateCompanyEmail.js.map +1 -0
- package/components/CompanyCreditDisplay/CompanyCreditDisplay.d.ts +7 -0
- package/components/CompanyCreditDisplay/index.d.ts +19 -0
- package/components/CompanyCreditHistoryDisplay/CompanyCreditHistoryDisplay.d.ts +15 -0
- package/components/CompanyCreditHistoryDisplay/index.d.ts +19 -0
- package/components/CompanyLoaders/CompanyLoaders.d.ts +14 -0
- package/components/CompanyRegistrationForm/CompanyRegistrationForm.d.ts +13 -0
- package/components/CompanyRegistrationForm/Form/Form.d.ts +5 -0
- package/components/CompanyRegistrationForm/Form/FormInputs/FormInputs.d.ts +5 -0
- package/components/CompanyRegistrationForm/Form/FormInputs/index.d.ts +18 -0
- package/components/CompanyRegistrationForm/Form/fieldHandlers.d.ts +26 -0
- package/components/CompanyRegistrationForm/Form/fieldValidationRules.d.ts +63 -0
- package/components/CompanyRegistrationForm/Form/formValidation.d.ts +17 -0
- package/components/CompanyRegistrationForm/Form/getCompanyFieldsConfig.d.ts +13 -0
- package/components/CompanyRegistrationForm/Form/index.d.ts +18 -0
- package/components/CompanyRegistrationForm/index.d.ts +20 -0
- package/components/CompanyRegistrationSuccess/CompanyRegistrationSuccess.d.ts +8 -0
- package/components/CompanyRegistrationSuccess/index.d.ts +18 -0
- package/components/CompanyStructureCard/CompanyStructureCard.d.ts +12 -0
- package/components/CompanyStructureCard/index.d.ts +18 -0
- package/components/CompanyStructureEmpty/CompanyStructureEmpty.d.ts +9 -0
- package/components/CompanyStructureEmpty/index.d.ts +19 -0
- package/components/CompanyTeamForm/CompanyTeamForm.d.ts +17 -0
- package/components/CompanyTeamForm/index.d.ts +18 -0
- package/components/CompanyUserForm/CompanyUserForm.d.ts +10 -0
- package/components/CompanyUserForm/index.d.ts +18 -0
- package/components/CompanyUsersFilters/CompanyUsersFilters.d.ts +29 -0
- package/components/CompanyUsersFilters/index.d.ts +18 -0
- package/components/CompanyUsersManagementModal/CompanyUsersManagementModal.d.ts +18 -0
- package/components/CompanyUsersManagementModal/index.d.ts +19 -0
- package/components/CustomerCompanyInfoCard/CustomerCompanyInfoCard.d.ts +9 -0
- package/components/CustomerCompanyInfoCard/index.d.ts +18 -0
- package/components/DeleteRoleModal/DeleteRoleModal.d.ts +9 -0
- package/components/DeleteRoleModal/index.d.ts +19 -0
- package/components/EditCompanyProfile/CompanyAccountFields.d.ts +1 -2
- package/components/EditCompanyProfile/LegalAddressFields.d.ts +1 -1
- package/components/EditRoleAndPermission/EditRoleAndPermission.d.ts +24 -0
- package/components/EditRoleAndPermission/index.d.ts +19 -0
- package/components/RoleAndPermissionTable/RoleAndPermissionTable.d.ts +23 -0
- package/components/RoleAndPermissionTable/index.d.ts +19 -0
- package/components/Tree/Tree.d.ts +62 -0
- package/components/Tree/index.d.ts +18 -0
- package/components/index.d.ts +15 -0
- package/containers/CompanyCredit/CompanyCredit.d.ts +16 -0
- package/containers/CompanyCredit/index.d.ts +19 -0
- package/containers/CompanyCredit.d.ts +3 -0
- package/containers/CompanyCredit.js +4 -0
- package/containers/CompanyCredit.js.map +1 -0
- package/containers/CompanyProfile.js +1 -1
- package/containers/CompanyProfile.js.map +1 -1
- package/containers/CompanyRegistration/CompanyRegistration.d.ts +15 -0
- package/containers/CompanyRegistration/index.d.ts +19 -0
- package/containers/CompanyRegistration.d.ts +3 -0
- package/containers/CompanyRegistration.js +4 -0
- package/containers/CompanyRegistration.js.map +1 -0
- package/containers/CompanyStructure/CompanyStructure.d.ts +5 -0
- package/containers/CompanyStructure/index.d.ts +19 -0
- package/containers/CompanyStructure.d.ts +3 -0
- package/containers/CompanyStructure.js +4 -0
- package/containers/CompanyStructure.js.map +1 -0
- package/containers/CompanyUsers/CompanyUsers.d.ts +7 -0
- package/containers/CompanyUsers/index.d.ts +19 -0
- package/containers/CompanyUsers.d.ts +3 -0
- package/containers/CompanyUsers.js +4 -0
- package/containers/CompanyUsers.js.map +1 -0
- package/containers/CustomerCompanyInfo/CustomerCompanyInfo.d.ts +9 -0
- package/containers/CustomerCompanyInfo/index.d.ts +19 -0
- package/containers/CustomerCompanyInfo.d.ts +1 -0
- package/containers/CustomerCompanyInfo.js +4 -0
- package/containers/CustomerCompanyInfo.js.map +1 -0
- package/containers/RolesAndPermissions/RolesAndPermissions.d.ts +8 -0
- package/containers/RolesAndPermissions/index.d.ts +19 -0
- package/containers/RolesAndPermissions.d.ts +3 -0
- package/containers/RolesAndPermissions.js +4 -0
- package/containers/RolesAndPermissions.js.map +1 -0
- package/containers/index.d.ts +7 -0
- package/data/models/company-credit-history.d.ts +54 -0
- package/data/models/company-credit-info.d.ts +33 -0
- package/data/models/company-role.d.ts +48 -0
- package/data/models/company-structure.d.ts +26 -0
- package/data/models/company-team.d.ts +24 -0
- package/data/models/company-user.d.ts +33 -0
- package/data/models/company.d.ts +58 -17
- package/data/models/customer-company-info.d.ts +23 -0
- package/data/models/index.d.ts +7 -0
- package/data/transforms/company.d.ts +5 -0
- package/data/transforms/index.d.ts +8 -0
- package/data/transforms/transform-company-credit-history.d.ts +5 -0
- package/data/transforms/transform-company-credit.d.ts +5 -0
- package/data/transforms/transform-company-roles.d.ts +15 -0
- package/data/transforms/transform-company-structure.d.ts +22 -0
- package/data/transforms/transform-company-team.d.ts +10 -0
- package/data/transforms/transform-company-user.d.ts +18 -0
- package/data/transforms/transform-company.d.ts +5 -1
- package/data/transforms/transform-customer-company-info.d.ts +10 -0
- package/data/transforms/transform-store-config.d.ts +4 -0
- package/hooks/containers/index.d.ts +3 -0
- package/hooks/containers/useCompanyCreditHistory.d.ts +32 -0
- package/hooks/containers/useCompanyProfile.d.ts +2 -8
- package/hooks/containers/useCompanyUsers.d.ts +34 -0
- package/hooks/containers/useCustomerCompanyInfo.d.ts +12 -0
- package/hooks/index.d.ts +9 -0
- package/hooks/useCompanyContextListener.d.ts +62 -0
- package/hooks/useCompanyRegistrationForm.d.ts +37 -0
- package/hooks/useCompanyRoles.d.ts +28 -0
- package/hooks/useCompanyStructureCard.d.ts +36 -0
- package/hooks/useCompanyTeamForm.d.ts +30 -0
- package/hooks/useCompanyUserForm.d.ts +37 -0
- package/hooks/useCountryAndRegionFields.d.ts +20 -0
- package/hooks/useModal.d.ts +24 -0
- package/hooks/usePermissions.d.ts +31 -0
- package/hooks/useUserPermissions.d.ts +26 -0
- package/i18n/en_US.json.d.ts +345 -4
- package/lib/acdl.d.ts +2 -1
- package/lib/company-permissions.d.ts +25 -0
- package/lib/encoding.d.ts +43 -0
- package/lib/fetch-error.d.ts +6 -1
- package/lib/index.d.ts +3 -0
- package/lib/network-error.d.ts +4 -0
- package/lib/userHelpers.d.ts +47 -0
- package/lib/validationFields.d.ts +16 -0
- package/package.json +1 -1
- package/render.js +12 -2
- package/render.js.map +1 -1
- package/types/api/{checkIsCompanyEnabled.types.d.ts → checkCompanyCreditEnabled.types.d.ts} +3 -3
- package/types/api/companyRoles.types.d.ts +137 -0
- package/types/api/companyUsers.types.d.ts +70 -0
- package/types/api/createCompanyTeam.types.d.ts +27 -0
- package/types/api/createCompanyUser.types.d.ts +31 -0
- package/types/api/deleteCompanyTeam.types.d.ts +20 -0
- package/types/api/deleteCompanyUser.types.d.ts +28 -0
- package/types/api/fetchUserPermissions.types.d.ts +43 -0
- package/types/api/getCompany.types.d.ts +1 -1
- package/types/api/getCompanyCredit.types.d.ts +40 -0
- package/types/api/getCompanyCreditHistory.types.d.ts +61 -0
- package/types/api/getCompanyCreditHistoryParams.types.d.ts +53 -0
- package/types/api/getCompanyStructure.types.d.ts +33 -0
- package/types/api/getCompanyTeam.types.d.ts +20 -0
- package/types/api/getCompanyUser.types.d.ts +20 -0
- package/types/api/getCustomerCompanyInfo.types.d.ts +40 -0
- package/types/api/getStoreConfig.types.d.ts +33 -0
- package/types/api/index.d.ts +29 -0
- package/types/api/initialize.types.d.ts +21 -0
- package/types/api/isCompanyUserEmailAvailable.types.d.ts +20 -0
- package/types/api/updateCompany.types.d.ts +1 -1
- package/types/api/updateCompanyStructure.types.d.ts +21 -0
- package/types/api/updateCompanyTeam.types.d.ts +22 -0
- package/types/api/updateCompanyUser.types.d.ts +27 -0
- package/types/api/updateCompanyUserStatus.types.d.ts +22 -0
- package/types/companyForm.types.d.ts +33 -0
- package/types/companyPermission.types.d.ts +33 -0
- package/types/companyProfile.types.d.ts +43 -0
- package/types/companyStructure.types.d.ts +28 -0
- package/types/customerCompanyInfo.types.d.ts +11 -0
- package/types/events.d.ts +21 -0
- package/types/form.types.d.ts +93 -0
- package/types/hook.types.d.ts +18 -0
- package/types/index.d.ts +25 -2
- package/api/checkIsCompanyEnabled/checkIsCompanyEnabled.d.ts +0 -4
- package/api/updateCompany/graphql/updateCompany.graphql.d.ts +0 -2
- package/chunks/getCountries.js +0 -135
- package/chunks/getCountries.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
/**
|
|
18
|
+
* Check if the current authenticated customer belongs to any company
|
|
19
|
+
* @returns Promise<boolean> - true if customer belongs to one or more companies, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
export declare const isCompanyUser: () => Promise<boolean>;
|
|
22
|
+
//# sourceMappingURL=isCompanyUser.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const IS_COMPANY_USER_EMAIL_AVAILABLE = "\n query isCompanyUserEmailAvailable($email: String!) {\n isCompanyUserEmailAvailable(email: $email) { is_email_available }\n }\n";
|
|
18
|
+
//# sourceMappingURL=isCompanyUserEmailAvailable.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './isCompanyUserEmailAvailable';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if an email address is available for use by a new company user
|
|
3
|
+
* @param email - The email address to check for availability
|
|
4
|
+
* @returns Promise resolving to boolean indicating availability or null if check failed
|
|
5
|
+
*/
|
|
6
|
+
export declare function isCompanyUserEmailAvailable(email: string): Promise<boolean | null>;
|
|
7
|
+
//# sourceMappingURL=isCompanyUserEmailAvailable.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const UPDATE_COMPANY_STRUCTURE = "\n mutation updateCompanyStructure($treeId: ID!, $parentTreeId: ID!) {\n updateCompanyStructure(input: { tree_id: $treeId, parent_tree_id: $parentTreeId }) {\n __typename\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyStructure.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './updateCompanyStructure';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UpdateCompanyStructureInput } from '../../types/api/updateCompanyStructure.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates the company structure by moving a node to a new parent
|
|
5
|
+
*
|
|
6
|
+
* @param input - Object containing the node ID and new parent ID
|
|
7
|
+
* @returns Promise resolving to boolean indicating success
|
|
8
|
+
* @throws {Error} When network errors or GraphQL errors occur
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateCompanyStructure(input: UpdateCompanyStructureInput): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=updateCompanyStructure.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const UPDATE_COMPANY_TEAM = "\n mutation updateCompanyTeam($input: CompanyTeamUpdateInput!) {\n updateCompanyTeam(input: $input) { __typename team { id name } }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyTeam.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './updateCompanyTeam';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UpdateCompanyTeamInput } from '../../types/api/updateCompanyTeam.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates an existing company team with the provided information
|
|
5
|
+
*
|
|
6
|
+
* @param input - Team information including ID (base64 encoded UID) and fields to update
|
|
7
|
+
* @returns Promise resolving to boolean indicating success
|
|
8
|
+
* @throws {Error} When network errors or GraphQL errors occur
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateCompanyTeam(input: UpdateCompanyTeamInput): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=updateCompanyTeam.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const UPDATE_COMPANY_USER = "\n mutation updateCompanyUser($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) { __typename user { id } }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyUser.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './updateCompanyUser';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UpdateCompanyUserInput } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates an existing company user with the provided information
|
|
5
|
+
* @param input - User information including ID (base64 encoded UID) and fields to update
|
|
6
|
+
* @returns Promise resolving to boolean indicating success
|
|
7
|
+
*/
|
|
8
|
+
export declare function updateCompanyUser(input: UpdateCompanyUserInput): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=updateCompanyUser.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export declare const UPDATE_COMPANY_USER_STATUS_MUTATION = "\n mutation UPDATE_COMPANY_USER_STATUS($input: CompanyUserUpdateInput!) {\n updateCompanyUser(input: $input) {\n user {\n id\n status\n }\n }\n }\n";
|
|
18
|
+
//# sourceMappingURL=updateCompanyUserStatus.graphql.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
export * from './updateCompanyUserStatus';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UpdateCompanyUserStatusParams, UpdateCompanyUserStatusResponse } from '../../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Updates a company user's status (Active/Inactive)
|
|
5
|
+
* @param params - The parameters containing user ID and new status
|
|
6
|
+
* @param params.id - The ID of the user to update (base64 encoded UID from GraphQL)
|
|
7
|
+
* @param params.status - The new status for the user (ACTIVE or INACTIVE)
|
|
8
|
+
* @returns Promise<UpdateCompanyUserStatusResponse> - Object containing success status and updated user data
|
|
9
|
+
*/
|
|
10
|
+
export declare const updateCompanyUserStatus: (params: UpdateCompanyUserStatusParams) => Promise<UpdateCompanyUserStatusResponse>;
|
|
11
|
+
//# sourceMappingURL=updateCompanyUserStatus.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{
|
|
3
|
+
import{f as m,h as c}from"./chunks/network-error.js";import{g as I,r as P,s as G,a as L,b as M}from"./chunks/network-error.js";import{f as D}from"./chunks/fetchUserPermissions.js";import{a as w,i as F}from"./chunks/isCompanyUser.js";import{c as B,g as Q}from"./chunks/getCustomerCompany.js";import{D as q,S as K,c as W,g as z}from"./chunks/transform-store-config.js";import{c as J,d as V,a as X,g as Z,b as $,u as ee}from"./chunks/updateCompanyTeam.js";import{c as ae,d as te,g as oe,i as ne,u as se}from"./chunks/updateCompanyUser.js";import{g as ie,u as ce}from"./chunks/updateCompany.js";import{g as pe,u as de}from"./chunks/updateCompanyUserStatus.js";import{g as ue,v as fe}from"./chunks/validateCompanyEmail.js";import{a as Ee,g as ge}from"./chunks/getCompanyCreditHistory.js";import{G as l,t as p}from"./chunks/isCompanyRoleNameAvailable.js";import{c as Re,d as Te,a as Ae,g as _e,i as Ue,u as Se}from"./chunks/isCompanyRoleNameAvailable.js";import{f as d}from"./chunks/company-permissions.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";import"./chunks/fetch-error.js";const A=async e=>{try{const r=await m(l,{variables:e,method:"GET",cache:"no-cache"});return p(r)}catch(r){return c(r)}},_=e=>d(e),U=(e,r)=>{const n=new Set(r),a=t=>{var o;const s=((o=t.children)==null?void 0:o.map(a).filter(i=>i!==null))||[];return n.has(t.id)||s.length>0?{...t,children:s}:null};return e.map(a).filter(t=>t!==null)},S=async(e={})=>({success:!0,config:e}),C=`
|
|
4
|
+
query GET_CUSTOMER_COMPANIES_WITH_ROLES {
|
|
5
|
+
customer {
|
|
6
|
+
companies(input: {}) {
|
|
7
|
+
items {
|
|
8
|
+
id
|
|
9
|
+
name
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
role {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`,b=async()=>{var e,r,n;try{const a=await m(C,{method:"POST"});if((e=a.errors)!=null&&e.length)return!1;const t=(r=a.data)==null?void 0:r.customer;if(!t)return!1;const s=((n=t.companies)==null?void 0:n.items)??[];if(!Array.isArray(s)||s.length===0)return!1;const o=t.role;return o?o.id==="0"||typeof o.id=="number"&&o.id===0||o.name==="Company Administrator":!1}catch(a){return console.error("Error checking if customer is company admin:",a),!1}};var u=(e=>(e.ALLOCATION="ALLOCATION",e.UPDATE="UPDATE",e.PURCHASE="PURCHASE",e.REIMBURSEMENT="REIMBURSEMENT",e))(u||{});const f=`
|
|
19
|
+
query CHECK_COMPANY_CREDIT_ENABLED {
|
|
20
|
+
storeConfig{
|
|
21
|
+
company_credit_enabled
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`,N=async()=>{var e,r,n;try{const a=await m(f,{method:"GET",cache:"no-cache"});return(e=a.errors)!=null&&e.length?{creditEnabled:!1,error:"Unable to check company credit configuration"}:((n=(r=a.data)==null?void 0:r.storeConfig)==null?void 0:n.company_credit_enabled)===!0?{creditEnabled:!0}:{creditEnabled:!1,error:"Company credit is not enabled in store configuration"}}catch{return{creditEnabled:!1,error:"Company credit functionality not available"}}};export{u as CompanyCreditOperationType,q as DEFAULT_COUNTRY,K as STORE_CONFIG_DEFAULTS,w as allowCompanyRegistration,U as buildPermissionTree,N as checkCompanyCreditEnabled,B as companyEnabled,W as createCompany,Re as createCompanyRole,J as createCompanyTeam,ae as createCompanyUser,Te as deleteCompanyRole,V as deleteCompanyTeam,te as deleteCompanyUser,m as fetchGraphQl,D as fetchUserPermissions,_ as flattenPermissionIds,ie as getCompany,Ae as getCompanyAclResources,Ee as getCompanyCredit,ge as getCompanyCreditHistory,A as getCompanyRole,_e as getCompanyRoles,X as getCompanyStructure,Z as getCompanyTeam,oe as getCompanyUser,pe as getCompanyUsers,I as getConfig,ue as getCountries,Q as getCustomerCompany,z as getStoreConfig,S as initialize,b as isCompanyAdmin,Ue as isCompanyRoleNameAvailable,F as isCompanyUser,ne as isCompanyUserEmailAvailable,P as removeFetchGraphQlHeader,G as setEndpoint,L as setFetchGraphQlHeader,M as setFetchGraphQlHeaders,ce as updateCompany,Se as updateCompanyRole,$ as updateCompanyStructure,ee as updateCompanyTeam,se as updateCompanyUser,de as updateCompanyUserStatus,fe as validateCompanyEmail};
|
|
4
25
|
//# sourceMappingURL=api.js.map
|
package/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/checkIsCompanyEnabled/checkIsCompanyEnabled.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n\nexport interface CompanyDropinConfig {\n langDefinitions?: Record<string, Record<string, string>>;\n models?: Record<string, any>;\n}\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { validateCompanyEmail } from '../validateCompanyEmail';\nimport { CheckIsCompanyEnabledResponse } from '../../types/api/checkIsCompanyEnabled.types';\n\nexport const checkIsCompanyEnabled = async (): Promise<CheckIsCompanyEnabledResponse> => {\n try {\n // Use validateCompanyEmail with a dummy email to check if Company functionality is available\n await validateCompanyEmail('test@test.com');\n \n // If the validation API works (regardless of email availability), Company functionality is enabled\n return {\n companyEnabled: true\n };\n } catch (error) {\n return {\n companyEnabled: false,\n error: 'Company functionality not available'\n };\n }\n};"],"names":["initialize","config","checkIsCompanyEnabled","validateCompanyEmail"],"mappings":"qOAuBO,MAAMA,EAAa,MAAOC,EAA8B,MACtD,CACL,QAAS,GACT,OAAAA,CAAA,GCPSC,EAAwB,SAAoD,CACvF,GAAI,CAEF,aAAMC,EAAqB,eAAe,EAGnC,CACL,eAAgB,EAAA,CAEpB,MAAgB,CACd,MAAO,CACL,eAAgB,GAChB,MAAO,qCAAA,CAEX,CACF"}
|
|
1
|
+
{"version":3,"file":"api.js","sources":["/@dropins/storefront-company-management/src/api/companyRoles/getCompanyRole.ts","/@dropins/storefront-company-management/src/api/companyRoles/utils.ts","/@dropins/storefront-company-management/src/api/initialize/initialize.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/graphql/isCompanyAdmin.graphql.ts","/@dropins/storefront-company-management/src/api/isCompanyAdmin/isCompanyAdmin.ts","/@dropins/storefront-company-management/src/types/api/getCompanyCreditHistoryParams.types.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/graphql/checkCompanyCreditEnabled.graphql.ts","/@dropins/storefront-company-management/src/api/checkCompanyCreditEnabled/checkCompanyCreditEnabled.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { fetchGraphQl } from '../fetch-graphql';\nimport { handleNetworkError } from '../../lib/network-error';\nimport { GET_COMPANY_ROLE } from './graphql/queries';\nimport { GetCompanyRoleVariables, GetCompanyRoleResponse } from '../../types/api/companyRoles.types';\nimport { CompanyRoleModel } from '../../data/models/company-role';\nimport { transformGetCompanyRoleResponse } from '../../data/transforms/transform-company-roles';\n\n/**\n * Fetch a single company role by ID\n */\nexport const getCompanyRole = async (\n variables: GetCompanyRoleVariables\n): Promise<CompanyRoleModel> => {\n try {\n const response: GetCompanyRoleResponse = await fetchGraphQl(GET_COMPANY_ROLE, {\n variables,\n method: 'GET',\n cache: 'no-cache',\n });\n\n return transformGetCompanyRoleResponse(response);\n } catch (error) {\n return handleNetworkError(error as Error);\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { flattenIdsToArray } from '../../lib/company-permissions';\nimport { CompanyAclResourceModel } from '../../data/models/company-role';\n\n/**\n * Helper function to flatten ACL resources into a list of permission IDs\n */\nexport const flattenPermissionIds = (resources: CompanyAclResourceModel[]): string[] => {\n return flattenIdsToArray(resources);\n};\n\n/**\n * Helper function to build a permission tree from flat permission IDs\n */\nexport const buildPermissionTree = (\n allResources: CompanyAclResourceModel[],\n selectedIds: string[]\n): CompanyAclResourceModel[] => {\n const selectedSet = new Set(selectedIds);\n \n const filterTree = (resource: CompanyAclResourceModel): CompanyAclResourceModel | null => {\n const filteredChildren = resource.children\n ?.map(filterTree)\n .filter((child): child is CompanyAclResourceModel => child !== null) || [];\n \n if (selectedSet.has(resource.id) || filteredChildren.length > 0) {\n return {\n ...resource,\n children: filteredChildren,\n };\n }\n \n return null;\n };\n \n return allResources\n .map(filterTree)\n .filter((resource): resource is CompanyAclResourceModel => resource !== null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n// import { events } from '@adobe-commerce/event-bus';\n\n\nimport { CompanyDropinConfig } from '../../types/api/initialize.types';\n\nexport const initialize = async (config: CompanyDropinConfig = {}) => {\n return {\n success: true,\n config,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const GET_CUSTOMER_COMPANIES_WITH_ROLES = /* GraphQL */ `\n query GET_CUSTOMER_COMPANIES_WITH_ROLES {\n customer {\n companies(input: {}) {\n items {\n id\n name\n }\n }\n role {\n id\n name\n }\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n \nimport { fetchGraphQl } from '../fetch-graphql';\nimport { GET_CUSTOMER_COMPANIES_WITH_ROLES } from './graphql/isCompanyAdmin.graphql';\n\ninterface CompanyRole {\n id: string;\n name: string;\n}\n\ninterface CompanyBasicInfo {\n id: string;\n name: string;\n}\n\ninterface CustomerCompaniesWithRolesResponse {\n customer: {\n companies: {\n items: CompanyBasicInfo[];\n };\n role: CompanyRole | null;\n } | null;\n}\n\n/**\n * Check if the current authenticated customer is a company administrator in any company\n * @returns Promise<boolean> - true if customer is a company admin in at least one company, false otherwise\n */\nexport const isCompanyAdmin = async (): Promise<boolean> => {\n try {\n const response = await fetchGraphQl<CustomerCompaniesWithRolesResponse>(GET_CUSTOMER_COMPANIES_WITH_ROLES, {\n method: 'POST',\n });\n\n if (response.errors?.length) {\n return false;\n }\n\n const customer = response.data?.customer;\n if (!customer) {\n return false;\n }\n\n // Check if user is part of at least one company\n const companies = customer.companies?.items ?? [];\n if (!Array.isArray(companies) || companies.length === 0) {\n return false;\n }\n\n // Check if user has admin role\n const customerRole = customer.role;\n if (!customerRole) {\n return false;\n }\n\n // Check if user is company administrator by role ID or name\n return customerRole.id === '0' || \n (typeof customerRole.id === 'number' && customerRole.id === 0) ||\n customerRole.name === 'Company Administrator';\n } catch (error) {\n console.error('Error checking if customer is company admin:', error);\n return false;\n }\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport enum CompanyCreditOperationType {\n ALLOCATION = 'ALLOCATION',\n UPDATE = 'UPDATE',\n PURCHASE = 'PURCHASE',\n REIMBURSEMENT = 'REIMBURSEMENT'\n}\n\nexport interface CompanyCreditHistoryFilterInput {\n /**\n * The purchase order number associated with the company credit operation.\n */\n customReferenceNumber?: string;\n\n /**\n * The type of the company credit operation.\n */\n operationType?: CompanyCreditOperationType;\n\n /**\n * The name of the person submitting the company credit operation.\n */\n updatedBy?: string;\n}\n\nexport interface GetCompanyCreditHistoryParams {\n /**\n * Filter criteria for narrowing the results of a credit history search.\n */\n filter?: CompanyCreditHistoryFilterInput;\n\n /**\n * Number of items to return per page.\n * @default 20\n */\n pageSize?: number;\n\n /**\n * Current page number.\n * @default 1\n */\n currentPage?: number;\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const CHECK_COMPANY_CREDIT_ENABLED = /* GraphQL */ `\n query CHECK_COMPANY_CREDIT_ENABLED {\n storeConfig{\n company_credit_enabled\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECK_COMPANY_CREDIT_ENABLED } from \"./graphql/checkCompanyCreditEnabled.graphql\";\nimport { CheckCompanyCreditEnabledResponse } from '../../types/api/checkCompanyCreditEnabled.types';\nimport { fetchGraphQl } from '../fetch-graphql';\n\nexport const checkCompanyCreditEnabled = async (): Promise<CheckCompanyCreditEnabledResponse> => {\n try {\n const response = await fetchGraphQl(CHECK_COMPANY_CREDIT_ENABLED, {\n method: 'GET',\n cache: 'no-cache',\n });\n\n // If there are errors, return false with error message\n if (response.errors?.length) {\n return {\n creditEnabled: false,\n error: 'Unable to check company credit configuration'\n };\n }\n\n // Check if company credit is enabled in store config\n const companyCreditEnabled = response.data?.storeConfig?.company_credit_enabled;\n \n if (companyCreditEnabled === true) {\n return {\n creditEnabled: true\n };\n }\n\n // If company credit is disabled or not configured\n return {\n creditEnabled: false,\n error: 'Company credit is not enabled in store configuration'\n };\n\n } catch (error) {\n return {\n creditEnabled: false,\n error: 'Company credit functionality not available'\n };\n }\n};\n"],"names":["getCompanyRole","variables","response","fetchGraphQl","GET_COMPANY_ROLE","transformGetCompanyRoleResponse","error","handleNetworkError","flattenPermissionIds","resources","flattenIdsToArray","buildPermissionTree","allResources","selectedIds","selectedSet","filterTree","resource","filteredChildren","_a","child","initialize","config","GET_CUSTOMER_COMPANIES_WITH_ROLES","isCompanyAdmin","customer","_b","companies","_c","customerRole","CompanyCreditOperation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AW,EACpD,MAAO,GAIT,MAAME,EAAeJ,EAAS,KAC9B,OAAKI,EAKEA,EAAa,KAAO,KACnB,OAAOA,EAAa,IAAO,UAAYA,EAAa,KAAO,GAC5DA,EAAa,OAAS,wBANpB,EAOX,OAAStB,EAAO,CACd,eAAQ,MAAM,+CAAgDA,CAAK,EAC5D,EACT,CACF,EC7DO,IAAKuB,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,cAAgB,gBAJNA,IAAAA,GAAA,CAAA,CAAA,ECAL,MAAMC,EAA6C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECI7CC,EAA4B,SAAwD,WAC/F,GAAI,CACF,MAAM7B,EAAW,MAAMC,EAAa2B,EAA8B,CAChE,OAAQ,MACR,MAAO,UAAA,CACR,EAGD,OAAIZ,EAAAhB,EAAS,SAAT,MAAAgB,EAAiB,OACZ,CACL,cAAe,GACf,MAAO,8CAAA,IAKkBS,GAAAF,EAAAvB,EAAS,OAAT,YAAAuB,EAAe,cAAf,YAAAE,EAA4B,0BAE5B,GACpB,CACL,cAAe,EAAA,EAKZ,CACL,cAAe,GACf,MAAO,sDAAA,CAGX,MAAgB,CACd,MAAO,CACL,cAAe,GACf,MAAO,4CAAA,CAEX,CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsxs as t,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{Card as s,Skeleton as r,SkeletonRow as a}from"@dropins/tools/components.js";import{classes as o}from"@dropins/tools/lib.js";const u=({testId:i,withCard:n=!0})=>{const l=t(r,{"data-testid":i||"companySkeletonLoader",children:[e(a,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(a,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(a,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return n?l:e(s,{variant:"secondary",className:o(["company-company-loaders","company-company-loaders--card-loader"]),children:l})},h=({testId:i})=>t("div",{className:"company-credit-skeleton-loader","data-testid":i||"companyCreditSkeletonLoader",children:[e(r,{children:e(a,{variant:"row",size:"small",lines:2})}),e(r,{children:e(a,{variant:"row",size:"small",lines:2})}),e(r,{children:e(a,{variant:"row",size:"small",lines:2})})]}),p=({testId:i})=>e("div",{className:"company-credit-history-skeleton-loader","data-testid":i||"companyCreditHistorySkeletonLoader",children:e(r,{children:e(a,{variant:"row",size:"small",fullWidth:!0,lines:3})})}),y=({rows:i=6})=>t(r,{"data-testid":"companyStructureLoader",children:[e(a,{variant:"heading",size:"medium"}),e(a,{variant:"empty",size:"small"}),Array.from({length:i}).map((n,l)=>e(a,{size:"large",fullWidth:!0},l))]}),z=()=>t(r,{"data-testid":"companyUserFormLoader",children:[e(a,{variant:"heading",size:"medium"}),e(a,{variant:"empty",size:"small"}),e(a,{size:"large"}),e(a,{size:"large"}),e(a,{size:"large"}),e(a,{size:"large"}),e(a,{size:"large",fullWidth:!0}),e(a,{size:"large"}),e(a,{size:"large"})]}),g=()=>t(r,{"data-testid":"companyTeamFormLoader",children:[e(a,{variant:"heading",size:"medium"}),e(a,{variant:"empty",size:"small"}),e(a,{size:"large"}),e(a,{size:"large",fullWidth:!0}),e(a,{size:"large"})]});export{g as C,y as a,z as b,u as c,h as d,p as e};
|
|
4
|
+
//# sourceMappingURL=CompanyLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompanyLoaders.js","sources":["/@dropins/storefront-company-management/src/components/CompanyLoaders/CompanyLoaders.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { Skeleton, SkeletonRow, Card } from '@adobe-commerce/elsie/components';\nimport './CompanyLoaders.css';\nimport { classes } from '@adobe-commerce/elsie/lib';\n\nexport const CompanyCardLoader = ({\n testId,\n withCard = true,\n}: {\n testId?: string;\n withCard?: boolean;\n}) => {\n const defaultSkeleton = (\n <Skeleton data-testid={testId || 'companySkeletonLoader'}>\n <SkeletonRow\n variant=\"heading\"\n size=\"xlarge\"\n fullWidth={false}\n lines={1}\n />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n <SkeletonRow variant=\"heading\" size=\"xlarge\" fullWidth={true} lines={1} />\n </Skeleton>\n );\n\n if (withCard) {\n return defaultSkeleton;\n }\n\n return (\n <Card\n variant=\"secondary\"\n className={classes([\n 'company-company-loaders',\n 'company-company-loaders--card-loader',\n ])}\n >\n {defaultSkeleton}\n </Card>\n );\n};\n\nexport const CompanyUsersTableLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-users-skeleton-loader\" data-testid={testId || 'companyUsersSkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" fullWidth={true} lines={3} />\n </Skeleton>\n </div>\n );\n};\n\nexport const CompanyCreditLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-credit-skeleton-loader\" data-testid={testId || 'companyCreditSkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" lines={2} />\n </Skeleton>\n </div>\n );\n};\n\nexport const CompanyCreditHistoryLoader = ({ testId }: { testId?: string }) => {\n return (\n <div className=\"company-credit-history-skeleton-loader\" data-testid={testId || 'companyCreditHistorySkeletonLoader'}>\n <Skeleton>\n <SkeletonRow variant=\"row\" size=\"small\" fullWidth={true} lines={3} />\n </Skeleton>\n </div>\n );\n};\n\nexport const CompanyStructureLoader = ({ rows = 6 }: { rows?: number }) => {\n return (\n <Skeleton data-testid=\"companyStructureLoader\">\n <SkeletonRow variant=\"heading\" size=\"medium\" />\n <SkeletonRow variant=\"empty\" size=\"small\" />\n {Array.from({ length: rows }).map((_, i) => (\n <SkeletonRow key={i} size=\"large\" fullWidth={true} />\n ))}\n </Skeleton>\n );\n};\n\nexport const CompanyUserFormLoader = () => {\n return (\n <Skeleton data-testid=\"companyUserFormLoader\">\n <SkeletonRow variant=\"heading\" size=\"medium\" />\n <SkeletonRow variant=\"empty\" size=\"small\" />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" fullWidth={true} />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" />\n </Skeleton>\n );\n};\n\nexport const CompanyTeamFormLoader = () => {\n return (\n <Skeleton data-testid=\"companyTeamFormLoader\">\n <SkeletonRow variant=\"heading\" size=\"medium\" />\n <SkeletonRow variant=\"empty\" size=\"small\" />\n <SkeletonRow size=\"large\" />\n <SkeletonRow size=\"large\" fullWidth={true} />\n <SkeletonRow size=\"large\" />\n </Skeleton>\n );\n};\n"],"names":["CompanyCardLoader","testId","withCard","defaultSkeleton","jsxs","Skeleton","jsx","SkeletonRow","Card","classes","CompanyCreditLoader","CompanyCreditHistoryLoader","CompanyStructureLoader","rows","_","i","CompanyUserFormLoader","CompanyTeamFormLoader"],"mappings":"wMAoBO,MAAMA,EAAoB,CAAC,CAChC,OAAAC,EACA,SAAAC,EAAW,EACb,IAGM,CACJ,MAAMC,EACJC,EAACC,EAAA,CAAS,cAAaJ,GAAU,wBAC/B,SAAA,CAAAK,EAACC,EAAA,CACC,QAAQ,UACR,KAAK,SACL,UAAW,GACX,MAAO,CAAA,CAAA,EAETD,EAACC,GAAY,QAAQ,UAA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A,CAAS,cAAY,wBACpB,SAAA,CAAAC,EAACC,EAAA,CAAY,QAAQ,UAAU,KAAK,SAAS,EAC7CD,EAACC,EAAA,CAAY,QAAQ,QAAQ,KAAK,QAAQ,EAC1CD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,QAAQ,UAAW,GAAM,EAC3CD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,CAAA,EAC5B,EAISU,EAAwB,IAEjCb,EAACC,EAAA,CAAS,cAAY,wBACpB,SAAA,CAAAC,EAACC,EAAA,CAAY,QAAQ,UAAU,KAAK,SAAS,EAC7CD,EAACC,EAAA,CAAY,QAAQ,QAAQ,KAAK,QAAQ,EAC1CD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,EAC1BD,EAACC,EAAA,CAAY,KAAK,QAAQ,UAAW,GAAM,EAC3CD,EAACC,EAAA,CAAY,KAAK,OAAA,CAAQ,CAAA,EAC5B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsxs as F,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{memo as X}from"@dropins/tools/preact-compat.js";import{useState as p,useEffect as J}from"@dropins/tools/preact-hooks.js";import{Card as K,InLineAlert as Q,ProgressSpinner as W,Field as T,Input as A,Picker as P,Button as D}from"@dropins/tools/components.js";import{i as Y}from"./company-permissions.js";import{g as Z,c as ee,u as te,i as ae}from"./updateCompanyUser.js";import{useText as H}from"@dropins/tools/i18n.js";import{u as re}from"./useCompanyRoles.js";import{b as se}from"./CompanyLoaders.js";const y={firstName:255,lastName:255,email:254,jobTitle:255,telephone:20};function oe(M){const{mode:x,entityId:g,parentStructureId:j,onSaved:q,onError:b,onSuccess:v}=M,l=H({firstNameRequired:"Company.CompanyStructure.shared.validation.firstNameRequired",lastNameRequired:"Company.CompanyStructure.shared.validation.lastNameRequired",emailRequired:"Company.CompanyStructure.shared.validation.emailRequired",emailInvalid:"Company.CompanyStructure.shared.validation.emailInvalid",jobTitleRequired:"Company.CompanyStructure.shared.validation.jobTitleRequired",workPhoneRequired:"Company.CompanyStructure.shared.validation.workPhoneRequired",selectRole:"Company.CompanyStructure.shared.validation.selectRole",firstNameMaxLength:"Company.CompanyStructure.shared.validation.firstNameMaxLength",lastNameMaxLength:"Company.CompanyStructure.shared.validation.lastNameMaxLength",emailMaxLength:"Company.CompanyStructure.shared.validation.emailMaxLength",jobTitleMaxLength:"Company.CompanyStructure.shared.validation.jobTitleMaxLength",telephoneMaxLength:"Company.CompanyStructure.shared.validation.telephoneMaxLength",createUserError:"Company.CompanyStructure.messages.createUserError",saveUserError:"Company.CompanyStructure.messages.saveUserError",createUserSuccess:"Company.CompanyStructure.messages.createUserSuccess",updateUserSuccess:"Company.CompanyStructure.messages.updateUserSuccess"}),[r,L]=p({firstName:"",lastName:"",email:"",jobTitle:"",telephone:"",roleId:"",status:"ACTIVE"}),[w,u]=p({}),[m,h]=p({}),[V,U]=p(!1),[f,R]=p(null),[_,E]=p(null),[S,k]=p(""),[i,a]=p(""),[o,B]=p(!1);J(()=>{x!=="edit"||!g||(U(!0),Z(g).then(e=>{var C;if(!e)return;const t=e.email||"";L(N=>({...N,firstName:e.firstName||"",lastName:e.lastName||"",email:t,jobTitle:e.jobTitle||"",telephone:e.telephone||"",status:e.status||"ACTIVE"})),a(t),(C=e==null?void 0:e.role)!=null&&C.id&&L(N=>({...N,roleId:e.role.id})),B((e==null?void 0:e.isCompanyAdmin)??!1)}).finally(()=>U(!1)))},[x,g]);const z=e=>/.+@.+\..+/.test(e),$=(e,t)=>e==="firstName"?t!=null&&t.trim()?t.length>y.firstName?l.firstNameMaxLength:null:l.firstNameRequired:e==="lastName"?t!=null&&t.trim()?t.length>y.lastName?l.lastNameMaxLength:null:l.lastNameRequired:e==="email"?t!=null&&t.trim()?t.length>y.email?l.emailMaxLength:z(t.trim())?null:l.emailInvalid:l.emailRequired:e==="jobTitle"?t&&t.length>y.jobTitle?l.jobTitleMaxLength:null:e==="telephone"?t&&t.length>y.telephone?l.telephoneMaxLength:null:e==="roleId"?t?null:l.selectRole:null,G=(e,t)=>{L(C=>({...C,[e]:t})),e==="email"&&E(null),f&&R(null)};return{values:r,errors:w,touched:m,loading:V,setValue:G,onBlur:async(e,t)=>{t!==void 0&&G(e,t),h(I=>({...I,[e]:!0}));const C=t!==void 0?t:r[e],N=$(e,C);if(u(N?I=>({...I,[e]:N}):I=>{const d={...I};return delete d[e],d}),e==="email"){const d=(t!==void 0?t:r.email||"").trim();if(x==="edit"&&d.toLowerCase()===(i||"").trim().toLowerCase()){E(null);return}if(z(d)&&d!==S){const n=await ae(d);k(d),E(n),n===!1&&u(c=>({...c,email:"A user with this email address is already a member of your company."}))}}},submit:async()=>{const e=["firstName","lastName","email","roleId","jobTitle","telephone"],t={},C={};for(const n of e){C[n]=!0;const c=$(n,r[n]);c&&(t[n]=c)}if(u(t),h(C),Object.keys(t).length||_===!1){setTimeout(()=>{const n=document.querySelector(".company-user-form__content .dropin-field__hint--error");if(n){const c=n.closest(".dropin-field");if(c){c.scrollIntoView({behavior:"smooth",block:"center"});const O=c.querySelector("input, select");O&&O.focus()}}},100);return}const N=`${r.firstName||""} ${r.lastName||""}`.trim()||r.email||"",d=o||Y({id:r.roleId})?"ACTIVE":r.status;try{if(x==="add"){const n=await ee({email:r.email||"",firstName:r.firstName||"",lastName:r.lastName||"",jobTitle:r.jobTitle||"",telephone:r.telephone||"",roleId:r.roleId,status:d,targetId:j??null});if(!n){const c=l.createUserError;b?b(c):R(c);return}q({label:N,structureId:n.structureId,entityId:n.id,type:"user"}),v&&v(l.createUserSuccess)}else g&&(await te({id:g,email:r.email||"",firstName:r.firstName||"",lastName:r.lastName||"",jobTitle:r.jobTitle||"",telephone:r.telephone||"",status:d,roleId:r.roleId}),q({label:N,entityId:g,type:"user"}),v&&v(l.updateUserSuccess))}catch(n){const c=n instanceof Error?n.message:l.saveUserError;b?b(c):R(c)}},isCompanyAdmin:o,generalError:f}}const Ce=X(({mode:M,entityId:x,parentStructureId:g,permissions:j,onSaved:q,onCancel:b,onError:v,onSuccess:l})=>{const r=(j==null?void 0:j.canEditUsers)??!1,{roles:L,isLoading:w}=re(),{values:u,errors:m,touched:h,loading:V,setValue:U,onBlur:f,submit:R,isCompanyAdmin:_,generalError:E}=oe({mode:M,entityId:x,parentStructureId:g,onSaved:q,onError:v?a=>{v(a),b()}:void 0,onSuccess:l}),[S,k]=p(!1),i=H({addUser:"Company.CompanyStructure.shared.titles.addUser",editUser:"Company.CompanyStructure.shared.titles.editUser",jobTitle:"Company.CompanyStructure.shared.fields.jobTitle",userRole:"Company.CompanyStructure.shared.fields.userRole",firstName:"Company.CompanyStructure.shared.fields.firstName",lastName:"Company.CompanyStructure.shared.fields.lastName",email:"Company.CompanyStructure.shared.fields.email",workPhoneNumber:"Company.CompanyStructure.shared.fields.workPhoneNumber",status:"Company.CompanyStructure.shared.fields.status",selectRole:"Company.CompanyStructure.shared.options.selectRole",active:"Company.CompanyStructure.shared.options.active",inactive:"Company.CompanyStructure.shared.options.inactive",companyAdministrator:"Company.CompanyStructure.shared.options.companyAdministrator",save:"Company.CompanyStructure.shared.buttons.save",cancel:"Company.CompanyStructure.shared.buttons.cancel"});return F("div",{children:[s("h3",{className:"acm-structure-panel__title",children:M==="add"?i.addUser:i.editUser}),F(K,{variant:"secondary",className:`company-user-form__card ${S?"is-working":""}`,children:[!v&&E?s(Q,{className:"company-user-form__notification",type:"error",variant:"secondary",heading:E}):null,S?s("div",{className:"company-user-form__overlay","aria-live":"polite",children:s(W,{size:"small"})}):null,V||w?s(se,{}):F("div",{className:"company-user-form__content",children:[s(T,{label:i.jobTitle,className:"acm-structure-panel__field",error:h.jobTitle&&m.jobTitle?m.jobTitle:void 0,children:s(A,{name:"job_title",type:"text",value:u.jobTitle||"",onBlur:a=>{const o=a.target;f("jobTitle",o.value)},variant:"primary",size:"medium",maxLength:y.jobTitle})}),s(T,{label:i.userRole,required:!0,className:"acm-structure-panel__field",error:!_&&h.roleId&&m.roleId?m.roleId:void 0,disabled:_,children:_?s(P,{name:"role",value:"MA==",options:[{value:"MA==",text:i.companyAdministrator}]}):s(P,{name:"role",value:u.roleId||"placeholder",onChange:a=>{var o,B;return U("roleId",String(((o=a==null?void 0:a.target)==null?void 0:o.value)==="placeholder"?"":((B=a==null?void 0:a.target)==null?void 0:B.value)??""))},onBlur:a=>{const o=a.target;f("roleId",o.value==="placeholder"?"":o.value)},options:[{value:"placeholder",text:i.selectRole,disabled:!0},...L.map(a=>({value:a.id,text:a.name}))]})}),s(T,{label:i.firstName,required:!0,className:"acm-structure-panel__field",error:h.firstName&&m.firstName?m.firstName:void 0,children:s(A,{name:"first_name",type:"text",value:u.firstName,onBlur:a=>{const o=a.target;f("firstName",o.value)},variant:"primary",size:"medium",maxLength:y.firstName})}),s(T,{label:i.lastName,required:!0,className:"acm-structure-panel__field",error:h.lastName&&m.lastName?m.lastName:void 0,children:s(A,{name:"last_name",type:"text",value:u.lastName,onBlur:a=>{const o=a.target;f("lastName",o.value)},variant:"primary",size:"medium",maxLength:y.lastName})}),s(T,{label:i.email,required:!0,className:"acm-structure-panel__field",error:h.email&&m.email?m.email:void 0,children:s(A,{name:"email",type:"email",value:u.email,onBlur:a=>{const o=a.target;f("email",o.value)},placeholder:"jdoe@example.com",variant:"primary",size:"medium",maxLength:y.email})}),s(T,{label:i.workPhoneNumber,className:"acm-structure-panel__field",error:h.telephone&&m.telephone?m.telephone:void 0,children:s(A,{name:"telephone",type:"text",value:u.telephone||"",onBlur:a=>{const o=a.target;f("telephone",o.value)},variant:"primary",size:"medium",maxLength:y.telephone})}),s(T,{label:i.status,className:"acm-structure-panel__field",disabled:_||!r,children:s(P,{name:"status",value:u.status,onChange:a=>{var o;return U("status",String(((o=a==null?void 0:a.target)==null?void 0:o.value)??"ACTIVE"))},options:[{value:"ACTIVE",text:i.active},{value:"INACTIVE",text:i.inactive}]})})]})]}),V||w?null:F("div",{className:"acm-structure-modal__actions",children:[s(D,{type:"button",variant:"primary",disabled:S||!r,onClick:async()=>{if(!S){k(!0);try{await R()}finally{k(!1)}}},children:i.save}),s(D,{type:"button",variant:"secondary",disabled:S,onClick:b,children:i.cancel})]})]})});export{Ce as C};
|
|
4
|
+
//# sourceMappingURL=CompanyUserForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompanyUserForm.js","sources":["/@dropins/storefront-company-management/src/hooks/useCompanyUserForm.ts","/@dropins/storefront-company-management/src/components/CompanyUserForm/CompanyUserForm.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { useEffect, useState } from 'preact/hooks';\nimport { createCompanyUser, getCompanyUser, isCompanyUserEmailAvailable, updateCompanyUser } from '@/company-management/api';\nimport { isCompanyAdministrator } from '@/company-management/lib';\nimport { CompanyUserModel } from '@/company-management/data/models';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nexport type UserStatus = 'ACTIVE' | 'INACTIVE';\n\n// Field length constants (based on Magento backend validation)\nexport const FIELD_MAX_LENGTHS = {\n firstName: 255,\n lastName: 255,\n email: 254,\n jobTitle: 255,\n telephone: 20,\n} as const;\n\nexport function useCompanyUserForm(opts: {\n mode: 'add' | 'edit';\n entityId?: string;\n parentStructureId?: string | null;\n onSaved: (result: { label: string; structureId?: string; entityId?: string; type: 'user' }) => void;\n onError?: (error: string) => void;\n onSuccess?: (message: string) => void;\n}) {\n const { mode, entityId, parentStructureId, onSaved, onError, onSuccess } = opts;\n \n const translations = useText({\n firstNameRequired: 'Company.CompanyStructure.shared.validation.firstNameRequired',\n lastNameRequired: 'Company.CompanyStructure.shared.validation.lastNameRequired',\n emailRequired: 'Company.CompanyStructure.shared.validation.emailRequired',\n emailInvalid: 'Company.CompanyStructure.shared.validation.emailInvalid',\n jobTitleRequired: 'Company.CompanyStructure.shared.validation.jobTitleRequired',\n workPhoneRequired: 'Company.CompanyStructure.shared.validation.workPhoneRequired',\n selectRole: 'Company.CompanyStructure.shared.validation.selectRole',\n firstNameMaxLength: 'Company.CompanyStructure.shared.validation.firstNameMaxLength',\n lastNameMaxLength: 'Company.CompanyStructure.shared.validation.lastNameMaxLength',\n emailMaxLength: 'Company.CompanyStructure.shared.validation.emailMaxLength',\n jobTitleMaxLength: 'Company.CompanyStructure.shared.validation.jobTitleMaxLength',\n telephoneMaxLength: 'Company.CompanyStructure.shared.validation.telephoneMaxLength',\n createUserError: 'Company.CompanyStructure.messages.createUserError',\n saveUserError: 'Company.CompanyStructure.messages.saveUserError',\n createUserSuccess: 'Company.CompanyStructure.messages.createUserSuccess',\n updateUserSuccess: 'Company.CompanyStructure.messages.updateUserSuccess',\n });\n const [values, setValues] = useState<Partial<CompanyUserModel> & { roleId: string; status: UserStatus }>({ \n firstName: '', \n lastName: '', \n email: '', \n jobTitle: '', \n telephone: '', \n roleId: '', \n status: 'ACTIVE' \n });\n const [errors, setErrors] = useState<Record<string, string>>({});\n const [touched, setTouched] = useState<Record<string, boolean>>({});\n const [loading, setLoading] = useState(false);\n const [generalError, setGeneralError] = useState<string | null>(null);\n const [emailAvailable, setEmailAvailable] = useState<boolean | null>(null);\n const [emailChecked, setEmailChecked] = useState<string>('');\n const [originalEmail, setOriginalEmail] = useState<string>('');\n const [isCompanyAdmin, setIsCompanyAdmin] = useState<boolean>(false);\n\n useEffect(() => {\n if (mode !== 'edit' || !entityId) return;\n setLoading(true);\n void getCompanyUser(entityId).then((u) => {\n if (!u) return;\n const loadedEmail = u.email || '';\n setValues((v) => ({ ...v, firstName: u.firstName || '', lastName: u.lastName || '', email: loadedEmail, jobTitle: u.jobTitle || '', telephone: u.telephone || '', status: (u.status || 'ACTIVE') as UserStatus }));\n setOriginalEmail(loadedEmail);\n if (u?.role?.id) setValues((v) => ({ ...v, roleId: u.role!.id }));\n setIsCompanyAdmin(u?.isCompanyAdmin ?? false);\n }).finally(() => setLoading(false));\n }, [mode, entityId]);\n\n const isEmailValid = (value: string): boolean => /.+@.+\\..+/.test(value);\n const validateField = (field: keyof CompanyUserModel | 'roleId', value: any): string | null => {\n if (field === 'firstName') {\n if (!value?.trim()) return translations.firstNameRequired;\n if (value.length > FIELD_MAX_LENGTHS.firstName) return translations.firstNameMaxLength;\n return null;\n }\n if (field === 'lastName') {\n if (!value?.trim()) return translations.lastNameRequired;\n if (value.length > FIELD_MAX_LENGTHS.lastName) return translations.lastNameMaxLength;\n return null;\n }\n if (field === 'email') {\n if (!value?.trim()) return translations.emailRequired;\n if (value.length > FIELD_MAX_LENGTHS.email) return translations.emailMaxLength;\n return isEmailValid(value.trim()) ? null : translations.emailInvalid;\n }\n // jobTitle and telephone are now optional fields (USF-3012)\n if (field === 'jobTitle') {\n if (value && value.length > FIELD_MAX_LENGTHS.jobTitle) return translations.jobTitleMaxLength;\n return null;\n }\n if (field === 'telephone') {\n if (value && value.length > FIELD_MAX_LENGTHS.telephone) return translations.telephoneMaxLength;\n return null;\n }\n if (field === 'roleId') return value ? null : translations.selectRole;\n return null;\n };\n\n const setValue = (field: keyof CompanyUserModel | 'roleId', value: any) => {\n setValues((v) => ({ ...v, [field]: value }));\n if (field === 'email') setEmailAvailable(null);\n if (generalError) setGeneralError(null);\n };\n\n const onBlur = async (field: keyof CompanyUserModel | 'roleId', value?: any) => {\n // Update form data if value is provided (this preserves spaces and other characters)\n if (value !== undefined) {\n setValue(field, value);\n }\n \n setTouched((t) => ({ ...t, [field]: true }));\n \n // Use provided value or current state value for validation\n const valueToValidate = value !== undefined ? value : values[field];\n const err = validateField(field, valueToValidate);\n if (err) {\n setErrors((p) => ({ ...p, [field]: err }));\n } else {\n // Clear error if field is now valid\n setErrors((p) => {\n const newErrors = { ...p };\n delete newErrors[field];\n return newErrors;\n });\n }\n \n if (field === 'email') {\n const emailValue = value !== undefined ? value : (values.email || '');\n const trimmed = emailValue.trim();\n if (mode === 'edit' && trimmed.toLowerCase() === (originalEmail || '').trim().toLowerCase()) {\n setEmailAvailable(null);\n return;\n }\n if (isEmailValid(trimmed) && trimmed !== emailChecked) {\n const available = await isCompanyUserEmailAvailable(trimmed);\n setEmailChecked(trimmed);\n setEmailAvailable(available);\n if (available === false) setErrors((p) => ({ ...p, email: 'A user with this email address is already a member of your company.' }));\n }\n }\n };\n\n const submit = async () => {\n // Validate all fields including optional ones for length (USF-3474)\n const fields: (keyof CompanyUserModel | 'roleId')[] = ['firstName', 'lastName', 'email', 'roleId', 'jobTitle', 'telephone'];\n const next: Record<string, string> = {};\n const touchedFields: Record<string, boolean> = {};\n \n for (const f of fields) {\n touchedFields[f as string] = true;\n const err = validateField(f, values[f]);\n if (err) next[f as string] = err;\n }\n \n setErrors(next);\n setTouched(touchedFields);\n \n if (Object.keys(next).length || emailAvailable === false) {\n // Scroll to the first error field\n setTimeout(() => {\n const firstErrorField = document.querySelector('.company-user-form__content .dropin-field__hint--error');\n if (firstErrorField) {\n const fieldContainer = firstErrorField.closest('.dropin-field');\n if (fieldContainer) {\n fieldContainer.scrollIntoView({ behavior: 'smooth', block: 'center' });\n const input = fieldContainer.querySelector('input, select') as HTMLElement;\n if (input) {\n input.focus();\n }\n }\n }\n }, 100);\n return;\n }\n\n const label = `${values.firstName || ''} ${values.lastName || ''}`.trim() || values.email || '';\n const adminEffective = isCompanyAdmin || isCompanyAdministrator({ id: values.roleId });\n const effectiveStatus = adminEffective ? 'ACTIVE' : values.status;\n try {\n if (mode === 'add') {\n const res = await createCompanyUser({ email: values.email || '', firstName: values.firstName || '', lastName: values.lastName || '', jobTitle: values.jobTitle || '', telephone: values.telephone || '', roleId: values.roleId, status: effectiveStatus, targetId: parentStructureId ?? null });\n if (!res) {\n const errorMessage = translations.createUserError;\n if (onError) {\n onError(errorMessage);\n } else {\n setGeneralError(errorMessage);\n }\n return;\n }\n onSaved({ label, structureId: res.structureId, entityId: res.id, type: 'user' });\n if (onSuccess) {\n onSuccess(translations.createUserSuccess);\n }\n } else if (entityId) {\n await updateCompanyUser({ id: entityId, email: values.email || '', firstName: values.firstName || '', lastName: values.lastName || '', jobTitle: values.jobTitle || '', telephone: values.telephone || '', status: effectiveStatus, roleId: values.roleId });\n onSaved({ label, entityId, type: 'user' });\n if (onSuccess) {\n onSuccess(translations.updateUserSuccess);\n }\n }\n } catch (error: unknown) {\n const errorMessage = error instanceof Error ? error.message : translations.saveUserError;\n if (onError) {\n onError(errorMessage);\n } else {\n setGeneralError(errorMessage);\n }\n }\n };\n\n return { values, errors, touched, loading, setValue, onBlur, submit, isCompanyAdmin, generalError };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\nimport { FunctionComponent } from 'preact';\nimport { memo } from 'preact/compat';\nimport { useState } from 'preact/hooks';\nimport { Field, Input, Button, Card, Picker, ProgressSpinner, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { CompanyUserFormLoader } from '@/company-management/components/CompanyLoaders';\nimport { useCompanyUserForm, FIELD_MAX_LENGTHS } from '@/company-management/hooks/useCompanyUserForm';\nimport { useCompanyRoles } from '@/company-management/hooks/useCompanyRoles';\nimport { CompanyUserFormProps } from '@/company-management/types/companyForm.types';\nimport './CompanyUserForm.css';\n\n/**\n * CompanyUserForm component for creating and editing company users\n * Provides form fields for user information including name, email, role, and status\n */\nexport const CompanyUserForm: FunctionComponent<CompanyUserFormProps> = memo(({ mode, entityId, parentStructureId, permissions, onSaved, onCancel, onError, onSuccess }) => {\n const canEditUsers = permissions?.canEditUsers ?? false;\n const { roles, isLoading: rolesLoading } = useCompanyRoles();\n const { values, errors, touched, loading, setValue, onBlur, submit, isCompanyAdmin, generalError } = useCompanyUserForm({ \n mode, \n entityId, \n parentStructureId, \n onSaved,\n onError: onError ? (error: string) => {\n onError(error);\n onCancel();\n } : undefined,\n onSuccess\n });\n const [saving, setSaving] = useState(false);\n \n const translations = useText({\n addUser: 'Company.CompanyStructure.shared.titles.addUser',\n editUser: 'Company.CompanyStructure.shared.titles.editUser',\n jobTitle: 'Company.CompanyStructure.shared.fields.jobTitle',\n userRole: 'Company.CompanyStructure.shared.fields.userRole',\n firstName: 'Company.CompanyStructure.shared.fields.firstName',\n lastName: 'Company.CompanyStructure.shared.fields.lastName',\n email: 'Company.CompanyStructure.shared.fields.email',\n workPhoneNumber: 'Company.CompanyStructure.shared.fields.workPhoneNumber',\n status: 'Company.CompanyStructure.shared.fields.status',\n selectRole: 'Company.CompanyStructure.shared.options.selectRole',\n active: 'Company.CompanyStructure.shared.options.active',\n inactive: 'Company.CompanyStructure.shared.options.inactive',\n companyAdministrator: 'Company.CompanyStructure.shared.options.companyAdministrator',\n save: 'Company.CompanyStructure.shared.buttons.save',\n cancel: 'Company.CompanyStructure.shared.buttons.cancel',\n });\n\n return (\n <div>\n <h3 className=\"acm-structure-panel__title\">{mode === 'add' ? translations.addUser : translations.editUser}</h3>\n <Card variant=\"secondary\" className={`company-user-form__card ${saving ? 'is-working' : ''}`}>\n {!onError && generalError ? (\n <InLineAlert \n className=\"company-user-form__notification\" \n type=\"error\" \n variant=\"secondary\" \n heading={generalError} \n />\n ) : null}\n {saving ? <div className=\"company-user-form__overlay\" aria-live=\"polite\"><ProgressSpinner size=\"small\" /></div> : null}\n {loading || rolesLoading ? (\n <CompanyUserFormLoader />\n ) : (\n <div className=\"company-user-form__content\">\n\n <Field label={translations.jobTitle} className=\"acm-structure-panel__field\" error={touched.jobTitle && errors.jobTitle ? errors.jobTitle : undefined}>\n <Input name=\"job_title\" type=\"text\" value={values.jobTitle || ''} onBlur={(e: Event) => { const target = e.target as HTMLInputElement; onBlur('jobTitle', target.value); }} variant=\"primary\" size=\"medium\" maxLength={FIELD_MAX_LENGTHS.jobTitle} />\n </Field>\n\n <Field label={translations.userRole} required className=\"acm-structure-panel__field\" error={!isCompanyAdmin && touched.roleId && errors.roleId ? errors.roleId : undefined} disabled={isCompanyAdmin}>\n {isCompanyAdmin ? (\n <Picker name=\"role\" value={'MA=='} options={[{ value: 'MA==', text: translations.companyAdministrator }]} />\n ) : (\n <Picker\n name=\"role\"\n value={values.roleId || 'placeholder'}\n onChange={(e: any) => setValue('roleId', String(e?.target?.value === 'placeholder' ? '' : e?.target?.value ?? ''))}\n onBlur={(e: Event) => { const target = e.target as HTMLSelectElement; void onBlur('roleId', target.value === 'placeholder' ? '' : target.value); }}\n options={[{ value: 'placeholder', text: translations.selectRole, disabled: true }, ...roles.map((r) => ({ value: r.id, text: r.name }))]}\n />\n )}\n </Field>\n\n <Field label={translations.firstName} required className=\"acm-structure-panel__field\" error={touched.firstName && errors.firstName ? errors.firstName : undefined}>\n <Input name=\"first_name\" type=\"text\" value={values.firstName} onBlur={(e: Event) => { const target = e.target as HTMLInputElement; onBlur('firstName', target.value); }} variant=\"primary\" size=\"medium\" maxLength={FIELD_MAX_LENGTHS.firstName} />\n </Field>\n\n <Field label={translations.lastName} required className=\"acm-structure-panel__field\" error={touched.lastName && errors.lastName ? errors.lastName : undefined}>\n <Input name=\"last_name\" type=\"text\" value={values.lastName} onBlur={(e: Event) => { const target = e.target as HTMLInputElement; onBlur('lastName', target.value); }} variant=\"primary\" size=\"medium\" maxLength={FIELD_MAX_LENGTHS.lastName} />\n </Field>\n\n <Field label={translations.email} required className=\"acm-structure-panel__field\" error={touched.email && errors.email ? errors.email : undefined}>\n <Input name=\"email\" type=\"email\" value={values.email} onBlur={(e: Event) => { const target = e.target as HTMLInputElement; void onBlur('email', target.value); }} placeholder=\"jdoe@example.com\" variant=\"primary\" size=\"medium\" maxLength={FIELD_MAX_LENGTHS.email} />\n </Field>\n\n <Field label={translations.workPhoneNumber} className=\"acm-structure-panel__field\" error={touched.telephone && errors.telephone ? errors.telephone : undefined}>\n <Input name=\"telephone\" type=\"text\" value={values.telephone || ''} onBlur={(e: Event) => { const target = e.target as HTMLInputElement; onBlur('telephone', target.value); }} variant=\"primary\" size=\"medium\" maxLength={FIELD_MAX_LENGTHS.telephone} />\n </Field>\n\n <Field label={translations.status} className=\"acm-structure-panel__field\" disabled={isCompanyAdmin || !canEditUsers}>\n <Picker\n name=\"status\"\n value={values.status}\n onChange={(e: any) => setValue('status', String(e?.target?.value ?? 'ACTIVE'))}\n options={[{ value: 'ACTIVE', text: translations.active }, { value: 'INACTIVE', text: translations.inactive }]}\n />\n </Field>\n </div>\n )}\n </Card>\n {!(loading || rolesLoading) ? (\n <div className=\"acm-structure-modal__actions\">\n <Button type=\"button\" variant=\"primary\" disabled={saving || !canEditUsers} onClick={async () => { if (saving) return; setSaving(true); try { await submit(); } finally { setSaving(false); } }}>\n {translations.save}\n </Button>\n <Button\n type=\"button\"\n variant=\"secondary\"\n disabled={saving}\n onClick={onCancel}\n >\n {translations.cancel}\n </Button>\n </div>\n ) : null}\n </div>\n );\n});\n\nexport default CompanyUserForm;\n"],"names":["FIELD_MAX_LENGTHS","useCompanyUserForm","opts","mode","entityId","parentStructureId","onSaved","onError","onSuccess","translations","useText","values","setValues","useState","errors","setErrors","touched","setTouched","loading","setLoading","generalError","setGeneralError","emailAvailable","setEmailAvailable","emailChecked","setEmailChecked","originalEmail","setOriginalEmail","isCompanyAdmin","setIsCompanyAdmin","useEffect","getCompanyUser","u","loadedEmail","v","_a","isEmailValid","value","validateField","field","setValue","t","valueToValidate","err","p","newErrors","trimmed","available","isCompanyUserEmailAvailable","fields","next","touchedFields","f","firstErrorField","fieldContainer","input","label","effectiveStatus","isCompanyAdministrator","res","createCompanyUser","errorMessage","updateCompanyUser","error","CompanyUserForm","memo","permissions","onCancel","canEditUsers","roles","rolesLoading","useCompanyRoles","onBlur","submit","saving","setSaving","jsx","jsxs","Card","InLineAlert","ProgressSpinner","CompanyUserFormLoader","Field","Input","e","target","Picker","_b","r","Button"],"mappings":"ikBAyBO,MAAMA,EAAoB,CAC/B,UAAW,IACX,SAAU,IACV,MAAO,IACP,SAAU,IACV,UAAW,EACb,EAEO,SAASC,GAAmBC,EAOhC,CACD,KAAM,CAAE,KAAAC,EAAM,SAAAC,EAAU,kBAAAC,EAAmB,QAAAC,EAAS,QAAAC,EAAS,UAAAC,GAAcN,EAErEO,EAAeC,EAAQ,CAC3B,kBAAmB,+DACnB,iBAAkB,8DAClB,cAAe,2DACf,aAAc,0DACd,iBAAkB,8DAClB,kBAAmB,+DACnB,WAAY,wDACZ,mBAAoB,gEACpB,kBAAmB,+DACnB,eAAgB,4DAChB,kBAAmB,+DACnB,mBAAoB,gEACpB,gBAAiB,oDACjB,cAAe,kDACf,kBAAmB,sDACnB,kBAAmB,qDAAA,CACpB,EACK,CAACC,EAAQC,CAAS,EAAIC,EAA6E,CACvG,UAAW,GACX,SAAU,GACV,MAAO,GACP,SAAU,GACV,UAAW,GACX,OAAQ,GACR,OAAQ,QAAA,CACT,EACK,CAACC,EAAQC,CAAS,EAAIF,EAAiC,CAAA,CAAE,EACzD,CAACG,EAASC,CAAU,EAAIJ,EAAkC,CAAA,CAAE,EAC5D,CAACK,EAASC,CAAU,EAAIN,EAAS,EAAK,EACtC,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AC,CAAE,MAAO,SAAU,KAAM1B,EAAa,MAAA,EAAU,CAAE,MAAO,WAAY,KAAMA,EAAa,SAAU,CAAA,CAAA,CAC9G,CACF,CAAA,CAAA,CACF,CAAA,EAEJ,EACGS,GAAWoD,EAcV,KAbFO,EAAC,MAAA,CAAI,UAAU,+BACb,SAAA,CAAAD,EAACa,EAAA,CAAO,KAAK,SAAS,QAAQ,UAAU,SAAUf,GAAU,CAACN,EAAc,QAAS,SAAY,CAAE,GAAI,CAAAM,EAAgB,CAAAC,EAAU,EAAI,EAAG,GAAI,CAAE,MAAMF,EAAA,CAAU,QAAA,CAAYE,EAAU,EAAK,CAAG,EAAE,EAC1L,WAAa,KAChB,EACAC,EAACa,EAAA,CACC,KAAK,SACL,QAAQ,YACR,SAAUf,EACV,QAASP,EAER,SAAA1D,EAAa,MAAA,CAAA,CAChB,CAAA,CACF,CACE,EACN,CAEJ,CAAC"}
|
package/chunks/Tree.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! Copyright 2025 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as $,jsxs as st}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as et,useRef as nt,useCallback as X}from"@dropins/tools/preact-hooks.js";import{Checkbox as ot}from"@dropins/tools/components.js";var at=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},J={exports:{}};/*! mobile-drag-drop 3.0.0-rc.0 | Copyright (c) 2022 Tim Ruffles | MIT License */(function(x,w){(function(E,I){I(w)})(at,function(E){var I="dnd-poly-",y=["none","copy","copyLink","copyMove","link","linkMove","move","all"],d=["none","copy","move","link"];function H(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("test",null,e)}catch{}return t}var L=H();function P(t){return t&&t.tagName}function N(t,e,i){document.addEventListener(t,e,!!L&&{passive:i})}function z(t,e){document.removeEventListener(t,e)}function j(t,e,i,r){r===void 0&&(r=!1);var s=L?{passive:!0,capture:r}:r;return t.addEventListener(e,i,s),{off:function(){t.removeEventListener(e,i,s)}}}function Y(t){return t.length===0?0:t.reduce(function(e,i){return i+e},0)/t.length}function q(t,e){for(var i=0;i<t.changedTouches.length;i++)if(t.changedTouches[i].identifier===e)return!0;return!1}function B(t,e,i){for(var r=[],s=[],l=0;l<e.touches.length;l++){var n=e.touches[l];r.push(n[t+"X"]),s.push(n[t+"Y"])}i.x=Y(r),i.y=Y(s)}var F=["","-webkit-"];function A(t,n,i,r,s){var l=n.x,n=n.y;r&&(l+=r.x,n+=r.y),(s=s===void 0||s)&&(l-=parseInt(t.offsetWidth,10)/2,n-=parseInt(t.offsetHeight,10)/2);for(var o="translate3d("+l+"px,"+n+"px, 0)",a=0;a<F.length;a++){var u=F[a]+"transform";t.style[u]=o+" "+i[a]}}var C=(Object.defineProperty(O.prototype,"dropEffect",{get:function(){return this.t},set:function(t){this.i.mode!==0&&-1<y.indexOf(t)&&(this.t=t)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"types",{get:function(){if(this.i.mode!==0)return Object.freeze(this.i.types)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"effectAllowed",{get:function(){return this.i.effectAllowed},set:function(t){this.i.mode===2&&-1<y.indexOf(t)&&(this.i.effectAllowed=t)},enumerable:!1,configurable:!0}),O.prototype.setData=function(t,e){if(this.i.mode===2){if(-1<t.indexOf(" "))throw new Error("illegal arg: type contains space");this.i.data[t]=e,this.i.types.indexOf(t)===-1&&this.i.types.push(t)}},O.prototype.getData=function(t){if(this.i.mode===1||this.i.mode===2)return this.i.data[t]||""},O.prototype.clearData=function(t){this.i.mode===2&&(t&&this.i.data[t]?(delete this.i.data[t],-1<(t=this.i.types.indexOf(t))&&this.i.types.splice(t,1)):(this.i.data={},this.i.types=[]))},O.prototype.setDragImage=function(t,e,i){this.i.mode===2&&this.h(t,e,i)},O);function O(t,e){this.i=t,this.h=e,this.t=d[0]}function G(t,e){return t?t===y[0]?d[0]:t.indexOf(y[1])===0||t===y[7]?d[1]:t.indexOf(y[4])===0?d[3]:t===y[6]?d[2]:d[1]:e.nodeType===3&&e.tagName==="A"?d[3]:d[1]}function S(t,e,i,r,s,l,n){return n===void 0&&(n=null),s=function(o,a,u,m,c,h,v){n===void 0&&(v=null);var b=i.changedTouches[0],m=new Event(t,{bubbles:!0,cancelable:m});return m.dataTransfer=h,m.relatedTarget=v,m.screenX=b.screenX,m.screenY=b.screenY,m.clientX=b.clientX,m.clientY=b.clientY,m.pageX=b.pageX,m.pageY=b.pageY,o=o.getBoundingClientRect(),m.offsetX=m.clientX-o.left,m.offsetY=m.clientY-o.top,m}(e,0,0,l=l===void 0||l,document.defaultView,s,n),s=!e.dispatchEvent(s),r.mode=0,s}function K(t,e){if(!t||t===y[7])return e;if(e===d[1]){if(t.indexOf(d[1])===0)return d[1]}else if(e===d[3]){if(t.indexOf(d[3])===0||-1<t.indexOf("Link"))return d[3]}else if(e===d[2]&&(t.indexOf(d[2])===0||-1<t.indexOf("Move")))return d[2];return d[0]}var _=(T.prototype.o=function(){var t=this;this.u=1,this.l=d[0],this.v={data:{},effectAllowed:void 0,mode:3,types:[]},this.p={x:null,y:null},this.g={x:null,y:null};var e=this.m;if(this.I=new C(this.v,function(l,n,o){e=l,typeof n!="number"&&typeof o!="number"||(t.j={x:n||0,y:o||0})}),this.v.mode=2,this.I.dropEffect=d[0],S("dragstart",this.m,this.k,this.v,this.I))return this.u=3,this.C(),!1;B("page",this.k,this.g);var i,r,s=this.S.dragImageSetup(e);return this.A=(i=s,F.map(function(l){return l=i.style[l+"transform"],l&&l!=="none"?l.replace(/translate\(\D*\d+[^,]*,\D*\d+[^,]*\)\s*/g,""):""})),s.style.position="absolute",s.style.left="0px",s.style.top="0px",s.style.zIndex="999999",s.classList.add("dnd-poly-drag-image"),s.classList.add("dnd-poly-icon"),this.O=s,this.j||(this.S.dragImageOffset?this.j={x:this.S.dragImageOffset.x,y:this.S.dragImageOffset.y}:this.S.dragImageCenterOnTouch?(r=getComputedStyle(e),this.j={x:0-parseInt(r.marginLeft,10),y:0-parseInt(r.marginTop,10)}):(s=e.getBoundingClientRect(),r=getComputedStyle(e),this.j={x:s.left-this.M.clientX-parseInt(r.marginLeft,10)+s.width/2,y:s.top-this.M.clientY-parseInt(r.marginTop,10)+s.height/2})),A(this.O,this.g,this.A,this.j,this.S.dragImageCenterOnTouch),document.body.appendChild(this.O),this.D=window.setInterval(function(){t.F||(t.F=!0,t.N(),t.F=!1)},this.S.iterationInterval),!0},T.prototype.C=function(){this.D&&(clearInterval(this.D),this.D=null),z("touchmove",this.P),z("touchend",this.T),z("touchcancel",this.T),this.O&&(this.O.parentNode.removeChild(this.O),this.O=null),this.L(this.S,this.k,this.u)},T.prototype._=function(t){var e=this;if(q(t,this.M.identifier)!==!1){if(this.k=t,this.u===0){var i=void 0;if(this.S.dragStartConditionOverride)try{i=this.S.dragStartConditionOverride(t)}catch{i=!1}else i=t.touches.length===1;return i?void(this.o()===!0&&(this.H.preventDefault(),t.preventDefault())):void this.C()}if(t.preventDefault(),B("client",t,this.p),B("page",t,this.g),this.S.dragImageTranslateOverride)try{var r=!1;if(this.S.dragImageTranslateOverride(t,{x:this.p.x,y:this.p.y},this.V,function(s,l){e.O&&(r=!0,e.p.x+=s,e.p.y+=l,e.g.x+=s,e.g.y+=l,A(e.O,e.g,e.A,e.j,e.S.dragImageCenterOnTouch))}),r)return}catch{}A(this.O,this.g,this.A,this.j,this.S.dragImageCenterOnTouch)}},T.prototype.X=function(t){if(q(t,this.M.identifier)!==!1){if(this.S.dragImageTranslateOverride)try{this.S.dragImageTranslateOverride(void 0,void 0,void 0,function(){})}catch{}this.u!==0?(t.preventDefault(),this.u=t.type==="touchcancel"?3:2):this.C()}},T.prototype.N=function(){var t=this,e=this.l;this.v.mode=3,this.I.dropEffect=d[0];var i,r,s,l,n,o=S("drag",this.m,this.k,this.v,this.I);if(o&&(this.l=d[0]),o||this.u===2||this.u===3)return this.Y(this.u)?(l=this.m,i=this.O,r=this.A,u=function(){t.q()},void((n=getComputedStyle(l)).visibility!=="hidden"&&n.display!=="none"?(i.classList.add("dnd-poly-snapback"),s=getComputedStyle(i),o=parseFloat(s.transitionDuration),isNaN(o)||o===0?u():((l={x:(a=l.getBoundingClientRect()).left,y:a.top}).x+=document.body.scrollLeft||document.documentElement.scrollLeft,l.y+=document.body.scrollTop||document.documentElement.scrollTop,l.x-=parseInt(n.marginLeft,10),l.y-=parseInt(n.marginTop,10),a=parseFloat(s.transitionDelay),a=Math.round(1e3*(o+a)),A(i,l,r,void 0,!1),setTimeout(u,a))):u())):void this.q();var a=this.S.elementFromPoint(this.p.x,this.p.y),u=this.B;a!==this.V&&a!==this.B&&(this.V=a,this.B!==null&&(this.v.mode=3,this.I.dropEffect=d[0],S("dragexit",this.B,this.k,this.v,this.I,!1)),this.V===null?this.B=this.V:(this.v.mode=3,this.I.dropEffect=G(this.v.effectAllowed,this.m),S("dragenter",this.V,this.k,this.v,this.I)?(this.B=this.V,this.l=K(this.I.effectAllowed,this.I.dropEffect)):this.V!==document.body&&(this.B=document.body))),u!==this.B&&P(u)&&(this.v.mode=3,this.I.dropEffect=d[0],S("dragleave",u,this.k,this.v,this.I,!1,this.B)),P(this.B)&&(this.v.mode=3,this.I.dropEffect=G(this.v.effectAllowed,this.m),S("dragover",this.B,this.k,this.v,this.I)===!1?this.l=d[0]:this.l=K(this.I.effectAllowed,this.I.dropEffect)),e!==this.l&&this.O.classList.remove(I+e),e=I+this.l,this.O.classList.add(e)},T.prototype.Y=function(t){return t=this.l===d[0]||this.B===null||t===3,t?P(this.B)&&(this.v.mode=3,this.I.dropEffect=d[0],S("dragleave",this.B,this.k,this.v,this.I,!1)):P(this.B)&&(this.v.mode=1,this.I.dropEffect=this.l,S("drop",this.B,this.k,this.v,this.I)===!0?this.l=this.I.dropEffect:this.l=d[0]),t},T.prototype.q=function(){this.v.mode=3,this.I.dropEffect=this.l,S("dragend",this.m,this.k,this.v,this.I,!1),this.u=2,this.C()},T);function T(t,e,i,r){this.H=t,this.S=e,this.m=i,this.L=r,this.u=0,this.V=null,this.B=null,this.k=t,this.M=t.changedTouches[0],this.P=this._.bind(this),this.T=this.X.bind(this),N("touchmove",this.P,!1),N("touchend",this.T,!1),N("touchcancel",this.T,!1)}var R,g={iterationInterval:150,tryFindDraggableTarget:function(t){for(var e=0,i=t.composedPath();e<i.length;e++){var r=i[e];do if(r.draggable!==!1&&(r.draggable===!0||r.getAttribute&&r.getAttribute("draggable")==="true"))return r;while((r=r.parentNode)&&r!==document.body)}},dragImageSetup:function(t){var e=t.cloneNode(!0);return function i(r,s){if(r.nodeType===1){for(var l,n,o=getComputedStyle(r),a=0;a<o.length;a++){var u=o[a];s.style.setProperty(u,o.getPropertyValue(u),o.getPropertyPriority(u))}s.style.pointerEvents="none",s.removeAttribute("id"),s.removeAttribute("class"),s.removeAttribute("draggable"),s.nodeName==="CANVAS"&&(l=s,n=(n=r).getContext("2d").getImageData(0,0,n.width,n.height),l.getContext("2d").putImageData(n,0,0))}if(r.hasChildNodes())for(a=0;a<r.childNodes.length;a++)i(r.childNodes[a],s.childNodes[a]);(function f(c){if(c instanceof HTMLElement&&(c.style.pointerEvents="none"),c.children&&c.children.length)for(var h=0;h<c.children.length;h++)f(c.children[h]);if(c.shadowRoot&&c.shadowRoot.children.length)for(h=0;h<c.shadowRoot.children.length;h++)f(c.shadowRoot.children[h])})(s)}(t,e),e},elementFromPoint:function(t,e){var i=document.elementFromPoint(t,e);if(i){for(;i.shadowRoot;){var r=i.shadowRoot.elementFromPoint(t,e);if(r===null||r===i)break;i=r}return i}}};function W(t){if(!R){var e=g.tryFindDraggableTarget(t);if(e)try{R=new _(t,g,e,k)}catch(i){throw k(g,t,3),i}}}function M(t){function e(a){s.off(),l.off(),n.off(),o.off(),i&&i.dispatchEvent(new CustomEvent("dnd-poly-dragstart-cancel",{bubbles:!0,cancelable:!0})),clearTimeout(r)}var i=t.target;i&&i.dispatchEvent(new CustomEvent("dnd-poly-dragstart-pending",{bubbles:!0,cancelable:!0}));var r=window.setTimeout(function(){s.off(),l.off(),n.off(),o.off(),W(t)},g.holdToDrag),s=j(i,"touchend",e),l=j(i,"touchcancel",e),n=j(i,"touchmove",e),o=j(window,"scroll",e,!0)}function k(t,e,i){if(i===0&&t.defaultActionOverride)try{t.defaultActionOverride(e),e.defaultPrevented}catch{}R=null}E.polyfill=function(t){if(t&&Object.keys(t).forEach(function(i){g[i]=t[i]}),!g.forceApply&&(e=(e=!!window.chrome||/chrome/i.test(navigator.userAgent),{dragEvents:"ondragstart"in document.documentElement,draggable:"draggable"in document.documentElement,userAgentSupportingNativeDnD:!(/iPad|iPhone|iPod|Android/.test(navigator.userAgent)||e&&"ontouchstart"in document.documentElement)}),e.userAgentSupportingNativeDnD&&e.draggable&&e.dragEvents))return!1;var e;return g.holdToDrag?N("touchstart",M,!1):N("touchstart",W,!1),!0},E.supportsPassiveEventListener=H,Object.defineProperty(E,"G",{value:!0})})})(J,J.exports);var lt=J.exports;let it=!1;if(typeof window<"u"&&!it){try{window.addEventListener("touchmove",()=>{},{passive:!1})}catch{}lt.polyfill({holdToDrag:300,tryFindDraggableTarget:x=>{let w=x.target;for(;w&&w!==document.body;){if(w.getAttribute("draggable")==="true")return w;w=w.parentElement}}}),document.addEventListener("contextmenu",x=>{x.target.closest('[draggable="true"]')&&x.preventDefault()}),it=!0}const dt=(x,w=!1)=>{const E=new Map;for(const I of x){const y=I.parentId??null,d=E.get(y)??[];d.push(I),E.set(y,d)}if(!w)for(const[,I]of E)I.sort((y,d)=>y.label.localeCompare(d.label));return E},ut=({items:x,rootId:w=null,className:E,expandedIds:I,selectedId:y=null,selectedIds:d,onExpandedChange:H,onSelectedChange:L,onSelectedIdsChange:P,renderNode:N,role:z="tree",preserveOrder:j=!1,draggable:Y,canDrop:q,onMove:B,isCheckable:F,checkedIds:A,onCheckedChange:C,biDirectionalChecking:O=!1,renderExpander:G,renderCheckbox:S,renderIcon:K})=>{const _=et(()=>dt(x,j),[x,j]),T=nt(null),R=nt(!1),g=et(()=>new Map(x.map(n=>[n.id,n])),[x]),W=(n,o)=>{const a=[],u=[o];for(;u.length;){const f=u.pop(),c=n.get(f)??[];for(const h of c)a.push(h.id),u.push(h.id)}return a},M=X(n=>W(_,n),[_]),k=X(n=>F?F(n):!0,[F]),t=X(n=>{if(!g.get(n))return{checked:!1,indeterminate:!1};const a=A??new Set;if(O){if(a.has(n))return{checked:!0,indeterminate:!1};const c=M(n).filter(v=>{const b=g.get(v);return b?k(b):!1});return c.length===0?{checked:!1,indeterminate:!1}:c.reduce((v,b)=>a.has(b)?v+1:v,0)===0?{checked:!1,indeterminate:!1}:{checked:!1,indeterminate:!0}}const u=[n,...M(n)].filter(c=>{const h=g.get(c);return h?k(h):!1});if(u.length===0)return{checked:!1,indeterminate:!1};const f=u.reduce((c,h)=>a.has(h)?c+1:c,0);return f===0?{checked:!1,indeterminate:!1}:f===u.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},[g,M,k,A,O]),e=X(n=>{if(!C)return;const o=new Set(A??[]),{checked:a}=t(n),u=M(n),f=[n,...u].filter(c=>{const h=g.get(c);return h?k(h):!1});if(a)for(const c of f)o.delete(c);else for(const c of f)o.add(c);if(O&&!a){const c=g.get(n);if(c){let h=c.parentId;for(;h;){const v=g.get(h);if(!v||!k(v))break;o.add(h),h=v.parentId}}}C(o)},[A,C,t,M,g,k,O]),i=X(n=>$(ot,{name:`tree-checkbox-${Math.random().toString(36).substr(2,9)}`,checked:n.checked,indeterminate:n.indeterminate,onChange:n.onCheck}),[]),r=X(n=>{const o=new Set(I);o.has(n)?o.delete(n):o.add(n),H(o)},[I,H]),s=X(n=>{const o=g.get(n);if(o&&k(o)&&C&&e(n),!P){L==null||L(n);return}const a=!!R.current,u=a?new Set(d??[]):new Set;a&&u.has(n)?u.delete(n):u.add(n),P(u),R.current=!1},[L,P,d,g,k,C,e]),l=(n,o)=>{const a=_.get(n)??[];return a.length?$("ul",{role:o===1?z:"group",className:o===1?E??"acm-tree":"acm-tree__group",children:a.map((f,c)=>{const h=(_.get(f.id)??[]).length>0,v=I.has(f.id),b=d?d.has(f.id):y===f.id,m=!!(Y!=null&&Y(f)),Q=p=>q?q(p,f.id):p!==f.id,U=h?()=>G?G({expanded:v,hasChildren:h,toggle:()=>r(f.id)}):null:void 0,Z=(()=>{if(!C)return;const p=g.get(f.id);if(!p||!k(p))return;const D=t(f.id),V=S||i;return()=>V({checked:D.checked,indeterminate:D.indeterminate,onCheck:()=>e(f.id)})})(),tt=K?()=>K({item:f,level:o,hasChildren:h,expanded:v}):void 0,rt=N({item:f,level:o,expanded:v,selected:!!b,hasChildren:h,toggle:()=>r(f.id),select:()=>s(f.id),...U?{expander:U}:{},...Z?{checkbox:Z}:{},...tt?{icon:tt}:{}});return st("li",{role:"treeitem",className:"acm-tree__item","data-level":o,"aria-expanded":h?v:void 0,"aria-selected":b||void 0,"aria-level":o,"aria-setsize":a.length,"aria-posinset":c+1,draggable:m,onMouseDown:p=>{R.current=!!(p.metaKey||p.ctrlKey)},onDragStart:p=>{var D;if(p.stopPropagation(),!!m){T.current=f.id;try{(D=p.dataTransfer)==null||D.setData("text/plain",f.id)}catch{}}},onDragEnter:p=>{p.preventDefault()},onDragOver:p=>{var V;p.stopPropagation();const D=T.current??(((V=p.dataTransfer)==null?void 0:V.getData("text/plain"))||"");D&&Q(D)&&p.preventDefault()},onDrop:p=>{var V;p.stopPropagation();const D=T.current??(((V=p.dataTransfer)==null?void 0:V.getData("text/plain"))||"");T.current=null,D&&Q(D)&&(B==null||B({id:D,newParentId:f.id}))},children:[rt,h&&v?l(f.id,o+1):null]},f.id)})}):null};return $("div",{className:"acm-tree-root",children:l(w,1)})};export{ut as T};
|
|
4
|
+
//# sourceMappingURL=Tree.js.map
|