@thunderid/react 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/presentation/ChangeCredential/BaseChangeCredential.cjs +1 -1
- package/dist/cjs/components/presentation/auth/AcceptInvite/BaseAcceptInvite.cjs +1 -1
- package/dist/cjs/components/presentation/auth/AcceptInvite/BaseAcceptInvite.cjs.map +1 -1
- package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs +56 -17
- package/dist/cjs/components/presentation/auth/AuthOptionFactory.cjs.map +1 -1
- package/dist/cjs/components/presentation/auth/InviteUser/BaseInviteUser.cjs +21 -5
- package/dist/cjs/components/presentation/auth/InviteUser/BaseInviteUser.cjs.map +1 -1
- package/dist/cjs/components/presentation/auth/InviteUser/InviteUser.cjs +6 -0
- package/dist/cjs/components/presentation/auth/InviteUser/InviteUser.cjs.map +1 -1
- package/dist/cjs/components/primitives/AuthFlowSelect/AuthFlowSelect.cjs +21 -0
- package/dist/cjs/components/primitives/AuthFlowSelect/AuthFlowSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.cjs +32 -0
- package/dist/cjs/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/CopyableText/CopyableText.cjs +41 -21
- package/dist/cjs/components/primitives/CopyableText/CopyableText.cjs.map +1 -1
- package/dist/cjs/components/primitives/CopyableText/CopyableText.styles.cjs +5 -2
- package/dist/cjs/components/primitives/CopyableText/CopyableText.styles.cjs.map +1 -1
- package/dist/cjs/components/primitives/Icons/Copy.cjs +33 -0
- package/dist/cjs/components/primitives/Icons/Copy.cjs.map +1 -0
- package/dist/cjs/components/primitives/PasswordField/PasswordField.cjs +2 -1
- package/dist/cjs/components/primitives/PasswordField/PasswordField.cjs.map +1 -1
- package/dist/cjs/components/primitives/Select/ResourceSelect.cjs +104 -0
- package/dist/cjs/components/primitives/Select/ResourceSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/Select/Select.cjs +72 -21
- package/dist/cjs/components/primitives/Select/Select.cjs.map +1 -1
- package/dist/cjs/components/primitives/Select/Select.styles.cjs +19 -3
- package/dist/cjs/components/primitives/Select/Select.styles.cjs.map +1 -1
- package/dist/cjs/components/primitives/Select/useSelectMessages.cjs +21 -0
- package/dist/cjs/components/primitives/Select/useSelectMessages.cjs.map +1 -0
- package/dist/cjs/components/primitives/TextField/TextField.cjs +19 -3
- package/dist/cjs/components/primitives/TextField/TextField.cjs.map +1 -1
- package/dist/cjs/components/primitives/TextField/TextField.styles.cjs +18 -5
- package/dist/cjs/components/primitives/TextField/TextField.styles.cjs.map +1 -1
- package/dist/cjs/components/primitives/UserSelect/BaseUserSelect.cjs +33 -0
- package/dist/cjs/components/primitives/UserSelect/BaseUserSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/UserSelect/UserSelect.cjs +21 -0
- package/dist/cjs/components/primitives/UserSelect/UserSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/UserTypeSelect/BaseUserTypeSelect.cjs +31 -0
- package/dist/cjs/components/primitives/UserTypeSelect/BaseUserTypeSelect.cjs.map +1 -0
- package/dist/cjs/components/primitives/UserTypeSelect/UserTypeSelect.cjs +21 -0
- package/dist/cjs/components/primitives/UserTypeSelect/UserTypeSelect.cjs.map +1 -0
- package/dist/cjs/hooks/useFetchAuthFlows.cjs +36 -0
- package/dist/cjs/hooks/useFetchAuthFlows.cjs.map +1 -0
- package/dist/cjs/hooks/useFetchUserTypes.cjs +34 -0
- package/dist/cjs/hooks/useFetchUserTypes.cjs.map +1 -0
- package/dist/cjs/hooks/useFetchUsers.cjs +35 -0
- package/dist/cjs/hooks/useFetchUsers.cjs.map +1 -0
- package/dist/cjs/hooks/useInfiniteOptions.cjs +129 -0
- package/dist/cjs/hooks/useInfiniteOptions.cjs.map +1 -0
- package/dist/cjs/hooks/useManagementEndpoint.cjs.map +1 -1
- package/dist/cjs/index.cjs +56 -0
- package/dist/cjs/utils/createAuthenticatedFetcher.cjs +1 -0
- package/dist/cjs/utils/createAuthenticatedFetcher.cjs.map +1 -1
- package/dist/components/presentation/ChangeCredential/BaseChangeCredential.js +1 -1
- package/dist/components/presentation/auth/AcceptInvite/BaseAcceptInvite.d.ts.map +1 -1
- package/dist/components/presentation/auth/AcceptInvite/BaseAcceptInvite.js +1 -1
- package/dist/components/presentation/auth/AcceptInvite/BaseAcceptInvite.js.map +1 -1
- package/dist/components/presentation/auth/AuthOptionFactory.d.ts +9 -1
- package/dist/components/presentation/auth/AuthOptionFactory.d.ts.map +1 -1
- package/dist/components/presentation/auth/AuthOptionFactory.js +56 -17
- package/dist/components/presentation/auth/AuthOptionFactory.js.map +1 -1
- package/dist/components/presentation/auth/InviteUser/BaseInviteUser.d.ts +18 -2
- package/dist/components/presentation/auth/InviteUser/BaseInviteUser.d.ts.map +1 -1
- package/dist/components/presentation/auth/InviteUser/BaseInviteUser.js +22 -6
- package/dist/components/presentation/auth/InviteUser/BaseInviteUser.js.map +1 -1
- package/dist/components/presentation/auth/InviteUser/InviteUser.d.ts +2 -1
- package/dist/components/presentation/auth/InviteUser/InviteUser.d.ts.map +1 -1
- package/dist/components/presentation/auth/InviteUser/InviteUser.js +6 -0
- package/dist/components/presentation/auth/InviteUser/InviteUser.js.map +1 -1
- package/dist/components/primitives/AuthFlowSelect/AuthFlowSelect.d.ts +11 -0
- package/dist/components/primitives/AuthFlowSelect/AuthFlowSelect.d.ts.map +1 -0
- package/dist/components/primitives/AuthFlowSelect/AuthFlowSelect.js +19 -0
- package/dist/components/primitives/AuthFlowSelect/AuthFlowSelect.js.map +1 -0
- package/dist/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.d.ts +14 -0
- package/dist/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.d.ts.map +1 -0
- package/dist/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.js +29 -0
- package/dist/components/primitives/AuthFlowSelect/BaseAuthFlowSelect.js.map +1 -0
- package/dist/components/primitives/CopyableText/CopyableText.d.ts +9 -0
- package/dist/components/primitives/CopyableText/CopyableText.d.ts.map +1 -1
- package/dist/components/primitives/CopyableText/CopyableText.js +40 -21
- package/dist/components/primitives/CopyableText/CopyableText.js.map +1 -1
- package/dist/components/primitives/CopyableText/CopyableText.styles.d.ts.map +1 -1
- package/dist/components/primitives/CopyableText/CopyableText.styles.js +5 -2
- package/dist/components/primitives/CopyableText/CopyableText.styles.js.map +1 -1
- package/dist/components/primitives/Icons/Copy.d.ts +7 -0
- package/dist/components/primitives/Icons/Copy.d.ts.map +1 -0
- package/dist/components/primitives/Icons/Copy.js +31 -0
- package/dist/components/primitives/Icons/Copy.js.map +1 -0
- package/dist/components/primitives/PasswordField/PasswordField.d.ts +9 -1
- package/dist/components/primitives/PasswordField/PasswordField.d.ts.map +1 -1
- package/dist/components/primitives/PasswordField/PasswordField.js +2 -1
- package/dist/components/primitives/PasswordField/PasswordField.js.map +1 -1
- package/dist/components/primitives/Select/ResourceSelect.d.ts +36 -0
- package/dist/components/primitives/Select/ResourceSelect.d.ts.map +1 -0
- package/dist/components/primitives/Select/ResourceSelect.js +100 -0
- package/dist/components/primitives/Select/ResourceSelect.js.map +1 -0
- package/dist/components/primitives/Select/Select.d.ts +22 -13
- package/dist/components/primitives/Select/Select.d.ts.map +1 -1
- package/dist/components/primitives/Select/Select.js +72 -22
- package/dist/components/primitives/Select/Select.js.map +1 -1
- package/dist/components/primitives/Select/Select.styles.d.ts.map +1 -1
- package/dist/components/primitives/Select/Select.styles.js +19 -3
- package/dist/components/primitives/Select/Select.styles.js.map +1 -1
- package/dist/components/primitives/Select/__tests__/selectTestUtils.d.ts +6 -0
- package/dist/components/primitives/Select/__tests__/selectTestUtils.d.ts.map +1 -0
- package/dist/components/primitives/Select/useSelectMessages.d.ts +9 -0
- package/dist/components/primitives/Select/useSelectMessages.d.ts.map +1 -0
- package/dist/components/primitives/Select/useSelectMessages.js +18 -0
- package/dist/components/primitives/Select/useSelectMessages.js.map +1 -0
- package/dist/components/primitives/TextField/TextField.d.ts +8 -0
- package/dist/components/primitives/TextField/TextField.d.ts.map +1 -1
- package/dist/components/primitives/TextField/TextField.js +19 -3
- package/dist/components/primitives/TextField/TextField.js.map +1 -1
- package/dist/components/primitives/TextField/TextField.styles.d.ts +2 -1
- package/dist/components/primitives/TextField/TextField.styles.d.ts.map +1 -1
- package/dist/components/primitives/TextField/TextField.styles.js +18 -5
- package/dist/components/primitives/TextField/TextField.styles.js.map +1 -1
- package/dist/components/primitives/UserSelect/BaseUserSelect.d.ts +15 -0
- package/dist/components/primitives/UserSelect/BaseUserSelect.d.ts.map +1 -0
- package/dist/components/primitives/UserSelect/BaseUserSelect.js +30 -0
- package/dist/components/primitives/UserSelect/BaseUserSelect.js.map +1 -0
- package/dist/components/primitives/UserSelect/UserSelect.d.ts +11 -0
- package/dist/components/primitives/UserSelect/UserSelect.d.ts.map +1 -0
- package/dist/components/primitives/UserSelect/UserSelect.js +19 -0
- package/dist/components/primitives/UserSelect/UserSelect.js.map +1 -0
- package/dist/components/primitives/UserTypeSelect/BaseUserTypeSelect.d.ts +14 -0
- package/dist/components/primitives/UserTypeSelect/BaseUserTypeSelect.d.ts.map +1 -0
- package/dist/components/primitives/UserTypeSelect/BaseUserTypeSelect.js +28 -0
- package/dist/components/primitives/UserTypeSelect/BaseUserTypeSelect.js.map +1 -0
- package/dist/components/primitives/UserTypeSelect/UserTypeSelect.d.ts +11 -0
- package/dist/components/primitives/UserTypeSelect/UserTypeSelect.d.ts.map +1 -0
- package/dist/components/primitives/UserTypeSelect/UserTypeSelect.js +19 -0
- package/dist/components/primitives/UserTypeSelect/UserTypeSelect.js.map +1 -0
- package/dist/hooks/useFetchAuthFlows.d.ts +9 -0
- package/dist/hooks/useFetchAuthFlows.d.ts.map +1 -0
- package/dist/hooks/useFetchAuthFlows.js +33 -0
- package/dist/hooks/useFetchAuthFlows.js.map +1 -0
- package/dist/hooks/useFetchUserTypes.d.ts +8 -0
- package/dist/hooks/useFetchUserTypes.d.ts.map +1 -0
- package/dist/hooks/useFetchUserTypes.js +31 -0
- package/dist/hooks/useFetchUserTypes.js.map +1 -0
- package/dist/hooks/useFetchUsers.d.ts +8 -0
- package/dist/hooks/useFetchUsers.d.ts.map +1 -0
- package/dist/hooks/useFetchUsers.js +32 -0
- package/dist/hooks/useFetchUsers.js.map +1 -0
- package/dist/hooks/useInfiniteOptions.d.ts +31 -0
- package/dist/hooks/useInfiniteOptions.d.ts.map +1 -0
- package/dist/hooks/useInfiniteOptions.js +126 -0
- package/dist/hooks/useInfiniteOptions.js.map +1 -0
- package/dist/hooks/useManagementEndpoint.d.ts +1 -1
- package/dist/hooks/useManagementEndpoint.d.ts.map +1 -1
- package/dist/hooks/useManagementEndpoint.js.map +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/utils/createAuthenticatedFetcher.d.ts.map +1 -1
- package/dist/utils/createAuthenticatedFetcher.js +1 -0
- package/dist/utils/createAuthenticatedFetcher.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,14 +7,24 @@ import { bem, withVendorCSSClassPrefix } from "@thunderid/browser";
|
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/primitives/TextField/TextField.tsx
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Makes an element with `role="button"` respond to Enter and Space, as a native button does.
|
|
12
|
+
*/
|
|
13
|
+
const activateOnKey = (activate) => (event) => {
|
|
14
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
activate();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const TextField = ({ label, error, required, className, disabled, helperText, startIcon, endAdornment, endIcon, endIconLabel = "End icon", onStartIconClick, onEndIconClick, type = "text", style = {},...rest }) => {
|
|
11
20
|
const { theme, colorScheme } = useTheme_default();
|
|
12
21
|
const hasError = !!error;
|
|
13
|
-
const styles = TextField_styles_default(theme, colorScheme, disabled ?? false, hasError, !!startIcon, !!endIcon);
|
|
22
|
+
const styles = TextField_styles_default(theme, colorScheme, disabled ?? false, hasError, !!startIcon, !!endIcon, !!endAdornment);
|
|
14
23
|
const inputClassName = cx(withVendorCSSClassPrefix(bem("text-field", "input")), styles["input"], hasError && styles["inputError"], disabled && styles["inputDisabled"]);
|
|
15
24
|
const containerClassName = cx(withVendorCSSClassPrefix(bem("text-field", "container")), styles["inputContainer"]);
|
|
16
25
|
const startIconClassName = cx(withVendorCSSClassPrefix(bem("text-field", "start-icon")), styles["startIcon"]);
|
|
17
26
|
const endIconClassName = cx(withVendorCSSClassPrefix(bem("text-field", "end-icon")), styles["endIcon"]);
|
|
27
|
+
const endAdornmentClassName = cx(withVendorCSSClassPrefix(bem("text-field", "end-adornment")), styles["endAdornment"]);
|
|
18
28
|
return /* @__PURE__ */ jsxs(FormControl_default, {
|
|
19
29
|
error,
|
|
20
30
|
helperText,
|
|
@@ -32,6 +42,7 @@ const TextField = ({ label, error, required, className, disabled, helperText, st
|
|
|
32
42
|
onClick: onStartIconClick,
|
|
33
43
|
role: onStartIconClick ? "button" : void 0,
|
|
34
44
|
tabIndex: onStartIconClick && !disabled ? 0 : void 0,
|
|
45
|
+
onKeyDown: onStartIconClick && !disabled ? activateOnKey(onStartIconClick) : void 0,
|
|
35
46
|
"aria-label": "Start icon",
|
|
36
47
|
children: startIcon
|
|
37
48
|
}),
|
|
@@ -48,8 +59,13 @@ const TextField = ({ label, error, required, className, disabled, helperText, st
|
|
|
48
59
|
onClick: onEndIconClick,
|
|
49
60
|
role: onEndIconClick ? "button" : void 0,
|
|
50
61
|
tabIndex: onEndIconClick && !disabled ? 0 : void 0,
|
|
51
|
-
|
|
62
|
+
onKeyDown: onEndIconClick && !disabled ? activateOnKey(onEndIconClick) : void 0,
|
|
63
|
+
"aria-label": endIconLabel,
|
|
52
64
|
children: endIcon
|
|
65
|
+
}),
|
|
66
|
+
endAdornment && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: endAdornmentClassName,
|
|
68
|
+
children: endAdornment
|
|
53
69
|
})
|
|
54
70
|
]
|
|
55
71
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":["TextField: FC<TextFieldProps>","useTheme","styles: Record<string, string>","useStyles","inputClassName: string","containerClassName: string","startIconClassName: string","endIconClassName: string","FormControl","InputLabel"],"sources":["../../../../src/components/primitives/TextField/TextField.tsx"],"sourcesContent":["// Copyright 2024 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {withVendorCSSClassPrefix, bem} from '@thunderid/browser';\nimport {FC, InputHTMLAttributes, ReactNode} from 'react';\nimport useStyles from './TextField.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport {cx} from '../../../styles/emotion';\nimport FormControl from '../FormControl/FormControl';\nimport InputLabel from '../InputLabel/InputLabel';\n\nexport interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className'> {\n /**\n * Additional CSS class names\n */\n className?: string;\n /**\n * Whether the field is disabled\n */\n disabled?: boolean;\n /**\n * Icon to display at the end (right) of the input\n */\n endIcon?: ReactNode;\n /**\n * Error message to display below the input\n */\n error?: string;\n /**\n * Helper text to display below the input\n */\n helperText?: string;\n /**\n * Label text to display above the input\n */\n label?: string;\n /**\n * Click handler for the end icon\n */\n onEndIconClick?: () => void;\n /**\n * Click handler for the start icon\n */\n onStartIconClick?: () => void;\n /**\n * Whether the field is required\n */\n required?: boolean;\n /**\n * Icon to display at the start (left) of the input\n */\n startIcon?: ReactNode;\n}\n\nconst TextField: FC<TextFieldProps> = ({\n label,\n error,\n required,\n className,\n disabled,\n helperText,\n startIcon,\n endIcon,\n onStartIconClick,\n onEndIconClick,\n type = 'text',\n style = {},\n ...rest\n}: TextFieldProps) => {\n const {theme, colorScheme}: ReturnType<typeof useTheme> = useTheme();\n const hasError = !!error;\n const hasStartIcon = !!startIcon;\n const hasEndIcon = !!endIcon;\n const styles: Record<string, string> = useStyles(\n theme,\n colorScheme,\n disabled ?? false,\n hasError,\n hasStartIcon,\n hasEndIcon,\n );\n\n const inputClassName: string = cx(\n withVendorCSSClassPrefix(bem('text-field', 'input')),\n styles['input'],\n hasError && styles['inputError'],\n disabled && styles['inputDisabled'],\n );\n\n const containerClassName: string = cx(\n withVendorCSSClassPrefix(bem('text-field', 'container')),\n styles['inputContainer'],\n );\n\n const startIconClassName: string = cx(withVendorCSSClassPrefix(bem('text-field', 'start-icon')), styles['startIcon']);\n\n const endIconClassName: string = cx(withVendorCSSClassPrefix(bem('text-field', 'end-icon')), styles['endIcon']);\n\n return (\n <FormControl\n error={error}\n helperText={helperText}\n className={cx(withVendorCSSClassPrefix(bem('text-field')), className)}\n style={style}\n >\n {label && (\n <InputLabel required={required} error={hasError}>\n {label}\n </InputLabel>\n )}\n <div className={containerClassName}>\n {startIcon && (\n <div\n className={startIconClassName}\n onClick={onStartIconClick}\n role={onStartIconClick ? 'button' : undefined}\n tabIndex={onStartIconClick && !disabled ? 0 : undefined}\n aria-label=\"Start icon\"\n >\n {startIcon}\n </div>\n )}\n <input\n className={inputClassName}\n type={type}\n disabled={disabled}\n aria-invalid={hasError}\n aria-required={required}\n {...rest}\n />\n {endIcon && (\n <div\n className={endIconClassName}\n onClick={onEndIconClick}\n role={onEndIconClick ? 'button' : undefined}\n tabIndex={onEndIconClick && !disabled ? 0 : undefined}\n aria-label
|
|
1
|
+
{"version":3,"file":"TextField.js","names":["TextField: FC<TextFieldProps>","useTheme","styles: Record<string, string>","useStyles","inputClassName: string","containerClassName: string","startIconClassName: string","endIconClassName: string","endAdornmentClassName: string","FormControl","InputLabel"],"sources":["../../../../src/components/primitives/TextField/TextField.tsx"],"sourcesContent":["// Copyright 2024 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {withVendorCSSClassPrefix, bem} from '@thunderid/browser';\nimport {FC, InputHTMLAttributes, KeyboardEvent, ReactNode} from 'react';\nimport useStyles from './TextField.styles';\nimport useTheme from '../../../contexts/Theme/useTheme';\nimport {cx} from '../../../styles/emotion';\nimport FormControl from '../FormControl/FormControl';\nimport InputLabel from '../InputLabel/InputLabel';\n\nexport interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'className'> {\n /**\n * Additional CSS class names\n */\n className?: string;\n /**\n * Whether the field is disabled\n */\n disabled?: boolean;\n /**\n * Extra content shown inside the field, at its end after the end icon, such as an action button\n */\n endAdornment?: ReactNode;\n /**\n * Icon to display at the end (right) of the input\n */\n endIcon?: ReactNode;\n /**\n * Accessible name of the end icon when it is a button, that is when `onEndIconClick` is set\n */\n endIconLabel?: string;\n /**\n * Error message to display below the input\n */\n error?: string;\n /**\n * Helper text to display below the input\n */\n helperText?: string;\n /**\n * Label text to display above the input\n */\n label?: string;\n /**\n * Click handler for the end icon\n */\n onEndIconClick?: () => void;\n /**\n * Click handler for the start icon\n */\n onStartIconClick?: () => void;\n /**\n * Whether the field is required\n */\n required?: boolean;\n /**\n * Icon to display at the start (left) of the input\n */\n startIcon?: ReactNode;\n}\n\n/**\n * Makes an element with `role=\"button\"` respond to Enter and Space, as a native button does.\n */\nconst activateOnKey =\n (activate: () => void) =>\n (event: KeyboardEvent<HTMLDivElement>): void => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n activate();\n }\n };\n\nconst TextField: FC<TextFieldProps> = ({\n label,\n error,\n required,\n className,\n disabled,\n helperText,\n startIcon,\n endAdornment,\n endIcon,\n endIconLabel = 'End icon',\n onStartIconClick,\n onEndIconClick,\n type = 'text',\n style = {},\n ...rest\n}: TextFieldProps) => {\n const {theme, colorScheme}: ReturnType<typeof useTheme> = useTheme();\n const hasError = !!error;\n const hasStartIcon = !!startIcon;\n const hasEndIcon = !!endIcon;\n const hasEndAdornment = !!endAdornment;\n const styles: Record<string, string> = useStyles(\n theme,\n colorScheme,\n disabled ?? false,\n hasError,\n hasStartIcon,\n hasEndIcon,\n hasEndAdornment,\n );\n\n const inputClassName: string = cx(\n withVendorCSSClassPrefix(bem('text-field', 'input')),\n styles['input'],\n hasError && styles['inputError'],\n disabled && styles['inputDisabled'],\n );\n\n const containerClassName: string = cx(\n withVendorCSSClassPrefix(bem('text-field', 'container')),\n styles['inputContainer'],\n );\n\n const startIconClassName: string = cx(withVendorCSSClassPrefix(bem('text-field', 'start-icon')), styles['startIcon']);\n\n const endIconClassName: string = cx(withVendorCSSClassPrefix(bem('text-field', 'end-icon')), styles['endIcon']);\n\n const endAdornmentClassName: string = cx(\n withVendorCSSClassPrefix(bem('text-field', 'end-adornment')),\n styles['endAdornment'],\n );\n\n return (\n <FormControl\n error={error}\n helperText={helperText}\n className={cx(withVendorCSSClassPrefix(bem('text-field')), className)}\n style={style}\n >\n {label && (\n <InputLabel required={required} error={hasError}>\n {label}\n </InputLabel>\n )}\n <div className={containerClassName}>\n {startIcon && (\n <div\n className={startIconClassName}\n onClick={onStartIconClick}\n role={onStartIconClick ? 'button' : undefined}\n tabIndex={onStartIconClick && !disabled ? 0 : undefined}\n onKeyDown={onStartIconClick && !disabled ? activateOnKey(onStartIconClick) : undefined}\n aria-label=\"Start icon\"\n >\n {startIcon}\n </div>\n )}\n <input\n className={inputClassName}\n type={type}\n disabled={disabled}\n aria-invalid={hasError}\n aria-required={required}\n {...rest}\n />\n {endIcon && (\n <div\n className={endIconClassName}\n onClick={onEndIconClick}\n role={onEndIconClick ? 'button' : undefined}\n tabIndex={onEndIconClick && !disabled ? 0 : undefined}\n onKeyDown={onEndIconClick && !disabled ? activateOnKey(onEndIconClick) : undefined}\n aria-label={endIconLabel}\n >\n {endIcon}\n </div>\n )}\n {endAdornment && <div className={endAdornmentClassName}>{endAdornment}</div>}\n </div>\n </FormControl>\n );\n};\n\nexport default TextField;\n"],"mappings":";;;;;;;;;;;;AAiEA,MAAM,iBACH,cACA,UAA+C;AAC9C,KAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,KAAK;AAC9C,QAAM,gBAAgB;AACtB,YAAU;;;AAIhB,MAAMA,aAAiC,EACrC,OACA,OACA,UACA,WACA,UACA,YACA,WACA,cACA,SACA,eAAe,YACf,kBACA,gBACA,OAAO,QACP,QAAQ,EAAE,CACV,GAAG,WACiB;CACpB,MAAM,EAAC,OAAO,gBAA4CC,kBAAU;CACpE,MAAM,WAAW,CAAC,CAAC;CAInB,MAAMC,SAAiCC,yBACrC,OACA,aACA,YAAY,OACZ,UAPmB,CAAC,CAAC,WACJ,CAAC,CAAC,SACG,CAAC,CAAC,aASzB;CAED,MAAMC,iBAAyB,GAC7B,yBAAyB,IAAI,cAAc,QAAQ,CAAC,EACpD,OAAO,UACP,YAAY,OAAO,eACnB,YAAY,OAAO,iBACpB;CAED,MAAMC,qBAA6B,GACjC,yBAAyB,IAAI,cAAc,YAAY,CAAC,EACxD,OAAO,kBACR;CAED,MAAMC,qBAA6B,GAAG,yBAAyB,IAAI,cAAc,aAAa,CAAC,EAAE,OAAO,aAAa;CAErH,MAAMC,mBAA2B,GAAG,yBAAyB,IAAI,cAAc,WAAW,CAAC,EAAE,OAAO,WAAW;CAE/G,MAAMC,wBAAgC,GACpC,yBAAyB,IAAI,cAAc,gBAAgB,CAAC,EAC5D,OAAO,gBACR;AAED,QACE,qBAACC;EACQ;EACK;EACZ,WAAW,GAAG,yBAAyB,IAAI,aAAa,CAAC,EAAE,UAAU;EAC9D;aAEN,SACC,oBAACC;GAAqB;GAAU,OAAO;aACpC;IACU,EAEf,qBAAC;GAAI,WAAW;;IACb,aACC,oBAAC;KACC,WAAW;KACX,SAAS;KACT,MAAM,mBAAmB,WAAW;KACpC,UAAU,oBAAoB,CAAC,WAAW,IAAI;KAC9C,WAAW,oBAAoB,CAAC,WAAW,cAAc,iBAAiB,GAAG;KAC7E,cAAW;eAEV;MACG;IAER,oBAAC;KACC,WAAW;KACL;KACI;KACV,gBAAc;KACd,iBAAe;KACf,GAAI;MACJ;IACD,WACC,oBAAC;KACC,WAAW;KACX,SAAS;KACT,MAAM,iBAAiB,WAAW;KAClC,UAAU,kBAAkB,CAAC,WAAW,IAAI;KAC5C,WAAW,kBAAkB,CAAC,WAAW,cAAc,eAAe,GAAG;KACzE,cAAY;eAEX;MACG;IAEP,gBAAgB,oBAAC;KAAI,WAAW;eAAwB;MAAmB;;IACxE;GACM;;AAIlB,wBAAe"}
|
|
@@ -7,8 +7,9 @@ import { Theme } from '@thunderid/browser';
|
|
|
7
7
|
* @param hasError - Whether the component has an error
|
|
8
8
|
* @param hasStartIcon - Whether the component has a start icon
|
|
9
9
|
* @param hasEndIcon - Whether the component has an end icon
|
|
10
|
+
* @param hasEndAdornment - Whether the component has extra content before the end icon
|
|
10
11
|
* @returns Object containing CSS class names for component styling
|
|
11
12
|
*/
|
|
12
|
-
declare const useStyles: (theme: Theme, colorScheme: string, disabled: boolean, hasError: boolean, hasStartIcon: boolean, hasEndIcon: boolean) => Record<string, string>;
|
|
13
|
+
declare const useStyles: (theme: Theme, colorScheme: string, disabled: boolean, hasError: boolean, hasStartIcon: boolean, hasEndIcon: boolean, hasEndAdornment?: boolean) => Record<string, string>;
|
|
13
14
|
export default useStyles;
|
|
14
15
|
//# sourceMappingURL=TextField.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/TextField/TextField.styles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAIzC
|
|
1
|
+
{"version":3,"file":"TextField.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/TextField/TextField.styles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAIzC;;;;;;;;;;GAUG;AACH,QAAA,MAAM,SAAS,GACb,OAAO,KAAK,EACZ,aAAa,MAAM,EACnB,UAAU,OAAO,EACjB,UAAU,OAAO,EACjB,cAAc,OAAO,EACrB,YAAY,OAAO,EACnB,yBAAuB,KACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAkIiE,CAAC;AAE1F,eAAe,SAAS,CAAC"}
|
|
@@ -10,11 +10,14 @@ import { useMemo } from "react";
|
|
|
10
10
|
* @param hasError - Whether the component has an error
|
|
11
11
|
* @param hasStartIcon - Whether the component has a start icon
|
|
12
12
|
* @param hasEndIcon - Whether the component has an end icon
|
|
13
|
+
* @param hasEndAdornment - Whether the component has extra content before the end icon
|
|
13
14
|
* @returns Object containing CSS class names for component styling
|
|
14
15
|
*/
|
|
15
|
-
const useStyles = (theme, colorScheme, disabled, hasError, hasStartIcon, hasEndIcon) => useMemo(() => {
|
|
16
|
+
const useStyles = (theme, colorScheme, disabled, hasError, hasStartIcon, hasEndIcon, hasEndAdornment = false) => useMemo(() => {
|
|
16
17
|
const inlineStartPadding = hasStartIcon ? `calc(${theme.vars.spacing.unit} * 5)` : `calc(${theme.vars.spacing.unit} * 1.5)`;
|
|
17
|
-
|
|
18
|
+
let inlineEndPadding = `calc(${theme.vars.spacing.unit} * 1.5)`;
|
|
19
|
+
if (hasEndIcon && hasEndAdornment) inlineEndPadding = `calc(${theme.vars.spacing.unit} * 8)`;
|
|
20
|
+
else if (hasEndIcon || hasEndAdornment) inlineEndPadding = `calc(${theme.vars.spacing.unit} * 5)`;
|
|
18
21
|
const inputContainer = css`
|
|
19
22
|
position: relative;
|
|
20
23
|
display: flex;
|
|
@@ -102,11 +105,20 @@ const useStyles = (theme, colorScheme, disabled, hasError, hasStartIcon, hasEndI
|
|
|
102
105
|
${icon};
|
|
103
106
|
inset-inline-start: ${theme.vars.spacing.unit};
|
|
104
107
|
`;
|
|
105
|
-
|
|
106
|
-
endIcon: css`
|
|
108
|
+
const endIcon = css`
|
|
107
109
|
${icon};
|
|
110
|
+
inset-inline-end: calc(${theme.vars.spacing.unit} * ${hasEndAdornment ? 4.5 : 1});
|
|
111
|
+
`;
|
|
112
|
+
return {
|
|
113
|
+
endAdornment: css`
|
|
114
|
+
position: absolute;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
top: 50%;
|
|
118
|
+
transform: translateY(-50%);
|
|
108
119
|
inset-inline-end: ${theme.vars.spacing.unit};
|
|
109
120
|
`,
|
|
121
|
+
endIcon,
|
|
110
122
|
icon,
|
|
111
123
|
input,
|
|
112
124
|
inputContainer,
|
|
@@ -120,7 +132,8 @@ const useStyles = (theme, colorScheme, disabled, hasError, hasStartIcon, hasEndI
|
|
|
120
132
|
disabled,
|
|
121
133
|
hasError,
|
|
122
134
|
hasStartIcon,
|
|
123
|
-
hasEndIcon
|
|
135
|
+
hasEndIcon,
|
|
136
|
+
hasEndAdornment
|
|
124
137
|
]);
|
|
125
138
|
var TextField_styles_default = useStyles;
|
|
126
139
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.styles.js","names":["inlineStartPadding: string","
|
|
1
|
+
{"version":3,"file":"TextField.styles.js","names":["inlineStartPadding: string","inputContainer: string","input: string","inputError: string","inputDisabled: string","icon: string","startIcon: string","endIcon: string"],"sources":["../../../../src/components/primitives/TextField/TextField.styles.ts"],"sourcesContent":["// Copyright 2024 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {Theme} from '@thunderid/browser';\nimport {useMemo} from 'react';\nimport {css} from '../../../styles/emotion';\n\n/**\n * Creates styles for the TextField component using BEM methodology\n * @param theme - The theme object containing design tokens\n * @param colorScheme - The current color scheme (used for memoization)\n * @param disabled - Whether the component is disabled\n * @param hasError - Whether the component has an error\n * @param hasStartIcon - Whether the component has a start icon\n * @param hasEndIcon - Whether the component has an end icon\n * @param hasEndAdornment - Whether the component has extra content before the end icon\n * @returns Object containing CSS class names for component styling\n */\nconst useStyles = (\n theme: Theme,\n colorScheme: string,\n disabled: boolean,\n hasError: boolean,\n hasStartIcon: boolean,\n hasEndIcon: boolean,\n hasEndAdornment = false,\n): Record<string, string> =>\n useMemo(() => {\n const inlineStartPadding: string = hasStartIcon\n ? `calc(${theme.vars.spacing.unit} * 5)`\n : `calc(${theme.vars.spacing.unit} * 1.5)`;\n let inlineEndPadding = `calc(${theme.vars.spacing.unit} * 1.5)`;\n\n if (hasEndIcon && hasEndAdornment) {\n inlineEndPadding = `calc(${theme.vars.spacing.unit} * 8)`;\n } else if (hasEndIcon || hasEndAdornment) {\n inlineEndPadding = `calc(${theme.vars.spacing.unit} * 5)`;\n }\n\n const inputContainer: string = css`\n position: relative;\n display: flex;\n align-items: center;\n `;\n\n const input: string = css`\n width: 100%;\n padding-block: ${theme.vars.spacing.unit};\n padding-inline-start: ${inlineStartPadding};\n padding-inline-end: ${inlineEndPadding};\n border: 1px solid ${hasError ? theme.vars.colors.error.main : theme.vars.colors.border};\n border-radius: ${theme.vars.components?.Field?.root?.borderRadius || theme.vars.borderRadius.medium};\n font-size: ${theme.vars.typography.fontSizes.md};\n font-family: ${theme.vars.typography.fontFamily};\n color: ${theme.vars.colors.text.primary};\n background-color: ${disabled ? theme.vars.colors.background.disabled : theme.vars.colors.background.surface};\n outline: none;\n transition:\n border-color 0.2s ease,\n box-shadow 0.2s ease;\n\n &:focus {\n border-color: ${hasError ? theme.vars.colors.error.main : theme.vars.colors.primary.main};\n box-shadow: 0 0 0 2px ${hasError ? `${theme.vars.colors.error.main}20` : `${theme.vars.colors.primary.main}20`};\n }\n\n &:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n }\n\n &:hover:not(:disabled) {\n border-color: ${hasError ? theme.vars.colors.error.main : theme.vars.colors.primary.main};\n }\n\n &::placeholder {\n color: ${theme.vars.colors.text.secondary};\n opacity: 0.7;\n }\n `;\n\n const inputError: string = css`\n border-color: ${theme.vars.colors.error.main};\n\n &:focus {\n border-color: ${theme.vars.colors.error.main};\n box-shadow: 0 0 0 2px ${theme.vars.colors.error.main}20;\n }\n\n &:hover:not(:disabled) {\n border-color: ${theme.vars.colors.error.main};\n }\n `;\n\n const inputDisabled: string = css`\n background-color: ${theme.vars.colors.background.disabled};\n opacity: 0.6;\n cursor: not-allowed;\n `;\n\n const icon: string = css`\n position: absolute;\n background: none;\n border: none;\n cursor: ${disabled ? 'not-allowed' : 'pointer'};\n padding: calc(${theme.vars.spacing.unit} / 2);\n display: flex;\n align-items: center;\n justify-content: center;\n color: ${theme.vars.colors.text.secondary};\n opacity: ${disabled ? 0.5 : 1};\n top: 50%;\n transform: translateY(-50%);\n transition:\n color 0.2s ease,\n opacity 0.2s ease;\n\n &:hover:not(:disabled) {\n color: ${theme.vars.colors.text.primary};\n }\n\n &:focus {\n outline: 2px solid ${theme.vars.colors.primary.main};\n outline-offset: 2px;\n }\n `;\n\n const startIcon: string = css`\n ${icon};\n inset-inline-start: ${theme.vars.spacing.unit};\n `;\n\n const endIcon: string = css`\n ${icon};\n inset-inline-end: calc(${theme.vars.spacing.unit} * ${hasEndAdornment ? 4.5 : 1});\n `;\n\n const endAdornment: string = css`\n position: absolute;\n display: flex;\n align-items: center;\n top: 50%;\n transform: translateY(-50%);\n inset-inline-end: ${theme.vars.spacing.unit};\n `;\n\n return {\n endAdornment,\n endIcon,\n icon,\n input,\n inputContainer,\n inputDisabled,\n inputError,\n startIcon,\n };\n }, [theme, colorScheme, disabled, hasError, hasStartIcon, hasEndIcon, hasEndAdornment]);\n\nexport default useStyles;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,aACJ,OACA,aACA,UACA,UACA,cACA,YACA,kBAAkB,UAElB,cAAc;CACZ,MAAMA,qBAA6B,eAC/B,QAAQ,MAAM,KAAK,QAAQ,KAAK,SAChC,QAAQ,MAAM,KAAK,QAAQ,KAAK;CACpC,IAAI,mBAAmB,QAAQ,MAAM,KAAK,QAAQ,KAAK;AAEvD,KAAI,cAAc,gBAChB,oBAAmB,QAAQ,MAAM,KAAK,QAAQ,KAAK;UAC1C,cAAc,gBACvB,oBAAmB,QAAQ,MAAM,KAAK,QAAQ,KAAK;CAGrD,MAAMC,iBAAyB,GAAG;;;;;CAMlC,MAAMC,QAAgB,GAAG;;uBAEN,MAAM,KAAK,QAAQ,KAAK;8BACjB,mBAAmB;4BACrB,iBAAiB;0BACnB,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM,KAAK,OAAO,OAAO;uBACtE,MAAM,KAAK,YAAY,OAAO,MAAM,gBAAgB,MAAM,KAAK,aAAa,OAAO;mBACvF,MAAM,KAAK,WAAW,UAAU,GAAG;qBACjC,MAAM,KAAK,WAAW,WAAW;eACvC,MAAM,KAAK,OAAO,KAAK,QAAQ;0BACpB,WAAW,MAAM,KAAK,OAAO,WAAW,WAAW,MAAM,KAAK,OAAO,WAAW,QAAQ;;;;;;;wBAO1F,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM,KAAK,OAAO,QAAQ,KAAK;gCACjE,WAAW,GAAG,MAAM,KAAK,OAAO,MAAM,KAAK,MAAM,GAAG,MAAM,KAAK,OAAO,QAAQ,KAAK,IAAI;;;;;;;;;wBAS/F,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM,KAAK,OAAO,QAAQ,KAAK;;;;iBAIhF,MAAM,KAAK,OAAO,KAAK,UAAU;;;;CAK9C,MAAMC,aAAqB,GAAG;sBACZ,MAAM,KAAK,OAAO,MAAM,KAAK;;;wBAG3B,MAAM,KAAK,OAAO,MAAM,KAAK;gCACrB,MAAM,KAAK,OAAO,MAAM,KAAK;;;;wBAIrC,MAAM,KAAK,OAAO,MAAM,KAAK;;;CAIjD,MAAMC,gBAAwB,GAAG;0BACX,MAAM,KAAK,OAAO,WAAW,SAAS;;;;CAK5D,MAAMC,OAAe,GAAG;;;;gBAIZ,WAAW,gBAAgB,UAAU;sBAC/B,MAAM,KAAK,QAAQ,KAAK;;;;eAI/B,MAAM,KAAK,OAAO,KAAK,UAAU;iBAC/B,WAAW,KAAM,EAAE;;;;;;;;iBAQnB,MAAM,KAAK,OAAO,KAAK,QAAQ;;;;6BAInB,MAAM,KAAK,OAAO,QAAQ,KAAK;;;;CAKxD,MAAMC,YAAoB,GAAG;QACzB,KAAK;4BACe,MAAM,KAAK,QAAQ,KAAK;;CAGhD,MAAMC,UAAkB,GAAG;QACvB,KAAK;+BACkB,MAAM,KAAK,QAAQ,KAAK,KAAK,kBAAkB,MAAM,EAAE;;AAYlF,QAAO;EACL,cAV2B,GAAG;;;;;;0BAMV,MAAM,KAAK,QAAQ,KAAK;;EAK5C;EACA;EACA;EACA;EACA;EACA;EACA;EACD;GACA;CAAC;CAAO;CAAa;CAAU;CAAU;CAAc;CAAY;CAAgB,CAAC;AAEzF,+BAAe"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FetchUsers, UserSelectOptionMapping } from '@thunderid/browser';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { ResourceSelectProps } from '../Select/ResourceSelect';
|
|
4
|
+
export interface BaseUserSelectProps extends Omit<ResourceSelectProps, 'bemBlock' | 'defaults' | 'fallbackMessages' | 'fetchPage' | 'mapping' | 'messageKey' | 'resource' | 'type'> {
|
|
5
|
+
fetchUsers?: FetchUsers;
|
|
6
|
+
mapping?: UserSelectOptionMapping;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Single-user picker: a `Select` that loads from the given `fetchUsers`, submitting the user's ID and
|
|
10
|
+
* labelling each user from `display`, `username`, or `email` unless `mapping` says otherwise.
|
|
11
|
+
* Building block for {@link UserSelect}; for a custom data source use `Select` with `useInfiniteOptions`.
|
|
12
|
+
*/
|
|
13
|
+
declare const BaseUserSelect: FC<BaseUserSelectProps>;
|
|
14
|
+
export default BaseUserSelect;
|
|
15
|
+
//# sourceMappingURL=BaseUserSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseUserSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/UserSelect/BaseUserSelect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAwB,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAAuB,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7E,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,mBAAmB,EACnB,UAAU,GAAG,UAAU,GAAG,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,CAC5G;IACD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACnC;AAID;;;;GAIG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAY3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import ResourceSelect_default from "../Select/ResourceSelect.js";
|
|
2
|
+
import { EmbeddedFlowComponentType, UserSelectConstants } from "@thunderid/browser";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/primitives/UserSelect/BaseUserSelect.tsx
|
|
6
|
+
const USER_DEFAULTS = { labelAttributes: UserSelectConstants.LABEL_ATTRIBUTES };
|
|
7
|
+
/**
|
|
8
|
+
* Single-user picker: a `Select` that loads from the given `fetchUsers`, submitting the user's ID and
|
|
9
|
+
* labelling each user from `display`, `username`, or `email` unless `mapping` says otherwise.
|
|
10
|
+
* Building block for {@link UserSelect}; for a custom data source use `Select` with `useInfiniteOptions`.
|
|
11
|
+
*/
|
|
12
|
+
const BaseUserSelect = ({ fetchUsers, mapping,...rest }) => /* @__PURE__ */ jsx(ResourceSelect_default, {
|
|
13
|
+
...rest,
|
|
14
|
+
bemBlock: "user-select",
|
|
15
|
+
defaults: USER_DEFAULTS,
|
|
16
|
+
fallbackMessages: {
|
|
17
|
+
ariaLabel: "Select a user",
|
|
18
|
+
empty: "No users found."
|
|
19
|
+
},
|
|
20
|
+
fetchPage: fetchUsers,
|
|
21
|
+
mapping,
|
|
22
|
+
messageKey: "user_select",
|
|
23
|
+
resource: "users",
|
|
24
|
+
type: EmbeddedFlowComponentType.UserSelect
|
|
25
|
+
});
|
|
26
|
+
var BaseUserSelect_default = BaseUserSelect;
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { BaseUserSelect_default as default };
|
|
30
|
+
//# sourceMappingURL=BaseUserSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseUserSelect.js","names":["USER_DEFAULTS: SelectOptionDefaults","BaseUserSelect: FC<BaseUserSelectProps>","ResourceSelect"],"sources":["../../../../src/components/primitives/UserSelect/BaseUserSelect.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {EmbeddedFlowComponentType, UserSelectConstants} from '@thunderid/browser';\nimport type {FetchUsers, SelectOptionDefaults, UserSelectOptionMapping} from '@thunderid/browser';\nimport {FC} from 'react';\nimport ResourceSelect, {ResourceSelectProps} from '../Select/ResourceSelect';\n\nexport interface BaseUserSelectProps\n extends Omit<\n ResourceSelectProps,\n 'bemBlock' | 'defaults' | 'fallbackMessages' | 'fetchPage' | 'mapping' | 'messageKey' | 'resource' | 'type'\n > {\n fetchUsers?: FetchUsers;\n mapping?: UserSelectOptionMapping;\n}\n\nconst USER_DEFAULTS: SelectOptionDefaults = {labelAttributes: UserSelectConstants.LABEL_ATTRIBUTES};\n\n/**\n * Single-user picker: a `Select` that loads from the given `fetchUsers`, submitting the user's ID and\n * labelling each user from `display`, `username`, or `email` unless `mapping` says otherwise.\n * Building block for {@link UserSelect}; for a custom data source use `Select` with `useInfiniteOptions`.\n */\nconst BaseUserSelect: FC<BaseUserSelectProps> = ({fetchUsers, mapping, ...rest}: BaseUserSelectProps) => (\n <ResourceSelect\n {...rest}\n bemBlock=\"user-select\"\n defaults={USER_DEFAULTS}\n fallbackMessages={{ariaLabel: 'Select a user', empty: 'No users found.'}}\n fetchPage={fetchUsers}\n mapping={mapping}\n messageKey=\"user_select\"\n resource=\"users\"\n type={EmbeddedFlowComponentType.UserSelect}\n />\n);\n\nexport default BaseUserSelect;\n"],"mappings":";;;;;AAiBA,MAAMA,gBAAsC,EAAC,iBAAiB,oBAAoB,kBAAiB;;;;;;AAOnG,MAAMC,kBAA2C,EAAC,YAAY,QAAS,GAAG,WACxE,oBAACC;CACC,GAAI;CACJ,UAAS;CACT,UAAU;CACV,kBAAkB;EAAC,WAAW;EAAiB,OAAO;EAAkB;CACxE,WAAW;CACF;CACT,YAAW;CACX,UAAS;CACT,MAAM,0BAA0B;EAChC;AAGJ,6BAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BaseUserSelectProps } from './BaseUserSelect';
|
|
3
|
+
export type UserSelectProps = Omit<BaseUserSelectProps, 'fetchUsers'>;
|
|
4
|
+
/**
|
|
5
|
+
* Single-user picker for signed-in screens. It loads the user directory itself with the signed-in
|
|
6
|
+
* user's access token and submits the chosen user's ID, so it takes no data source. For any other
|
|
7
|
+
* data source use {@link Select} with {@link useInfiniteOptions}.
|
|
8
|
+
*/
|
|
9
|
+
declare const UserSelect: FC<UserSelectProps>;
|
|
10
|
+
export default UserSelect;
|
|
11
|
+
//# sourceMappingURL=UserSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/UserSelect/UserSelect.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAAuB,EAAC,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAGrE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;AAEtE;;;;GAIG;AACH,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAEnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import useFetchUsers_default from "../../../hooks/useFetchUsers.js";
|
|
2
|
+
import BaseUserSelect_default from "./BaseUserSelect.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/primitives/UserSelect/UserSelect.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Single-user picker for signed-in screens. It loads the user directory itself with the signed-in
|
|
8
|
+
* user's access token and submits the chosen user's ID, so it takes no data source. For any other
|
|
9
|
+
* data source use {@link Select} with {@link useInfiniteOptions}.
|
|
10
|
+
*/
|
|
11
|
+
const UserSelect = (props) => /* @__PURE__ */ jsx(BaseUserSelect_default, {
|
|
12
|
+
...props,
|
|
13
|
+
fetchUsers: useFetchUsers_default()
|
|
14
|
+
});
|
|
15
|
+
var UserSelect_default = UserSelect;
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { UserSelect_default as default };
|
|
19
|
+
//# sourceMappingURL=UserSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserSelect.js","names":["UserSelect: FC<UserSelectProps>","BaseUserSelect","useFetchUsers"],"sources":["../../../../src/components/primitives/UserSelect/UserSelect.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {FC} from 'react';\nimport BaseUserSelect, {BaseUserSelectProps} from './BaseUserSelect';\nimport useFetchUsers from '../../../hooks/useFetchUsers';\n\nexport type UserSelectProps = Omit<BaseUserSelectProps, 'fetchUsers'>;\n\n/**\n * Single-user picker for signed-in screens. It loads the user directory itself with the signed-in\n * user's access token and submits the chosen user's ID, so it takes no data source. For any other\n * data source use {@link Select} with {@link useInfiniteOptions}.\n */\nconst UserSelect: FC<UserSelectProps> = (props: UserSelectProps) => (\n <BaseUserSelect {...props} fetchUsers={useFetchUsers()} />\n);\n\nexport default UserSelect;\n"],"mappings":";;;;;;;;;;AAcA,MAAMA,cAAmC,UACvC,oBAACC;CAAe,GAAI;CAAO,YAAYC,uBAAe;EAAI;AAG5D,yBAAe"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FetchUserTypes } from '@thunderid/browser';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { ResourceSelectProps } from '../Select/ResourceSelect';
|
|
4
|
+
export interface BaseUserTypeSelectProps extends Omit<ResourceSelectProps, 'bemBlock' | 'defaults' | 'fallbackMessages' | 'fetchPage' | 'mapping' | 'messageKey' | 'resource' | 'type'> {
|
|
5
|
+
fetchUserTypes?: FetchUserTypes;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* User-type picker: a `Select` that loads from the given `fetchUserTypes`, showing and submitting
|
|
9
|
+
* each user type's handle. Building block for {@link UserTypeSelect}; for a custom data source use
|
|
10
|
+
* `Select` with `useInfiniteOptions`.
|
|
11
|
+
*/
|
|
12
|
+
declare const BaseUserTypeSelect: FC<BaseUserTypeSelectProps>;
|
|
13
|
+
export default BaseUserTypeSelect;
|
|
14
|
+
//# sourceMappingURL=BaseUserTypeSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseUserTypeSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/UserTypeSelect/BaseUserTypeSelect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAAuB,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7E,MAAM,WAAW,uBACf,SAAQ,IAAI,CACV,mBAAmB,EACnB,UAAU,GAAG,UAAU,GAAG,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,CAC5G;IACD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAcnD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ResourceSelect_default from "../Select/ResourceSelect.js";
|
|
2
|
+
import { EmbeddedFlowComponentType, UserTypeSelectConstants } from "@thunderid/browser";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/primitives/UserTypeSelect/BaseUserTypeSelect.tsx
|
|
6
|
+
/**
|
|
7
|
+
* User-type picker: a `Select` that loads from the given `fetchUserTypes`, showing and submitting
|
|
8
|
+
* each user type's handle. Building block for {@link UserTypeSelect}; for a custom data source use
|
|
9
|
+
* `Select` with `useInfiniteOptions`.
|
|
10
|
+
*/
|
|
11
|
+
const BaseUserTypeSelect = ({ fetchUserTypes,...rest }) => /* @__PURE__ */ jsx(ResourceSelect_default, {
|
|
12
|
+
...rest,
|
|
13
|
+
bemBlock: "user-type-select",
|
|
14
|
+
fallbackMessages: {
|
|
15
|
+
ariaLabel: "Select a user type",
|
|
16
|
+
empty: "No user types found."
|
|
17
|
+
},
|
|
18
|
+
fetchPage: fetchUserTypes,
|
|
19
|
+
mapping: UserTypeSelectConstants.MAPPING,
|
|
20
|
+
messageKey: "user_type_select",
|
|
21
|
+
resource: "user types",
|
|
22
|
+
type: EmbeddedFlowComponentType.UserTypeSelect
|
|
23
|
+
});
|
|
24
|
+
var BaseUserTypeSelect_default = BaseUserTypeSelect;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { BaseUserTypeSelect_default as default };
|
|
28
|
+
//# sourceMappingURL=BaseUserTypeSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseUserTypeSelect.js","names":["BaseUserTypeSelect: FC<BaseUserTypeSelectProps>","ResourceSelect"],"sources":["../../../../src/components/primitives/UserTypeSelect/BaseUserTypeSelect.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {EmbeddedFlowComponentType, UserTypeSelectConstants} from '@thunderid/browser';\nimport type {FetchUserTypes} from '@thunderid/browser';\nimport {FC} from 'react';\nimport ResourceSelect, {ResourceSelectProps} from '../Select/ResourceSelect';\n\nexport interface BaseUserTypeSelectProps\n extends Omit<\n ResourceSelectProps,\n 'bemBlock' | 'defaults' | 'fallbackMessages' | 'fetchPage' | 'mapping' | 'messageKey' | 'resource' | 'type'\n > {\n fetchUserTypes?: FetchUserTypes;\n}\n\n/**\n * User-type picker: a `Select` that loads from the given `fetchUserTypes`, showing and submitting\n * each user type's handle. Building block for {@link UserTypeSelect}; for a custom data source use\n * `Select` with `useInfiniteOptions`.\n */\nconst BaseUserTypeSelect: FC<BaseUserTypeSelectProps> = ({fetchUserTypes, ...rest}: BaseUserTypeSelectProps) => (\n <ResourceSelect\n {...rest}\n bemBlock=\"user-type-select\"\n fallbackMessages={{\n ariaLabel: 'Select a user type',\n empty: 'No user types found.',\n }}\n fetchPage={fetchUserTypes}\n mapping={UserTypeSelectConstants.MAPPING}\n messageKey=\"user_type_select\"\n resource=\"user types\"\n type={EmbeddedFlowComponentType.UserTypeSelect}\n />\n);\n\nexport default BaseUserTypeSelect;\n"],"mappings":";;;;;;;;;;AAqBA,MAAMA,sBAAmD,EAAC,eAAgB,GAAG,WAC3E,oBAACC;CACC,GAAI;CACJ,UAAS;CACT,kBAAkB;EAChB,WAAW;EACX,OAAO;EACR;CACD,WAAW;CACX,SAAS,wBAAwB;CACjC,YAAW;CACX,UAAS;CACT,MAAM,0BAA0B;EAChC;AAGJ,iCAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BaseUserTypeSelectProps } from './BaseUserTypeSelect';
|
|
3
|
+
export type UserTypeSelectProps = Omit<BaseUserTypeSelectProps, 'fetchUserTypes'>;
|
|
4
|
+
/**
|
|
5
|
+
* User-type picker for signed-in screens. It loads the user types itself with the signed-in user's
|
|
6
|
+
* access token and submits the chosen type's handle, so it takes no data source. For any other data
|
|
7
|
+
* source use `Select` with `useInfiniteOptions`.
|
|
8
|
+
*/
|
|
9
|
+
declare const UserTypeSelect: FC<UserTypeSelectProps>;
|
|
10
|
+
export default UserTypeSelect;
|
|
11
|
+
//# sourceMappingURL=UserTypeSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserTypeSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/UserTypeSelect/UserTypeSelect.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AACzB,OAA2B,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAGjF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;AAElF;;;;GAIG;AACH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAE3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import useFetchUserTypes_default from "../../../hooks/useFetchUserTypes.js";
|
|
2
|
+
import BaseUserTypeSelect_default from "./BaseUserTypeSelect.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/primitives/UserTypeSelect/UserTypeSelect.tsx
|
|
6
|
+
/**
|
|
7
|
+
* User-type picker for signed-in screens. It loads the user types itself with the signed-in user's
|
|
8
|
+
* access token and submits the chosen type's handle, so it takes no data source. For any other data
|
|
9
|
+
* source use `Select` with `useInfiniteOptions`.
|
|
10
|
+
*/
|
|
11
|
+
const UserTypeSelect = (props) => /* @__PURE__ */ jsx(BaseUserTypeSelect_default, {
|
|
12
|
+
...props,
|
|
13
|
+
fetchUserTypes: useFetchUserTypes_default()
|
|
14
|
+
});
|
|
15
|
+
var UserTypeSelect_default = UserTypeSelect;
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { UserTypeSelect_default as default };
|
|
19
|
+
//# sourceMappingURL=UserTypeSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserTypeSelect.js","names":["UserTypeSelect: FC<UserTypeSelectProps>","BaseUserTypeSelect","useFetchUserTypes"],"sources":["../../../../src/components/primitives/UserTypeSelect/UserTypeSelect.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {FC} from 'react';\nimport BaseUserTypeSelect, {BaseUserTypeSelectProps} from './BaseUserTypeSelect';\nimport useFetchUserTypes from '../../../hooks/useFetchUserTypes';\n\nexport type UserTypeSelectProps = Omit<BaseUserTypeSelectProps, 'fetchUserTypes'>;\n\n/**\n * User-type picker for signed-in screens. It loads the user types itself with the signed-in user's\n * access token and submits the chosen type's handle, so it takes no data source. For any other data\n * source use `Select` with `useInfiniteOptions`.\n */\nconst UserTypeSelect: FC<UserTypeSelectProps> = (props: UserTypeSelectProps) => (\n <BaseUserTypeSelect {...props} fetchUserTypes={useFetchUserTypes()} />\n);\n\nexport default UserTypeSelect;\n"],"mappings":";;;;;;;;;;AAcA,MAAMA,kBAA2C,UAC/C,oBAACC;CAAmB,GAAI;CAAO,gBAAgBC,2BAAmB;EAAI;AAGxE,6BAAe"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FetchAuthFlows } from '@thunderid/browser';
|
|
2
|
+
/**
|
|
3
|
+
* A `FetchAuthFlows` backed by the flow list, restricted to authentication flows and authenticated with
|
|
4
|
+
* the signed-in user's access token. Its identity is stable across renders, since a picker resets its
|
|
5
|
+
* loaded pages when the loader changes.
|
|
6
|
+
*/
|
|
7
|
+
declare const useFetchAuthFlows: () => FetchAuthFlows;
|
|
8
|
+
export default useFetchAuthFlows;
|
|
9
|
+
//# sourceMappingURL=useFetchAuthFlows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchAuthFlows.d.ts","sourceRoot":"","sources":["../../src/hooks/useFetchAuthFlows.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAgC,MAAM,oBAAoB,CAAC;AAKtF;;;;GAIG;AACH,QAAA,MAAM,iBAAiB,QAAO,cAoB7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import useManagementEndpoint_default from "./useManagementEndpoint.js";
|
|
2
|
+
import { useResolvedFetcher } from "./useResourceQuery.js";
|
|
3
|
+
import { AuthFlowSelectConstants, SelectConstants, getFlows, toAuthFlowSelectPage } from "@thunderid/browser";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useFetchAuthFlows.ts
|
|
7
|
+
/**
|
|
8
|
+
* A `FetchAuthFlows` backed by the flow list, restricted to authentication flows and authenticated with
|
|
9
|
+
* the signed-in user's access token. Its identity is stable across renders, since a picker resets its
|
|
10
|
+
* loaded pages when the loader changes.
|
|
11
|
+
*/
|
|
12
|
+
const useFetchAuthFlows = () => {
|
|
13
|
+
const { baseUrl, url } = useManagementEndpoint_default("flows");
|
|
14
|
+
const fetcher = useResolvedFetcher();
|
|
15
|
+
return useCallback(async ({ limit, offset, signal }) => toAuthFlowSelectPage(await getFlows({
|
|
16
|
+
baseUrl,
|
|
17
|
+
fetcher,
|
|
18
|
+
flowType: AuthFlowSelectConstants.FLOW_TYPE,
|
|
19
|
+
limit: Math.min(limit, SelectConstants.MAX_PAGE_SIZE),
|
|
20
|
+
offset,
|
|
21
|
+
signal,
|
|
22
|
+
url
|
|
23
|
+
}), offset), [
|
|
24
|
+
baseUrl,
|
|
25
|
+
fetcher,
|
|
26
|
+
url
|
|
27
|
+
]);
|
|
28
|
+
};
|
|
29
|
+
var useFetchAuthFlows_default = useFetchAuthFlows;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { useFetchAuthFlows_default as default };
|
|
33
|
+
//# sourceMappingURL=useFetchAuthFlows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchAuthFlows.js","names":["useManagementEndpoint","fetcher: ReturnType<typeof useResolvedFetcher>"],"sources":["../../src/hooks/useFetchAuthFlows.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {AuthFlowSelectConstants, getFlows, SelectConstants, toAuthFlowSelectPage} from '@thunderid/browser';\nimport type {FetchAuthFlows, SelectPage, SelectPageRequest} from '@thunderid/browser';\nimport {useCallback} from 'react';\nimport useManagementEndpoint, {ManagementEndpoint} from './useManagementEndpoint';\nimport {useResolvedFetcher} from './useResourceQuery';\n\n/**\n * A `FetchAuthFlows` backed by the flow list, restricted to authentication flows and authenticated with\n * the signed-in user's access token. Its identity is stable across renders, since a picker resets its\n * loaded pages when the loader changes.\n */\nconst useFetchAuthFlows = (): FetchAuthFlows => {\n const {baseUrl, url}: ManagementEndpoint = useManagementEndpoint('flows');\n const fetcher: ReturnType<typeof useResolvedFetcher> = useResolvedFetcher();\n\n return useCallback(\n async ({limit, offset, signal}: SelectPageRequest): Promise<SelectPage> =>\n toAuthFlowSelectPage(\n await getFlows({\n baseUrl,\n fetcher,\n flowType: AuthFlowSelectConstants.FLOW_TYPE,\n limit: Math.min(limit, SelectConstants.MAX_PAGE_SIZE),\n offset,\n signal,\n url,\n }),\n offset,\n ),\n [baseUrl, fetcher, url],\n );\n};\n\nexport default useFetchAuthFlows;\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,0BAA0C;CAC9C,MAAM,EAAC,SAAS,QAA2BA,8BAAsB,QAAQ;CACzE,MAAMC,UAAiD,oBAAoB;AAE3E,QAAO,YACL,OAAO,EAAC,OAAO,QAAQ,aACrB,qBACE,MAAM,SAAS;EACb;EACA;EACA,UAAU,wBAAwB;EAClC,OAAO,KAAK,IAAI,OAAO,gBAAgB,cAAc;EACrD;EACA;EACA;EACD,CAAC,EACF,OACD,EACH;EAAC;EAAS;EAAS;EAAI,CACxB;;AAGH,gCAAe"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FetchUserTypes } from '@thunderid/browser';
|
|
2
|
+
/**
|
|
3
|
+
* A `FetchUserTypes` backed by the user type list, authenticated with the signed-in user's access token.
|
|
4
|
+
* Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.
|
|
5
|
+
*/
|
|
6
|
+
declare const useFetchUserTypes: () => FetchUserTypes;
|
|
7
|
+
export default useFetchUserTypes;
|
|
8
|
+
//# sourceMappingURL=useFetchUserTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchUserTypes.d.ts","sourceRoot":"","sources":["../../src/hooks/useFetchUserTypes.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAgC,MAAM,oBAAoB,CAAC;AAKtF;;;GAGG;AACH,QAAA,MAAM,iBAAiB,QAAO,cAmB7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import useManagementEndpoint_default from "./useManagementEndpoint.js";
|
|
2
|
+
import { useResolvedFetcher } from "./useResourceQuery.js";
|
|
3
|
+
import { SelectConstants, getUserTypes, toUserTypeSelectPage } from "@thunderid/browser";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useFetchUserTypes.ts
|
|
7
|
+
/**
|
|
8
|
+
* A `FetchUserTypes` backed by the user type list, authenticated with the signed-in user's access token.
|
|
9
|
+
* Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.
|
|
10
|
+
*/
|
|
11
|
+
const useFetchUserTypes = () => {
|
|
12
|
+
const { baseUrl, url } = useManagementEndpoint_default("userTypes");
|
|
13
|
+
const fetcher = useResolvedFetcher();
|
|
14
|
+
return useCallback(async ({ limit, offset, signal }) => toUserTypeSelectPage(await getUserTypes({
|
|
15
|
+
baseUrl,
|
|
16
|
+
fetcher,
|
|
17
|
+
limit: Math.min(limit, SelectConstants.MAX_PAGE_SIZE),
|
|
18
|
+
offset,
|
|
19
|
+
signal,
|
|
20
|
+
url
|
|
21
|
+
}), offset), [
|
|
22
|
+
baseUrl,
|
|
23
|
+
fetcher,
|
|
24
|
+
url
|
|
25
|
+
]);
|
|
26
|
+
};
|
|
27
|
+
var useFetchUserTypes_default = useFetchUserTypes;
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useFetchUserTypes_default as default };
|
|
31
|
+
//# sourceMappingURL=useFetchUserTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchUserTypes.js","names":["useManagementEndpoint","fetcher: ReturnType<typeof useResolvedFetcher>"],"sources":["../../src/hooks/useFetchUserTypes.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {getUserTypes, SelectConstants, toUserTypeSelectPage} from '@thunderid/browser';\nimport type {FetchUserTypes, SelectPage, SelectPageRequest} from '@thunderid/browser';\nimport {useCallback} from 'react';\nimport useManagementEndpoint, {ManagementEndpoint} from './useManagementEndpoint';\nimport {useResolvedFetcher} from './useResourceQuery';\n\n/**\n * A `FetchUserTypes` backed by the user type list, authenticated with the signed-in user's access token.\n * Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.\n */\nconst useFetchUserTypes = (): FetchUserTypes => {\n const {baseUrl, url}: ManagementEndpoint = useManagementEndpoint('userTypes');\n const fetcher: ReturnType<typeof useResolvedFetcher> = useResolvedFetcher();\n\n return useCallback(\n async ({limit, offset, signal}: SelectPageRequest): Promise<SelectPage> =>\n toUserTypeSelectPage(\n await getUserTypes({\n baseUrl,\n fetcher,\n limit: Math.min(limit, SelectConstants.MAX_PAGE_SIZE),\n offset,\n signal,\n url,\n }),\n offset,\n ),\n [baseUrl, fetcher, url],\n );\n};\n\nexport default useFetchUserTypes;\n"],"mappings":";;;;;;;;;;AAaA,MAAM,0BAA0C;CAC9C,MAAM,EAAC,SAAS,QAA2BA,8BAAsB,YAAY;CAC7E,MAAMC,UAAiD,oBAAoB;AAE3E,QAAO,YACL,OAAO,EAAC,OAAO,QAAQ,aACrB,qBACE,MAAM,aAAa;EACjB;EACA;EACA,OAAO,KAAK,IAAI,OAAO,gBAAgB,cAAc;EACrD;EACA;EACA;EACD,CAAC,EACF,OACD,EACH;EAAC;EAAS;EAAS;EAAI,CACxB;;AAGH,gCAAe"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FetchUsers } from '@thunderid/browser';
|
|
2
|
+
/**
|
|
3
|
+
* A `FetchUsers` backed by the user directory, authenticated with the signed-in user's access token.
|
|
4
|
+
* Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.
|
|
5
|
+
*/
|
|
6
|
+
declare const useFetchUsers: () => FetchUsers;
|
|
7
|
+
export default useFetchUsers;
|
|
8
|
+
//# sourceMappingURL=useFetchUsers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchUsers.d.ts","sourceRoot":"","sources":["../../src/hooks/useFetchUsers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAgC,MAAM,oBAAoB,CAAC;AAKlF;;;GAGG;AACH,QAAA,MAAM,aAAa,QAAO,UASzB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import useManagementEndpoint_default from "./useManagementEndpoint.js";
|
|
2
|
+
import { useResolvedFetcher } from "./useResourceQuery.js";
|
|
3
|
+
import { getUsers, toUserSelectPage } from "@thunderid/browser";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/hooks/useFetchUsers.ts
|
|
7
|
+
/**
|
|
8
|
+
* A `FetchUsers` backed by the user directory, authenticated with the signed-in user's access token.
|
|
9
|
+
* Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.
|
|
10
|
+
*/
|
|
11
|
+
const useFetchUsers = () => {
|
|
12
|
+
const { baseUrl, url } = useManagementEndpoint_default("users");
|
|
13
|
+
const fetcher = useResolvedFetcher();
|
|
14
|
+
return useCallback(async ({ filter, limit, offset, signal }) => toUserSelectPage(await getUsers({
|
|
15
|
+
baseUrl,
|
|
16
|
+
fetcher,
|
|
17
|
+
filter,
|
|
18
|
+
limit,
|
|
19
|
+
offset,
|
|
20
|
+
signal,
|
|
21
|
+
url
|
|
22
|
+
}), offset), [
|
|
23
|
+
baseUrl,
|
|
24
|
+
fetcher,
|
|
25
|
+
url
|
|
26
|
+
]);
|
|
27
|
+
};
|
|
28
|
+
var useFetchUsers_default = useFetchUsers;
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useFetchUsers_default as default };
|
|
32
|
+
//# sourceMappingURL=useFetchUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFetchUsers.js","names":["useManagementEndpoint","fetcher: ReturnType<typeof useResolvedFetcher>"],"sources":["../../src/hooks/useFetchUsers.ts"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {getUsers, toUserSelectPage} from '@thunderid/browser';\nimport type {FetchUsers, SelectPage, SelectPageRequest} from '@thunderid/browser';\nimport {useCallback} from 'react';\nimport useManagementEndpoint, {ManagementEndpoint} from './useManagementEndpoint';\nimport {useResolvedFetcher} from './useResourceQuery';\n\n/**\n * A `FetchUsers` backed by the user directory, authenticated with the signed-in user's access token.\n * Its identity is stable across renders, since a picker resets its loaded pages when the loader changes.\n */\nconst useFetchUsers = (): FetchUsers => {\n const {baseUrl, url}: ManagementEndpoint = useManagementEndpoint('users');\n const fetcher: ReturnType<typeof useResolvedFetcher> = useResolvedFetcher();\n\n return useCallback(\n async ({filter, limit, offset, signal}: SelectPageRequest): Promise<SelectPage> =>\n toUserSelectPage(await getUsers({baseUrl, fetcher, filter, limit, offset, signal, url}), offset),\n [baseUrl, fetcher, url],\n );\n};\n\nexport default useFetchUsers;\n"],"mappings":";;;;;;;;;;AAaA,MAAM,sBAAkC;CACtC,MAAM,EAAC,SAAS,QAA2BA,8BAAsB,QAAQ;CACzE,MAAMC,UAAiD,oBAAoB;AAE3E,QAAO,YACL,OAAO,EAAC,QAAQ,OAAO,QAAQ,aAC7B,iBAAiB,MAAM,SAAS;EAAC;EAAS;EAAS;EAAQ;EAAO;EAAQ;EAAQ;EAAI,CAAC,EAAE,OAAO,EAClG;EAAC;EAAS;EAAS;EAAI,CACxB;;AAGH,4BAAe"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SelectOption, SelectOptionInput, SelectOptionsBatch, SelectOptionsLoadContext } from '@thunderid/browser';
|
|
2
|
+
export type InfiniteOptionsLoadContext<TCursor = unknown> = SelectOptionsLoadContext<TCursor>;
|
|
3
|
+
export type InfiniteOptionsBatch<TCursor = unknown> = SelectOptionsBatch<TCursor>;
|
|
4
|
+
export interface UseInfiniteOptionsArgs<TCursor = unknown> {
|
|
5
|
+
/** Options shown before anything is loaded, and again after {@link UseInfiniteOptionsResult.reset}. */
|
|
6
|
+
initialOptions?: SelectOptionInput[];
|
|
7
|
+
/** Loads the next batch. Returning nothing counts as an empty batch. */
|
|
8
|
+
load: (context: InfiniteOptionsLoadContext<TCursor>) => Promise<InfiniteOptionsBatch<TCursor> | null | undefined>;
|
|
9
|
+
/** Called with the error of every failed load. A failed load never changes the options. */
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface UseInfiniteOptionsResult {
|
|
13
|
+
/** The error of the last load, cleared by the next successful one. */
|
|
14
|
+
error: Error | null;
|
|
15
|
+
/** Whether more batches may be available. */
|
|
16
|
+
hasMore: boolean;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
/** Pass to `Select` while `hasMore` is true, so its load more option is listed only while there is more to load. Its identity is stable across renders. */
|
|
19
|
+
onLoadMore: () => void;
|
|
20
|
+
options: SelectOption[];
|
|
21
|
+
/** Back to `initialOptions`; reloads right away if loading had already started. */
|
|
22
|
+
reset: () => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Keeps the option list of a `Select` that loads more options when the user asks for them. It owns the cursor,
|
|
26
|
+
* appends each batch without duplicates, and stops at the end of the data. Nothing is rendered, so it works with
|
|
27
|
+
* any list component.
|
|
28
|
+
*/
|
|
29
|
+
declare const useInfiniteOptions: <TCursor = unknown>({ initialOptions, load, onError, }: UseInfiniteOptionsArgs<TCursor>) => UseInfiniteOptionsResult;
|
|
30
|
+
export default useInfiniteOptions;
|
|
31
|
+
//# sourceMappingURL=useInfiniteOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfiniteOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useInfiniteOptions.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AAQ5B,MAAM,MAAM,0BAA0B,CAAC,OAAO,GAAG,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAE9F,MAAM,MAAM,oBAAoB,CAAC,OAAO,GAAG,OAAO,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAElF,MAAM,WAAW,sBAAsB,CAAC,OAAO,GAAG,OAAO;IACvD,uGAAuG;IACvG,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACrC,wEAAwE;IACxE,IAAI,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAClH,2FAA2F;IAC3F,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,2JAA2J;IAC3J,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,mFAAmF;IACnF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,QAAA,MAAM,kBAAkB,GAAI,OAAO,GAAG,OAAO,EAAE,oCAI5C,sBAAsB,CAAC,OAAO,CAAC,KAAG,wBAgIpC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|