@thunderid/react 0.3.3 → 0.3.4
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/dist/ThunderIDReactClient.d.ts +1 -5
- package/dist/ThunderIDReactClient.d.ts.map +1 -1
- package/dist/ThunderIDReactClient.js +1 -68
- package/dist/ThunderIDReactClient.js.map +1 -1
- package/dist/cjs/ThunderIDReactClient.cjs +0 -67
- package/dist/cjs/ThunderIDReactClient.cjs.map +1 -1
- package/dist/cjs/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.cjs +1 -1
- package/dist/cjs/components/presentation/UserAvatar/BaseUserAvatar.cjs +57 -0
- package/dist/cjs/components/presentation/UserAvatar/BaseUserAvatar.cjs.map +1 -0
- package/dist/cjs/components/presentation/UserAvatar/UserAvatar.cjs +36 -0
- package/dist/cjs/components/presentation/UserAvatar/UserAvatar.cjs.map +1 -0
- package/dist/cjs/components/presentation/UserDropdown/BaseUserDropdown.cjs +6 -5
- package/dist/cjs/components/presentation/UserDropdown/BaseUserDropdown.cjs.map +1 -1
- package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs +3 -15
- package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs.map +1 -1
- package/dist/cjs/contexts/Theme/ThemeContext.cjs.map +1 -1
- package/dist/cjs/contexts/Theme/ThemeProvider.cjs +2 -5
- package/dist/cjs/contexts/Theme/ThemeProvider.cjs.map +1 -1
- package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs +0 -2
- package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
- package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs +14 -90
- package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
- package/dist/cjs/index.cjs +6 -51
- package/dist/components/presentation/LanguageSwitcher/BaseLanguageSwitcher.js +1 -1
- package/dist/components/presentation/UserAvatar/BaseUserAvatar.d.ts +50 -0
- package/dist/components/presentation/UserAvatar/BaseUserAvatar.d.ts.map +1 -0
- package/dist/components/presentation/UserAvatar/BaseUserAvatar.js +55 -0
- package/dist/components/presentation/UserAvatar/BaseUserAvatar.js.map +1 -0
- package/dist/components/presentation/UserAvatar/UserAvatar.d.ts +46 -0
- package/dist/components/presentation/UserAvatar/UserAvatar.d.ts.map +1 -0
- package/dist/components/presentation/UserAvatar/UserAvatar.js +34 -0
- package/dist/components/presentation/UserAvatar/UserAvatar.js.map +1 -0
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.d.ts.map +1 -1
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.js +6 -5
- package/dist/components/presentation/UserDropdown/BaseUserDropdown.js.map +1 -1
- package/dist/components/presentation/auth/AuthOptionFactory.d.ts +2 -2
- package/dist/components/presentation/auth/AuthOptionFactory.d.ts.map +1 -1
- package/dist/components/presentation/auth/AuthOptionFactory.js +3 -15
- package/dist/components/presentation/auth/AuthOptionFactory.js.map +1 -1
- package/dist/contexts/Theme/ThemeContext.d.ts +0 -12
- package/dist/contexts/Theme/ThemeContext.d.ts.map +1 -1
- package/dist/contexts/Theme/ThemeContext.js.map +1 -1
- package/dist/contexts/Theme/ThemeProvider.d.ts +0 -4
- package/dist/contexts/Theme/ThemeProvider.d.ts.map +1 -1
- package/dist/contexts/Theme/ThemeProvider.js +2 -5
- package/dist/contexts/Theme/ThemeProvider.js.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts +2 -3
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDContext.js +0 -2
- package/dist/contexts/ThunderID/ThunderIDContext.js.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDProvider.js +15 -91
- package/dist/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
- package/dist/index.d.ts +4 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -27
- package/package.json +2 -2
- package/dist/api/createOrganization.d.ts +0 -86
- package/dist/api/createOrganization.d.ts.map +0 -1
- package/dist/api/createOrganization.js +0 -80
- package/dist/api/createOrganization.js.map +0 -1
- package/dist/api/getAllOrganizations.d.ts +0 -78
- package/dist/api/getAllOrganizations.d.ts.map +0 -1
- package/dist/api/getAllOrganizations.js +0 -71
- package/dist/api/getAllOrganizations.js.map +0 -1
- package/dist/api/getMeOrganizations.d.ts +0 -82
- package/dist/api/getMeOrganizations.d.ts.map +0 -1
- package/dist/api/getMeOrganizations.js +0 -75
- package/dist/api/getMeOrganizations.js.map +0 -1
- package/dist/api/getOrganization.d.ts +0 -74
- package/dist/api/getOrganization.d.ts.map +0 -1
- package/dist/api/getOrganization.js +0 -67
- package/dist/api/getOrganization.js.map +0 -1
- package/dist/api/getSchemas.d.ts +0 -72
- package/dist/api/getSchemas.d.ts.map +0 -1
- package/dist/api/getSchemas.js +0 -65
- package/dist/api/getSchemas.js.map +0 -1
- package/dist/api/updateOrganization.d.ts +0 -81
- package/dist/api/updateOrganization.d.ts.map +0 -1
- package/dist/api/updateOrganization.js +0 -74
- package/dist/api/updateOrganization.js.map +0 -1
- package/dist/cjs/api/createOrganization.cjs +0 -82
- package/dist/cjs/api/createOrganization.cjs.map +0 -1
- package/dist/cjs/api/getAllOrganizations.cjs +0 -73
- package/dist/cjs/api/getAllOrganizations.cjs.map +0 -1
- package/dist/cjs/api/getMeOrganizations.cjs +0 -77
- package/dist/cjs/api/getMeOrganizations.cjs.map +0 -1
- package/dist/cjs/api/getOrganization.cjs +0 -69
- package/dist/cjs/api/getOrganization.cjs.map +0 -1
- package/dist/cjs/api/getSchemas.cjs +0 -67
- package/dist/cjs/api/getSchemas.cjs.map +0 -1
- package/dist/cjs/api/updateOrganization.cjs +0 -76
- package/dist/cjs/api/updateOrganization.cjs.map +0 -1
- package/dist/cjs/components/control/OrganizationContext/OrganizationContext.cjs +0 -34
- package/dist/cjs/components/control/OrganizationContext/OrganizationContext.cjs.map +0 -1
- package/dist/cjs/components/control/OrganizationContext/OrganizationContextController.cjs +0 -58
- package/dist/cjs/components/control/OrganizationContext/OrganizationContextController.cjs.map +0 -1
- package/dist/cjs/components/presentation/CreateOrganization/BaseCreateOrganization.cjs +0 -183
- package/dist/cjs/components/presentation/CreateOrganization/BaseCreateOrganization.cjs.map +0 -1
- package/dist/cjs/components/presentation/CreateOrganization/BaseCreateOrganization.styles.cjs +0 -150
- package/dist/cjs/components/presentation/CreateOrganization/BaseCreateOrganization.styles.cjs.map +0 -1
- package/dist/cjs/components/presentation/CreateOrganization/CreateOrganization.cjs +0 -90
- package/dist/cjs/components/presentation/CreateOrganization/CreateOrganization.cjs.map +0 -1
- package/dist/cjs/components/presentation/Organization/BaseOrganization.cjs +0 -41
- package/dist/cjs/components/presentation/Organization/BaseOrganization.cjs.map +0 -1
- package/dist/cjs/components/presentation/Organization/Organization.cjs +0 -49
- package/dist/cjs/components/presentation/Organization/Organization.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationList/BaseOrganizationList.cjs +0 -257
- package/dist/cjs/components/presentation/OrganizationList/BaseOrganizationList.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationList/BaseOrganizationList.styles.cjs +0 -236
- package/dist/cjs/components/presentation/OrganizationList/BaseOrganizationList.styles.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationList/OrganizationList.cjs +0 -86
- package/dist/cjs/components/presentation/OrganizationList/OrganizationList.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationList/OrganizationList.styles.cjs +0 -75
- package/dist/cjs/components/presentation/OrganizationList/OrganizationList.styles.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationProfile/BaseOrganizationProfile.cjs +0 -328
- package/dist/cjs/components/presentation/OrganizationProfile/BaseOrganizationProfile.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.cjs +0 -166
- package/dist/cjs/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationProfile/OrganizationProfile.cjs +0 -126
- package/dist/cjs/components/presentation/OrganizationProfile/OrganizationProfile.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.cjs +0 -288
- package/dist/cjs/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.cjs +0 -237
- package/dist/cjs/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.cjs.map +0 -1
- package/dist/cjs/components/presentation/OrganizationSwitcher/OrganizationSwitcher.cjs +0 -127
- package/dist/cjs/components/presentation/OrganizationSwitcher/OrganizationSwitcher.cjs.map +0 -1
- package/dist/cjs/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.cjs +0 -183
- package/dist/cjs/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.cjs.map +0 -1
- package/dist/cjs/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.cjs +0 -128
- package/dist/cjs/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.cjs.map +0 -1
- package/dist/cjs/components/primitives/Icons/Building.cjs +0 -75
- package/dist/cjs/components/primitives/Icons/Building.cjs.map +0 -1
- package/dist/cjs/contexts/Branding/BrandingContext.cjs +0 -12
- package/dist/cjs/contexts/Branding/BrandingContext.cjs.map +0 -1
- package/dist/cjs/contexts/Branding/BrandingProvider.cjs +0 -96
- package/dist/cjs/contexts/Branding/BrandingProvider.cjs.map +0 -1
- package/dist/cjs/contexts/Branding/useBrandingContext.cjs +0 -40
- package/dist/cjs/contexts/Branding/useBrandingContext.cjs.map +0 -1
- package/dist/cjs/contexts/Organization/OrganizationContext.cjs +0 -27
- package/dist/cjs/contexts/Organization/OrganizationContext.cjs.map +0 -1
- package/dist/cjs/contexts/Organization/OrganizationProvider.cjs +0 -97
- package/dist/cjs/contexts/Organization/OrganizationProvider.cjs.map +0 -1
- package/dist/cjs/contexts/Organization/useOrganization.cjs +0 -100
- package/dist/cjs/contexts/Organization/useOrganization.cjs.map +0 -1
- package/dist/cjs/hooks/useBranding.cjs +0 -71
- package/dist/cjs/hooks/useBranding.cjs.map +0 -1
- package/dist/components/control/OrganizationContext/OrganizationContext.d.ts +0 -40
- package/dist/components/control/OrganizationContext/OrganizationContext.d.ts.map +0 -1
- package/dist/components/control/OrganizationContext/OrganizationContext.js +0 -32
- package/dist/components/control/OrganizationContext/OrganizationContext.js.map +0 -1
- package/dist/components/control/OrganizationContext/OrganizationContextController.d.ts +0 -35
- package/dist/components/control/OrganizationContext/OrganizationContextController.d.ts.map +0 -1
- package/dist/components/control/OrganizationContext/OrganizationContextController.js +0 -55
- package/dist/components/control/OrganizationContext/OrganizationContextController.js.map +0 -1
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts +0 -60
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.d.ts.map +0 -1
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.js +0 -178
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.js.map +0 -1
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.styles.d.ts +0 -27
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.styles.d.ts.map +0 -1
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.styles.js +0 -147
- package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.styles.js.map +0 -1
- package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts +0 -68
- package/dist/components/presentation/CreateOrganization/CreateOrganization.d.ts.map +0 -1
- package/dist/components/presentation/CreateOrganization/CreateOrganization.js +0 -87
- package/dist/components/presentation/CreateOrganization/CreateOrganization.js.map +0 -1
- package/dist/components/presentation/Organization/BaseOrganization.d.ts +0 -67
- package/dist/components/presentation/Organization/BaseOrganization.d.ts.map +0 -1
- package/dist/components/presentation/Organization/BaseOrganization.js +0 -39
- package/dist/components/presentation/Organization/BaseOrganization.js.map +0 -1
- package/dist/components/presentation/Organization/Organization.d.ts +0 -67
- package/dist/components/presentation/Organization/Organization.d.ts.map +0 -1
- package/dist/components/presentation/Organization/Organization.js +0 -47
- package/dist/components/presentation/Organization/Organization.js.map +0 -1
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts +0 -135
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.js +0 -252
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.js.map +0 -1
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.styles.d.ts +0 -27
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.styles.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.styles.js +0 -233
- package/dist/components/presentation/OrganizationList/BaseOrganizationList.styles.js.map +0 -1
- package/dist/components/presentation/OrganizationList/OrganizationList.d.ts +0 -93
- package/dist/components/presentation/OrganizationList/OrganizationList.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationList/OrganizationList.js +0 -82
- package/dist/components/presentation/OrganizationList/OrganizationList.js.map +0 -1
- package/dist/components/presentation/OrganizationList/OrganizationList.styles.d.ts +0 -27
- package/dist/components/presentation/OrganizationList/OrganizationList.styles.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationList/OrganizationList.styles.js +0 -72
- package/dist/components/presentation/OrganizationList/OrganizationList.styles.js.map +0 -1
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts +0 -160
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.js +0 -323
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.js.map +0 -1
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.d.ts +0 -27
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.js +0 -163
- package/dist/components/presentation/OrganizationProfile/BaseOrganizationProfile.styles.js.map +0 -1
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts +0 -120
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.js +0 -122
- package/dist/components/presentation/OrganizationProfile/OrganizationProfile.js.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts +0 -149
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.js +0 -282
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.js.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.d.ts +0 -27
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.js +0 -234
- package/dist/components/presentation/OrganizationSwitcher/BaseOrganizationSwitcher.styles.js.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts +0 -71
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.d.ts.map +0 -1
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.js +0 -124
- package/dist/components/presentation/OrganizationSwitcher/OrganizationSwitcher.js.map +0 -1
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.d.ts +0 -30
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.d.ts.map +0 -1
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.js +0 -179
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.js.map +0 -1
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.d.ts +0 -21
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.d.ts.map +0 -1
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.js +0 -125
- package/dist/components/presentation/auth/OrganizationUnitPicker/OrganizationUnitPicker.styles.js.map +0 -1
- package/dist/components/presentation/auth/OrganizationUnitPicker/index.d.ts +0 -20
- package/dist/components/presentation/auth/OrganizationUnitPicker/index.d.ts.map +0 -1
- package/dist/components/primitives/Icons/Building.js +0 -73
- package/dist/components/primitives/Icons/Building.js.map +0 -1
- package/dist/contexts/Branding/BrandingContext.d.ts +0 -53
- package/dist/contexts/Branding/BrandingContext.d.ts.map +0 -1
- package/dist/contexts/Branding/BrandingContext.js +0 -10
- package/dist/contexts/Branding/BrandingContext.js.map +0 -1
- package/dist/contexts/Branding/BrandingProvider.d.ts +0 -89
- package/dist/contexts/Branding/BrandingProvider.d.ts.map +0 -1
- package/dist/contexts/Branding/BrandingProvider.js +0 -92
- package/dist/contexts/Branding/BrandingProvider.js.map +0 -1
- package/dist/contexts/Branding/useBrandingContext.d.ts +0 -45
- package/dist/contexts/Branding/useBrandingContext.d.ts.map +0 -1
- package/dist/contexts/Branding/useBrandingContext.js +0 -38
- package/dist/contexts/Branding/useBrandingContext.js.map +0 -1
- package/dist/contexts/Organization/OrganizationContext.d.ts +0 -41
- package/dist/contexts/Organization/OrganizationContext.d.ts.map +0 -1
- package/dist/contexts/Organization/OrganizationContext.js +0 -25
- package/dist/contexts/Organization/OrganizationContext.js.map +0 -1
- package/dist/contexts/Organization/OrganizationProvider.d.ts +0 -94
- package/dist/contexts/Organization/OrganizationProvider.d.ts.map +0 -1
- package/dist/contexts/Organization/OrganizationProvider.js +0 -93
- package/dist/contexts/Organization/OrganizationProvider.js.map +0 -1
- package/dist/contexts/Organization/useOrganization.d.ts +0 -105
- package/dist/contexts/Organization/useOrganization.d.ts.map +0 -1
- package/dist/contexts/Organization/useOrganization.js +0 -98
- package/dist/contexts/Organization/useOrganization.js.map +0 -1
- package/dist/hooks/useBranding.d.ts +0 -128
- package/dist/hooks/useBranding.d.ts.map +0 -1
- package/dist/hooks/useBranding.js +0 -69
- package/dist/hooks/useBranding.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOrganization.cjs","names":["context: OrganizationContextProps | null","OrganizationContext"],"sources":["../../../../src/contexts/Organization/useOrganization.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {useContext} from 'react';\nimport OrganizationContext, {OrganizationContextProps} from './OrganizationContext';\n\n/**\n * Hook to access the Organization context.\n *\n * This hook provides access to organization data including:\n * - List of organizations the user belongs to\n * - Current organization\n * - Functions to switch organizations and refresh data\n * - Function to fetch organizations programmatically\n * - Loading states and error handling\n *\n * @returns {OrganizationContextProps} The organization context value containing all organization-related data and functions\n * @throws {Error} Throws an error if used outside of OrganizationProvider\n *\n * @example\n * ```tsx\n * import {useOrganization} from '@thunderid/react';\n *\n * function OrganizationSelector() {\n * const {\n * organizations,\n * currentOrganization,\n * switchOrganization,\n * revalidateMyOrganizations,\n * getOrganizations,\n * isLoading,\n * error\n * } = useOrganization();\n *\n * if (isLoading) {\n * return <div>Loading organizations...</div>;\n * }\n *\n * if (error) {\n * return <div>Error: {error}</div>;\n * }\n *\n * return (\n * <div>\n * <h2>Current: {currentOrganization?.name}</h2>\n * <select\n * value={currentOrganization?.id || ''}\n * onChange={(e) => {\n * const org = organizations?.find(o => o.id === e.target.value);\n * if (org) switchOrganization(org);\n * }}\n * >\n * {organizations?.map(org => (\n * <option key={org.id} value={org.id}>\n * {org.name}\n * </option>\n * ))}\n * </select>\n * <button onClick={revalidateMyOrganizations}>\n * Refresh Organizations\n * </button>\n * <button onClick={async () => {\n * const fresh = await getOrganizations();\n * console.log('Fresh organizations:', fresh);\n * }}>\n * Get Organizations Manually\n * </button>\n * </div>\n * );\n * }\n *\n * // Switch to a specific organization\n * function SwitchOrgButton() {\n * const {organizations, switchOrganization} = useOrganization();\n *\n * const handleSwitch = (orgId: string) => {\n * const org = organizations?.find(o => o.id === orgId);\n * if (org) {\n * switchOrganization(org);\n * }\n * };\n *\n * return (\n * <button onClick={() => handleSwitch('org-123')}>\n * Switch to Organization\n * </button>\n * );\n * }\n * ```\n */\nconst useOrganization = (): OrganizationContextProps => {\n const context: OrganizationContextProps | null = useContext(OrganizationContext);\n\n if (!context) {\n throw new Error('useOrganization must be used within an OrganizationProvider');\n }\n\n return context;\n};\n\nexport default useOrganization;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,MAAM,wBAAkD;CACtD,MAAMA,gCAAsDC,oCAAoB;AAEhF,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,8DAA8D;AAGhF,QAAO;;AAGT,8BAAe"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_useBrandingContext = require('../contexts/Branding/useBrandingContext.cjs');
|
|
3
|
-
let __thunderid_browser = require("@thunderid/browser");
|
|
4
|
-
__thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
|
|
5
|
-
|
|
6
|
-
//#region src/hooks/useBranding.ts
|
|
7
|
-
const logger = (0, __thunderid_browser.createPackageComponentLogger)("@thunderid/react", "useBranding");
|
|
8
|
-
/**
|
|
9
|
-
* React hook for accessing branding preferences from the BrandingProvider context.
|
|
10
|
-
* This hook provides access to branding preferences, theme data, and loading states.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Consider using useBrandingContext directly for better performance.
|
|
13
|
-
* This hook is maintained for backward compatibility.
|
|
14
|
-
*
|
|
15
|
-
* @param config - Configuration options (deprecated, use BrandingProvider props instead)
|
|
16
|
-
* @returns Object containing branding preference data, theme, loading state, error, and refetch function
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* Basic usage:
|
|
20
|
-
* ```tsx
|
|
21
|
-
* function MyComponent() {
|
|
22
|
-
* const { theme, activeTheme, isLoading, error } = useBranding();
|
|
23
|
-
*
|
|
24
|
-
* if (isLoading) return <div>Loading branding...</div>;
|
|
25
|
-
* if (error) return <div>Error: {error.message}</div>;
|
|
26
|
-
*
|
|
27
|
-
* return (
|
|
28
|
-
* <div style={{ color: theme?.colors?.primary?.main }}>
|
|
29
|
-
* <p>Active theme mode: {activeTheme}</p>
|
|
30
|
-
* <p>Styled with ThunderID branding</p>
|
|
31
|
-
* </div>
|
|
32
|
-
* );
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* For new implementations, use BrandingProvider with useBrandingContext:
|
|
38
|
-
* ```tsx
|
|
39
|
-
* // In your root component
|
|
40
|
-
* <BrandingProvider baseUrl="https://localhost:8090">
|
|
41
|
-
* <App />
|
|
42
|
-
* </BrandingProvider>
|
|
43
|
-
*
|
|
44
|
-
* // In your component
|
|
45
|
-
* function MyComponent() {
|
|
46
|
-
* const { theme, activeTheme, isLoading, error } = useBrandingContext();
|
|
47
|
-
* // ... rest of your component
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
const useBranding = () => {
|
|
52
|
-
try {
|
|
53
|
-
return require_useBrandingContext.default();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
logger.warn("useBranding: BrandingProvider not available. Make sure to wrap your app with BrandingProvider or ThunderIDProvider with branding preferences.");
|
|
56
|
-
return {
|
|
57
|
-
activeTheme: null,
|
|
58
|
-
brandingPreference: null,
|
|
59
|
-
error: /* @__PURE__ */ new Error("BrandingProvider not available"),
|
|
60
|
-
fetchBranding: async () => {},
|
|
61
|
-
isLoading: false,
|
|
62
|
-
refetch: async () => {},
|
|
63
|
-
theme: null
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var useBranding_default = useBranding;
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.default = useBranding_default;
|
|
71
|
-
//# sourceMappingURL=useBranding.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBranding.cjs","names":["logger: ReturnType<typeof createPackageComponentLogger>","useBrandingContext"],"sources":["../../../src/hooks/useBranding.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {BrandingPreference, Theme, createPackageComponentLogger} from '@thunderid/browser';\nimport useBrandingContext from '../contexts/Branding/useBrandingContext';\n\nconst logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(\n '@thunderid/react',\n 'useBranding',\n);\n\n/**\n * Configuration options for the useBranding hook\n * @deprecated Use BrandingProvider instead for better performance and consistency\n */\nexport interface UseBrandingConfig {\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n autoFetch?: boolean;\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n fetcher?: (url: string, config: RequestInit) => Promise<Response>;\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n forceTheme?: 'light' | 'dark';\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n locale?: string;\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n name?: string;\n /**\n * @deprecated This configuration is now handled by BrandingProvider\n */\n type?: string;\n}\n\n/**\n * Return type of the useBranding hook\n */\nexport interface UseBrandingReturn {\n /**\n * The active theme mode from branding preference ('light' | 'dark')\n */\n activeTheme: 'light' | 'dark' | null;\n /**\n * The raw branding preference data\n */\n brandingPreference: BrandingPreference | null;\n /**\n * Error state\n */\n error: Error | null;\n /**\n * Function to manually fetch branding preference\n */\n fetchBranding: () => Promise<void>;\n /**\n * Loading state\n */\n isLoading: boolean;\n /**\n * Function to refetch branding preference\n * This bypasses the single-call restriction and forces a new API call\n */\n refetch: () => Promise<void>;\n /**\n * The transformed theme object\n */\n theme: Theme | null;\n}\n\n/**\n * React hook for accessing branding preferences from the BrandingProvider context.\n * This hook provides access to branding preferences, theme data, and loading states.\n *\n * @deprecated Consider using useBrandingContext directly for better performance.\n * This hook is maintained for backward compatibility.\n *\n * @param config - Configuration options (deprecated, use BrandingProvider props instead)\n * @returns Object containing branding preference data, theme, loading state, error, and refetch function\n *\n * @example\n * Basic usage:\n * ```tsx\n * function MyComponent() {\n * const { theme, activeTheme, isLoading, error } = useBranding();\n *\n * if (isLoading) return <div>Loading branding...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n *\n * return (\n * <div style={{ color: theme?.colors?.primary?.main }}>\n * <p>Active theme mode: {activeTheme}</p>\n * <p>Styled with ThunderID branding</p>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * For new implementations, use BrandingProvider with useBrandingContext:\n * ```tsx\n * // In your root component\n * <BrandingProvider baseUrl=\"https://localhost:8090\">\n * <App />\n * </BrandingProvider>\n *\n * // In your component\n * function MyComponent() {\n * const { theme, activeTheme, isLoading, error } = useBrandingContext();\n * // ... rest of your component\n * }\n * ```\n */\nexport const useBranding = (): UseBrandingReturn => {\n try {\n return useBrandingContext();\n } catch (error) {\n logger.warn(\n 'useBranding: BrandingProvider not available. ' +\n 'Make sure to wrap your app with BrandingProvider or ThunderIDProvider with branding preferences.',\n );\n\n return {\n activeTheme: null,\n brandingPreference: null,\n error: new Error('BrandingProvider not available'),\n fetchBranding: async (): Promise<void> => {},\n isLoading: false,\n refetch: async (): Promise<void> => {},\n theme: null,\n };\n }\n};\n\nexport default useBranding;\n"],"mappings":";;;;;;AAqBA,MAAMA,+DACJ,oBACA,cACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GD,MAAa,oBAAuC;AAClD,KAAI;AACF,SAAOC,oCAAoB;UACpB,OAAO;AACd,SAAO,KACL,gJAED;AAED,SAAO;GACL,aAAa;GACb,oBAAoB;GACpB,uBAAO,IAAI,MAAM,iCAAiC;GAClD,eAAe,YAA2B;GAC1C,WAAW;GACX,SAAS,YAA2B;GACpC,OAAO;GACR;;;AAIL,0BAAe"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
|
-
import { FC, PropsWithChildren } from 'react';
|
|
19
|
-
import { ThunderIDProviderProps } from '../../../contexts/ThunderID/ThunderIDProvider';
|
|
20
|
-
export interface OrganizationContextProps extends Omit<ThunderIDProviderProps, 'organizationChain' | 'baseUrl'> {
|
|
21
|
-
/**
|
|
22
|
-
* Optional base URL for the organization context. If not provided, it will default to the source provider's base URL.
|
|
23
|
-
*/
|
|
24
|
-
baseUrl?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Instance ID for this organization context. Must be unique across the app if multiple contexts are used.
|
|
27
|
-
*/
|
|
28
|
-
instanceId: number;
|
|
29
|
-
/**
|
|
30
|
-
* Optional source instance ID. If not provided, immediate parent provider is used as source.
|
|
31
|
-
*/
|
|
32
|
-
sourceInstanceId?: number;
|
|
33
|
-
/**
|
|
34
|
-
* ID of the organization to authenticate with
|
|
35
|
-
*/
|
|
36
|
-
targetOrganizationId: string;
|
|
37
|
-
}
|
|
38
|
-
declare const OrganizationContext: FC<PropsWithChildren<OrganizationContextProps>>;
|
|
39
|
-
export default OrganizationContext;
|
|
40
|
-
//# sourceMappingURL=OrganizationContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationContext.d.ts","sourceRoot":"","sources":["../../../../src/components/control/OrganizationContext/OrganizationContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAE5C,OAA0B,EAAC,sBAAsB,EAAC,MAAM,+CAA+C,CAAC;AAGxG,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC7G;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,mBAAmB,EAAE,EAAE,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAuCxE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import useThunderID_default from "../../../contexts/ThunderID/useThunderID.js";
|
|
2
|
-
import ThunderIDProvider_default from "../../../contexts/ThunderID/ThunderIDProvider.js";
|
|
3
|
-
import OrganizationContextController_default from "./OrganizationContextController.js";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
//#region src/components/control/OrganizationContext/OrganizationContext.tsx
|
|
7
|
-
const OrganizationContext = ({ instanceId, baseUrl, clientId, afterSignInUrl, afterSignOutUrl, targetOrganizationId, sourceInstanceId, scopes, children,...rest }) => {
|
|
8
|
-
const { isSignedIn: isSourceSignedIn, instanceId: sourceInstanceIdFromContext, baseUrl: sourceBaseUrl, clientId: sourceClientId } = useThunderID_default();
|
|
9
|
-
return /* @__PURE__ */ jsx(ThunderIDProvider_default, {
|
|
10
|
-
instanceId,
|
|
11
|
-
baseUrl: baseUrl || sourceBaseUrl,
|
|
12
|
-
clientId: clientId || sourceClientId,
|
|
13
|
-
afterSignInUrl,
|
|
14
|
-
afterSignOutUrl,
|
|
15
|
-
scopes,
|
|
16
|
-
organizationChain: {
|
|
17
|
-
sourceInstanceId: sourceInstanceId || sourceInstanceIdFromContext,
|
|
18
|
-
targetOrganizationId
|
|
19
|
-
},
|
|
20
|
-
...rest,
|
|
21
|
-
children: /* @__PURE__ */ jsx(OrganizationContextController_default, {
|
|
22
|
-
targetOrganizationId,
|
|
23
|
-
isSourceSignedIn,
|
|
24
|
-
children
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
var OrganizationContext_default = OrganizationContext;
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { OrganizationContext_default as default };
|
|
32
|
-
//# sourceMappingURL=OrganizationContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationContext.js","names":["OrganizationContext: FC<PropsWithChildren<OrganizationContextProps>>","useThunderID","ThunderIDProvider","OrganizationContextController"],"sources":["../../../../src/components/control/OrganizationContext/OrganizationContext.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {FC, PropsWithChildren} from 'react';\nimport OrganizationContextController from './OrganizationContextController';\nimport ThunderIDProvider, {ThunderIDProviderProps} from '../../../contexts/ThunderID/ThunderIDProvider';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\nexport interface OrganizationContextProps extends Omit<ThunderIDProviderProps, 'organizationChain' | 'baseUrl'> {\n /**\n * Optional base URL for the organization context. If not provided, it will default to the source provider's base URL.\n */\n baseUrl?: string;\n /**\n * Instance ID for this organization context. Must be unique across the app if multiple contexts are used.\n */\n instanceId: number;\n /**\n * Optional source instance ID. If not provided, immediate parent provider is used as source.\n */\n sourceInstanceId?: number;\n /**\n * ID of the organization to authenticate with\n */\n targetOrganizationId: string;\n}\n\nconst OrganizationContext: FC<PropsWithChildren<OrganizationContextProps>> = ({\n instanceId,\n baseUrl,\n clientId,\n afterSignInUrl,\n afterSignOutUrl,\n targetOrganizationId,\n sourceInstanceId,\n scopes,\n children,\n ...rest\n}: PropsWithChildren<OrganizationContextProps>) => {\n // Get the source provider's signed-in status\n const {\n isSignedIn: isSourceSignedIn,\n instanceId: sourceInstanceIdFromContext,\n baseUrl: sourceBaseUrl,\n clientId: sourceClientId,\n } = useThunderID();\n\n return (\n <ThunderIDProvider\n instanceId={instanceId}\n baseUrl={baseUrl || sourceBaseUrl}\n clientId={clientId || sourceClientId}\n afterSignInUrl={afterSignInUrl}\n afterSignOutUrl={afterSignOutUrl}\n scopes={scopes}\n organizationChain={{\n sourceInstanceId: sourceInstanceId || sourceInstanceIdFromContext,\n targetOrganizationId,\n }}\n {...rest}\n >\n <OrganizationContextController targetOrganizationId={targetOrganizationId} isSourceSignedIn={isSourceSignedIn}>\n {children}\n </OrganizationContextController>\n </ThunderIDProvider>\n );\n};\n\nexport default OrganizationContext;\n"],"mappings":";;;;;;AA0CA,MAAMA,uBAAwE,EAC5E,YACA,SACA,UACA,gBACA,iBACA,sBACA,kBACA,QACA,SACA,GAAG,WAC8C;CAEjD,MAAM,EACJ,YAAY,kBACZ,YAAY,6BACZ,SAAS,eACT,UAAU,mBACRC,sBAAc;AAElB,QACE,oBAACC;EACa;EACZ,SAAS,WAAW;EACpB,UAAU,YAAY;EACN;EACC;EACT;EACR,mBAAmB;GACjB,kBAAkB,oBAAoB;GACtC;GACD;EACD,GAAI;YAEJ,oBAACC;GAAoD;GAAwC;GAC1F;IAC6B;GACd;;AAIxB,kCAAe"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
|
-
import { FC } from 'react';
|
|
19
|
-
interface OrganizationContextControllerProps {
|
|
20
|
-
/**
|
|
21
|
-
* Children to render
|
|
22
|
-
*/
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the source provider is signed in
|
|
26
|
-
*/
|
|
27
|
-
isSourceSignedIn: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* ID of the organization to authenticate with
|
|
30
|
-
*/
|
|
31
|
-
targetOrganizationId: string;
|
|
32
|
-
}
|
|
33
|
-
declare const OrganizationContextController: FC<OrganizationContextControllerProps>;
|
|
34
|
-
export default OrganizationContextController;
|
|
35
|
-
//# sourceMappingURL=OrganizationContextController.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationContextController.d.ts","sourceRoot":"","sources":["../../../../src/components/control/OrganizationContext/OrganizationContextController.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,EAAE,EAAoB,MAAM,OAAO,CAAC;AAG5C,UAAU,kCAAkC;IAC1C;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,6BAA6B,EAAE,EAAE,CAAC,kCAAkC,CAkEzE,CAAC;AAEF,eAAe,6BAA6B,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import useThunderID_default from "../../../contexts/ThunderID/useThunderID.js";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
//#region src/components/control/OrganizationContext/OrganizationContextController.tsx
|
|
6
|
-
const OrganizationContextController = ({ targetOrganizationId, isSourceSignedIn, children }) => {
|
|
7
|
-
const { isInitialized, isSignedIn, switchOrganization, isLoading } = useThunderID_default();
|
|
8
|
-
const hasAuthenticatedRef = useRef(false);
|
|
9
|
-
const isAuthenticatingRef = useRef(false);
|
|
10
|
-
/**
|
|
11
|
-
* Handle the organization switch when:
|
|
12
|
-
* - Current instance is initialized and NOT signed in
|
|
13
|
-
* - Source provider IS signed in
|
|
14
|
-
* Uses the `switchOrganization` function from the ThunderID context.
|
|
15
|
-
*/
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const performOrganizationSwitch = async () => {
|
|
18
|
-
if (hasAuthenticatedRef.current || isAuthenticatingRef.current) return;
|
|
19
|
-
if (!isInitialized || isLoading) return;
|
|
20
|
-
if (isSignedIn) {
|
|
21
|
-
hasAuthenticatedRef.current = true;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!isSourceSignedIn) return;
|
|
25
|
-
try {
|
|
26
|
-
isAuthenticatingRef.current = true;
|
|
27
|
-
hasAuthenticatedRef.current = true;
|
|
28
|
-
await switchOrganization({
|
|
29
|
-
id: targetOrganizationId,
|
|
30
|
-
name: "",
|
|
31
|
-
orgHandle: ""
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error("Linked organization authentication failed:", error);
|
|
35
|
-
hasAuthenticatedRef.current = false;
|
|
36
|
-
} finally {
|
|
37
|
-
isAuthenticatingRef.current = false;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
performOrganizationSwitch();
|
|
41
|
-
}, [
|
|
42
|
-
isInitialized,
|
|
43
|
-
isSignedIn,
|
|
44
|
-
isLoading,
|
|
45
|
-
isSourceSignedIn,
|
|
46
|
-
targetOrganizationId,
|
|
47
|
-
switchOrganization
|
|
48
|
-
]);
|
|
49
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
50
|
-
};
|
|
51
|
-
var OrganizationContextController_default = OrganizationContextController;
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
export { OrganizationContextController_default as default };
|
|
55
|
-
//# sourceMappingURL=OrganizationContextController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationContextController.js","names":["OrganizationContextController: FC<OrganizationContextControllerProps>","useThunderID","hasAuthenticatedRef: React.MutableRefObject<boolean>","isAuthenticatingRef: React.MutableRefObject<boolean>"],"sources":["../../../../src/components/control/OrganizationContext/OrganizationContextController.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {Organization} from '@thunderid/browser';\nimport {FC, useEffect, useRef} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\ninterface OrganizationContextControllerProps {\n /**\n * Children to render\n */\n children: React.ReactNode;\n /**\n * Whether the source provider is signed in\n */\n isSourceSignedIn: boolean;\n /**\n * ID of the organization to authenticate with\n */\n targetOrganizationId: string;\n}\n\nconst OrganizationContextController: FC<OrganizationContextControllerProps> = ({\n targetOrganizationId,\n isSourceSignedIn,\n children,\n}: OrganizationContextControllerProps) => {\n const {isInitialized, isSignedIn, switchOrganization, isLoading} = useThunderID();\n const hasAuthenticatedRef: React.MutableRefObject<boolean> = useRef(false);\n const isAuthenticatingRef: React.MutableRefObject<boolean> = useRef(false);\n\n /**\n * Handle the organization switch when:\n * - Current instance is initialized and NOT signed in\n * - Source provider IS signed in\n * Uses the `switchOrganization` function from the ThunderID context.\n */\n useEffect(() => {\n const performOrganizationSwitch = async (): Promise<void> => {\n // Prevent multiple authentication attempts\n if (hasAuthenticatedRef.current || isAuthenticatingRef.current) {\n return;\n }\n\n // Wait for initialization to complete\n if (!isInitialized || isLoading) {\n return;\n }\n\n // Only proceed if user is not already signed in to this instance\n if (isSignedIn) {\n hasAuthenticatedRef.current = true;\n return;\n }\n\n // CRITICAL: Only proceed if source provider is signed in\n if (!isSourceSignedIn) {\n return;\n }\n\n try {\n isAuthenticatingRef.current = true;\n hasAuthenticatedRef.current = true;\n\n // Build the organization object for authentication\n const targetOrganization: Organization = {\n id: targetOrganizationId,\n name: '', // Name will be populated after authentication\n orgHandle: '', // Will be populated after authentication\n };\n\n // Call the switchOrganization API from context (handles token exchange)\n await switchOrganization(targetOrganization);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Linked organization authentication failed:', error);\n\n // Reset the flag to allow retry\n hasAuthenticatedRef.current = false;\n } finally {\n isAuthenticatingRef.current = false;\n }\n };\n\n performOrganizationSwitch();\n }, [isInitialized, isSignedIn, isLoading, isSourceSignedIn, targetOrganizationId, switchOrganization]);\n\n return <>{children}</>;\n};\n\nexport default OrganizationContextController;\n"],"mappings":";;;;;AAqCA,MAAMA,iCAAyE,EAC7E,sBACA,kBACA,eACwC;CACxC,MAAM,EAAC,eAAe,YAAY,oBAAoB,cAAaC,sBAAc;CACjF,MAAMC,sBAAuD,OAAO,MAAM;CAC1E,MAAMC,sBAAuD,OAAO,MAAM;;;;;;;AAQ1E,iBAAgB;EACd,MAAM,4BAA4B,YAA2B;AAE3D,OAAI,oBAAoB,WAAW,oBAAoB,QACrD;AAIF,OAAI,CAAC,iBAAiB,UACpB;AAIF,OAAI,YAAY;AACd,wBAAoB,UAAU;AAC9B;;AAIF,OAAI,CAAC,iBACH;AAGF,OAAI;AACF,wBAAoB,UAAU;AAC9B,wBAAoB,UAAU;AAU9B,UAAM,mBAPmC;KACvC,IAAI;KACJ,MAAM;KACN,WAAW;KACZ,CAG2C;YACrC,OAAO;AAEd,YAAQ,MAAM,8CAA8C,MAAM;AAGlE,wBAAoB,UAAU;aACtB;AACR,wBAAoB,UAAU;;;AAIlC,6BAA2B;IAC1B;EAAC;EAAe;EAAY;EAAW;EAAkB;EAAsB;EAAmB,CAAC;AAEtG,QAAO,gCAAG,WAAY;;AAGxB,4CAAe"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
|
-
import { CreateOrganizationPayload, Preferences } from '@thunderid/browser';
|
|
19
|
-
import { CSSProperties, FC, ReactNode } from 'react';
|
|
20
|
-
/**
|
|
21
|
-
* Interface for organization form data.
|
|
22
|
-
*/
|
|
23
|
-
export interface OrganizationFormData {
|
|
24
|
-
description: string;
|
|
25
|
-
handle: string;
|
|
26
|
-
name: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Props interface for the BaseCreateOrganization component.
|
|
30
|
-
*/
|
|
31
|
-
export interface BaseCreateOrganizationProps {
|
|
32
|
-
cardLayout?: boolean;
|
|
33
|
-
className?: string;
|
|
34
|
-
defaultParentId?: string;
|
|
35
|
-
error?: string | null;
|
|
36
|
-
initialValues?: Partial<OrganizationFormData>;
|
|
37
|
-
loading?: boolean;
|
|
38
|
-
mode?: 'inline' | 'popup';
|
|
39
|
-
onCancel?: () => void;
|
|
40
|
-
onOpenChange?: (open: boolean) => void;
|
|
41
|
-
onSubmit?: (payload: CreateOrganizationPayload) => void | Promise<void>;
|
|
42
|
-
onSuccess?: (organization: any) => void;
|
|
43
|
-
open?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Component-level preferences to override global i18n and theme settings.
|
|
46
|
-
* Preferences are deep-merged with global ones, with component preferences
|
|
47
|
-
* taking precedence. Affects this component and all its descendants.
|
|
48
|
-
*/
|
|
49
|
-
preferences?: Preferences;
|
|
50
|
-
renderAdditionalFields?: () => ReactNode;
|
|
51
|
-
style?: CSSProperties;
|
|
52
|
-
title?: string;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* BaseCreateOrganization component provides the core functionality for creating organizations.
|
|
56
|
-
* This component serves as the base for framework-specific implementations.
|
|
57
|
-
*/
|
|
58
|
-
export declare const BaseCreateOrganization: FC<BaseCreateOrganizationProps>;
|
|
59
|
-
export default BaseCreateOrganization;
|
|
60
|
-
//# sourceMappingURL=BaseCreateOrganization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCreateOrganization.d.ts","sourceRoot":"","sources":["../../../../src/components/presentation/CreateOrganization/BaseCreateOrganization.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,yBAAyB,EAAgC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAc,aAAa,EAAE,EAAE,EAA2B,SAAS,EAAW,MAAM,OAAO,CAAC;AAgBnG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,sBAAsB,CAAC,EAAE,MAAM,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgBD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAyLlE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import useTheme_default from "../../../contexts/Theme/useTheme.js";
|
|
2
|
-
import useTranslation_default from "../../../hooks/useTranslation.js";
|
|
3
|
-
import Button_default from "../../primitives/Button/Button.js";
|
|
4
|
-
import Alert_default from "../../primitives/Alert/Alert.js";
|
|
5
|
-
import FormControl_default from "../../primitives/FormControl/FormControl.js";
|
|
6
|
-
import InputLabel_default from "../../primitives/InputLabel/InputLabel.js";
|
|
7
|
-
import TextField_default from "../../primitives/TextField/TextField.js";
|
|
8
|
-
import Dialog_default from "../../primitives/Dialog/Dialog.js";
|
|
9
|
-
import BaseCreateOrganization_styles_default from "./BaseCreateOrganization.styles.js";
|
|
10
|
-
import { createPackageComponentLogger } from "@thunderid/browser";
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { cx } from "@emotion/css";
|
|
14
|
-
|
|
15
|
-
//#region src/components/presentation/CreateOrganization/BaseCreateOrganization.tsx
|
|
16
|
-
const logger$1 = createPackageComponentLogger("@thunderid/react", "BaseCreateOrganization");
|
|
17
|
-
/**
|
|
18
|
-
* Removes special characters except space and hyphen from the organization name
|
|
19
|
-
* and generates a valid handle.
|
|
20
|
-
* @param name
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
const generateHandleFromName = (name) => name.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
24
|
-
/**
|
|
25
|
-
* BaseCreateOrganization component provides the core functionality for creating organizations.
|
|
26
|
-
* This component serves as the base for framework-specific implementations.
|
|
27
|
-
*/
|
|
28
|
-
const BaseCreateOrganization = ({ cardLayout = true, className = "", defaultParentId = "", error, initialValues = {}, loading = false, mode = "inline", onCancel, onOpenChange, onSubmit, onSuccess, open = false, preferences, renderAdditionalFields, style, title = "Create Organization" }) => {
|
|
29
|
-
const { theme, colorScheme } = useTheme_default();
|
|
30
|
-
const styles = BaseCreateOrganization_styles_default(theme, colorScheme);
|
|
31
|
-
const { t } = useTranslation_default(preferences?.i18n);
|
|
32
|
-
const [formData, setFormData] = useState({
|
|
33
|
-
description: "",
|
|
34
|
-
handle: "",
|
|
35
|
-
name: "",
|
|
36
|
-
...initialValues
|
|
37
|
-
});
|
|
38
|
-
const [formErrors, setFormErrors] = useState({});
|
|
39
|
-
const validateForm = () => {
|
|
40
|
-
const errors = {};
|
|
41
|
-
if (!formData.name.trim()) errors.name = "Organization name is required";
|
|
42
|
-
if (!formData.handle.trim()) errors.handle = "Organization handle is required";
|
|
43
|
-
else if (!/^[a-z0-9-]+$/.test(formData.handle)) errors.handle = "Handle can only contain lowercase letters, numbers, and hyphens";
|
|
44
|
-
if (!formData.description.trim()) errors.description = "Organization description is required";
|
|
45
|
-
setFormErrors(errors);
|
|
46
|
-
return Object.keys(errors).length === 0;
|
|
47
|
-
};
|
|
48
|
-
const handleInputChange = (field, value) => {
|
|
49
|
-
setFormData((prev) => ({
|
|
50
|
-
...prev,
|
|
51
|
-
[field]: value
|
|
52
|
-
}));
|
|
53
|
-
if (formErrors[field]) setFormErrors((prev) => ({
|
|
54
|
-
...prev,
|
|
55
|
-
[field]: void 0
|
|
56
|
-
}));
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Handles changes to the organization name input.
|
|
60
|
-
* Automatically generates the organization handle based on the name if the handle is not set or matches
|
|
61
|
-
*
|
|
62
|
-
* @param value - The new value for the organization name.
|
|
63
|
-
*/
|
|
64
|
-
const handleNameChange = (value) => {
|
|
65
|
-
handleInputChange("name", value);
|
|
66
|
-
if (!formData.handle || formData.handle === generateHandleFromName(formData.name)) handleInputChange("handle", generateHandleFromName(value));
|
|
67
|
-
};
|
|
68
|
-
const handleSubmit = async (e) => {
|
|
69
|
-
e.preventDefault();
|
|
70
|
-
if (!validateForm() || loading) return;
|
|
71
|
-
const payload = {
|
|
72
|
-
description: formData.description.trim(),
|
|
73
|
-
name: formData.name.trim(),
|
|
74
|
-
orgHandle: formData.handle.trim(),
|
|
75
|
-
parentId: defaultParentId,
|
|
76
|
-
type: "TENANT"
|
|
77
|
-
};
|
|
78
|
-
try {
|
|
79
|
-
await onSubmit?.(payload);
|
|
80
|
-
if (onSuccess) onSuccess(payload);
|
|
81
|
-
} catch (submitError) {
|
|
82
|
-
logger$1.error("Form submission error:");
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const createOrganizationContent = /* @__PURE__ */ jsx("div", {
|
|
86
|
-
className: cx(styles["root"], cardLayout && styles["card"], className),
|
|
87
|
-
style,
|
|
88
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
89
|
-
className: cx(styles["content"]),
|
|
90
|
-
children: [/* @__PURE__ */ jsxs("form", {
|
|
91
|
-
id: "create-organization-form",
|
|
92
|
-
className: cx(styles["form"]),
|
|
93
|
-
onSubmit: handleSubmit,
|
|
94
|
-
children: [
|
|
95
|
-
error && /* @__PURE__ */ jsxs(Alert_default, {
|
|
96
|
-
variant: "error",
|
|
97
|
-
className: styles["errorAlert"],
|
|
98
|
-
children: [/* @__PURE__ */ jsx(Alert_default.Title, { children: "Error" }), /* @__PURE__ */ jsx(Alert_default.Description, { children: error })]
|
|
99
|
-
}),
|
|
100
|
-
/* @__PURE__ */ jsx("div", {
|
|
101
|
-
className: cx(styles["fieldGroup"]),
|
|
102
|
-
children: /* @__PURE__ */ jsx(TextField_default, {
|
|
103
|
-
label: `${t("elements.fields.organization.name.label")}`,
|
|
104
|
-
placeholder: t("elements.fields.organization.name.placeholder"),
|
|
105
|
-
value: formData.name,
|
|
106
|
-
onChange: (e) => handleNameChange(e.target.value),
|
|
107
|
-
disabled: loading,
|
|
108
|
-
required: true,
|
|
109
|
-
error: formErrors.name,
|
|
110
|
-
className: cx(styles["input"])
|
|
111
|
-
})
|
|
112
|
-
}),
|
|
113
|
-
/* @__PURE__ */ jsx("div", {
|
|
114
|
-
className: cx(styles["fieldGroup"]),
|
|
115
|
-
children: /* @__PURE__ */ jsx(TextField_default, {
|
|
116
|
-
label: `${t("elements.fields.organization.handle.label") || "Organization Handle"}`,
|
|
117
|
-
placeholder: t("elements.fields.organization.handle.placeholder") || "my-organization",
|
|
118
|
-
value: formData.handle,
|
|
119
|
-
onChange: (e) => handleInputChange("handle", e.target.value),
|
|
120
|
-
disabled: loading,
|
|
121
|
-
required: true,
|
|
122
|
-
error: formErrors.handle,
|
|
123
|
-
helperText: "This will be your organization's unique identifier. Only lowercase letters, numbers, and hyphens are allowed.",
|
|
124
|
-
className: cx(styles["input"])
|
|
125
|
-
})
|
|
126
|
-
}),
|
|
127
|
-
/* @__PURE__ */ jsx("div", {
|
|
128
|
-
className: cx(styles["fieldGroup"]),
|
|
129
|
-
children: /* @__PURE__ */ jsxs(FormControl_default, {
|
|
130
|
-
error: formErrors.description,
|
|
131
|
-
children: [/* @__PURE__ */ jsx(InputLabel_default, {
|
|
132
|
-
required: true,
|
|
133
|
-
children: t("elements.fields.organization.description.label")
|
|
134
|
-
}), /* @__PURE__ */ jsx("textarea", {
|
|
135
|
-
className: cx(styles["textarea"], formErrors.description && styles["textareaError"]),
|
|
136
|
-
placeholder: t("organization.create.description.placeholder"),
|
|
137
|
-
value: formData.description,
|
|
138
|
-
onChange: (e) => handleInputChange("description", e.target.value),
|
|
139
|
-
disabled: loading,
|
|
140
|
-
required: true
|
|
141
|
-
})]
|
|
142
|
-
})
|
|
143
|
-
}),
|
|
144
|
-
renderAdditionalFields?.()
|
|
145
|
-
]
|
|
146
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
147
|
-
className: cx(styles["actions"]),
|
|
148
|
-
children: [onCancel && /* @__PURE__ */ jsx(Button_default, {
|
|
149
|
-
type: "button",
|
|
150
|
-
variant: "outline",
|
|
151
|
-
onClick: onCancel,
|
|
152
|
-
disabled: loading,
|
|
153
|
-
children: t("organization.create.buttons.cancel.text")
|
|
154
|
-
}), /* @__PURE__ */ jsx(Button_default, {
|
|
155
|
-
type: "submit",
|
|
156
|
-
variant: "solid",
|
|
157
|
-
color: "primary",
|
|
158
|
-
disabled: loading,
|
|
159
|
-
form: "create-organization-form",
|
|
160
|
-
children: loading ? t("organization.create.buttons.create_organization.loading.text") : t("organization.create.buttons.create_organization.text")
|
|
161
|
-
})]
|
|
162
|
-
})]
|
|
163
|
-
})
|
|
164
|
-
});
|
|
165
|
-
if (mode === "popup") return /* @__PURE__ */ jsx(Dialog_default, {
|
|
166
|
-
open,
|
|
167
|
-
onOpenChange,
|
|
168
|
-
children: /* @__PURE__ */ jsxs(Dialog_default.Content, { children: [/* @__PURE__ */ jsx(Dialog_default.Heading, { children: title }), /* @__PURE__ */ jsx("div", {
|
|
169
|
-
className: styles["popup"],
|
|
170
|
-
children: createOrganizationContent
|
|
171
|
-
})] })
|
|
172
|
-
});
|
|
173
|
-
return createOrganizationContent;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
export { BaseCreateOrganization };
|
|
178
|
-
//# sourceMappingURL=BaseCreateOrganization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCreateOrganization.js","names":["logger: ReturnType<typeof createPackageComponentLogger>","BaseCreateOrganization: FC<BaseCreateOrganizationProps>","useTheme","styles: ReturnType<typeof useStyles>","useStyles","useTranslation","errors: Partial<OrganizationFormData>","payload: CreateOrganizationPayload","createOrganizationContent: ReactElement","AlertPrimitive","TextField","FormControl","InputLabel","Button","DialogPrimitive"],"sources":["../../../../src/components/presentation/CreateOrganization/BaseCreateOrganization.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {cx} from '@emotion/css';\nimport {CreateOrganizationPayload, createPackageComponentLogger, Preferences} from '@thunderid/browser';\nimport {ChangeEvent, CSSProperties, FC, FormEvent, ReactElement, ReactNode, useState} from 'react';\nimport useStyles from './BaseCreateOrganization.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport useTranslation from '../../../hooks/useTranslation';\nimport AlertPrimitive from '../../primitives/Alert/Alert';\nimport Button from '../../primitives/Button/Button';\nimport DialogPrimitive from '../../primitives/Dialog/Dialog';\nimport FormControl from '../../primitives/FormControl/FormControl';\nimport InputLabel from '../../primitives/InputLabel/InputLabel';\nimport TextField from '../../primitives/TextField/TextField';\n\nconst logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(\n '@thunderid/react',\n 'BaseCreateOrganization',\n);\n\n/**\n * Interface for organization form data.\n */\nexport interface OrganizationFormData {\n description: string;\n handle: string;\n name: string;\n}\n\n/**\n * Props interface for the BaseCreateOrganization component.\n */\nexport interface BaseCreateOrganizationProps {\n cardLayout?: boolean;\n className?: string;\n defaultParentId?: string;\n error?: string | null;\n initialValues?: Partial<OrganizationFormData>;\n loading?: boolean;\n mode?: 'inline' | 'popup';\n onCancel?: () => void;\n onOpenChange?: (open: boolean) => void;\n onSubmit?: (payload: CreateOrganizationPayload) => void | Promise<void>;\n onSuccess?: (organization: any) => void;\n open?: boolean;\n /**\n * Component-level preferences to override global i18n and theme settings.\n * Preferences are deep-merged with global ones, with component preferences\n * taking precedence. Affects this component and all its descendants.\n */\n preferences?: Preferences;\n renderAdditionalFields?: () => ReactNode;\n style?: CSSProperties;\n\n title?: string;\n}\n\n/**\n * Removes special characters except space and hyphen from the organization name\n * and generates a valid handle.\n * @param name\n * @returns\n */\nconst generateHandleFromName = (name: string): string =>\n name\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '');\n\n/**\n * BaseCreateOrganization component provides the core functionality for creating organizations.\n * This component serves as the base for framework-specific implementations.\n */\nexport const BaseCreateOrganization: FC<BaseCreateOrganizationProps> = ({\n cardLayout = true,\n className = '',\n defaultParentId = '',\n error,\n initialValues = {},\n loading = false,\n mode = 'inline',\n onCancel,\n onOpenChange,\n onSubmit,\n onSuccess,\n open = false,\n preferences,\n renderAdditionalFields,\n style,\n title = 'Create Organization',\n}: BaseCreateOrganizationProps): ReactElement => {\n const {theme, colorScheme} = useTheme();\n const styles: ReturnType<typeof useStyles> = useStyles(theme, colorScheme);\n const {t} = useTranslation(preferences?.i18n);\n const [formData, setFormData] = useState<OrganizationFormData>({\n description: '',\n handle: '',\n name: '',\n ...initialValues,\n });\n const [formErrors, setFormErrors] = useState<Partial<OrganizationFormData> & {avatar?: string}>({});\n\n const validateForm = (): boolean => {\n const errors: Partial<OrganizationFormData> = {};\n\n if (!formData.name.trim()) {\n errors.name = 'Organization name is required';\n }\n\n if (!formData.handle.trim()) {\n errors.handle = 'Organization handle is required';\n } else if (!/^[a-z0-9-]+$/.test(formData.handle)) {\n errors.handle = 'Handle can only contain lowercase letters, numbers, and hyphens';\n }\n\n if (!formData.description.trim()) {\n errors.description = 'Organization description is required';\n }\n\n setFormErrors(errors);\n return Object.keys(errors).length === 0;\n };\n\n const handleInputChange = (field: keyof OrganizationFormData, value: string): void => {\n setFormData((prev: OrganizationFormData) => ({\n ...prev,\n [field]: value,\n }));\n\n if (formErrors[field]) {\n setFormErrors((prev: Partial<OrganizationFormData> & {avatar?: string}) => ({\n ...prev,\n [field]: undefined,\n }));\n }\n };\n\n /**\n * Handles changes to the organization name input.\n * Automatically generates the organization handle based on the name if the handle is not set or matches\n *\n * @param value - The new value for the organization name.\n */\n const handleNameChange = (value: string): void => {\n handleInputChange('name', value);\n\n if (!formData.handle || formData.handle === generateHandleFromName(formData.name)) {\n const newHandle: string = generateHandleFromName(value);\n handleInputChange('handle', newHandle);\n }\n };\n\n const handleSubmit = async (e: FormEvent): Promise<void> => {\n e.preventDefault();\n\n if (!validateForm() || loading) {\n return;\n }\n\n const payload: CreateOrganizationPayload = {\n description: formData.description.trim(),\n name: formData.name.trim(),\n orgHandle: formData.handle.trim(),\n parentId: defaultParentId,\n type: 'TENANT',\n };\n\n try {\n await onSubmit?.(payload);\n if (onSuccess) {\n onSuccess(payload);\n }\n } catch (submitError) {\n // Error handling is done by parent component\n logger.error('Form submission error:');\n }\n };\n\n const createOrganizationContent: ReactElement = (\n <div className={cx(styles['root'], cardLayout && styles['card'], className)} style={style}>\n <div className={cx(styles['content'])}>\n <form id=\"create-organization-form\" className={cx(styles['form'])} onSubmit={handleSubmit}>\n {error && (\n <AlertPrimitive variant=\"error\" className={styles['errorAlert']}>\n <AlertPrimitive.Title>Error</AlertPrimitive.Title>\n <AlertPrimitive.Description>{error}</AlertPrimitive.Description>\n </AlertPrimitive>\n )}\n <div className={cx(styles['fieldGroup'])}>\n <TextField\n label={`${t('elements.fields.organization.name.label')}`}\n placeholder={t('elements.fields.organization.name.placeholder')}\n value={formData.name}\n onChange={(e: ChangeEvent<HTMLInputElement>): void => handleNameChange(e.target.value)}\n disabled={loading}\n required\n error={formErrors.name}\n className={cx(styles['input'])}\n />\n </div>\n <div className={cx(styles['fieldGroup'])}>\n <TextField\n label={`${t('elements.fields.organization.handle.label') || 'Organization Handle'}`}\n placeholder={t('elements.fields.organization.handle.placeholder') || 'my-organization'}\n value={formData.handle}\n onChange={(e: ChangeEvent<HTMLInputElement>): void => handleInputChange('handle', e.target.value)}\n disabled={loading}\n required\n error={formErrors.handle}\n helperText=\"This will be your organization's unique identifier. Only lowercase letters, numbers, and hyphens are allowed.\"\n className={cx(styles['input'])}\n />\n </div>\n <div className={cx(styles['fieldGroup'])}>\n <FormControl error={formErrors.description}>\n <InputLabel required>{t('elements.fields.organization.description.label')}</InputLabel>\n <textarea\n className={cx(styles['textarea'], formErrors.description && styles['textareaError'])}\n placeholder={t('organization.create.description.placeholder')}\n value={formData.description}\n onChange={(e: ChangeEvent<HTMLTextAreaElement>): void =>\n handleInputChange('description', e.target.value)\n }\n disabled={loading}\n required\n />\n </FormControl>\n </div>\n {renderAdditionalFields?.()}\n </form>\n <div className={cx(styles['actions'])}>\n {onCancel && (\n <Button type=\"button\" variant=\"outline\" onClick={onCancel} disabled={loading}>\n {t('organization.create.buttons.cancel.text')}\n </Button>\n )}\n <Button type=\"submit\" variant=\"solid\" color=\"primary\" disabled={loading} form=\"create-organization-form\">\n {loading\n ? t('organization.create.buttons.create_organization.loading.text')\n : t('organization.create.buttons.create_organization.text')}\n </Button>\n </div>\n </div>\n </div>\n );\n\n if (mode === 'popup') {\n return (\n <DialogPrimitive open={open} onOpenChange={onOpenChange}>\n <DialogPrimitive.Content>\n <DialogPrimitive.Heading>{title}</DialogPrimitive.Heading>\n <div className={styles['popup']}>{createOrganizationContent}</div>\n </DialogPrimitive.Content>\n </DialogPrimitive>\n );\n }\n\n return createOrganizationContent;\n};\n\nexport default BaseCreateOrganization;\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAMA,WAA0D,6BAC9D,oBACA,yBACD;;;;;;;AA6CD,MAAM,0BAA0B,SAC9B,KACG,aAAa,CACb,QAAQ,iBAAiB,GAAG,CAC5B,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,IAAI,CACnB,QAAQ,UAAU,GAAG;;;;;AAM1B,MAAaC,0BAA2D,EACtE,aAAa,MACb,YAAY,IACZ,kBAAkB,IAClB,OACA,gBAAgB,EAAE,EAClB,UAAU,OACV,OAAO,UACP,UACA,cACA,UACA,WACA,OAAO,OACP,aACA,wBACA,OACA,QAAQ,4BACuC;CAC/C,MAAM,EAAC,OAAO,gBAAeC,kBAAU;CACvC,MAAMC,SAAuCC,sCAAU,OAAO,YAAY;CAC1E,MAAM,EAAC,MAAKC,uBAAe,aAAa,KAAK;CAC7C,MAAM,CAAC,UAAU,eAAe,SAA+B;EAC7D,aAAa;EACb,QAAQ;EACR,MAAM;EACN,GAAG;EACJ,CAAC;CACF,MAAM,CAAC,YAAY,iBAAiB,SAA4D,EAAE,CAAC;CAEnG,MAAM,qBAA8B;EAClC,MAAMC,SAAwC,EAAE;AAEhD,MAAI,CAAC,SAAS,KAAK,MAAM,CACvB,QAAO,OAAO;AAGhB,MAAI,CAAC,SAAS,OAAO,MAAM,CACzB,QAAO,SAAS;WACP,CAAC,eAAe,KAAK,SAAS,OAAO,CAC9C,QAAO,SAAS;AAGlB,MAAI,CAAC,SAAS,YAAY,MAAM,CAC9B,QAAO,cAAc;AAGvB,gBAAc,OAAO;AACrB,SAAO,OAAO,KAAK,OAAO,CAAC,WAAW;;CAGxC,MAAM,qBAAqB,OAAmC,UAAwB;AACpF,eAAa,UAAgC;GAC3C,GAAG;IACF,QAAQ;GACV,EAAE;AAEH,MAAI,WAAW,OACb,gBAAe,UAA6D;GAC1E,GAAG;IACF,QAAQ;GACV,EAAE;;;;;;;;CAUP,MAAM,oBAAoB,UAAwB;AAChD,oBAAkB,QAAQ,MAAM;AAEhC,MAAI,CAAC,SAAS,UAAU,SAAS,WAAW,uBAAuB,SAAS,KAAK,CAE/E,mBAAkB,UADQ,uBAAuB,MAAM,CACjB;;CAI1C,MAAM,eAAe,OAAO,MAAgC;AAC1D,IAAE,gBAAgB;AAElB,MAAI,CAAC,cAAc,IAAI,QACrB;EAGF,MAAMC,UAAqC;GACzC,aAAa,SAAS,YAAY,MAAM;GACxC,MAAM,SAAS,KAAK,MAAM;GAC1B,WAAW,SAAS,OAAO,MAAM;GACjC,UAAU;GACV,MAAM;GACP;AAED,MAAI;AACF,SAAM,WAAW,QAAQ;AACzB,OAAI,UACF,WAAU,QAAQ;WAEb,aAAa;AAEpB,YAAO,MAAM,yBAAyB;;;CAI1C,MAAMC,4BACJ,oBAAC;EAAI,WAAW,GAAG,OAAO,SAAS,cAAc,OAAO,SAAS,UAAU;EAAS;YAClF,qBAAC;GAAI,WAAW,GAAG,OAAO,WAAW;cACnC,qBAAC;IAAK,IAAG;IAA2B,WAAW,GAAG,OAAO,QAAQ;IAAE,UAAU;;KAC1E,SACC,qBAACC;MAAe,SAAQ;MAAQ,WAAW,OAAO;iBAChD,oBAACA,cAAe,mBAAM,UAA4B,EAClD,oBAACA,cAAe,yBAAa,QAAmC;OACjD;KAEnB,oBAAC;MAAI,WAAW,GAAG,OAAO,cAAc;gBACtC,oBAACC;OACC,OAAO,GAAG,EAAE,0CAA0C;OACtD,aAAa,EAAE,gDAAgD;OAC/D,OAAO,SAAS;OAChB,WAAW,MAA2C,iBAAiB,EAAE,OAAO,MAAM;OACtF,UAAU;OACV;OACA,OAAO,WAAW;OAClB,WAAW,GAAG,OAAO,SAAS;QAC9B;OACE;KACN,oBAAC;MAAI,WAAW,GAAG,OAAO,cAAc;gBACtC,oBAACA;OACC,OAAO,GAAG,EAAE,4CAA4C,IAAI;OAC5D,aAAa,EAAE,kDAAkD,IAAI;OACrE,OAAO,SAAS;OAChB,WAAW,MAA2C,kBAAkB,UAAU,EAAE,OAAO,MAAM;OACjG,UAAU;OACV;OACA,OAAO,WAAW;OAClB,YAAW;OACX,WAAW,GAAG,OAAO,SAAS;QAC9B;OACE;KACN,oBAAC;MAAI,WAAW,GAAG,OAAO,cAAc;gBACtC,qBAACC;OAAY,OAAO,WAAW;kBAC7B,oBAACC;QAAW;kBAAU,EAAE,iDAAiD;SAAc,EACvF,oBAAC;QACC,WAAW,GAAG,OAAO,aAAa,WAAW,eAAe,OAAO,iBAAiB;QACpF,aAAa,EAAE,8CAA8C;QAC7D,OAAO,SAAS;QAChB,WAAW,MACT,kBAAkB,eAAe,EAAE,OAAO,MAAM;QAElD,UAAU;QACV;SACA;QACU;OACV;KACL,0BAA0B;;KACtB,EACP,qBAAC;IAAI,WAAW,GAAG,OAAO,WAAW;eAClC,YACC,oBAACC;KAAO,MAAK;KAAS,SAAQ;KAAU,SAAS;KAAU,UAAU;eAClE,EAAE,0CAA0C;MACtC,EAEX,oBAACA;KAAO,MAAK;KAAS,SAAQ;KAAQ,OAAM;KAAU,UAAU;KAAS,MAAK;eAC3E,UACG,EAAE,+DAA+D,GACjE,EAAE,uDAAuD;MACtD;KACL;IACF;GACF;AAGR,KAAI,SAAS,QACX,QACE,oBAACC;EAAsB;EAAoB;YACzC,qBAACA,eAAgB,sBACf,oBAACA,eAAgB,qBAAS,QAAgC,EAC1D,oBAAC;GAAI,WAAW,OAAO;aAAW;IAAgC,IAC1C;GACV;AAItB,QAAO"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
|
-
import { Theme } from '@thunderid/browser';
|
|
19
|
-
/**
|
|
20
|
-
* Creates styles for the BaseCreateOrganization component using BEM methodology
|
|
21
|
-
* @param theme - The theme object containing design tokens
|
|
22
|
-
* @param colorScheme - The current color scheme (used for memoization)
|
|
23
|
-
* @returns Object containing CSS class names for component styling
|
|
24
|
-
*/
|
|
25
|
-
declare const useStyles: (theme: Theme, colorScheme: string) => Record<string, string>;
|
|
26
|
-
export default useStyles;
|
|
27
|
-
//# sourceMappingURL=BaseCreateOrganization.styles.d.ts.map
|
package/dist/components/presentation/CreateOrganization/BaseCreateOrganization.styles.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCreateOrganization.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/presentation/CreateOrganization/BaseCreateOrganization.styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAGzC;;;;;GAKG;AACH,QAAA,MAAM,SAAS,GAAI,OAAO,KAAK,EAAE,aAAa,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAqJxE,CAAC;AAEL,eAAe,SAAS,CAAC"}
|