@ttoss/components 2.16.0 → 2.17.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/index.d.mts CHANGED
@@ -894,7 +894,13 @@ type OAuthConsentLabels = {
894
894
  * Props for the OAuthConsent component.
895
895
  */
896
896
  type OAuthConsentProps = {
897
- /** Display name or identifier of the requesting OAuth client. */clientName: string; /** Scope tree to render. */
897
+ /** Display name or identifier of the requesting OAuth client. */clientName: string;
898
+ /**
899
+ * URL of the client's logo or icon. When provided, renders the image above
900
+ * the consent heading. Falls back to the first letter of `clientName` if the
901
+ * image fails to load. When omitted, no logo is shown (backward-compatible).
902
+ */
903
+ clientLogoUrl?: string; /** Scope tree to render. */
898
904
  scopes: ConsentScope[];
899
905
  /**
900
906
  * Called when the user approves. Receives the minimal granted scope set
@@ -958,6 +964,7 @@ declare const collectGrantedScopes: (scopes: ConsentScope[], selected: Set<strin
958
964
  */
959
965
  declare const OAuthConsent: ({
960
966
  clientName,
967
+ clientLogoUrl,
961
968
  scopes,
962
969
  onAuthorize,
963
970
  onAuthorized,
package/dist/index.mjs CHANGED
@@ -2980,6 +2980,48 @@ var NotificationsMenu = ({
2980
2980
  });
2981
2981
  };
2982
2982
 
2983
+ //#endregion
2984
+ //#region src/components/OAuthConsent/ClientLogo.tsx
2985
+ var ClientLogo = ({
2986
+ src,
2987
+ clientName
2988
+ }) => {
2989
+ const [errored, setErrored] = React.useState(false);
2990
+ if (errored) return /* @__PURE__ */jsx(Flex, {
2991
+ "aria-hidden": "true",
2992
+ sx: {
2993
+ width: 48,
2994
+ height: 48,
2995
+ borderRadius: "lg",
2996
+ backgroundColor: "display.background.muted.default",
2997
+ alignItems: "center",
2998
+ justifyContent: "center"
2999
+ },
3000
+ children: /* @__PURE__ */jsx(Text, {
3001
+ sx: {
3002
+ fontSize: "xl",
3003
+ fontWeight: "bold",
3004
+ color: "display.text.muted.default"
3005
+ },
3006
+ children: clientName.charAt(0).toUpperCase()
3007
+ })
3008
+ });
3009
+ return /* @__PURE__ */jsx("img", {
3010
+ src,
3011
+ alt: `${clientName} logo`,
3012
+ onError: () => {
3013
+ return setErrored(true);
3014
+ },
3015
+ style: {
3016
+ width: 48,
3017
+ height: 48,
3018
+ borderRadius: 8,
3019
+ objectFit: "contain",
3020
+ display: "block"
3021
+ }
3022
+ });
3023
+ };
3024
+
2983
3025
  //#endregion
2984
3026
  //#region src/components/OAuthConsent/OAuthConsent.tsx
2985
3027
  /**
@@ -3040,6 +3082,7 @@ var ScopeRow = ({
3040
3082
  busy
3041
3083
  });
3042
3084
  const checkboxId = `consent-scope-${scope.key}`;
3085
+ const labelId = `consent-scope-label-${scope.key}`;
3043
3086
  const descId = `consent-scope-desc-${scope.key}`;
3044
3087
  return /* @__PURE__ */jsxs(Box, {
3045
3088
  as: "li",
@@ -3047,6 +3090,7 @@ var ScopeRow = ({
3047
3090
  listStyle: "none"
3048
3091
  },
3049
3092
  children: [/* @__PURE__ */jsxs(Flex, {
3093
+ as: "label",
3050
3094
  sx: {
3051
3095
  gap: 3,
3052
3096
  alignItems: "flex-start",
@@ -3055,6 +3099,7 @@ var ScopeRow = ({
3055
3099
  borderRadius: "md",
3056
3100
  opacity: ancestorSelected ? .55 : 1,
3057
3101
  transition: "background-color 0.15s ease",
3102
+ cursor: isInteractive ? "pointer" : "default",
3058
3103
  ...(isInteractive && {
3059
3104
  "&:hover": {
3060
3105
  backgroundColor: "display.background.muted.default"
@@ -3070,6 +3115,7 @@ var ScopeRow = ({
3070
3115
  id: checkboxId,
3071
3116
  checked: isChecked,
3072
3117
  disabled: isDisabled,
3118
+ "aria-labelledby": labelId,
3073
3119
  "aria-describedby": descId,
3074
3120
  onChange: () => {
3075
3121
  onToggle(scope, ancestorSelected);
@@ -3080,15 +3126,15 @@ var ScopeRow = ({
3080
3126
  flex: 1,
3081
3127
  minWidth: 0
3082
3128
  },
3083
- children: [/* @__PURE__ */jsx(Label, {
3084
- htmlFor: checkboxId,
3129
+ children: [/* @__PURE__ */jsx(Text, {
3130
+ as: "span",
3131
+ id: labelId,
3085
3132
  sx: {
3086
3133
  fontWeight: "semibold",
3087
3134
  fontSize: "md",
3088
3135
  lineHeight: "short",
3089
- cursor: isInteractive ? "pointer" : "default",
3090
3136
  color: "display.text.primary.default",
3091
- width: "fit-content"
3137
+ display: "block"
3092
3138
  },
3093
3139
  children: scope.label
3094
3140
  }), /* @__PURE__ */jsx(Text, {
@@ -3175,6 +3221,7 @@ var ConsentCard = ({
3175
3221
  */
3176
3222
  var OAuthConsent = ({
3177
3223
  clientName,
3224
+ clientLogoUrl,
3178
3225
  scopes,
3179
3226
  onAuthorize,
3180
3227
  onAuthorized,
@@ -3224,7 +3271,15 @@ var OAuthConsent = ({
3224
3271
  })]
3225
3272
  });
3226
3273
  return /* @__PURE__ */jsxs(ConsentCard, {
3227
- children: [/* @__PURE__ */jsx(Heading, {
3274
+ children: [clientLogoUrl && /* @__PURE__ */jsx(Box, {
3275
+ sx: {
3276
+ marginBottom: 4
3277
+ },
3278
+ children: /* @__PURE__ */jsx(ClientLogo, {
3279
+ src: clientLogoUrl,
3280
+ clientName
3281
+ })
3282
+ }), /* @__PURE__ */jsx(Heading, {
3228
3283
  as: "h1",
3229
3284
  sx: {
3230
3285
  fontSize: "3xl",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/components",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "React components for ttoss ecosystem.",
5
5
  "keywords": [
6
6
  "React",
@@ -54,19 +54,19 @@
54
54
  "tsdown": "^0.22.2",
55
55
  "tsx": "^4.21.0",
56
56
  "@ttoss/config": "^1.37.17",
57
+ "@ttoss/i18n-cli": "^0.8.17",
57
58
  "@ttoss/react-hooks": "^2.3.20",
58
59
  "@ttoss/react-icons": "^0.7.21",
59
60
  "@ttoss/react-i18n": "^2.3.0",
60
61
  "@ttoss/test-utils": "^4.2.18",
61
- "@ttoss/i18n-cli": "^0.8.17",
62
62
  "@ttoss/ui": "^6.9.28"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": ">=16.8.0",
66
66
  "@ttoss/react-hooks": "^2.3.20",
67
- "@ttoss/react-i18n": "^2.3.0",
68
67
  "@ttoss/react-icons": "^0.7.21",
69
- "@ttoss/ui": "^6.9.28"
68
+ "@ttoss/ui": "^6.9.28",
69
+ "@ttoss/react-i18n": "^2.3.0"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public",