@niledatabase/react 1.0.0-alpha.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/GoogleLoginButton/GoogleLoginButton.d.ts +13 -0
- package/dist/GoogleLoginButton/GoogleLoginButton.stories.d.ts +12 -0
- package/dist/GoogleLoginButton/index.d.ts +1 -0
- package/dist/LoginForm/LoginForm.d.ts +3 -0
- package/dist/LoginForm/SingleSignOn.d.ts +7 -0
- package/dist/LoginForm/UserLoginForm.stories.d.ts +5 -0
- package/dist/LoginForm/index.d.ts +2 -0
- package/dist/LoginForm/types.d.ts +16 -0
- package/dist/SSO/BaseSSOForm.d.ts +8 -0
- package/dist/SSO/Okta.d.ts +3 -0
- package/dist/SSO/SSO.stories.d.ts +6 -0
- package/dist/SSO/index.d.ts +3 -0
- package/dist/SSO/types.d.ts +8 -0
- package/dist/SignUpForm/NewUserSignUp.stories.d.ts +5 -0
- package/dist/SignUpForm/SignUpForm.d.ts +3 -0
- package/dist/SignUpForm/index.d.ts +1 -0
- package/dist/SignUpForm/types.d.ts +13 -0
- package/dist/UserTenantList/CreateUser.d.ts +9 -0
- package/dist/UserTenantList/UserList.d.ts +17 -0
- package/dist/UserTenantList/UserList.stories.d.ts +5 -0
- package/dist/UserTenantList/UserModal.d.ts +8 -0
- package/dist/UserTenantList/index.d.ts +1 -0
- package/dist/UserTenantList/useDataParser.d.ts +4 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/theme.d.ts +2 -0
- package/dist/context/types.d.ts +18 -0
- package/dist/hooks/useResults.d.ts +22 -0
- package/dist/hooks/useTextSizer.d.ts +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/lib/SimpleForm/CheckGroup/index.d.ts +10 -0
- package/dist/lib/SimpleForm/index.d.ts +11 -0
- package/dist/lib/SimpleForm/types.d.ts +36 -0
- package/dist/react.cjs.development.js +2 -0
- package/dist/react.cjs.development.js.map +1 -0
- package/dist/react.cjs.production.min.js +2 -0
- package/dist/react.cjs.production.min.js.map +1 -0
- package/dist/react.esm.js +2 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/utils/getColumnSize.d.ts +2 -0
- package/package.json +117 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs.development.js","sources":["../src/context/theme.ts","../src/context/index.tsx","../src/GoogleLoginButton/google.svg","../src/lib/SimpleForm/CheckGroup/index.tsx","../src/lib/SimpleForm/types.ts","../src/lib/SimpleForm/index.tsx","../src/UserTenantList/UserModal.tsx","../src/UserTenantList/CreateUser.tsx","../src/UserTenantList/useDataParser.ts","../src/utils/getColumnSize.ts","../src/hooks/useTextSizer.ts","../src/SSO/BaseSSOForm.tsx","../src/SSO/Okta.tsx","../src/GoogleLoginButton/GoogleLoginButton.tsx","../src/LoginForm/SingleSignOn.tsx","../src/LoginForm/LoginForm.tsx","../src/SignUpForm/SignUpForm.tsx","../src/UserTenantList/UserList.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n//@ts-nocheck\nimport { extendTheme as extendJoyTheme } from '@mui/joy/styles';\n\nexport default extendJoyTheme({\n cssVarPrefix: 'joy',\n colorSchemes: {\n light: {\n palette: {\n primary: {\n '50': '#fff3e4',\n '100': '#ffe1bc',\n '200': '#ffcd92',\n '300': '#ffb96a',\n '400': '#feaa51',\n '500': '#ff9c3f',\n '600': '#f9913d',\n '700': '#f28239',\n '800': '#eb7435',\n '900': '#e05c2e',\n },\n text: {\n tertiary: 'rgba(0 0 0 / 0.56)',\n },\n },\n },\n dark: {\n palette: {\n primary: {\n '50': '#fff3e4',\n '100': '#ffe1bc',\n '200': '#ffcd92',\n '300': '#ffb96a',\n '400': '#feaa51',\n '500': '#ff9c3f',\n '600': '#f9913d',\n '700': '#f28239',\n '800': '#eb7435',\n '900': '#e05c2e',\n },\n text: {\n tertiary: 'rgba(255 255 255 / 0.5)',\n },\n },\n },\n },\n});\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\nimport React, { useMemo, createContext, useContext } from 'react';\nimport BrowserApi, { Client } from '@niledatabase/browser';\nimport { CssVarsProvider } from '@mui/joy/styles';\nimport { QueryClientProvider, QueryClient } from '@tanstack/react-query';\n\nimport defaultTheme from './theme';\nimport { NileContext, NileProviderProps, NileReactConfig } from './types';\n\nconst queryClient = new QueryClient();\n\nconst defaultContext: NileContext = {\n api: BrowserApi({\n basePath: 'https://prod.thenile.dev',\n credentials: 'include',\n }),\n basePath: '',\n};\n\nconst context = createContext<NileContext>(defaultContext);\n\nconst { Provider } = context;\n\nexport const BaseQueryProvider = ({\n children,\n}: {\n children: JSX.Element;\n}): JSX.Element => {\n return (\n <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n );\n};\n\nexport const NileProvider = (props: NileProviderProps) => {\n const {\n children,\n theme,\n tenantId,\n QueryProvider = BaseQueryProvider,\n basePath = 'https://prod.thenile.dev',\n api,\n } = props;\n\n const values = useMemo<NileContext>((): NileContext => {\n return {\n api:\n api ??\n BrowserApi({\n basePath,\n credentials: 'include',\n }),\n tenantId: String(tenantId),\n basePath,\n };\n }, [api, basePath, tenantId]);\n\n return (\n <QueryProvider>\n <CssVarsProvider defaultMode=\"system\" theme={theme ?? defaultTheme}>\n <Provider value={values}>{children}</Provider>\n </CssVarsProvider>\n </QueryProvider>\n );\n};\n\nconst useNileContext = (): NileContext => {\n return useContext(context);\n};\n\nexport const useNileConfig = (): NileReactConfig => {\n const { basePath, tenantId } = useNileContext();\n return useMemo(\n () => ({\n tenantId,\n basePath,\n }),\n [basePath, tenantId]\n );\n};\n\nexport const useApi = (): Client => {\n return useNileContext().api;\n};\n","<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\">\n <g fill=\"#000\" fill-rule=\"evenodd\">\n <path d=\"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z\" fill=\"#EA4335\" />\n <path d=\"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z\" fill=\"#4285F4\" />\n <path d=\"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z\" fill=\"#FBBC05\" />\n <path d=\"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z\" fill=\"#34A853\" />\n <path fill=\"none\" d=\"M0 0h18v18H0z\" />\n </g>\n</svg>","import * as React from 'react';\nimport Box from '@mui/joy/Box';\nimport Checkbox from '@mui/joy/Checkbox';\nimport List from '@mui/joy/List';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport Stack from '@mui/joy/Stack';\nimport FormLabel from '@mui/joy/FormLabel';\nimport ListItem from '@mui/joy/ListItem';\nimport Typography from '@mui/joy/Typography';\n\nimport { Attribute, DisplayProps, Options } from '../types';\n\ntype Props = {\n attribute: Attribute;\n display: DisplayProps;\n options: Options;\n helperText: string;\n};\nexport default function CheckGroup(props: Props) {\n const { options, attribute, display, helperText } = props;\n const { watch, control } = useFormContext();\n const currentVals = watch(attribute.name);\n const checkProps: { color?: 'danger'; id?: string } = {};\n if (helperText) {\n checkProps.color = 'danger';\n }\n return (\n <Controller\n name={attribute.name}\n rules={{ required: Boolean(attribute.required) }}\n control={control}\n render={({ field }) => {\n return (\n <Stack>\n <FormLabel htmlFor={`${field.name}`}>{display.label}</FormLabel>\n <Box\n role=\"group\"\n aria-labelledby={attribute.name}\n sx={{\n borderRadius: 'var(--joy-radius-sm)',\n p: 0.5,\n border: helperText\n ? '1px solid var(--joy-palette-danger-outlinedBorder)'\n : 'none',\n }}\n >\n <List\n orientation=\"horizontal\"\n wrap\n sx={{\n '--List-gap': '8px',\n }}\n >\n {options.map((item) => {\n checkProps.id = String(item.value);\n return (\n <ListItem key={`${item.value}-${item.label}`}>\n <Checkbox\n overlay={options.length > 1}\n {...checkProps}\n checked={currentVals.includes(item.value)}\n disableIcon={options.length > 1}\n variant=\"soft\"\n label={item.label}\n onChange={(event) => {\n if (attribute.allowMultiple) {\n if (event.target.checked) {\n if (!currentVals) {\n field.onChange([item.value]);\n } else {\n field.onChange(currentVals.concat(item.value));\n }\n } else {\n const remaining = currentVals.filter(\n (val: string | number) => val !== item.value\n );\n if (remaining.length > 0) {\n field.onChange(remaining);\n } else {\n field.onChange('');\n }\n }\n } else {\n if (event.target.checked) {\n field.onChange(item.value);\n } else {\n field.onChange('');\n }\n }\n }}\n />\n </ListItem>\n );\n })}\n </List>\n </Box>\n <Typography\n sx={{ color: 'var(--joy-palette-danger-500)' }}\n level=\"body-sm\"\n >\n {helperText}\n </Typography>\n </Stack>\n );\n }}\n />\n );\n}\n","export enum AttributeType {\n Text = 'text',\n Password = 'password',\n Select = 'select',\n Number = 'number',\n Float = 'float',\n Checkbox = 'checkbox',\n Switch = 'switch',\n}\ntype SimplePrimitive = number | string | boolean;\n\n// possibly no value for `<Switch/>`\nexport type Options = { label: string; value?: SimplePrimitive }[];\nexport type Attribute = {\n name: string;\n type?: AttributeType;\n defaultValue?: SimplePrimitive;\n options?: Options;\n allowMultiple?: boolean;\n label?: string;\n required?: boolean;\n placeholder?: string;\n helpText?: string;\n disabled?: boolean;\n};\n\nexport type DisplayProps = {\n key: string;\n id: string;\n label: string;\n placeholder: string;\n error?: boolean;\n color?: 'danger';\n disabled?: boolean;\n};\n","import React from 'react';\nimport Button from '@mui/joy/Button';\nimport { Controller, FormProvider, useForm } from 'react-hook-form';\nimport Stack from '@mui/joy/Stack';\nimport Input from '@mui/joy/Input';\nimport FormControl from '@mui/joy/FormControl';\nimport FormHelperText from '@mui/joy/FormHelperText';\nimport Error from '@mui/icons-material/Error';\nimport FormLabel from '@mui/joy/FormLabel';\nimport Select from '@mui/joy/Select';\nimport Option from '@mui/joy/Option';\nimport Box from '@mui/joy/Box';\nimport Tooltip from '@mui/joy/Tooltip';\nimport { Switch } from '@mui/joy';\n\nimport CheckGroup from './CheckGroup';\nimport { Attribute, AttributeType, DisplayProps } from './types';\n\ntype AttrMap = {\n [key: string]: string | number | boolean | string[] | number[];\n};\n\ntype FieldConfig = {\n required?: boolean;\n};\n\nexport const getAttributeDefault = (\n attribute: Attribute\n): string | number | boolean | string[] | number[] => {\n // have to look to see if it is an enum\n if (attribute.allowMultiple === true) {\n if (!Array.isArray(attribute.defaultValue) && attribute.defaultValue) {\n if (typeof attribute.defaultValue === 'number') {\n return [attribute.defaultValue];\n }\n return [String(attribute.defaultValue)];\n }\n }\n return attribute.defaultValue ?? '';\n};\n\nfunction Labler(props: { error?: string; attr: Attribute }) {\n const { error, attr } = props;\n if (error) {\n return (\n <Tooltip title={error} color=\"danger\" sx={{ cursor: 'pointer' }}>\n <FormLabel>\n {attr.label ?? attr.name}\n <Error sx={{ ml: 0.5, '--Icon-color': '#c41c1c' }} fontSize=\"small\" />\n </FormLabel>\n </Tooltip>\n );\n }\n return <FormLabel>{attr.label ?? attr.name}</FormLabel>;\n}\nexport default function SimpleForm(props: {\n buttonText: string;\n cancelButton?: React.ReactNode;\n attributes: Attribute[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mutation: any;\n loading?: boolean;\n successMessage?: JSX.Element;\n}) {\n const {\n mutation,\n buttonText,\n attributes,\n cancelButton,\n loading,\n successMessage,\n } = props;\n\n const defaultValues = React.useMemo(\n () =>\n attributes.reduce((accum: AttrMap, attr: Attribute) => {\n accum[attr.name] = getAttributeDefault(attr);\n return accum;\n }, {}),\n [attributes]\n );\n\n const methods = useForm({\n defaultValues,\n });\n\n const {\n register,\n control,\n handleSubmit,\n formState: { errors },\n } = methods;\n const onSubmit = React.useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (data: any) => {\n mutation.mutate(data);\n },\n [mutation]\n );\n\n return (\n <FormProvider {...methods}>\n <Stack\n component=\"form\"\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onSubmit={handleSubmit((data) => onSubmit(data as any))}\n spacing={2}\n >\n {attributes.map((attr: Attribute): React.ReactNode => {\n const fieldConfig: FieldConfig = {};\n const display: DisplayProps = {\n key: attr.name,\n label: attr.label ?? attr.name,\n id: attr.label ?? attr.name,\n placeholder: attr.placeholder ?? attr.label ?? attr.name,\n error: Boolean(errors[attr.name]),\n disabled: Boolean(attr.disabled),\n };\n const options = attr.options ?? [];\n const helperText = attr.helpText ?? '';\n let error = '';\n\n if (attr.required) {\n error = errors[attr.name]\n ? `${attr.label ?? attr.name} is required`\n : '';\n fieldConfig.required = true;\n }\n\n switch (attr.type) {\n case AttributeType.Switch:\n return (\n <FormControl\n key={display.key}\n id={display.id}\n orientation=\"horizontal\"\n sx={{ alignItems: 'center' }}\n >\n <Box>\n <Labler error={error} attr={attr} />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </Box>\n <Controller\n control={control}\n rules={{ required: Boolean(attr.required) }}\n name={attr.name}\n render={({ field }) => {\n const color: { color?: 'danger' } = {};\n if (errors[attr.name]) {\n color.color = 'danger';\n }\n return (\n <Switch\n id={`switch-field-${attr.name}`}\n {...color}\n {...field}\n checked={Boolean(field.value)}\n onChange={(event) => {\n field.onChange(event.target.checked);\n }}\n color={field.value ? 'success' : 'neutral'}\n endDecorator={\n field.value ? options[0].label : options[1].label\n }\n sx={{\n '--Switch-thumbSize': '28px',\n }}\n />\n );\n }}\n />\n </FormControl>\n );\n case AttributeType.Checkbox:\n return (\n <CheckGroup\n key={display.key}\n attribute={attr}\n display={display}\n options={options}\n helperText={helperText}\n />\n );\n case AttributeType.Select:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Controller\n control={control}\n rules={{ required: Boolean(attr.required) }}\n name={attr.name}\n render={({ field }) => {\n const color: { color?: 'danger' } = {};\n if (errors[attr.name]) {\n color.color = 'danger';\n }\n return (\n <Stack>\n <Select\n id={`select-field-${attr.name}`}\n placeholder={`${display.placeholder}...`}\n {...color}\n {...field}\n onChange={(_, newValue) => {\n field.onChange(newValue);\n }}\n >\n {options.map((option) => {\n return (\n <Option\n key={String(option.value ?? '')}\n value={option.value}\n >\n {option.label}\n </Option>\n );\n })}\n </Select>\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </Stack>\n );\n }}\n />\n </FormControl>\n );\n case AttributeType.Password:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input\n {...display}\n {...register(attr.name, fieldConfig)}\n type={AttributeType.Password}\n />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n case AttributeType.Number:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input\n {...display}\n {...register(attr.name, fieldConfig)}\n type={AttributeType.Number}\n />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n\n case AttributeType.Text:\n default:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input {...display} {...register(attr.name, fieldConfig)} />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n }\n })}\n {cancelButton ? (\n <Stack spacing={2} direction=\"row\">\n {cancelButton}\n <Box>\n <Button type=\"submit\">{buttonText}</Button>\n </Box>\n </Stack>\n ) : (\n <Box>\n <Stack direction=\"row\" gap={2}>\n <Button type=\"submit\" loading={loading}>\n {buttonText}\n </Button>\n {successMessage}\n </Stack>\n </Box>\n )}\n </Stack>\n </FormProvider>\n );\n}\n","import React from 'react';\nimport {\n Button,\n Stack,\n Typography,\n FormControl,\n FormLabel,\n Input,\n Modal,\n ModalDialog,\n} from '@mui/joy';\nimport { useForm } from 'react-hook-form';\nimport { useMutation } from '@tanstack/react-query';\nimport { SignUp201Response, SignUpRequest } from '@niledatabase/browser';\n\nimport { useApi } from '../context';\n\nexport type UserFormProps = {\n open: boolean;\n setOpen: (open: boolean) => void;\n refetch?: (user: SignUp201Response) => void;\n};\n\nexport default function AddUser(props: UserFormProps) {\n const { open, setOpen, refetch } = props;\n const api = useApi();\n const [errorText, setErrorText] = React.useState<void | string>();\n const { watch, register, handleSubmit } = useForm<SignUpRequest>();\n const email = watch('email');\n\n React.useEffect(() => {\n if (errorText != null) {\n setErrorText();\n }\n // if email changes, no more error\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [email]);\n\n const mutation = useMutation(\n (data: SignUpRequest) =>\n api.users.createTenantUser({ signUpRequest: data }),\n {\n onSuccess(data) {\n refetch && refetch(data);\n setOpen(false);\n },\n onError(e) {\n if (e instanceof Error) {\n setErrorText(e.message);\n }\n },\n }\n );\n\n const handleUpdate = React.useCallback(\n async (data: SignUpRequest) => {\n setErrorText('');\n mutation.mutate(data);\n },\n [mutation]\n );\n\n return (\n <Modal open={open}>\n <ModalDialog>\n <Stack spacing={2}>\n <Typography level=\"h4\">Create user</Typography>\n <>\n {errorText && <Typography color=\"danger\">{errorText}</Typography>}\n </>\n <Stack\n component=\"form\"\n sx={{\n width: '40ch',\n }}\n spacing={1}\n onSubmit={handleSubmit((data) =>\n handleUpdate(data as SignUpRequest)\n )}\n >\n <FormControl\n sx={{\n '--FormHelperText-color': 'var(--joy-palette-danger-500)',\n }}\n >\n <FormLabel htmlFor=\"email\">Email</FormLabel>\n <Input\n {...register('email')}\n fullWidth\n size=\"lg\"\n id=\"email\"\n name=\"email\"\n autoComplete=\"current-email\"\n required\n error={Boolean(errorText)}\n />\n </FormControl>\n <FormControl\n sx={{\n '--FormHelperText-color': 'var(--joy-palette-danger-500)',\n }}\n >\n <FormLabel htmlFor=\"password\">Password</FormLabel>\n <Input\n {...register('password')}\n fullWidth\n size=\"lg\"\n id=\"password\"\n autoComplete=\"current-password\"\n type=\"password\"\n required\n />\n </FormControl>\n <Stack direction=\"row\" sx={{ pt: 2 }} spacing={2}>\n <Button onClick={() => setOpen(false)} variant=\"plain\">\n Cancel\n </Button>\n <Button type=\"submit\">Create</Button>\n </Stack>\n </Stack>\n </Stack>\n </ModalDialog>\n </Modal>\n );\n}\n","import React from 'react';\nimport Button from '@mui/joy/Button';\nimport Stack from '@mui/joy/Stack';\nimport { useState } from 'react';\nimport Add from '@mui/icons-material/Add';\nimport { SignUp201Response } from '@niledatabase/browser';\n\nimport UserModal from './UserModal';\n\ntype Props = {\n allowCreation: boolean;\n buttonText: string;\n onUserCreateSuccess?: (user: SignUp201Response) => void;\n};\nexport default function CreateUser(props: Props) {\n const { allowCreation, buttonText, onUserCreateSuccess } = props;\n const [open, setOpen] = useState(false);\n if (!allowCreation) {\n return null;\n }\n\n return (\n <Stack alignItems=\"flex-end\" gap={1}>\n <UserModal open={open} setOpen={setOpen} refetch={onUserCreateSuccess} />\n <Button startDecorator={<Add />} size=\"sm\" onClick={() => setOpen(true)}>\n {buttonText}\n </Button>\n </Stack>\n );\n}\n","import { useMemo } from 'react';\nimport { GridColDef, GridRowsProp } from '@mui/x-data-grid';\nimport { IdentifyUser200Response } from '@niledatabase/browser';\n\nimport getColumnSize from '../utils/getColumnSize';\nimport useTextSizer from '../hooks/useTextSizer';\n\nexport const internalRowId = '_nile_data_grid_identifier';\n\ntype Cleaned = { [key: string]: string | Set<string> };\n\nconst makeRenderable = (vals: IdentifyUser200Response) => {\n return Object.keys(vals).reduce((cleaned: Cleaned, key) => {\n const val = (vals as Cleaned)[key];\n if (val instanceof Set) {\n cleaned[key] = Array.from(val).join(', ');\n } else if (Array.isArray(val)) {\n cleaned[key] = val.join(', ');\n } else {\n cleaned[key] = val;\n }\n return cleaned;\n }, {});\n};\n\nconst parseResults = (\n data: void | IdentifyUser200Response[],\n ctx: CanvasRenderingContext2D | void,\n include: string[]\n): [GridColDef[], GridRowsProp] => {\n if (!data) {\n return [[], []];\n }\n const rows = data.map(makeRenderable);\n const fields = Object.keys(rows[0]);\n\n const existentCols: { [key: string]: number } = {};\n\n const mapCols = (col: string): GridColDef | void => {\n const width = getColumnSize(col, rows, ctx);\n const name = col.slice();\n if (include.includes(name)) {\n // add spaces to the end of column names so they are not duplicated in the UI\n if (existentCols[name] == null) {\n existentCols[name] = name.length;\n } else {\n existentCols[name] += 1;\n }\n return {\n field: name.padEnd(existentCols[name]),\n headerName: name.padEnd(existentCols[name]),\n width,\n };\n }\n };\n const cols = fields?.map(mapCols).filter(Boolean) ?? [];\n\n return [cols as GridColDef[], rows];\n};\n\nexport default function useDataParser(\n data: void | IdentifyUser200Response[],\n include: string[]\n): [GridColDef[], GridRowsProp] {\n const ctx = useTextSizer();\n const [cols, rows] = useMemo(\n () => parseResults(data, ctx, include),\n [data, ctx, include]\n );\n return [cols, rows];\n}\n","import { GridRowsProp } from '@mui/x-data-grid';\nimport isNull from 'lodash/isNull';\nimport isUndefined from 'lodash/isUndefined';\n\nexport default function getColumnSize(\n column: unknown,\n rows: GridRowsProp,\n canvasContext: void | CanvasRenderingContext2D\n) {\n const dataWidthReducer = (\n longest: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextRow: { [key: string]: any }\n ) => {\n let value = nextRow[String(column)];\n if (isNull(value) || isUndefined(value)) {\n value = '';\n }\n value = value?.toString();\n return longest.length > value.length ? longest : value;\n };\n\n let columnHeaderLen =\n canvasContext && column\n ? canvasContext.measureText(String(column)).width\n : 50;\n /* padding 12, icon-width 15 */\n columnHeaderLen += 15 + 12;\n\n let width = columnHeaderLen;\n width =\n 16 +\n Math.ceil(\n canvasContext\n ? canvasContext.measureText(rows.reduce(dataWidthReducer, '')).width\n : 50\n );\n if (width < columnHeaderLen) {\n width = columnHeaderLen;\n }\n /* Gracefull */\n width += 8;\n return width;\n}\n","import { useEffect, useState } from 'react';\n\nexport default function useTextSizer() {\n const [ctx, setCtx] = useState<CanvasRenderingContext2D>();\n useEffect(() => {\n const canvas = document.createElement('canvas');\n const canvasContext = canvas.getContext('2d');\n if (canvasContext) {\n canvasContext.font = '18px Roboto';\n setCtx(canvasContext);\n }\n }, []);\n return ctx;\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport { UpdateProviderRequest, SSOProvider } from '@niledatabase/browser';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\nimport Alert from '@mui/joy/Alert';\nimport CheckCircleOutlined from '@mui/icons-material/CheckCircleOutlined';\n\nimport SimpleForm from '../lib/SimpleForm';\nimport { useApi } from '../context';\nimport { Attribute, AttributeType } from '../lib/SimpleForm/types';\n\nimport { OktaProps } from './types';\n\ntype SSOFormRequest = Omit<UpdateProviderRequest, 'emailDomains'> & {\n emailDomains: string;\n};\nexport default function BaseSSOForm(\n props: Omit<OktaProps, 'callbackUrl' | 'providers'> & {\n providerName: string;\n configurationGuide: JSX.Element;\n config: SSOProvider;\n }\n) {\n const {\n config,\n providerName,\n onSuccess,\n onError,\n allowEdit = true,\n configurationGuide,\n } = props;\n\n const api = useApi();\n const [loading, setLoading] = React.useState(false);\n const [success, setSuccess] = React.useState(false);\n const [optimisticConfig, setConfig] = React.useState<SSOProvider>(config);\n const timer = React.useRef<NodeJS.Timeout>();\n const attributes = React.useMemo(() => {\n const attributes: Attribute[] = [\n {\n name: 'enabled',\n label: 'Allow Okta logins',\n type: AttributeType.Switch,\n defaultValue: optimisticConfig?.enabled === true,\n options: [\n {\n label: 'Enabled',\n },\n {\n label: 'Disabled',\n },\n ],\n disabled: !allowEdit,\n },\n {\n name: 'clientId',\n label: 'Client id',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.clientId ?? '',\n required: true,\n disabled: !allowEdit,\n },\n {\n name: 'configUrl',\n label: 'Config url',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.configUrl ?? '',\n helpText:\n 'The URL of the .well-known/openid-configuration for the identity provider',\n required: true,\n disabled: !allowEdit,\n },\n {\n name: 'emailDomains',\n label: 'Email domains',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.emailDomains?.join(', ') ?? '',\n required: true,\n helpText:\n 'A comma seperated list of email domains (yourDomain.com) to be used',\n disabled: !allowEdit,\n },\n ];\n if (!optimisticConfig?.clientId) {\n attributes.splice(2, 0, {\n name: 'clientSecret',\n label: 'Client secret',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n disabled: !allowEdit,\n });\n }\n return attributes;\n }, [\n allowEdit,\n optimisticConfig?.clientId,\n optimisticConfig?.configUrl,\n optimisticConfig?.emailDomains,\n optimisticConfig?.enabled,\n ]);\n\n const handleTimer = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n\n timer.current = setTimeout(() => {\n setSuccess(false);\n }, 3000);\n };\n\n const mutation = useMutation(\n (ssoRequest: SSOFormRequest) => {\n setLoading(true);\n const payload = {\n providerName: providerName.toLowerCase(),\n updateProviderRequest: {\n ...ssoRequest,\n emailDomains: ssoRequest.emailDomains.split(','),\n },\n };\n if (optimisticConfig != null) {\n return api.auth.updateProvider(payload);\n } else {\n return api.auth.createProvider(payload);\n }\n },\n {\n onSuccess: (data, vars) => {\n setConfig(data);\n setSuccess(true);\n onSuccess && onSuccess(data, vars);\n },\n onError,\n onSettled: (data, error, vars) => {\n setLoading(false);\n handleTimer();\n if (!data) {\n if (!error || error?.message.includes('Unterminated string')) {\n // something unexpected happened on the BE, but it's non-fatal\n setConfig({\n enabled: vars.enabled,\n clientId: vars.clientId,\n configUrl: vars.configUrl,\n emailDomains: vars.emailDomains.split(', '),\n } as SSOProvider);\n }\n setSuccess(true);\n onSuccess && onSuccess(data, vars);\n }\n },\n }\n );\n\n React.useEffect(() => {\n () => {\n clearTimeout(timer.current);\n };\n });\n\n return (\n <Stack gap={2} position=\"relative\">\n <Typography level=\"h4\">Step 1</Typography>\n {configurationGuide}\n <Typography level=\"h4\">Step 2</Typography>\n <SimpleForm\n mutation={mutation}\n buttonText=\"Update\"\n attributes={attributes}\n loading={loading}\n successMessage={\n <Alert\n color=\"success\"\n sx={{\n opacity: success ? 1 : 0,\n transition: 'opacity 200ms',\n height: '0.9rem',\n }}\n startDecorator={<CheckCircleOutlined />}\n >\n <Typography textAlign=\"center\" fontSize=\"sm\">\n Provider updated\n </Typography>\n </Alert>\n }\n />\n </Stack>\n );\n}\n","import React from 'react';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\nimport Box from '@mui/joy/Box';\nimport Input from '@mui/joy/Input';\nimport CopyAll from '@mui/icons-material/CopyAll';\nimport { Theme } from '@mui/joy/styles';\nimport Tooltip from '@mui/joy/Tooltip';\nimport CheckCircleOutlined from '@mui/icons-material/CheckCircleOutlined';\nimport { SSOProvider } from '@niledatabase/browser';\n\nimport BaseSSOForm from './BaseSSOForm';\nimport { OktaProps } from './types';\n\nfunction ConfigGuide({ callbackUrl }: { callbackUrl: string }) {\n const [copied, setCopied] = React.useState(false);\n\n const timer = React.useRef<NodeJS.Timeout>();\n React.useEffect(() => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n timer.current = setTimeout(() => {\n setCopied(false);\n }, 3250);\n () => {\n clearTimeout(timer.current);\n };\n }, [copied]);\n return (\n <Stack gap={2}>\n <Typography>\n In order for Okta to redirect properly, provide the following URL as the{' '}\n <Box component=\"span\" sx={{ fontFamily: 'monospace' }}>\n Sign-in redirect URIs\n </Box>{' '}\n in the admin configuration of your application.\n </Typography>\n <Input\n onClick={async () => {\n await navigator.clipboard.writeText(callbackUrl);\n setCopied(true);\n }}\n sx={(theme: Theme) => ({\n input: {\n cursor: 'pointer',\n },\n span: {\n cursor: 'pointer',\n },\n '&:hover svg': {\n '--Icon-color': theme.palette.primary[500],\n },\n })}\n value={callbackUrl}\n readOnly={true}\n endDecorator={\n <Tooltip title=\"Copy Okta redirect URL\">\n <Box\n position=\"relative\"\n width={copied ? '82px' : '24px'}\n height=\"24px\"\n >\n <Box\n position=\"absolute\"\n top=\"0\"\n left=\"0\"\n sx={{\n opacity: copied ? 0 : 1,\n transition: 'opacity 300ms',\n }}\n >\n <CopyAll />\n </Box>\n <Box\n position=\"absolute\"\n top=\"0\"\n left=\"0\"\n sx={{ opacity: !copied ? 0 : 1, transition: 'opacity 300ms' }}\n >\n <Stack direction=\"row\" gap={1}>\n <CheckCircleOutlined />\n <Typography color=\"primary\">Copied!</Typography>\n </Stack>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Stack>\n );\n}\n\nexport default function Okta(props: OktaProps) {\n const { callbackUrl, providers, ...remaining } = props;\n if (!providers) {\n return null;\n }\n const config = providers?.find((provider) => provider.provider === 'okta');\n return (\n <BaseSSOForm\n {...remaining}\n config={config as SSOProvider}\n providerName=\"Okta\"\n configurationGuide={<ConfigGuide callbackUrl={callbackUrl} />}\n />\n );\n}\n","import React from 'react';\nimport Box from '@mui/joy/Box';\nimport Button from '@mui/joy/Button';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\n\nimport { useNileConfig } from '../context';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport GoogleLogo from './google.svg';\n\nconst LOGIN_PATH = 'users/oidc/google/login';\n\n/**\n * A component for a Google login button, according to their design language.\n * This works when an identity provider is configured in the admin dashboard.\n * @param props href: a string to override the URL provided by the context\n * @returns a JSX.Element to render\n */\nexport default function GoogleSSOButton(props: {\n href?: string;\n workspace?: string;\n database?: string;\n newTenantName?: string;\n}) {\n const { workspace, database, newTenantName } = props;\n const { basePath } = useNileConfig();\n const encodedWorkspace = encodeURIComponent(workspace ?? '');\n const encodedDatabase = encodeURIComponent(database ?? '');\n const contextHref = `${basePath}/workspaces/${encodedWorkspace}/databases/${encodedDatabase}/${LOGIN_PATH}`;\n const query = newTenantName\n ? '?newTenant=' + encodeURIComponent(newTenantName)\n : '';\n const href = (props?.href ?? contextHref) + query;\n return (\n <Box\n component=\"a\"\n href={href}\n display=\"flex\"\n flex={1}\n sx={{ textDecoration: 'none' }}\n >\n <Box>\n <Button\n sx={{ padding: 0, textTransform: 'initial', flex: 1 }}\n aria-label=\"log in with google\"\n >\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n p={0}\n flex={1}\n fontFamily=\"Roboto, sans-serif\"\n fontSize=\"14px\"\n display=\"inline-flex\"\n color=\"rgb(255 255, 255)\"\n boxShadow=\"rgb(0 0 0 / 24%) 0px 2px 2px 0px rgb(0 0 0 / 24%) 0px 0px 1px 0px\"\n borderRadius=\"4px\"\n border=\"1px solid transparent\"\n fontWeight=\"500\"\n sx={{\n backgroundColor: 'rgb(66 133, 244)',\n }}\n >\n <Box\n padding=\"11px\"\n display=\"flex\"\n border=\"1px solid rgb(66, 133, 244)\"\n borderRadius=\"4px\"\n sx={{\n background: 'rgb(255, 255, 255)',\n }}\n >\n <GoogleLogo aria-hidden=\"true\" />\n </Box>\n <Box padding=\"10px\" flex={1}>\n <Typography\n sx={{ color: 'white' }}\n fontWeight={700}\n fontFamily=\"Roboto, sans-serif\"\n fontSize=\"14px\"\n height=\"20px\"\n >\n Continue with Google\n </Typography>\n </Box>\n </Stack>\n </Button>\n </Box>\n </Box>\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\n\nimport { Attribute } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\nimport SimpleForm from '../lib/SimpleForm';\nimport { AttributeType } from '../lib/SimpleForm/types';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function SingleSignOnForm(\n props: Props & {\n nextButtonText?: string;\n loginButtonText?: string;\n onSuccess: () => void;\n }\n) {\n const {\n attributes,\n onSuccess,\n onError,\n beforeMutate,\n nextButtonText = 'Next',\n loginButtonText = 'Log in',\n disableSSO = false,\n } = props;\n const api = useApi();\n const [buttonText, setButtonText] = React.useState(\n disableSSO ? loginButtonText : nextButtonText\n );\n\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n return await api.auth.login({\n loginRequest: { email: data.email, password: data.password },\n sso: !disableSSO,\n });\n },\n {\n onSuccess: (token, data) => {\n if (token) {\n if (token?.redirectURI) {\n window.location.href = token.redirectURI;\n } else if (buttonText !== loginButtonText) {\n setButtonText(loginButtonText);\n } else {\n onSuccess && onSuccess(token, data);\n }\n }\n },\n onError: (error, data) => {\n // it is possible SSO failed, so only show errors on if the password is available\n if (buttonText === loginButtonText) {\n onError && onError(error as Error, data);\n } else {\n setButtonText(loginButtonText);\n }\n },\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n ];\n if (buttonText === loginButtonText) {\n mainAttributes.push({\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n });\n }\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes, buttonText, loginButtonText]);\n\n return (\n <SimpleForm\n mutation={mutation}\n buttonText={buttonText}\n attributes={completeAttributes}\n />\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport Alert from '@mui/joy/Alert';\nimport Stack from '@mui/joy/Stack';\n\nimport { Attribute } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\nimport SimpleForm from '../lib/SimpleForm';\nimport { AttributeType } from '../lib/SimpleForm/types';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function LoginForm(props: Props) {\n const [error, setError] = React.useState<string | void>();\n const { attributes, onSuccess, onError, beforeMutate } = props;\n const api = useApi();\n\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n setError(undefined);\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n return await api.auth.login({\n loginRequest: data,\n });\n },\n {\n onSuccess,\n onError,\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n {\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n },\n ];\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes]);\n\n return (\n <Stack gap={2}>\n {error ? <Alert color=\"danger\">{error}</Alert> : null}\n <SimpleForm\n mutation={mutation}\n buttonText=\"Log in\"\n attributes={completeAttributes}\n />\n </Stack>\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport Stack from '@mui/joy/Stack';\nimport Alert from '@mui/joy/Alert';\n\nimport UserForm from '../lib/SimpleForm';\nimport { Attribute, AttributeType } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function SignUpForm(props: Props) {\n const [error, setError] = React.useState<string | void>();\n const {\n buttonText = 'Sign up',\n onSuccess,\n onError,\n attributes,\n beforeMutate,\n } = props;\n const api = useApi();\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n setError(undefined);\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n const { email, password, preferredName, newTenant, ...metadata } = data;\n if (Object.keys(metadata).length > 0) {\n // eslint-disable-next-line no-console\n console.warn('additional metadata not supported yet.');\n }\n return api.auth.signUp({\n signUpRequest: { email, password, preferredName, newTenant },\n });\n },\n {\n onSuccess,\n onError: (e: Error, vars) => {\n setError(e.message);\n onError && onError(e as Error, vars);\n },\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n {\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n },\n ];\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes]);\n\n return (\n <Stack gap={2}>\n {error ? <Alert color=\"danger\">{error}</Alert> : null}\n <UserForm\n mutation={mutation}\n buttonText={buttonText}\n attributes={completeAttributes}\n />\n </Stack>\n );\n}\n","import { DataGrid } from '@mui/x-data-grid';\nimport React from 'react';\nimport Stack from '@mui/joy/Stack';\nimport {\n IdentifyUser200Response,\n SignUp201Response,\n} from '@niledatabase/browser';\nimport { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';\nimport { Theme } from '@mui/system/createTheme';\n\nimport CreateUser from './CreateUser';\nimport useDataParser from './useDataParser';\n\ntype ColumnNames = string;\n\ntype Props = {\n data: void | IdentifyUser200Response[];\n allowCreation?: boolean;\n buttonText?: string;\n onUserCreateSuccess?: (user: SignUp201Response) => void;\n slots?: {\n dataGrid?: SxProps<Theme>;\n };\n // white list of columns to show\n include?: ColumnNames[];\n};\n\nexport default function UserList(props: Props) {\n const {\n data,\n allowCreation = true,\n buttonText = 'Add a user',\n onUserCreateSuccess,\n slots,\n include = ['email', 'preferedName'],\n } = props;\n\n const dataGridSx = {\n width: '100%',\n height: '100%',\n ...(slots?.dataGrid ?? {}),\n };\n\n const [columns, rows] = useDataParser(data, include);\n return (\n <Stack flex={1}>\n <CreateUser\n allowCreation={allowCreation}\n buttonText={buttonText}\n onUserCreateSuccess={onUserCreateSuccess}\n />\n <DataGrid\n sx={dataGridSx}\n rows={rows}\n columns={columns}\n hideFooter={true}\n />\n </Stack>\n );\n}\n"],"names":["extendJoyTheme","cssVarPrefix","colorSchemes","light","palette","primary","text","tertiary","dark","queryClient","QueryClient","defaultContext","api","BrowserApi","basePath","credentials","context","createContext","Provider","BaseQueryProvider","children","React","QueryClientProvider","client","useNileContext","useContext","useApi","_g","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","this","SvgGoogle","props","React.createElement","xmlns","width","height","fillRule","fill","d","CheckGroup","options","attribute","display","helperText","watch","control","useFormContext","currentVals","name","checkProps","color","Controller","rules","required","Boolean","render","field","Stack","FormLabel","htmlFor","label","Box","role","sx","borderRadius","p","border","List","orientation","wrap","map","item","id","String","value","ListItem","Checkbox","overlay","checked","includes","disableIcon","variant","onChange","event","allowMultiple","concat","remaining","filter","val","Typography","level","AttributeType","getAttributeDefault","Array","isArray","defaultValue","Labler","error","attr","Tooltip","title","cursor","Error","ml","fontSize","SimpleForm","mutation","buttonText","attributes","cancelButton","loading","successMessage","defaultValues","useMemo","reduce","accum","methods","useForm","register","handleSubmit","formState","errors","onSubmit","useCallback","data","mutate","FormProvider","component","spacing","fieldConfig","placeholder","disabled","helpText","type","Switch","FormControl","alignItems","FormHelperText","endDecorator","Select","_","newValue","option","Option","Password","Input","Number","Text","direction","Button","gap","AddUser","open","setOpen","refetch","errorText","setErrorText","useState","email","useEffect","useMutation","users","createTenantUser","signUpRequest","onSuccess","onError","e","message","handleUpdate","async","Modal","ModalDialog","fullWidth","size","autoComplete","pt","onClick","CreateUser","allowCreation","onUserCreateSuccess","UserModal","startDecorator","Add","makeRenderable","vals","keys","cleaned","Set","from","join","parseResults","ctx","include","rows","fields","existentCols","cols","col","column","canvasContext","columnHeaderLen","measureText","Math","ceil","longest","nextRow","isNull","isUndefined","toString","getColumnSize","slice","padEnd","headerName","useDataParser","setCtx","document","createElement","getContext","font","useTextSizer","BaseSSOForm","config","providerName","allowEdit","configurationGuide","setLoading","success","setSuccess","optimisticConfig","setConfig","timer","useRef","enabled","clientId","configUrl","emailDomains","splice","ssoRequest","payload","toLowerCase","updateProviderRequest","split","auth","updateProvider","createProvider","vars","onSettled","current","clearTimeout","setTimeout","position","Alert","opacity","transition","CheckCircleOutlined","textAlign","ConfigGuide","callbackUrl","copied","setCopied","fontFamily","navigator","clipboard","writeText","theme","input","span","readOnly","top","left","CopyAll","workspace","database","newTenantName","tenantId","useNileConfig","contextHref","encodeURIComponent","query","href","flex","textDecoration","padding","textTransform","boxShadow","fontWeight","backgroundColor","background","GoogleLogo","QueryProvider","values","CssVarsProvider","defaultMode","defaultTheme","providers","find","provider","beforeMutate","nextButtonText","loginButtonText","disableSSO","setButtonText","_data","login","loginRequest","password","sso","token","redirectURI","window","location","completeAttributes","mainAttributes","push","setError","undefined","preferredName","newTenant","metadata","console","warn","signUp","UserForm","slots","dataGridSx","dataGrid","columns","DataGrid","hideFooter"],"mappings":"ykCAIeA,cAAe,CAC5BC,aAAc,MACdC,aAAc,CACZC,MAAO,CACLC,QAAS,CACPC,QAAS,CACP,GAAM,UACN,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,WAETC,KAAM,CACJC,SAAU,wBAIhBC,KAAM,CACJJ,QAAS,CACPC,QAAS,CACP,GAAM,UACN,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,WAETC,KAAM,CACJC,SAAU,gCChCpB,MAAME,EAAc,IAAIC,cAElBC,EAA8B,CAClCC,IAAKC,EAAW,CACdC,SAAU,2BACVC,YAAa,YAEfD,SAAU,IAGNE,EAAUC,gBAA2BN,IAErCO,SAAEA,GAAaF,EAERG,EAAoB,EAC/BC,cAKEC,gBAACC,uBAAoBC,OAAQd,GAAcW,GAoCzCI,EAAiB,IACdC,aAAWT,GAcPU,EAAS,IACbF,IAAiBZ,ICjF1B,IAAIe,EACJ,SAASC,IAAiS,OAApRA,EAAWC,OAAOC,OAASD,OAAOC,OAAOC,OAAS,SAAUC,GAAU,IAAK,IAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAAK,CAAE,IAAIG,EAASF,UAAUD,GAAI,IAAK,IAAII,KAAOD,EAAcP,OAAOS,UAAUC,eAAeC,KAAKJ,EAAQC,KAAQL,EAAOK,GAAOD,EAAOC,IAAY,OAAOL,GAAkBJ,EAASa,MAAMC,KAAMR,WAEtU,IAAIS,EAAY,SAAmBC,GACjC,OAAoBC,gBAAoB,MAAOjB,EAAS,CACtDkB,MAAO,6BAC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AAIvE,WACpBA,EAAa,aAAYwE,oBACzBA,EAAmBgJ,MACnBA,EAAKnI,QACLA,EAAU,CAAC,QAAS,iBAClBjK,EAEEqS,EAAa,CACjBlS,MAAO,OACPC,OAAQ,UACJgS,GAAOE,UAAY,KAGlBC,EAASrI,GAAQoB,EAAczF,EAAMoE,GAC5C,OACExL,gBAACiD,GAAM+N,KAAM,GACXhR,gBAACyK,GACCC,cAAeA,EACfvE,WAAYA,EACZwE,oBAAqBA,IAEvB3K,gBAAC+T,YACCxQ,GAAIqQ,EACJnI,KAAMA,EACNqI,QAASA,EACTE,YAAY,IAIpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t),a=e(require("@niledatabase/browser")),n=require("@mui/joy/styles"),o=require("@tanstack/react-query"),l=e(require("@mui/joy/Box")),i=e(require("@mui/joy/Button")),s=e(require("@mui/joy/Stack")),c=e(require("@mui/joy/Typography")),u=e(require("@mui/joy/Alert")),m=require("react-hook-form"),d=e(require("@mui/joy/Input")),p=e(require("@mui/joy/FormControl")),b=e(require("@mui/joy/FormHelperText")),f=e(require("@mui/icons-material/Error")),g=e(require("@mui/joy/FormLabel")),h=e(require("@mui/joy/Select")),x=e(require("@mui/joy/Option")),E=e(require("@mui/joy/Tooltip")),y=require("@mui/joy"),w=e(require("@mui/joy/Checkbox")),T=e(require("@mui/joy/List")),v=e(require("@mui/joy/ListItem")),S=require("@mui/x-data-grid"),C=e(require("@mui/icons-material/Add")),q=e(require("lodash/isNull")),k=e(require("lodash/isUndefined")),F=e(require("@mui/icons-material/CopyAll")),j=e(require("@mui/icons-material/CheckCircleOutlined")),A=n.extendTheme({cssVarPrefix:"joy",colorSchemes:{light:{palette:{primary:{50:"#fff3e4",100:"#ffe1bc",200:"#ffcd92",300:"#ffb96a",400:"#feaa51",500:"#ff9c3f",600:"#f9913d",700:"#f28239",800:"#eb7435",900:"#e05c2e"},text:{tertiary:"rgba(0 0 0 / 0.56)"}}},dark:{palette:{primary:{50:"#fff3e4",100:"#ffe1bc",200:"#ffcd92",300:"#ffb96a",400:"#feaa51",500:"#ff9c3f",600:"#f9913d",700:"#f28239",800:"#eb7435",900:"#e05c2e"},text:{tertiary:"rgba(255 255 255 / 0.5)"}}}}});const P=new o.QueryClient,O={api:a({basePath:"https://prod.thenile.dev",credentials:"include"}),basePath:""},M=t.createContext(O),{Provider:U}=M,I=({children:e})=>r.createElement(o.QueryClientProvider,{client:P},e),R=()=>t.useContext(M),V=()=>R().api;var B;function L(){return L=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},L.apply(this,arguments)}var D=function(e){return t.createElement("svg",L({xmlns:"http://www.w3.org/2000/svg",width:18,height:18},e),B||(B=t.createElement("g",{fillRule:"evenodd"},t.createElement("path",{fill:"#EA4335",d:"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z"}),t.createElement("path",{fill:"#4285F4",d:"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z"}),t.createElement("path",{fill:"#FBBC05",d:"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z"}),t.createElement("path",{fill:"#34A853",d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z"}),t.createElement("path",{fill:"none",d:"M0 0h18v18H0z"}))))};function z(e){const{options:r,attribute:a,display:n,helperText:o}=e,{watch:i,control:u}=m.useFormContext(),d=i(a.name),p={};return o&&(p.color="danger"),t.createElement(m.Controller,{name:a.name,rules:{required:Boolean(a.required)},control:u,render:({field:e})=>t.createElement(s,null,t.createElement(g,{htmlFor:`${e.name}`},n.label),t.createElement(l,{role:"group","aria-labelledby":a.name,sx:{borderRadius:"var(--joy-radius-sm)",p:.5,border:o?"1px solid var(--joy-palette-danger-outlinedBorder)":"none"}},t.createElement(T,{orientation:"horizontal",wrap:!0,sx:{"--List-gap":"8px"}},r.map((n=>(p.id=String(n.value),t.createElement(v,{key:`${n.value}-${n.label}`},t.createElement(w,Object.assign({overlay:r.length>1},p,{checked:d.includes(n.value),disableIcon:r.length>1,variant:"soft",label:n.label,onChange:t=>{if(a.allowMultiple)if(t.target.checked)d?e.onChange(d.concat(n.value)):e.onChange([n.value]);else{const t=d.filter((e=>e!==n.value));t.length>0?e.onChange(t):e.onChange("")}else t.target.checked?e.onChange(n.value):e.onChange("")}})))))))),t.createElement(c,{sx:{color:"var(--joy-palette-danger-500)"},level:"body-sm"},o))})}var $;($=exports.FormAttributeType||(exports.FormAttributeType={})).Text="text",$.Password="password",$.Select="select",$.Number="number",$.Float="float",$.Checkbox="checkbox",$.Switch="switch";const N=e=>!0===e.allowMultiple&&!Array.isArray(e.defaultValue)&&e.defaultValue?"number"==typeof e.defaultValue?[e.defaultValue]:[String(e.defaultValue)]:e.defaultValue??"";function G(e){const{error:t,attr:a}=e;return t?r.createElement(E,{title:t,color:"danger",sx:{cursor:"pointer"}},r.createElement(g,null,a.label??a.name,r.createElement(f,{sx:{ml:.5,"--Icon-color":"#c41c1c"},fontSize:"small"}))):r.createElement(g,null,a.label??a.name)}function H(e){const{mutation:t,buttonText:a,attributes:n,cancelButton:o,loading:c,successMessage:u}=e,f=r.useMemo((()=>n.reduce(((e,t)=>(e[t.name]=N(t),e)),{})),[n]),g=m.useForm({defaultValues:f}),{register:E,control:w,handleSubmit:T,formState:{errors:v}}=g,S=r.useCallback((e=>{t.mutate(e)}),[t]);return r.createElement(m.FormProvider,Object.assign({},g),r.createElement(s,{component:"form",onSubmit:T((e=>S(e))),spacing:2},n.map((e=>{const t={},a={key:e.name,label:e.label??e.name,id:e.label??e.name,placeholder:e.placeholder??e.label??e.name,error:Boolean(v[e.name]),disabled:Boolean(e.disabled)},n=e.options??[],o=e.helpText??"";let i="";switch(e.required&&(i=v[e.name]?`${e.label??e.name} is required`:"",t.required=!0),e.type){case exports.FormAttributeType.Switch:return r.createElement(p,{key:a.key,id:a.id,orientation:"horizontal",sx:{alignItems:"center"}},r.createElement(l,null,r.createElement(G,{error:i,attr:e}),r.createElement(b,{id:`${e.name}-helper-text`},o)),r.createElement(m.Controller,{control:w,rules:{required:Boolean(e.required)},name:e.name,render:({field:t})=>{const a={};return v[e.name]&&(a.color="danger"),r.createElement(y.Switch,Object.assign({id:`switch-field-${e.name}`},a,t,{checked:Boolean(t.value),onChange:e=>{t.onChange(e.target.checked)},color:t.value?"success":"neutral",endDecorator:t.value?n[0].label:n[1].label,sx:{"--Switch-thumbSize":"28px"}}))}}));case exports.FormAttributeType.Checkbox:return r.createElement(z,{key:a.key,attribute:e,display:a,options:n,helperText:o});case exports.FormAttributeType.Select:return r.createElement(p,{key:a.key,id:a.id},r.createElement(G,{error:i,attr:e}),r.createElement(m.Controller,{control:w,rules:{required:Boolean(e.required)},name:e.name,render:({field:t})=>{const l={};return v[e.name]&&(l.color="danger"),r.createElement(s,null,r.createElement(h,Object.assign({id:`select-field-${e.name}`,placeholder:`${a.placeholder}...`},l,t,{onChange:(e,r)=>{t.onChange(r)}}),n.map((e=>r.createElement(x,{key:String(e.value??""),value:e.value},e.label)))),r.createElement(b,{id:`${e.name}-helper-text`},o))}}));case exports.FormAttributeType.Password:return r.createElement(p,{key:a.key,id:a.id},r.createElement(G,{error:i,attr:e}),r.createElement(d,Object.assign({},a,E(e.name,t),{type:exports.FormAttributeType.Password})),r.createElement(b,{id:`${e.name}-helper-text`},o));case exports.FormAttributeType.Number:return r.createElement(p,{key:a.key,id:a.id},r.createElement(G,{error:i,attr:e}),r.createElement(d,Object.assign({},a,E(e.name,t),{type:exports.FormAttributeType.Number})),r.createElement(b,{id:`${e.name}-helper-text`},o));case exports.FormAttributeType.Text:default:return r.createElement(p,{key:a.key,id:a.id},r.createElement(G,{error:i,attr:e}),r.createElement(d,Object.assign({},a,E(e.name,t))),r.createElement(b,{id:`${e.name}-helper-text`},o))}})),o?r.createElement(s,{spacing:2,direction:"row"},o,r.createElement(l,null,r.createElement(i,{type:"submit"},a))):r.createElement(l,null,r.createElement(s,{direction:"row",gap:2},r.createElement(i,{type:"submit",loading:c},a),u))))}function W(e){const{open:t,setOpen:a,refetch:n}=e,l=V(),[i,s]=r.useState(),{watch:c,register:u,handleSubmit:d}=m.useForm(),p=c("email");r.useEffect((()=>{null!=i&&s()}),[p]);const b=o.useMutation((e=>l.users.createTenantUser({signUpRequest:e})),{onSuccess(e){n&&n(e),a(!1)},onError(e){e instanceof Error&&s(e.message)}}),f=r.useCallback((async e=>{s(""),b.mutate(e)}),[b]);return r.createElement(y.Modal,{open:t},r.createElement(y.ModalDialog,null,r.createElement(y.Stack,{spacing:2},r.createElement(y.Typography,{level:"h4"},"Create user"),r.createElement(r.Fragment,null,i&&r.createElement(y.Typography,{color:"danger"},i)),r.createElement(y.Stack,{component:"form",sx:{width:"40ch"},spacing:1,onSubmit:d((e=>f(e)))},r.createElement(y.FormControl,{sx:{"--FormHelperText-color":"var(--joy-palette-danger-500)"}},r.createElement(y.FormLabel,{htmlFor:"email"},"Email"),r.createElement(y.Input,Object.assign({},u("email"),{fullWidth:!0,size:"lg",id:"email",name:"email",autoComplete:"current-email",required:!0,error:Boolean(i)}))),r.createElement(y.FormControl,{sx:{"--FormHelperText-color":"var(--joy-palette-danger-500)"}},r.createElement(y.FormLabel,{htmlFor:"password"},"Password"),r.createElement(y.Input,Object.assign({},u("password"),{fullWidth:!0,size:"lg",id:"password",autoComplete:"current-password",type:"password",required:!0}))),r.createElement(y.Stack,{direction:"row",sx:{pt:2},spacing:2},r.createElement(y.Button,{onClick:()=>a(!1),variant:"plain"},"Cancel"),r.createElement(y.Button,{type:"submit"},"Create"))))))}function Q(e){const{allowCreation:a,buttonText:n,onUserCreateSuccess:o}=e,[l,c]=t.useState(!1);return a?r.createElement(s,{alignItems:"flex-end",gap:1},r.createElement(W,{open:l,setOpen:c,refetch:o}),r.createElement(i,{startDecorator:r.createElement(C,null),size:"sm",onClick:()=>c(!0)},n)):null}const _=e=>Object.keys(e).reduce(((t,r)=>{const a=e[r];return a instanceof Set?t[r]=Array.from(a).join(", "):Array.isArray(a)?t[r]=a.join(", "):t[r]=a,t}),{}),J=(e,t,r)=>{if(!e)return[[],[]];const a=e.map(_),n=Object.keys(a[0]),o={},l=n?.map((e=>{const n=function(e,t,r){let a=r&&e?r.measureText(String(e)).width:50;a+=27;let n=a;return n=16+Math.ceil(r?r.measureText(t.reduce(((t,r)=>{let a=r[String(e)];return(q(a)||k(a))&&(a=""),a=a?.toString(),t.length>a.length?t:a}),"")).width:50),n<a&&(n=a),n+=8,n}(e,a,t),l=e.slice();if(r.includes(l))return null==o[l]?o[l]=l.length:o[l]+=1,{field:l.padEnd(o[l]),headerName:l.padEnd(o[l]),width:n}})).filter(Boolean)??[];return[l,a]};function K(e,r){const a=function(){const[e,r]=t.useState();return t.useEffect((()=>{const e=document.createElement("canvas").getContext("2d");e&&(e.font="18px Roboto",r(e))}),[]),e}(),[n,o]=t.useMemo((()=>J(e,a,r)),[e,a,r]);return[n,o]}function X(e){const{config:t,providerName:a,onSuccess:n,onError:l,allowEdit:i=!0,configurationGuide:m}=e,d=V(),[p,b]=r.useState(!1),[f,g]=r.useState(!1),[h,x]=r.useState(t),E=r.useRef(),y=r.useMemo((()=>{const e=[{name:"enabled",label:"Allow Okta logins",type:exports.FormAttributeType.Switch,defaultValue:!0===h?.enabled,options:[{label:"Enabled"},{label:"Disabled"}],disabled:!i},{name:"clientId",label:"Client id",type:exports.FormAttributeType.Text,defaultValue:h?.clientId??"",required:!0,disabled:!i},{name:"configUrl",label:"Config url",type:exports.FormAttributeType.Text,defaultValue:h?.configUrl??"",helpText:"The URL of the .well-known/openid-configuration for the identity provider",required:!0,disabled:!i},{name:"emailDomains",label:"Email domains",type:exports.FormAttributeType.Text,defaultValue:h?.emailDomains?.join(", ")??"",required:!0,helpText:"A comma seperated list of email domains (yourDomain.com) to be used",disabled:!i}];return h?.clientId||e.splice(2,0,{name:"clientSecret",label:"Client secret",type:exports.FormAttributeType.Password,defaultValue:"",required:!0,disabled:!i}),e}),[i,h?.clientId,h?.configUrl,h?.emailDomains,h?.enabled]),w=o.useMutation((e=>{b(!0);const t={providerName:a.toLowerCase(),updateProviderRequest:{...e,emailDomains:e.emailDomains.split(",")}};return null!=h?d.auth.updateProvider(t):d.auth.createProvider(t)}),{onSuccess:(e,t)=>{x(e),g(!0),n&&n(e,t)},onError:l,onSettled:(e,t,r)=>{b(!1),E.current&&clearTimeout(E.current),E.current=setTimeout((()=>{g(!1)}),3e3),e||(t&&!t?.message.includes("Unterminated string")||x({enabled:r.enabled,clientId:r.clientId,configUrl:r.configUrl,emailDomains:r.emailDomains.split(", ")}),g(!0),n&&n(e,r))}});return r.useEffect((()=>{})),r.createElement(s,{gap:2,position:"relative"},r.createElement(c,{level:"h4"},"Step 1"),m,r.createElement(c,{level:"h4"},"Step 2"),r.createElement(H,{mutation:w,buttonText:"Update",attributes:y,loading:p,successMessage:r.createElement(u,{color:"success",sx:{opacity:f?1:0,transition:"opacity 200ms",height:"0.9rem"},startDecorator:r.createElement(j,null)},r.createElement(c,{textAlign:"center",fontSize:"sm"},"Provider updated"))}))}function Y({callbackUrl:e}){const[t,a]=r.useState(!1),n=r.useRef();return r.useEffect((()=>{n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{a(!1)}),3250)}),[t]),r.createElement(s,{gap:2},r.createElement(c,null,"In order for Okta to redirect properly, provide the following URL as the"," ",r.createElement(l,{component:"span",sx:{fontFamily:"monospace"}},"Sign-in redirect URIs")," ","in the admin configuration of your application."),r.createElement(d,{onClick:async()=>{await navigator.clipboard.writeText(e),a(!0)},sx:e=>({input:{cursor:"pointer"},span:{cursor:"pointer"},"&:hover svg":{"--Icon-color":e.palette.primary[500]}}),value:e,readOnly:!0,endDecorator:r.createElement(E,{title:"Copy Okta redirect URL"},r.createElement(l,{position:"relative",width:t?"82px":"24px",height:"24px"},r.createElement(l,{position:"absolute",top:"0",left:"0",sx:{opacity:t?0:1,transition:"opacity 300ms"}},r.createElement(F,null)),r.createElement(l,{position:"absolute",top:"0",left:"0",sx:{opacity:t?1:0,transition:"opacity 300ms"}},r.createElement(s,{direction:"row",gap:1},r.createElement(j,null),r.createElement(c,{color:"primary"},"Copied!")))))}))}exports.GoogleLoginButton=function(e){const{workspace:a,database:n,newTenantName:o}=e,{basePath:u}=(()=>{const{basePath:e,tenantId:r}=R();return t.useMemo((()=>({tenantId:r,basePath:e})),[e,r])})(),m=`${u}/workspaces/${encodeURIComponent(a??"")}/databases/${encodeURIComponent(n??"")}/users/oidc/google/login`,d=o?"?newTenant="+encodeURIComponent(o):"",p=(e?.href??m)+d;return r.createElement(l,{component:"a",href:p,display:"flex",flex:1,sx:{textDecoration:"none"}},r.createElement(l,null,r.createElement(i,{sx:{padding:0,textTransform:"initial",flex:1},"aria-label":"log in with google"},r.createElement(s,{direction:"row",alignItems:"center",p:0,flex:1,fontFamily:"Roboto, sans-serif",fontSize:"14px",display:"inline-flex",color:"rgb(255 255, 255)",boxShadow:"rgb(0 0 0 / 24%) 0px 2px 2px 0px rgb(0 0 0 / 24%) 0px 0px 1px 0px",borderRadius:"4px",border:"1px solid transparent",fontWeight:"500",sx:{backgroundColor:"rgb(66 133, 244)"}},r.createElement(l,{padding:"11px",display:"flex",border:"1px solid rgb(66, 133, 244)",borderRadius:"4px",sx:{background:"rgb(255, 255, 255)"}},r.createElement(D,{"aria-hidden":"true"})),r.createElement(l,{padding:"10px",flex:1},r.createElement(c,{sx:{color:"white"},fontWeight:700,fontFamily:"Roboto, sans-serif",fontSize:"14px",height:"20px"},"Continue with Google"))))))},exports.NileProvider=e=>{const{children:o,theme:l,tenantId:i,QueryProvider:s=I,basePath:c="https://prod.thenile.dev",api:u}=e,m=t.useMemo((()=>({api:u??a({basePath:c,credentials:"include"}),tenantId:String(i),basePath:c})),[u,c,i]);return r.createElement(s,null,r.createElement(n.CssVarsProvider,{defaultMode:"system",theme:l??A},r.createElement(U,{value:m},o)))},exports.Okta=function(e){const{callbackUrl:t,providers:a,...n}=e;if(!a)return null;const o=a?.find((e=>"okta"===e.provider));return r.createElement(X,Object.assign({},n,{config:o,providerName:"Okta",configurationGuide:r.createElement(Y,{callbackUrl:t})}))},exports.SSOForm=X,exports.SingleSignOnForm=function(e){const{attributes:t,onSuccess:a,onError:n,beforeMutate:l,nextButtonText:i="Next",loginButtonText:s="Log in",disableSSO:c=!1}=e,u=V(),[m,d]=r.useState(c?s:i),p=o.useMutation((async e=>{const t=(l&&l(e))??e;return await u.auth.login({loginRequest:{email:t.email,password:t.password},sso:!c})}),{onSuccess:(e,t)=>{e&&(e?.redirectURI?window.location.href=e.redirectURI:m!==s?d(s):a&&a(e,t))},onError:(e,t)=>{m===s?n&&n(e,t):d(s)}}),b=r.useMemo((()=>{const e=[{name:"email",label:"Email",type:exports.FormAttributeType.Text,defaultValue:"",required:!0}];return m===s&&e.push({name:"password",label:"Password",type:exports.FormAttributeType.Password,defaultValue:"",required:!0}),t&&t.length>0?e.concat(t):e}),[t,m,s]);return r.createElement(H,{mutation:p,buttonText:m,attributes:b})},exports.UserLoginForm=function(e){const[t,a]=r.useState(),{attributes:n,onSuccess:l,onError:i,beforeMutate:c}=e,m=V(),d=o.useMutation((async e=>{a(void 0);const t=(c&&c(e))??e;return await m.auth.login({loginRequest:t})}),{onSuccess:l,onError:i}),p=r.useMemo((()=>{const e=[{name:"email",label:"Email",type:exports.FormAttributeType.Text,defaultValue:"",required:!0},{name:"password",label:"Password",type:exports.FormAttributeType.Password,defaultValue:"",required:!0}];return n&&n.length>0?e.concat(n):e}),[n]);return r.createElement(s,{gap:2},t?r.createElement(u,{color:"danger"},t):null,r.createElement(H,{mutation:d,buttonText:"Log in",attributes:p}))},exports.UserSignupForm=function(e){const[t,a]=r.useState(),{buttonText:n="Sign up",onSuccess:l,onError:i,attributes:c,beforeMutate:m}=e,d=V(),p=o.useMutation((async e=>{a(void 0);const t=(m&&m(e))??e,{email:r,password:n,preferredName:o,newTenant:l,...i}=t;return Object.keys(i).length>0&&console.warn("additional metadata not supported yet."),d.auth.signUp({signUpRequest:{email:r,password:n,preferredName:o,newTenant:l}})}),{onSuccess:l,onError:(e,t)=>{a(e.message),i&&i(e,t)}}),b=r.useMemo((()=>{const e=[{name:"email",label:"Email",type:exports.FormAttributeType.Text,defaultValue:"",required:!0},{name:"password",label:"Password",type:exports.FormAttributeType.Password,defaultValue:"",required:!0}];return c&&c.length>0?e.concat(c):e}),[c]);return r.createElement(s,{gap:2},t?r.createElement(u,{color:"danger"},t):null,r.createElement(H,{mutation:p,buttonText:n,attributes:b}))},exports.UserTenantList=function(e){const{data:t,allowCreation:a=!0,buttonText:n="Add a user",onUserCreateSuccess:o,slots:l,include:i=["email","preferedName"]}=e,c={width:"100%",height:"100%",...l?.dataGrid??{}},[u,m]=K(t,i);return r.createElement(s,{flex:1},r.createElement(Q,{allowCreation:a,buttonText:n,onUserCreateSuccess:o}),r.createElement(S.DataGrid,{sx:c,rows:m,columns:u,hideFooter:!0}))};
|
|
2
|
+
//# sourceMappingURL=react.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs.production.min.js","sources":["../src/context/theme.ts","../src/context/index.tsx","../src/GoogleLoginButton/google.svg","../src/lib/SimpleForm/CheckGroup/index.tsx","../src/lib/SimpleForm/types.ts","../src/lib/SimpleForm/index.tsx","../src/UserTenantList/UserModal.tsx","../src/UserTenantList/CreateUser.tsx","../src/UserTenantList/useDataParser.ts","../src/utils/getColumnSize.ts","../src/hooks/useTextSizer.ts","../src/SSO/BaseSSOForm.tsx","../src/SSO/Okta.tsx","../src/GoogleLoginButton/GoogleLoginButton.tsx","../src/LoginForm/SingleSignOn.tsx","../src/LoginForm/LoginForm.tsx","../src/SignUpForm/SignUpForm.tsx","../src/UserTenantList/UserList.tsx"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n//@ts-nocheck\nimport { extendTheme as extendJoyTheme } from '@mui/joy/styles';\n\nexport default extendJoyTheme({\n cssVarPrefix: 'joy',\n colorSchemes: {\n light: {\n palette: {\n primary: {\n '50': '#fff3e4',\n '100': '#ffe1bc',\n '200': '#ffcd92',\n '300': '#ffb96a',\n '400': '#feaa51',\n '500': '#ff9c3f',\n '600': '#f9913d',\n '700': '#f28239',\n '800': '#eb7435',\n '900': '#e05c2e',\n },\n text: {\n tertiary: 'rgba(0 0 0 / 0.56)',\n },\n },\n },\n dark: {\n palette: {\n primary: {\n '50': '#fff3e4',\n '100': '#ffe1bc',\n '200': '#ffcd92',\n '300': '#ffb96a',\n '400': '#feaa51',\n '500': '#ff9c3f',\n '600': '#f9913d',\n '700': '#f28239',\n '800': '#eb7435',\n '900': '#e05c2e',\n },\n text: {\n tertiary: 'rgba(255 255 255 / 0.5)',\n },\n },\n },\n },\n});\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\nimport React, { useMemo, createContext, useContext } from 'react';\nimport BrowserApi, { Client } from '@niledatabase/browser';\nimport { CssVarsProvider } from '@mui/joy/styles';\nimport { QueryClientProvider, QueryClient } from '@tanstack/react-query';\n\nimport defaultTheme from './theme';\nimport { NileContext, NileProviderProps, NileReactConfig } from './types';\n\nconst queryClient = new QueryClient();\n\nconst defaultContext: NileContext = {\n api: BrowserApi({\n basePath: 'https://prod.thenile.dev',\n credentials: 'include',\n }),\n basePath: '',\n};\n\nconst context = createContext<NileContext>(defaultContext);\n\nconst { Provider } = context;\n\nexport const BaseQueryProvider = ({\n children,\n}: {\n children: JSX.Element;\n}): JSX.Element => {\n return (\n <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n );\n};\n\nexport const NileProvider = (props: NileProviderProps) => {\n const {\n children,\n theme,\n tenantId,\n QueryProvider = BaseQueryProvider,\n basePath = 'https://prod.thenile.dev',\n api,\n } = props;\n\n const values = useMemo<NileContext>((): NileContext => {\n return {\n api:\n api ??\n BrowserApi({\n basePath,\n credentials: 'include',\n }),\n tenantId: String(tenantId),\n basePath,\n };\n }, [api, basePath, tenantId]);\n\n return (\n <QueryProvider>\n <CssVarsProvider defaultMode=\"system\" theme={theme ?? defaultTheme}>\n <Provider value={values}>{children}</Provider>\n </CssVarsProvider>\n </QueryProvider>\n );\n};\n\nconst useNileContext = (): NileContext => {\n return useContext(context);\n};\n\nexport const useNileConfig = (): NileReactConfig => {\n const { basePath, tenantId } = useNileContext();\n return useMemo(\n () => ({\n tenantId,\n basePath,\n }),\n [basePath, tenantId]\n );\n};\n\nexport const useApi = (): Client => {\n return useNileContext().api;\n};\n","<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\">\n <g fill=\"#000\" fill-rule=\"evenodd\">\n <path d=\"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z\" fill=\"#EA4335\" />\n <path d=\"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z\" fill=\"#4285F4\" />\n <path d=\"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z\" fill=\"#FBBC05\" />\n <path d=\"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z\" fill=\"#34A853\" />\n <path fill=\"none\" d=\"M0 0h18v18H0z\" />\n </g>\n</svg>","import * as React from 'react';\nimport Box from '@mui/joy/Box';\nimport Checkbox from '@mui/joy/Checkbox';\nimport List from '@mui/joy/List';\nimport { Controller, useFormContext } from 'react-hook-form';\nimport Stack from '@mui/joy/Stack';\nimport FormLabel from '@mui/joy/FormLabel';\nimport ListItem from '@mui/joy/ListItem';\nimport Typography from '@mui/joy/Typography';\n\nimport { Attribute, DisplayProps, Options } from '../types';\n\ntype Props = {\n attribute: Attribute;\n display: DisplayProps;\n options: Options;\n helperText: string;\n};\nexport default function CheckGroup(props: Props) {\n const { options, attribute, display, helperText } = props;\n const { watch, control } = useFormContext();\n const currentVals = watch(attribute.name);\n const checkProps: { color?: 'danger'; id?: string } = {};\n if (helperText) {\n checkProps.color = 'danger';\n }\n return (\n <Controller\n name={attribute.name}\n rules={{ required: Boolean(attribute.required) }}\n control={control}\n render={({ field }) => {\n return (\n <Stack>\n <FormLabel htmlFor={`${field.name}`}>{display.label}</FormLabel>\n <Box\n role=\"group\"\n aria-labelledby={attribute.name}\n sx={{\n borderRadius: 'var(--joy-radius-sm)',\n p: 0.5,\n border: helperText\n ? '1px solid var(--joy-palette-danger-outlinedBorder)'\n : 'none',\n }}\n >\n <List\n orientation=\"horizontal\"\n wrap\n sx={{\n '--List-gap': '8px',\n }}\n >\n {options.map((item) => {\n checkProps.id = String(item.value);\n return (\n <ListItem key={`${item.value}-${item.label}`}>\n <Checkbox\n overlay={options.length > 1}\n {...checkProps}\n checked={currentVals.includes(item.value)}\n disableIcon={options.length > 1}\n variant=\"soft\"\n label={item.label}\n onChange={(event) => {\n if (attribute.allowMultiple) {\n if (event.target.checked) {\n if (!currentVals) {\n field.onChange([item.value]);\n } else {\n field.onChange(currentVals.concat(item.value));\n }\n } else {\n const remaining = currentVals.filter(\n (val: string | number) => val !== item.value\n );\n if (remaining.length > 0) {\n field.onChange(remaining);\n } else {\n field.onChange('');\n }\n }\n } else {\n if (event.target.checked) {\n field.onChange(item.value);\n } else {\n field.onChange('');\n }\n }\n }}\n />\n </ListItem>\n );\n })}\n </List>\n </Box>\n <Typography\n sx={{ color: 'var(--joy-palette-danger-500)' }}\n level=\"body-sm\"\n >\n {helperText}\n </Typography>\n </Stack>\n );\n }}\n />\n );\n}\n","export enum AttributeType {\n Text = 'text',\n Password = 'password',\n Select = 'select',\n Number = 'number',\n Float = 'float',\n Checkbox = 'checkbox',\n Switch = 'switch',\n}\ntype SimplePrimitive = number | string | boolean;\n\n// possibly no value for `<Switch/>`\nexport type Options = { label: string; value?: SimplePrimitive }[];\nexport type Attribute = {\n name: string;\n type?: AttributeType;\n defaultValue?: SimplePrimitive;\n options?: Options;\n allowMultiple?: boolean;\n label?: string;\n required?: boolean;\n placeholder?: string;\n helpText?: string;\n disabled?: boolean;\n};\n\nexport type DisplayProps = {\n key: string;\n id: string;\n label: string;\n placeholder: string;\n error?: boolean;\n color?: 'danger';\n disabled?: boolean;\n};\n","import React from 'react';\nimport Button from '@mui/joy/Button';\nimport { Controller, FormProvider, useForm } from 'react-hook-form';\nimport Stack from '@mui/joy/Stack';\nimport Input from '@mui/joy/Input';\nimport FormControl from '@mui/joy/FormControl';\nimport FormHelperText from '@mui/joy/FormHelperText';\nimport Error from '@mui/icons-material/Error';\nimport FormLabel from '@mui/joy/FormLabel';\nimport Select from '@mui/joy/Select';\nimport Option from '@mui/joy/Option';\nimport Box from '@mui/joy/Box';\nimport Tooltip from '@mui/joy/Tooltip';\nimport { Switch } from '@mui/joy';\n\nimport CheckGroup from './CheckGroup';\nimport { Attribute, AttributeType, DisplayProps } from './types';\n\ntype AttrMap = {\n [key: string]: string | number | boolean | string[] | number[];\n};\n\ntype FieldConfig = {\n required?: boolean;\n};\n\nexport const getAttributeDefault = (\n attribute: Attribute\n): string | number | boolean | string[] | number[] => {\n // have to look to see if it is an enum\n if (attribute.allowMultiple === true) {\n if (!Array.isArray(attribute.defaultValue) && attribute.defaultValue) {\n if (typeof attribute.defaultValue === 'number') {\n return [attribute.defaultValue];\n }\n return [String(attribute.defaultValue)];\n }\n }\n return attribute.defaultValue ?? '';\n};\n\nfunction Labler(props: { error?: string; attr: Attribute }) {\n const { error, attr } = props;\n if (error) {\n return (\n <Tooltip title={error} color=\"danger\" sx={{ cursor: 'pointer' }}>\n <FormLabel>\n {attr.label ?? attr.name}\n <Error sx={{ ml: 0.5, '--Icon-color': '#c41c1c' }} fontSize=\"small\" />\n </FormLabel>\n </Tooltip>\n );\n }\n return <FormLabel>{attr.label ?? attr.name}</FormLabel>;\n}\nexport default function SimpleForm(props: {\n buttonText: string;\n cancelButton?: React.ReactNode;\n attributes: Attribute[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n mutation: any;\n loading?: boolean;\n successMessage?: JSX.Element;\n}) {\n const {\n mutation,\n buttonText,\n attributes,\n cancelButton,\n loading,\n successMessage,\n } = props;\n\n const defaultValues = React.useMemo(\n () =>\n attributes.reduce((accum: AttrMap, attr: Attribute) => {\n accum[attr.name] = getAttributeDefault(attr);\n return accum;\n }, {}),\n [attributes]\n );\n\n const methods = useForm({\n defaultValues,\n });\n\n const {\n register,\n control,\n handleSubmit,\n formState: { errors },\n } = methods;\n const onSubmit = React.useCallback(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (data: any) => {\n mutation.mutate(data);\n },\n [mutation]\n );\n\n return (\n <FormProvider {...methods}>\n <Stack\n component=\"form\"\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onSubmit={handleSubmit((data) => onSubmit(data as any))}\n spacing={2}\n >\n {attributes.map((attr: Attribute): React.ReactNode => {\n const fieldConfig: FieldConfig = {};\n const display: DisplayProps = {\n key: attr.name,\n label: attr.label ?? attr.name,\n id: attr.label ?? attr.name,\n placeholder: attr.placeholder ?? attr.label ?? attr.name,\n error: Boolean(errors[attr.name]),\n disabled: Boolean(attr.disabled),\n };\n const options = attr.options ?? [];\n const helperText = attr.helpText ?? '';\n let error = '';\n\n if (attr.required) {\n error = errors[attr.name]\n ? `${attr.label ?? attr.name} is required`\n : '';\n fieldConfig.required = true;\n }\n\n switch (attr.type) {\n case AttributeType.Switch:\n return (\n <FormControl\n key={display.key}\n id={display.id}\n orientation=\"horizontal\"\n sx={{ alignItems: 'center' }}\n >\n <Box>\n <Labler error={error} attr={attr} />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </Box>\n <Controller\n control={control}\n rules={{ required: Boolean(attr.required) }}\n name={attr.name}\n render={({ field }) => {\n const color: { color?: 'danger' } = {};\n if (errors[attr.name]) {\n color.color = 'danger';\n }\n return (\n <Switch\n id={`switch-field-${attr.name}`}\n {...color}\n {...field}\n checked={Boolean(field.value)}\n onChange={(event) => {\n field.onChange(event.target.checked);\n }}\n color={field.value ? 'success' : 'neutral'}\n endDecorator={\n field.value ? options[0].label : options[1].label\n }\n sx={{\n '--Switch-thumbSize': '28px',\n }}\n />\n );\n }}\n />\n </FormControl>\n );\n case AttributeType.Checkbox:\n return (\n <CheckGroup\n key={display.key}\n attribute={attr}\n display={display}\n options={options}\n helperText={helperText}\n />\n );\n case AttributeType.Select:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Controller\n control={control}\n rules={{ required: Boolean(attr.required) }}\n name={attr.name}\n render={({ field }) => {\n const color: { color?: 'danger' } = {};\n if (errors[attr.name]) {\n color.color = 'danger';\n }\n return (\n <Stack>\n <Select\n id={`select-field-${attr.name}`}\n placeholder={`${display.placeholder}...`}\n {...color}\n {...field}\n onChange={(_, newValue) => {\n field.onChange(newValue);\n }}\n >\n {options.map((option) => {\n return (\n <Option\n key={String(option.value ?? '')}\n value={option.value}\n >\n {option.label}\n </Option>\n );\n })}\n </Select>\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </Stack>\n );\n }}\n />\n </FormControl>\n );\n case AttributeType.Password:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input\n {...display}\n {...register(attr.name, fieldConfig)}\n type={AttributeType.Password}\n />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n case AttributeType.Number:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input\n {...display}\n {...register(attr.name, fieldConfig)}\n type={AttributeType.Number}\n />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n\n case AttributeType.Text:\n default:\n return (\n <FormControl key={display.key} id={display.id}>\n <Labler error={error} attr={attr} />\n <Input {...display} {...register(attr.name, fieldConfig)} />\n <FormHelperText id={`${attr.name}-helper-text`}>\n {helperText}\n </FormHelperText>\n </FormControl>\n );\n }\n })}\n {cancelButton ? (\n <Stack spacing={2} direction=\"row\">\n {cancelButton}\n <Box>\n <Button type=\"submit\">{buttonText}</Button>\n </Box>\n </Stack>\n ) : (\n <Box>\n <Stack direction=\"row\" gap={2}>\n <Button type=\"submit\" loading={loading}>\n {buttonText}\n </Button>\n {successMessage}\n </Stack>\n </Box>\n )}\n </Stack>\n </FormProvider>\n );\n}\n","import React from 'react';\nimport {\n Button,\n Stack,\n Typography,\n FormControl,\n FormLabel,\n Input,\n Modal,\n ModalDialog,\n} from '@mui/joy';\nimport { useForm } from 'react-hook-form';\nimport { useMutation } from '@tanstack/react-query';\nimport { SignUp201Response, SignUpRequest } from '@niledatabase/browser';\n\nimport { useApi } from '../context';\n\nexport type UserFormProps = {\n open: boolean;\n setOpen: (open: boolean) => void;\n refetch?: (user: SignUp201Response) => void;\n};\n\nexport default function AddUser(props: UserFormProps) {\n const { open, setOpen, refetch } = props;\n const api = useApi();\n const [errorText, setErrorText] = React.useState<void | string>();\n const { watch, register, handleSubmit } = useForm<SignUpRequest>();\n const email = watch('email');\n\n React.useEffect(() => {\n if (errorText != null) {\n setErrorText();\n }\n // if email changes, no more error\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [email]);\n\n const mutation = useMutation(\n (data: SignUpRequest) =>\n api.users.createTenantUser({ signUpRequest: data }),\n {\n onSuccess(data) {\n refetch && refetch(data);\n setOpen(false);\n },\n onError(e) {\n if (e instanceof Error) {\n setErrorText(e.message);\n }\n },\n }\n );\n\n const handleUpdate = React.useCallback(\n async (data: SignUpRequest) => {\n setErrorText('');\n mutation.mutate(data);\n },\n [mutation]\n );\n\n return (\n <Modal open={open}>\n <ModalDialog>\n <Stack spacing={2}>\n <Typography level=\"h4\">Create user</Typography>\n <>\n {errorText && <Typography color=\"danger\">{errorText}</Typography>}\n </>\n <Stack\n component=\"form\"\n sx={{\n width: '40ch',\n }}\n spacing={1}\n onSubmit={handleSubmit((data) =>\n handleUpdate(data as SignUpRequest)\n )}\n >\n <FormControl\n sx={{\n '--FormHelperText-color': 'var(--joy-palette-danger-500)',\n }}\n >\n <FormLabel htmlFor=\"email\">Email</FormLabel>\n <Input\n {...register('email')}\n fullWidth\n size=\"lg\"\n id=\"email\"\n name=\"email\"\n autoComplete=\"current-email\"\n required\n error={Boolean(errorText)}\n />\n </FormControl>\n <FormControl\n sx={{\n '--FormHelperText-color': 'var(--joy-palette-danger-500)',\n }}\n >\n <FormLabel htmlFor=\"password\">Password</FormLabel>\n <Input\n {...register('password')}\n fullWidth\n size=\"lg\"\n id=\"password\"\n autoComplete=\"current-password\"\n type=\"password\"\n required\n />\n </FormControl>\n <Stack direction=\"row\" sx={{ pt: 2 }} spacing={2}>\n <Button onClick={() => setOpen(false)} variant=\"plain\">\n Cancel\n </Button>\n <Button type=\"submit\">Create</Button>\n </Stack>\n </Stack>\n </Stack>\n </ModalDialog>\n </Modal>\n );\n}\n","import React from 'react';\nimport Button from '@mui/joy/Button';\nimport Stack from '@mui/joy/Stack';\nimport { useState } from 'react';\nimport Add from '@mui/icons-material/Add';\nimport { SignUp201Response } from '@niledatabase/browser';\n\nimport UserModal from './UserModal';\n\ntype Props = {\n allowCreation: boolean;\n buttonText: string;\n onUserCreateSuccess?: (user: SignUp201Response) => void;\n};\nexport default function CreateUser(props: Props) {\n const { allowCreation, buttonText, onUserCreateSuccess } = props;\n const [open, setOpen] = useState(false);\n if (!allowCreation) {\n return null;\n }\n\n return (\n <Stack alignItems=\"flex-end\" gap={1}>\n <UserModal open={open} setOpen={setOpen} refetch={onUserCreateSuccess} />\n <Button startDecorator={<Add />} size=\"sm\" onClick={() => setOpen(true)}>\n {buttonText}\n </Button>\n </Stack>\n );\n}\n","import { useMemo } from 'react';\nimport { GridColDef, GridRowsProp } from '@mui/x-data-grid';\nimport { IdentifyUser200Response } from '@niledatabase/browser';\n\nimport getColumnSize from '../utils/getColumnSize';\nimport useTextSizer from '../hooks/useTextSizer';\n\nexport const internalRowId = '_nile_data_grid_identifier';\n\ntype Cleaned = { [key: string]: string | Set<string> };\n\nconst makeRenderable = (vals: IdentifyUser200Response) => {\n return Object.keys(vals).reduce((cleaned: Cleaned, key) => {\n const val = (vals as Cleaned)[key];\n if (val instanceof Set) {\n cleaned[key] = Array.from(val).join(', ');\n } else if (Array.isArray(val)) {\n cleaned[key] = val.join(', ');\n } else {\n cleaned[key] = val;\n }\n return cleaned;\n }, {});\n};\n\nconst parseResults = (\n data: void | IdentifyUser200Response[],\n ctx: CanvasRenderingContext2D | void,\n include: string[]\n): [GridColDef[], GridRowsProp] => {\n if (!data) {\n return [[], []];\n }\n const rows = data.map(makeRenderable);\n const fields = Object.keys(rows[0]);\n\n const existentCols: { [key: string]: number } = {};\n\n const mapCols = (col: string): GridColDef | void => {\n const width = getColumnSize(col, rows, ctx);\n const name = col.slice();\n if (include.includes(name)) {\n // add spaces to the end of column names so they are not duplicated in the UI\n if (existentCols[name] == null) {\n existentCols[name] = name.length;\n } else {\n existentCols[name] += 1;\n }\n return {\n field: name.padEnd(existentCols[name]),\n headerName: name.padEnd(existentCols[name]),\n width,\n };\n }\n };\n const cols = fields?.map(mapCols).filter(Boolean) ?? [];\n\n return [cols as GridColDef[], rows];\n};\n\nexport default function useDataParser(\n data: void | IdentifyUser200Response[],\n include: string[]\n): [GridColDef[], GridRowsProp] {\n const ctx = useTextSizer();\n const [cols, rows] = useMemo(\n () => parseResults(data, ctx, include),\n [data, ctx, include]\n );\n return [cols, rows];\n}\n","import { GridRowsProp } from '@mui/x-data-grid';\nimport isNull from 'lodash/isNull';\nimport isUndefined from 'lodash/isUndefined';\n\nexport default function getColumnSize(\n column: unknown,\n rows: GridRowsProp,\n canvasContext: void | CanvasRenderingContext2D\n) {\n const dataWidthReducer = (\n longest: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextRow: { [key: string]: any }\n ) => {\n let value = nextRow[String(column)];\n if (isNull(value) || isUndefined(value)) {\n value = '';\n }\n value = value?.toString();\n return longest.length > value.length ? longest : value;\n };\n\n let columnHeaderLen =\n canvasContext && column\n ? canvasContext.measureText(String(column)).width\n : 50;\n /* padding 12, icon-width 15 */\n columnHeaderLen += 15 + 12;\n\n let width = columnHeaderLen;\n width =\n 16 +\n Math.ceil(\n canvasContext\n ? canvasContext.measureText(rows.reduce(dataWidthReducer, '')).width\n : 50\n );\n if (width < columnHeaderLen) {\n width = columnHeaderLen;\n }\n /* Gracefull */\n width += 8;\n return width;\n}\n","import { useEffect, useState } from 'react';\n\nexport default function useTextSizer() {\n const [ctx, setCtx] = useState<CanvasRenderingContext2D>();\n useEffect(() => {\n const canvas = document.createElement('canvas');\n const canvasContext = canvas.getContext('2d');\n if (canvasContext) {\n canvasContext.font = '18px Roboto';\n setCtx(canvasContext);\n }\n }, []);\n return ctx;\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport { UpdateProviderRequest, SSOProvider } from '@niledatabase/browser';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\nimport Alert from '@mui/joy/Alert';\nimport CheckCircleOutlined from '@mui/icons-material/CheckCircleOutlined';\n\nimport SimpleForm from '../lib/SimpleForm';\nimport { useApi } from '../context';\nimport { Attribute, AttributeType } from '../lib/SimpleForm/types';\n\nimport { OktaProps } from './types';\n\ntype SSOFormRequest = Omit<UpdateProviderRequest, 'emailDomains'> & {\n emailDomains: string;\n};\nexport default function BaseSSOForm(\n props: Omit<OktaProps, 'callbackUrl' | 'providers'> & {\n providerName: string;\n configurationGuide: JSX.Element;\n config: SSOProvider;\n }\n) {\n const {\n config,\n providerName,\n onSuccess,\n onError,\n allowEdit = true,\n configurationGuide,\n } = props;\n\n const api = useApi();\n const [loading, setLoading] = React.useState(false);\n const [success, setSuccess] = React.useState(false);\n const [optimisticConfig, setConfig] = React.useState<SSOProvider>(config);\n const timer = React.useRef<NodeJS.Timeout>();\n const attributes = React.useMemo(() => {\n const attributes: Attribute[] = [\n {\n name: 'enabled',\n label: 'Allow Okta logins',\n type: AttributeType.Switch,\n defaultValue: optimisticConfig?.enabled === true,\n options: [\n {\n label: 'Enabled',\n },\n {\n label: 'Disabled',\n },\n ],\n disabled: !allowEdit,\n },\n {\n name: 'clientId',\n label: 'Client id',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.clientId ?? '',\n required: true,\n disabled: !allowEdit,\n },\n {\n name: 'configUrl',\n label: 'Config url',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.configUrl ?? '',\n helpText:\n 'The URL of the .well-known/openid-configuration for the identity provider',\n required: true,\n disabled: !allowEdit,\n },\n {\n name: 'emailDomains',\n label: 'Email domains',\n type: AttributeType.Text,\n defaultValue: optimisticConfig?.emailDomains?.join(', ') ?? '',\n required: true,\n helpText:\n 'A comma seperated list of email domains (yourDomain.com) to be used',\n disabled: !allowEdit,\n },\n ];\n if (!optimisticConfig?.clientId) {\n attributes.splice(2, 0, {\n name: 'clientSecret',\n label: 'Client secret',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n disabled: !allowEdit,\n });\n }\n return attributes;\n }, [\n allowEdit,\n optimisticConfig?.clientId,\n optimisticConfig?.configUrl,\n optimisticConfig?.emailDomains,\n optimisticConfig?.enabled,\n ]);\n\n const handleTimer = () => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n\n timer.current = setTimeout(() => {\n setSuccess(false);\n }, 3000);\n };\n\n const mutation = useMutation(\n (ssoRequest: SSOFormRequest) => {\n setLoading(true);\n const payload = {\n providerName: providerName.toLowerCase(),\n updateProviderRequest: {\n ...ssoRequest,\n emailDomains: ssoRequest.emailDomains.split(','),\n },\n };\n if (optimisticConfig != null) {\n return api.auth.updateProvider(payload);\n } else {\n return api.auth.createProvider(payload);\n }\n },\n {\n onSuccess: (data, vars) => {\n setConfig(data);\n setSuccess(true);\n onSuccess && onSuccess(data, vars);\n },\n onError,\n onSettled: (data, error, vars) => {\n setLoading(false);\n handleTimer();\n if (!data) {\n if (!error || error?.message.includes('Unterminated string')) {\n // something unexpected happened on the BE, but it's non-fatal\n setConfig({\n enabled: vars.enabled,\n clientId: vars.clientId,\n configUrl: vars.configUrl,\n emailDomains: vars.emailDomains.split(', '),\n } as SSOProvider);\n }\n setSuccess(true);\n onSuccess && onSuccess(data, vars);\n }\n },\n }\n );\n\n React.useEffect(() => {\n () => {\n clearTimeout(timer.current);\n };\n });\n\n return (\n <Stack gap={2} position=\"relative\">\n <Typography level=\"h4\">Step 1</Typography>\n {configurationGuide}\n <Typography level=\"h4\">Step 2</Typography>\n <SimpleForm\n mutation={mutation}\n buttonText=\"Update\"\n attributes={attributes}\n loading={loading}\n successMessage={\n <Alert\n color=\"success\"\n sx={{\n opacity: success ? 1 : 0,\n transition: 'opacity 200ms',\n height: '0.9rem',\n }}\n startDecorator={<CheckCircleOutlined />}\n >\n <Typography textAlign=\"center\" fontSize=\"sm\">\n Provider updated\n </Typography>\n </Alert>\n }\n />\n </Stack>\n );\n}\n","import React from 'react';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\nimport Box from '@mui/joy/Box';\nimport Input from '@mui/joy/Input';\nimport CopyAll from '@mui/icons-material/CopyAll';\nimport { Theme } from '@mui/joy/styles';\nimport Tooltip from '@mui/joy/Tooltip';\nimport CheckCircleOutlined from '@mui/icons-material/CheckCircleOutlined';\nimport { SSOProvider } from '@niledatabase/browser';\n\nimport BaseSSOForm from './BaseSSOForm';\nimport { OktaProps } from './types';\n\nfunction ConfigGuide({ callbackUrl }: { callbackUrl: string }) {\n const [copied, setCopied] = React.useState(false);\n\n const timer = React.useRef<NodeJS.Timeout>();\n React.useEffect(() => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n timer.current = setTimeout(() => {\n setCopied(false);\n }, 3250);\n () => {\n clearTimeout(timer.current);\n };\n }, [copied]);\n return (\n <Stack gap={2}>\n <Typography>\n In order for Okta to redirect properly, provide the following URL as the{' '}\n <Box component=\"span\" sx={{ fontFamily: 'monospace' }}>\n Sign-in redirect URIs\n </Box>{' '}\n in the admin configuration of your application.\n </Typography>\n <Input\n onClick={async () => {\n await navigator.clipboard.writeText(callbackUrl);\n setCopied(true);\n }}\n sx={(theme: Theme) => ({\n input: {\n cursor: 'pointer',\n },\n span: {\n cursor: 'pointer',\n },\n '&:hover svg': {\n '--Icon-color': theme.palette.primary[500],\n },\n })}\n value={callbackUrl}\n readOnly={true}\n endDecorator={\n <Tooltip title=\"Copy Okta redirect URL\">\n <Box\n position=\"relative\"\n width={copied ? '82px' : '24px'}\n height=\"24px\"\n >\n <Box\n position=\"absolute\"\n top=\"0\"\n left=\"0\"\n sx={{\n opacity: copied ? 0 : 1,\n transition: 'opacity 300ms',\n }}\n >\n <CopyAll />\n </Box>\n <Box\n position=\"absolute\"\n top=\"0\"\n left=\"0\"\n sx={{ opacity: !copied ? 0 : 1, transition: 'opacity 300ms' }}\n >\n <Stack direction=\"row\" gap={1}>\n <CheckCircleOutlined />\n <Typography color=\"primary\">Copied!</Typography>\n </Stack>\n </Box>\n </Box>\n </Tooltip>\n }\n />\n </Stack>\n );\n}\n\nexport default function Okta(props: OktaProps) {\n const { callbackUrl, providers, ...remaining } = props;\n if (!providers) {\n return null;\n }\n const config = providers?.find((provider) => provider.provider === 'okta');\n return (\n <BaseSSOForm\n {...remaining}\n config={config as SSOProvider}\n providerName=\"Okta\"\n configurationGuide={<ConfigGuide callbackUrl={callbackUrl} />}\n />\n );\n}\n","import React from 'react';\nimport Box from '@mui/joy/Box';\nimport Button from '@mui/joy/Button';\nimport Stack from '@mui/joy/Stack';\nimport Typography from '@mui/joy/Typography';\n\nimport { useNileConfig } from '../context';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport GoogleLogo from './google.svg';\n\nconst LOGIN_PATH = 'users/oidc/google/login';\n\n/**\n * A component for a Google login button, according to their design language.\n * This works when an identity provider is configured in the admin dashboard.\n * @param props href: a string to override the URL provided by the context\n * @returns a JSX.Element to render\n */\nexport default function GoogleSSOButton(props: {\n href?: string;\n workspace?: string;\n database?: string;\n newTenantName?: string;\n}) {\n const { workspace, database, newTenantName } = props;\n const { basePath } = useNileConfig();\n const encodedWorkspace = encodeURIComponent(workspace ?? '');\n const encodedDatabase = encodeURIComponent(database ?? '');\n const contextHref = `${basePath}/workspaces/${encodedWorkspace}/databases/${encodedDatabase}/${LOGIN_PATH}`;\n const query = newTenantName\n ? '?newTenant=' + encodeURIComponent(newTenantName)\n : '';\n const href = (props?.href ?? contextHref) + query;\n return (\n <Box\n component=\"a\"\n href={href}\n display=\"flex\"\n flex={1}\n sx={{ textDecoration: 'none' }}\n >\n <Box>\n <Button\n sx={{ padding: 0, textTransform: 'initial', flex: 1 }}\n aria-label=\"log in with google\"\n >\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n p={0}\n flex={1}\n fontFamily=\"Roboto, sans-serif\"\n fontSize=\"14px\"\n display=\"inline-flex\"\n color=\"rgb(255 255, 255)\"\n boxShadow=\"rgb(0 0 0 / 24%) 0px 2px 2px 0px rgb(0 0 0 / 24%) 0px 0px 1px 0px\"\n borderRadius=\"4px\"\n border=\"1px solid transparent\"\n fontWeight=\"500\"\n sx={{\n backgroundColor: 'rgb(66 133, 244)',\n }}\n >\n <Box\n padding=\"11px\"\n display=\"flex\"\n border=\"1px solid rgb(66, 133, 244)\"\n borderRadius=\"4px\"\n sx={{\n background: 'rgb(255, 255, 255)',\n }}\n >\n <GoogleLogo aria-hidden=\"true\" />\n </Box>\n <Box padding=\"10px\" flex={1}>\n <Typography\n sx={{ color: 'white' }}\n fontWeight={700}\n fontFamily=\"Roboto, sans-serif\"\n fontSize=\"14px\"\n height=\"20px\"\n >\n Continue with Google\n </Typography>\n </Box>\n </Stack>\n </Button>\n </Box>\n </Box>\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\n\nimport { Attribute } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\nimport SimpleForm from '../lib/SimpleForm';\nimport { AttributeType } from '../lib/SimpleForm/types';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function SingleSignOnForm(\n props: Props & {\n nextButtonText?: string;\n loginButtonText?: string;\n onSuccess: () => void;\n }\n) {\n const {\n attributes,\n onSuccess,\n onError,\n beforeMutate,\n nextButtonText = 'Next',\n loginButtonText = 'Log in',\n disableSSO = false,\n } = props;\n const api = useApi();\n const [buttonText, setButtonText] = React.useState(\n disableSSO ? loginButtonText : nextButtonText\n );\n\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n return await api.auth.login({\n loginRequest: { email: data.email, password: data.password },\n sso: !disableSSO,\n });\n },\n {\n onSuccess: (token, data) => {\n if (token) {\n if (token?.redirectURI) {\n window.location.href = token.redirectURI;\n } else if (buttonText !== loginButtonText) {\n setButtonText(loginButtonText);\n } else {\n onSuccess && onSuccess(token, data);\n }\n }\n },\n onError: (error, data) => {\n // it is possible SSO failed, so only show errors on if the password is available\n if (buttonText === loginButtonText) {\n onError && onError(error as Error, data);\n } else {\n setButtonText(loginButtonText);\n }\n },\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n ];\n if (buttonText === loginButtonText) {\n mainAttributes.push({\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n });\n }\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes, buttonText, loginButtonText]);\n\n return (\n <SimpleForm\n mutation={mutation}\n buttonText={buttonText}\n attributes={completeAttributes}\n />\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport Alert from '@mui/joy/Alert';\nimport Stack from '@mui/joy/Stack';\n\nimport { Attribute } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\nimport SimpleForm from '../lib/SimpleForm';\nimport { AttributeType } from '../lib/SimpleForm/types';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function LoginForm(props: Props) {\n const [error, setError] = React.useState<string | void>();\n const { attributes, onSuccess, onError, beforeMutate } = props;\n const api = useApi();\n\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n setError(undefined);\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n return await api.auth.login({\n loginRequest: data,\n });\n },\n {\n onSuccess,\n onError,\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n {\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n },\n ];\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes]);\n\n return (\n <Stack gap={2}>\n {error ? <Alert color=\"danger\">{error}</Alert> : null}\n <SimpleForm\n mutation={mutation}\n buttonText=\"Log in\"\n attributes={completeAttributes}\n />\n </Stack>\n );\n}\n","import React from 'react';\nimport { useMutation } from '@tanstack/react-query';\nimport Stack from '@mui/joy/Stack';\nimport Alert from '@mui/joy/Alert';\n\nimport UserForm from '../lib/SimpleForm';\nimport { Attribute, AttributeType } from '../lib/SimpleForm/types';\nimport { useApi } from '../context';\n\nimport { Props, LoginInfo } from './types';\n\nexport default function SignUpForm(props: Props) {\n const [error, setError] = React.useState<string | void>();\n const {\n buttonText = 'Sign up',\n onSuccess,\n onError,\n attributes,\n beforeMutate,\n } = props;\n const api = useApi();\n const mutation = useMutation(\n async (_data: LoginInfo) => {\n setError(undefined);\n const possibleData = beforeMutate && beforeMutate(_data);\n const data = possibleData ?? _data;\n const { email, password, preferredName, newTenant, ...metadata } = data;\n if (Object.keys(metadata).length > 0) {\n // eslint-disable-next-line no-console\n console.warn('additional metadata not supported yet.');\n }\n return api.auth.signUp({\n signUpRequest: { email, password, preferredName, newTenant },\n });\n },\n {\n onSuccess,\n onError: (e: Error, vars) => {\n setError(e.message);\n onError && onError(e as Error, vars);\n },\n }\n );\n\n const completeAttributes = React.useMemo(() => {\n const mainAttributes: Attribute[] = [\n {\n name: 'email',\n label: 'Email',\n type: AttributeType.Text,\n defaultValue: '',\n required: true,\n },\n {\n name: 'password',\n label: 'Password',\n type: AttributeType.Password,\n defaultValue: '',\n required: true,\n },\n ];\n if (attributes && attributes.length > 0) {\n return mainAttributes.concat(attributes);\n }\n return mainAttributes;\n }, [attributes]);\n\n return (\n <Stack gap={2}>\n {error ? <Alert color=\"danger\">{error}</Alert> : null}\n <UserForm\n mutation={mutation}\n buttonText={buttonText}\n attributes={completeAttributes}\n />\n </Stack>\n );\n}\n","import { DataGrid } from '@mui/x-data-grid';\nimport React from 'react';\nimport Stack from '@mui/joy/Stack';\nimport {\n IdentifyUser200Response,\n SignUp201Response,\n} from '@niledatabase/browser';\nimport { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';\nimport { Theme } from '@mui/system/createTheme';\n\nimport CreateUser from './CreateUser';\nimport useDataParser from './useDataParser';\n\ntype ColumnNames = string;\n\ntype Props = {\n data: void | IdentifyUser200Response[];\n allowCreation?: boolean;\n buttonText?: string;\n onUserCreateSuccess?: (user: SignUp201Response) => void;\n slots?: {\n dataGrid?: SxProps<Theme>;\n };\n // white list of columns to show\n include?: ColumnNames[];\n};\n\nexport default function UserList(props: Props) {\n const {\n data,\n allowCreation = true,\n buttonText = 'Add a user',\n onUserCreateSuccess,\n slots,\n include = ['email', 'preferedName'],\n } = props;\n\n const dataGridSx = {\n width: '100%',\n height: '100%',\n ...(slots?.dataGrid ?? {}),\n };\n\n const [columns, rows] = useDataParser(data, include);\n return (\n <Stack flex={1}>\n <CreateUser\n allowCreation={allowCreation}\n buttonText={buttonText}\n onUserCreateSuccess={onUserCreateSuccess}\n />\n <DataGrid\n sx={dataGridSx}\n rows={rows}\n columns={columns}\n hideFooter={true}\n />\n </Stack>\n );\n}\n"],"names":["extendJoyTheme","cssVarPrefix","colorSchemes","light","palette","primary","text","tertiary","dark","queryClient","QueryClient","defaultContext","api","BrowserApi","basePath","credentials","context","createContext","Provider","BaseQueryProvider","children","React","QueryClientProvider","client","useNileContext","useContext","useApi","_g","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","this","SvgGoogle","props","React.createElement","xmlns","width","height","fillRule","fill","d","CheckGroup","options","attribute","display","helperText","watch","control","useFormContext","currentVals","name","checkProps","color","Controller","rules","required","Boolean","render","field","Stack","FormLabel","htmlFor","label","Box","role","sx","borderRadius","p","border","List","orientation","wrap","map","item","id","String","value","ListItem","Checkbox","overlay","checked","includes","disableIcon","variant","onChange","event","allowMultiple","concat","remaining","filter","val","Typography","level","AttributeType","getAttributeDefault","Array","isArray","defaultValue","Labler","error","attr","Tooltip","title","cursor","Error","ml","fontSize","SimpleForm","mutation","buttonText","attributes","cancelButton","loading","successMessage","defaultValues","useMemo","reduce","accum","methods","useForm","register","handleSubmit","formState","errors","onSubmit","useCallback","data","mutate","FormProvider","component","spacing","fieldConfig","placeholder","disabled","helpText","type","Switch","FormControl","alignItems","FormHelperText","endDecorator","Select","_","newValue","option","Option","Password","Input","Number","Text","direction","Button","gap","AddUser","open","setOpen","refetch","errorText","setErrorText","useState","email","useEffect","useMutation","users","createTenantUser","signUpRequest","onSuccess","onError","e","message","handleUpdate","async","Modal","ModalDialog","fullWidth","size","autoComplete","pt","onClick","CreateUser","allowCreation","onUserCreateSuccess","UserModal","startDecorator","Add","makeRenderable","vals","keys","cleaned","Set","from","join","parseResults","ctx","include","rows","fields","existentCols","cols","col","column","canvasContext","columnHeaderLen","measureText","Math","ceil","longest","nextRow","isNull","isUndefined","toString","getColumnSize","slice","padEnd","headerName","useDataParser","setCtx","document","createElement","getContext","font","useTextSizer","BaseSSOForm","config","providerName","allowEdit","configurationGuide","setLoading","success","setSuccess","optimisticConfig","setConfig","timer","useRef","enabled","clientId","configUrl","emailDomains","splice","ssoRequest","payload","toLowerCase","updateProviderRequest","split","auth","updateProvider","createProvider","vars","onSettled","current","clearTimeout","setTimeout","position","Alert","opacity","transition","CheckCircleOutlined","textAlign","ConfigGuide","callbackUrl","copied","setCopied","fontFamily","navigator","clipboard","writeText","theme","input","span","readOnly","top","left","CopyAll","workspace","database","newTenantName","tenantId","useNileConfig","contextHref","encodeURIComponent","query","href","flex","textDecoration","padding","textTransform","boxShadow","fontWeight","backgroundColor","background","GoogleLogo","QueryProvider","values","CssVarsProvider","defaultMode","defaultTheme","providers","find","provider","beforeMutate","nextButtonText","loginButtonText","disableSSO","setButtonText","_data","login","loginRequest","password","sso","token","redirectURI","window","location","completeAttributes","mainAttributes","push","setError","undefined","preferredName","newTenant","metadata","console","warn","signUp","UserForm","slots","dataGridSx","dataGrid","columns","DataGrid","hideFooter"],"mappings":"ykCAIeA,cAAe,CAC5BC,aAAc,MACdC,aAAc,CACZC,MAAO,CACLC,QAAS,CACPC,QAAS,CACP,GAAM,UACN,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,UACP,IAAO,WAETC,KAAM,CACJC,SAAU,wBAIhBC,KAAM,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
|
|
|
1
|
+
import e,{useMemo as t,useContext as r,createContext as a,createElement as n,useState as o,useEffect as l}from"react";import i from"@niledatabase/browser";import{extendTheme as c,CssVarsProvider as s}from"@mui/joy/styles";import{QueryClient as m,QueryClientProvider as u,useMutation as d}from"@tanstack/react-query";import p from"@mui/joy/Box";import f from"@mui/joy/Button";import g from"@mui/joy/Stack";import b from"@mui/joy/Typography";import h from"@mui/joy/Alert";import{useFormContext as E,Controller as y,useForm as x,FormProvider as w}from"react-hook-form";import v from"@mui/joy/Input";import S from"@mui/joy/FormControl";import k from"@mui/joy/FormHelperText";import C from"@mui/icons-material/Error";import T from"@mui/joy/FormLabel";import j from"@mui/joy/Select";import U from"@mui/joy/Option";import O from"@mui/joy/Tooltip";import{Switch as q,Modal as P,ModalDialog as I,Stack as R,Typography as F,FormControl as M,FormLabel as V,Input as B,Button as A}from"@mui/joy";import L from"@mui/joy/Checkbox";import z from"@mui/joy/List";import $ from"@mui/joy/ListItem";import{DataGrid as D}from"@mui/x-data-grid";import N from"@mui/icons-material/Add";import G from"lodash/isNull";import H from"lodash/isUndefined";import W from"@mui/icons-material/CopyAll";import Q from"@mui/icons-material/CheckCircleOutlined";var J=c({cssVarPrefix:"joy",colorSchemes:{light:{palette:{primary:{50:"#fff3e4",100:"#ffe1bc",200:"#ffcd92",300:"#ffb96a",400:"#feaa51",500:"#ff9c3f",600:"#f9913d",700:"#f28239",800:"#eb7435",900:"#e05c2e"},text:{tertiary:"rgba(0 0 0 / 0.56)"}}},dark:{palette:{primary:{50:"#fff3e4",100:"#ffe1bc",200:"#ffcd92",300:"#ffb96a",400:"#feaa51",500:"#ff9c3f",600:"#f9913d",700:"#f28239",800:"#eb7435",900:"#e05c2e"},text:{tertiary:"rgba(255 255 255 / 0.5)"}}}}});const K=new m,X=a({api:i({basePath:"https://prod.thenile.dev",credentials:"include"}),basePath:""}),{Provider:Y}=X,Z=({children:t})=>e.createElement(u,{client:K},t),_=r=>{const{children:a,theme:n,tenantId:o,QueryProvider:l=Z,basePath:c="https://prod.thenile.dev",api:m}=r,u=t((()=>({api:m??i({basePath:c,credentials:"include"}),tenantId:String(o),basePath:c})),[m,c,o]);return e.createElement(l,null,e.createElement(s,{defaultMode:"system",theme:n??J},e.createElement(Y,{value:u},a)))},ee=()=>r(X),te=()=>ee().api;var re;function ae(){return ae=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},ae.apply(this,arguments)}var ne=function(e){return n("svg",ae({xmlns:"http://www.w3.org/2000/svg",width:18,height:18},e),re||(re=n("g",{fillRule:"evenodd"},n("path",{fill:"#EA4335",d:"M9 3.48c1.69 0 2.83.73 3.48 1.34l2.54-2.48C13.46.89 11.43 0 9 0 5.48 0 2.44 2.02.96 4.96l2.91 2.26C4.6 5.05 6.62 3.48 9 3.48z"}),n("path",{fill:"#4285F4",d:"M17.64 9.2c0-.74-.06-1.28-.19-1.84H9v3.34h4.96c-.1.83-.64 2.08-1.84 2.92l2.84 2.2c1.7-1.57 2.68-3.88 2.68-6.62z"}),n("path",{fill:"#FBBC05",d:"M3.88 10.78A5.54 5.54 0 0 1 3.58 9c0-.62.11-1.22.29-1.78L.96 4.96A9.008 9.008 0 0 0 0 9c0 1.45.35 2.82.96 4.04l2.92-2.26z"}),n("path",{fill:"#34A853",d:"M9 18c2.43 0 4.47-.8 5.96-2.18l-2.84-2.2c-.76.53-1.78.9-3.12.9-2.38 0-4.4-1.57-5.12-3.74L.97 13.04C2.45 15.98 5.48 18 9 18z"}),n("path",{fill:"none",d:"M0 0h18v18H0z"}))))};function oe(r){const{workspace:a,database:n,newTenantName:o}=r,{basePath:l}=(()=>{const{basePath:e,tenantId:r}=ee();return t((()=>({tenantId:r,basePath:e})),[e,r])})(),i=`${l}/workspaces/${encodeURIComponent(a??"")}/databases/${encodeURIComponent(n??"")}/users/oidc/google/login`,c=o?"?newTenant="+encodeURIComponent(o):"",s=(r?.href??i)+c;return e.createElement(p,{component:"a",href:s,display:"flex",flex:1,sx:{textDecoration:"none"}},e.createElement(p,null,e.createElement(f,{sx:{padding:0,textTransform:"initial",flex:1},"aria-label":"log in with google"},e.createElement(g,{direction:"row",alignItems:"center",p:0,flex:1,fontFamily:"Roboto, sans-serif",fontSize:"14px",display:"inline-flex",color:"rgb(255 255, 255)",boxShadow:"rgb(0 0 0 / 24%) 0px 2px 2px 0px rgb(0 0 0 / 24%) 0px 0px 1px 0px",borderRadius:"4px",border:"1px solid transparent",fontWeight:"500",sx:{backgroundColor:"rgb(66 133, 244)"}},e.createElement(p,{padding:"11px",display:"flex",border:"1px solid rgb(66, 133, 244)",borderRadius:"4px",sx:{background:"rgb(255, 255, 255)"}},e.createElement(ne,{"aria-hidden":"true"})),e.createElement(p,{padding:"10px",flex:1},e.createElement(b,{sx:{color:"white"},fontWeight:700,fontFamily:"Roboto, sans-serif",fontSize:"14px",height:"20px"},"Continue with Google"))))))}function le(e){const{options:t,attribute:r,display:a,helperText:o}=e,{watch:l,control:i}=E(),c=l(r.name),s={};return o&&(s.color="danger"),n(y,{name:r.name,rules:{required:Boolean(r.required)},control:i,render:({field:e})=>n(g,null,n(T,{htmlFor:`${e.name}`},a.label),n(p,{role:"group","aria-labelledby":r.name,sx:{borderRadius:"var(--joy-radius-sm)",p:.5,border:o?"1px solid var(--joy-palette-danger-outlinedBorder)":"none"}},n(z,{orientation:"horizontal",wrap:!0,sx:{"--List-gap":"8px"}},t.map((a=>(s.id=String(a.value),n($,{key:`${a.value}-${a.label}`},n(L,Object.assign({overlay:t.length>1},s,{checked:c.includes(a.value),disableIcon:t.length>1,variant:"soft",label:a.label,onChange:t=>{if(r.allowMultiple)if(t.target.checked)c?e.onChange(c.concat(a.value)):e.onChange([a.value]);else{const t=c.filter((e=>e!==a.value));t.length>0?e.onChange(t):e.onChange("")}else t.target.checked?e.onChange(a.value):e.onChange("")}})))))))),n(b,{sx:{color:"var(--joy-palette-danger-500)"},level:"body-sm"},o))})}var ie;!function(e){e.Text="text",e.Password="password",e.Select="select",e.Number="number",e.Float="float",e.Checkbox="checkbox",e.Switch="switch"}(ie||(ie={}));const ce=e=>!0===e.allowMultiple&&!Array.isArray(e.defaultValue)&&e.defaultValue?"number"==typeof e.defaultValue?[e.defaultValue]:[String(e.defaultValue)]:e.defaultValue??"";function se(t){const{error:r,attr:a}=t;return r?e.createElement(O,{title:r,color:"danger",sx:{cursor:"pointer"}},e.createElement(T,null,a.label??a.name,e.createElement(C,{sx:{ml:.5,"--Icon-color":"#c41c1c"},fontSize:"small"}))):e.createElement(T,null,a.label??a.name)}function me(t){const{mutation:r,buttonText:a,attributes:n,cancelButton:o,loading:l,successMessage:i}=t,c=e.useMemo((()=>n.reduce(((e,t)=>(e[t.name]=ce(t),e)),{})),[n]),s=x({defaultValues:c}),{register:m,control:u,handleSubmit:d,formState:{errors:b}}=s,h=e.useCallback((e=>{r.mutate(e)}),[r]);return e.createElement(w,Object.assign({},s),e.createElement(g,{component:"form",onSubmit:d((e=>h(e))),spacing:2},n.map((t=>{const r={},a={key:t.name,label:t.label??t.name,id:t.label??t.name,placeholder:t.placeholder??t.label??t.name,error:Boolean(b[t.name]),disabled:Boolean(t.disabled)},n=t.options??[],o=t.helpText??"";let l="";switch(t.required&&(l=b[t.name]?`${t.label??t.name} is required`:"",r.required=!0),t.type){case ie.Switch:return e.createElement(S,{key:a.key,id:a.id,orientation:"horizontal",sx:{alignItems:"center"}},e.createElement(p,null,e.createElement(se,{error:l,attr:t}),e.createElement(k,{id:`${t.name}-helper-text`},o)),e.createElement(y,{control:u,rules:{required:Boolean(t.required)},name:t.name,render:({field:r})=>{const a={};return b[t.name]&&(a.color="danger"),e.createElement(q,Object.assign({id:`switch-field-${t.name}`},a,r,{checked:Boolean(r.value),onChange:e=>{r.onChange(e.target.checked)},color:r.value?"success":"neutral",endDecorator:r.value?n[0].label:n[1].label,sx:{"--Switch-thumbSize":"28px"}}))}}));case ie.Checkbox:return e.createElement(le,{key:a.key,attribute:t,display:a,options:n,helperText:o});case ie.Select:return e.createElement(S,{key:a.key,id:a.id},e.createElement(se,{error:l,attr:t}),e.createElement(y,{control:u,rules:{required:Boolean(t.required)},name:t.name,render:({field:r})=>{const l={};return b[t.name]&&(l.color="danger"),e.createElement(g,null,e.createElement(j,Object.assign({id:`select-field-${t.name}`,placeholder:`${a.placeholder}...`},l,r,{onChange:(e,t)=>{r.onChange(t)}}),n.map((t=>e.createElement(U,{key:String(t.value??""),value:t.value},t.label)))),e.createElement(k,{id:`${t.name}-helper-text`},o))}}));case ie.Password:return e.createElement(S,{key:a.key,id:a.id},e.createElement(se,{error:l,attr:t}),e.createElement(v,Object.assign({},a,m(t.name,r),{type:ie.Password})),e.createElement(k,{id:`${t.name}-helper-text`},o));case ie.Number:return e.createElement(S,{key:a.key,id:a.id},e.createElement(se,{error:l,attr:t}),e.createElement(v,Object.assign({},a,m(t.name,r),{type:ie.Number})),e.createElement(k,{id:`${t.name}-helper-text`},o));case ie.Text:default:return e.createElement(S,{key:a.key,id:a.id},e.createElement(se,{error:l,attr:t}),e.createElement(v,Object.assign({},a,m(t.name,r))),e.createElement(k,{id:`${t.name}-helper-text`},o))}})),o?e.createElement(g,{spacing:2,direction:"row"},o,e.createElement(p,null,e.createElement(f,{type:"submit"},a))):e.createElement(p,null,e.createElement(g,{direction:"row",gap:2},e.createElement(f,{type:"submit",loading:l},a),i))))}function ue(t){const[r,a]=e.useState(),{buttonText:n="Sign up",onSuccess:o,onError:l,attributes:i,beforeMutate:c}=t,s=te(),m=d((async e=>{a(void 0);const t=(c&&c(e))??e,{email:r,password:n,preferredName:o,newTenant:l,...i}=t;return Object.keys(i).length>0&&console.warn("additional metadata not supported yet."),s.auth.signUp({signUpRequest:{email:r,password:n,preferredName:o,newTenant:l}})}),{onSuccess:o,onError:(e,t)=>{a(e.message),l&&l(e,t)}}),u=e.useMemo((()=>{const e=[{name:"email",label:"Email",type:ie.Text,defaultValue:"",required:!0},{name:"password",label:"Password",type:ie.Password,defaultValue:"",required:!0}];return i&&i.length>0?e.concat(i):e}),[i]);return e.createElement(g,{gap:2},r?e.createElement(h,{color:"danger"},r):null,e.createElement(me,{mutation:m,buttonText:n,attributes:u}))}function de(t){const[r,a]=e.useState(),{attributes:n,onSuccess:o,onError:l,beforeMutate:i}=t,c=te(),s=d((async e=>{a(void 0);const t=(i&&i(e))??e;return await c.auth.login({loginRequest:t})}),{onSuccess:o,onError:l}),m=e.useMemo((()=>{const e=[{name:"email",label:"Email",type:ie.Text,defaultValue:"",required:!0},{name:"password",label:"Password",type:ie.Password,defaultValue:"",required:!0}];return n&&n.length>0?e.concat(n):e}),[n]);return e.createElement(g,{gap:2},r?e.createElement(h,{color:"danger"},r):null,e.createElement(me,{mutation:s,buttonText:"Log in",attributes:m}))}function pe(t){const{attributes:r,onSuccess:a,onError:n,beforeMutate:o,nextButtonText:l="Next",loginButtonText:i="Log in",disableSSO:c=!1}=t,s=te(),[m,u]=e.useState(c?i:l),p=d((async e=>{const t=(o&&o(e))??e;return await s.auth.login({loginRequest:{email:t.email,password:t.password},sso:!c})}),{onSuccess:(e,t)=>{e&&(e?.redirectURI?window.location.href=e.redirectURI:m!==i?u(i):a&&a(e,t))},onError:(e,t)=>{m===i?n&&n(e,t):u(i)}}),f=e.useMemo((()=>{const e=[{name:"email",label:"Email",type:ie.Text,defaultValue:"",required:!0}];return m===i&&e.push({name:"password",label:"Password",type:ie.Password,defaultValue:"",required:!0}),r&&r.length>0?e.concat(r):e}),[r,m,i]);return e.createElement(me,{mutation:p,buttonText:m,attributes:f})}function fe(t){const{open:r,setOpen:a,refetch:n}=t,o=te(),[l,i]=e.useState(),{watch:c,register:s,handleSubmit:m}=x(),u=c("email");e.useEffect((()=>{null!=l&&i()}),[u]);const p=d((e=>o.users.createTenantUser({signUpRequest:e})),{onSuccess(e){n&&n(e),a(!1)},onError(e){e instanceof Error&&i(e.message)}}),f=e.useCallback((async e=>{i(""),p.mutate(e)}),[p]);return e.createElement(P,{open:r},e.createElement(I,null,e.createElement(R,{spacing:2},e.createElement(F,{level:"h4"},"Create user"),e.createElement(e.Fragment,null,l&&e.createElement(F,{color:"danger"},l)),e.createElement(R,{component:"form",sx:{width:"40ch"},spacing:1,onSubmit:m((e=>f(e)))},e.createElement(M,{sx:{"--FormHelperText-color":"var(--joy-palette-danger-500)"}},e.createElement(V,{htmlFor:"email"},"Email"),e.createElement(B,Object.assign({},s("email"),{fullWidth:!0,size:"lg",id:"email",name:"email",autoComplete:"current-email",required:!0,error:Boolean(l)}))),e.createElement(M,{sx:{"--FormHelperText-color":"var(--joy-palette-danger-500)"}},e.createElement(V,{htmlFor:"password"},"Password"),e.createElement(B,Object.assign({},s("password"),{fullWidth:!0,size:"lg",id:"password",autoComplete:"current-password",type:"password",required:!0}))),e.createElement(R,{direction:"row",sx:{pt:2},spacing:2},e.createElement(A,{onClick:()=>a(!1),variant:"plain"},"Cancel"),e.createElement(A,{type:"submit"},"Create"))))))}function ge(t){const{allowCreation:r,buttonText:a,onUserCreateSuccess:n}=t,[l,i]=o(!1);return r?e.createElement(g,{alignItems:"flex-end",gap:1},e.createElement(fe,{open:l,setOpen:i,refetch:n}),e.createElement(f,{startDecorator:e.createElement(N,null),size:"sm",onClick:()=>i(!0)},a)):null}const be=e=>Object.keys(e).reduce(((t,r)=>{const a=e[r];return a instanceof Set?t[r]=Array.from(a).join(", "):Array.isArray(a)?t[r]=a.join(", "):t[r]=a,t}),{}),he=(e,t,r)=>{if(!e)return[[],[]];const a=e.map(be),n=Object.keys(a[0]),o={},l=n?.map((e=>{const n=function(e,t,r){let a=r&&e?r.measureText(String(e)).width:50;a+=27;let n=a;return n=16+Math.ceil(r?r.measureText(t.reduce(((t,r)=>{let a=r[String(e)];return(G(a)||H(a))&&(a=""),a=a?.toString(),t.length>a.length?t:a}),"")).width:50),n<a&&(n=a),n+=8,n}(e,a,t),l=e.slice();if(r.includes(l))return null==o[l]?o[l]=l.length:o[l]+=1,{field:l.padEnd(o[l]),headerName:l.padEnd(o[l]),width:n}})).filter(Boolean)??[];return[l,a]};function Ee(e,r){const a=function(){const[e,t]=o();return l((()=>{const e=document.createElement("canvas").getContext("2d");e&&(e.font="18px Roboto",t(e))}),[]),e}(),[n,i]=t((()=>he(e,a,r)),[e,a,r]);return[n,i]}function ye(t){const{data:r,allowCreation:a=!0,buttonText:n="Add a user",onUserCreateSuccess:o,slots:l,include:i=["email","preferedName"]}=t,c={width:"100%",height:"100%",...l?.dataGrid??{}},[s,m]=Ee(r,i);return e.createElement(g,{flex:1},e.createElement(ge,{allowCreation:a,buttonText:n,onUserCreateSuccess:o}),e.createElement(D,{sx:c,rows:m,columns:s,hideFooter:!0}))}function xe(t){const{config:r,providerName:a,onSuccess:n,onError:o,allowEdit:l=!0,configurationGuide:i}=t,c=te(),[s,m]=e.useState(!1),[u,p]=e.useState(!1),[f,E]=e.useState(r),y=e.useRef(),x=e.useMemo((()=>{const e=[{name:"enabled",label:"Allow Okta logins",type:ie.Switch,defaultValue:!0===f?.enabled,options:[{label:"Enabled"},{label:"Disabled"}],disabled:!l},{name:"clientId",label:"Client id",type:ie.Text,defaultValue:f?.clientId??"",required:!0,disabled:!l},{name:"configUrl",label:"Config url",type:ie.Text,defaultValue:f?.configUrl??"",helpText:"The URL of the .well-known/openid-configuration for the identity provider",required:!0,disabled:!l},{name:"emailDomains",label:"Email domains",type:ie.Text,defaultValue:f?.emailDomains?.join(", ")??"",required:!0,helpText:"A comma seperated list of email domains (yourDomain.com) to be used",disabled:!l}];return f?.clientId||e.splice(2,0,{name:"clientSecret",label:"Client secret",type:ie.Password,defaultValue:"",required:!0,disabled:!l}),e}),[l,f?.clientId,f?.configUrl,f?.emailDomains,f?.enabled]),w=d((e=>{m(!0);const t={providerName:a.toLowerCase(),updateProviderRequest:{...e,emailDomains:e.emailDomains.split(",")}};return null!=f?c.auth.updateProvider(t):c.auth.createProvider(t)}),{onSuccess:(e,t)=>{E(e),p(!0),n&&n(e,t)},onError:o,onSettled:(e,t,r)=>{m(!1),y.current&&clearTimeout(y.current),y.current=setTimeout((()=>{p(!1)}),3e3),e||(t&&!t?.message.includes("Unterminated string")||E({enabled:r.enabled,clientId:r.clientId,configUrl:r.configUrl,emailDomains:r.emailDomains.split(", ")}),p(!0),n&&n(e,r))}});return e.useEffect((()=>{})),e.createElement(g,{gap:2,position:"relative"},e.createElement(b,{level:"h4"},"Step 1"),i,e.createElement(b,{level:"h4"},"Step 2"),e.createElement(me,{mutation:w,buttonText:"Update",attributes:x,loading:s,successMessage:e.createElement(h,{color:"success",sx:{opacity:u?1:0,transition:"opacity 200ms",height:"0.9rem"},startDecorator:e.createElement(Q,null)},e.createElement(b,{textAlign:"center",fontSize:"sm"},"Provider updated"))}))}function we({callbackUrl:t}){const[r,a]=e.useState(!1),n=e.useRef();return e.useEffect((()=>{n.current&&clearTimeout(n.current),n.current=setTimeout((()=>{a(!1)}),3250)}),[r]),e.createElement(g,{gap:2},e.createElement(b,null,"In order for Okta to redirect properly, provide the following URL as the"," ",e.createElement(p,{component:"span",sx:{fontFamily:"monospace"}},"Sign-in redirect URIs")," ","in the admin configuration of your application."),e.createElement(v,{onClick:async()=>{await navigator.clipboard.writeText(t),a(!0)},sx:e=>({input:{cursor:"pointer"},span:{cursor:"pointer"},"&:hover svg":{"--Icon-color":e.palette.primary[500]}}),value:t,readOnly:!0,endDecorator:e.createElement(O,{title:"Copy Okta redirect URL"},e.createElement(p,{position:"relative",width:r?"82px":"24px",height:"24px"},e.createElement(p,{position:"absolute",top:"0",left:"0",sx:{opacity:r?0:1,transition:"opacity 300ms"}},e.createElement(W,null)),e.createElement(p,{position:"absolute",top:"0",left:"0",sx:{opacity:r?1:0,transition:"opacity 300ms"}},e.createElement(g,{direction:"row",gap:1},e.createElement(Q,null),e.createElement(b,{color:"primary"},"Copied!")))))}))}function ve(t){const{callbackUrl:r,providers:a,...n}=t;if(!a)return null;const o=a?.find((e=>"okta"===e.provider));return e.createElement(xe,Object.assign({},n,{config:o,providerName:"Okta",configurationGuide:e.createElement(we,{callbackUrl:r})}))}export{ie as FormAttributeType,oe as GoogleLoginButton,_ as NileProvider,ve as Okta,xe as SSOForm,pe as SingleSignOnForm,de as UserLoginForm,ue as UserSignupForm,ye as UserTenantList};
|
|
2
|
+
//# sourceMappingURL=react.esm.js.map
|