@dloizides/auth-web 1.12.1 → 1.14.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.js CHANGED
@@ -9,15 +9,18 @@ var authClient = require('@dloizides/auth-client');
9
9
  // src/components/AuthScreen.tsx
10
10
  var FULL_WIDTH = "100%";
11
11
  var CARD_BORDER_WIDTH = 1;
12
+ var CARD_TOP_OFFSET = 64;
12
13
  function useAuthScreenStyles(theme) {
13
14
  return react.useMemo(() => {
14
15
  const { colors, radii, spacing, typography } = theme;
15
16
  return reactNative.StyleSheet.create({
16
17
  screen: {
17
18
  flex: 1,
18
- justifyContent: "center",
19
+ // Deliberately NOT `justifyContent: 'center'` — see CARD_TOP_OFFSET.
20
+ justifyContent: "flex-start",
19
21
  alignItems: "center",
20
22
  padding: spacing.md,
23
+ paddingTop: CARD_TOP_OFFSET,
21
24
  backgroundColor: colors.background
22
25
  },
23
26
  card: {
@@ -75,7 +78,8 @@ var defaultAuthTheme = {
75
78
  typography: {
76
79
  title: 28,
77
80
  subtitle: 16,
78
- label: 14,
81
+ // 13, not 14 — the shared contract's `field` voice. See AuthThemeTypography.label.
82
+ label: 13,
79
83
  body: 16,
80
84
  caption: 12
81
85
  }
@@ -282,7 +286,9 @@ var DEFAULT_DEMO_CREDENTIALS_HINT_LABELS = {
282
286
  usernameLabel: "Username",
283
287
  passwordLabel: "Password",
284
288
  useCredentials: "Use these credentials",
285
- useCredentialsHint: "Fill the sign-in form with the demo username and password"
289
+ useCredentialsHint: "Fill the sign-in form with the demo username and password",
290
+ toggle: "Try the demo",
291
+ toggleHint: "Show the demo account username and password"
286
292
  };
287
293
 
288
294
  // src/components/labels/resetPasswordLabels.ts
@@ -379,7 +385,9 @@ var AuthTestIds = {
379
385
  demoCredentialsHint: "auth-demo-credentials-hint",
380
386
  demoCredentialsUsername: "auth-demo-credentials-username",
381
387
  demoCredentialsPassword: "auth-demo-credentials-password",
382
- demoCredentialsUseButton: "auth-demo-credentials-use"
388
+ demoCredentialsUseButton: "auth-demo-credentials-use",
389
+ // The collapsed disclosure trigger (`disclosure` variant only).
390
+ demoCredentialsToggle: "auth-demo-credentials-toggle"
383
391
  };
384
392
  function withTestIdPrefix(baseId, prefix) {
385
393
  return prefix === void 0 || prefix === "" ? baseId : `${prefix}-${baseId}`;
@@ -387,15 +395,21 @@ function withTestIdPrefix(baseId, prefix) {
387
395
  var FULL_WIDTH2 = "100%";
388
396
  var CARD_MAX_WIDTH = 420;
389
397
  var BUTTON_VERTICAL_PADDING = 14;
398
+ var SCREEN_TOP_OFFSET = 64;
390
399
  function useAuthStyles(theme) {
391
400
  return react.useMemo(() => {
392
401
  const { colors, radii, spacing, typography } = theme;
393
402
  return reactNative.StyleSheet.create({
394
403
  screen: {
395
404
  flex: 1,
396
- justifyContent: "center",
405
+ // Top-anchored, NOT centred — a centred card re-centres as it grows and
406
+ // drags the inputs up under the cursor. Same reasoning (and the same
407
+ // measurement) as `useAuthScreenStyles`' CARD_TOP_OFFSET; kept in step so
408
+ // a standalone `<LoginForm>` and an `<AuthScreen>`-composed one agree.
409
+ justifyContent: "flex-start",
397
410
  alignItems: "center",
398
411
  padding: spacing.md,
412
+ paddingTop: SCREEN_TOP_OFFSET,
399
413
  backgroundColor: colors.background
400
414
  },
401
415
  card: {
@@ -2009,14 +2023,15 @@ function DevicePinLengthPicker({
2009
2023
  const theme = useAuthTheme(themeProp);
2010
2024
  const dynamic = usePickerStyles(theme);
2011
2025
  const baseId = withTestIdPrefix(AuthTestIds.devicePinEnrollLength, testIdPrefix);
2012
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
2026
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "radiogroup", role: "radiogroup", style: styles2.row, children: DEVICE_PIN_ALLOWED_DIGITS.map((option) => {
2013
2027
  const active = option === selected;
2014
2028
  return /* @__PURE__ */ jsxRuntime.jsx(
2015
2029
  reactNative.Pressable,
2016
2030
  {
2031
+ "aria-checked": active,
2017
2032
  accessibilityHint: interpolate(optionHint, { count: option }),
2018
2033
  accessibilityLabel: String(option),
2019
- accessibilityRole: "button",
2034
+ accessibilityRole: "radio",
2020
2035
  accessibilityState: { selected: active },
2021
2036
  disabled,
2022
2037
  style: [styles2.pill, dynamic.pill, active ? dynamic.active : null],
@@ -3160,6 +3175,7 @@ function PreferredMethodSettingsCard({
3160
3175
  return /* @__PURE__ */ jsxRuntime.jsx(
3161
3176
  reactNative.TouchableOpacity,
3162
3177
  {
3178
+ "aria-checked": isSelected,
3163
3179
  accessibilityHint: labels.description,
3164
3180
  accessibilityLabel: option.label,
3165
3181
  accessibilityRole: "radio",
@@ -3216,7 +3232,62 @@ function PreferredMethodHint({
3216
3232
  }
3217
3233
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { testID: withTestIdPrefix(AuthTestIds.preferredMethodHint, testIdPrefix), children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.helperText, children: text }) });
3218
3234
  }
3235
+ function DemoCredentialsBody({
3236
+ credentials,
3237
+ labels,
3238
+ styles: styles3,
3239
+ authStyles,
3240
+ testIdPrefix,
3241
+ onUse
3242
+ }) {
3243
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
3244
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.row, children: [
3245
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.rowLabel, children: labels.usernameLabel }),
3246
+ /* @__PURE__ */ jsxRuntime.jsx(
3247
+ reactNative.Text,
3248
+ {
3249
+ selectable: true,
3250
+ style: styles3.rowValue,
3251
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsUsername, testIdPrefix),
3252
+ children: credentials.username
3253
+ }
3254
+ )
3255
+ ] }),
3256
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.row, children: [
3257
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.rowLabel, children: labels.passwordLabel }),
3258
+ /* @__PURE__ */ jsxRuntime.jsx(
3259
+ reactNative.Text,
3260
+ {
3261
+ selectable: true,
3262
+ style: styles3.rowValue,
3263
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsPassword, testIdPrefix),
3264
+ children: credentials.password
3265
+ }
3266
+ )
3267
+ ] }),
3268
+ onUse !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
3269
+ reactNative.TouchableOpacity,
3270
+ {
3271
+ accessibilityHint: labels.useCredentialsHint,
3272
+ accessibilityLabel: labels.useCredentials,
3273
+ accessibilityRole: "button",
3274
+ style: [authStyles.secondaryButton, styles3.useButton],
3275
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsUseButton, testIdPrefix),
3276
+ onPress: onUse,
3277
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: authStyles.secondaryButtonText, children: labels.useCredentials })
3278
+ }
3279
+ ) : null
3280
+ ] });
3281
+ }
3282
+
3283
+ // src/components/DemoCredentialsHintVariant.ts
3284
+ var DemoCredentialsHintVariant = /* @__PURE__ */ ((DemoCredentialsHintVariant2) => {
3285
+ DemoCredentialsHintVariant2["Panel"] = "panel";
3286
+ DemoCredentialsHintVariant2["Disclosure"] = "disclosure";
3287
+ return DemoCredentialsHintVariant2;
3288
+ })(DemoCredentialsHintVariant || {});
3219
3289
  var PANEL_BORDER_WIDTH = 1;
3290
+ var TRIGGER_MIN_HEIGHT = 32;
3220
3291
  var ACCENT_RAIL_WIDTH = 3;
3221
3292
  var TITLE_LETTER_SPACING = 0.8;
3222
3293
  var DESCRIPTION_LINE_HEIGHT_RATIO = 1.45;
@@ -3277,6 +3348,40 @@ function useDemoCredentialsStyles(theme) {
3277
3348
  flexShrink: 1,
3278
3349
  backgroundColor: colors.surface,
3279
3350
  color: colors.text
3351
+ },
3352
+ // ── Disclosure variant ──────────────────────────────────────────────
3353
+ // No panel fill, no border, no brand rail: the collapsed state is one
3354
+ // line of text and nothing else, so on a page a real customer uses it
3355
+ // reads as a footnote rather than as a second call to action.
3356
+ disclosure: {
3357
+ marginTop: spacing.md,
3358
+ alignSelf: "stretch"
3359
+ },
3360
+ disclosureTrigger: {
3361
+ alignSelf: "center",
3362
+ justifyContent: "center",
3363
+ minHeight: TRIGGER_MIN_HEIGHT,
3364
+ paddingHorizontal: spacing.xs
3365
+ },
3366
+ disclosureTriggerText: {
3367
+ fontSize: typography.caption,
3368
+ textDecorationLine: "underline",
3369
+ // `textSecondary`, NOT a dimmed `text`. This is the same token the rest
3370
+ // of the helper copy uses, so it inherits whatever AA contrast the
3371
+ // consuming app already guarantees. Discretion here is carried by the
3372
+ // caption size, the centred placement below the form, and the absence
3373
+ // of any fill or border — never by fading the text toward the
3374
+ // background, which is how "discreet" quietly becomes a contrast bug.
3375
+ color: colors.textSecondary
3376
+ },
3377
+ disclosureBody: {
3378
+ marginTop: spacing.sm,
3379
+ paddingTop: spacing.sm,
3380
+ borderTopWidth: PANEL_BORDER_WIDTH,
3381
+ borderTopColor: colors.border
3382
+ },
3383
+ useButton: {
3384
+ alignSelf: "stretch"
3280
3385
  }
3281
3386
  });
3282
3387
  }, [theme]);
@@ -3297,6 +3402,7 @@ function resolveDemoCredentials(credentials) {
3297
3402
  }
3298
3403
  function DemoCredentialsHint({
3299
3404
  credentials,
3405
+ variant = "disclosure" /* Disclosure */,
3300
3406
  theme: themeProp,
3301
3407
  labels: labelsProp,
3302
3408
  testIdPrefix,
@@ -3305,6 +3411,7 @@ function DemoCredentialsHint({
3305
3411
  const theme = useAuthTheme(themeProp);
3306
3412
  const authStyles = useAuthStyles(theme);
3307
3413
  const styles3 = useDemoCredentialsStyles(theme);
3414
+ const [expanded, setExpanded] = react.useState(false);
3308
3415
  const labels = react.useMemo(
3309
3416
  () => ({ ...DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, ...labelsProp }),
3310
3417
  [labelsProp]
@@ -3315,53 +3422,58 @@ function DemoCredentialsHint({
3315
3422
  onUse(resolved);
3316
3423
  }
3317
3424
  }, [resolved, onUse]);
3425
+ const handleToggle = react.useCallback(() => {
3426
+ setExpanded((current) => !current);
3427
+ }, []);
3318
3428
  if (resolved === null) {
3319
3429
  return null;
3320
3430
  }
3431
+ const body = /* @__PURE__ */ jsxRuntime.jsx(
3432
+ DemoCredentialsBody,
3433
+ {
3434
+ authStyles,
3435
+ credentials: resolved,
3436
+ labels,
3437
+ styles: styles3,
3438
+ testIdPrefix,
3439
+ onUse: onUse === void 0 ? void 0 : handleUse
3440
+ }
3441
+ );
3442
+ if (variant === "panel" /* Panel */) {
3443
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3444
+ reactNative.View,
3445
+ {
3446
+ style: styles3.panel,
3447
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsHint, testIdPrefix),
3448
+ children: [
3449
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
3450
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.description, children: labels.description }),
3451
+ body
3452
+ ]
3453
+ }
3454
+ );
3455
+ }
3321
3456
  return /* @__PURE__ */ jsxRuntime.jsxs(
3322
3457
  reactNative.View,
3323
3458
  {
3324
- style: styles3.panel,
3459
+ style: styles3.disclosure,
3325
3460
  testID: withTestIdPrefix(AuthTestIds.demoCredentialsHint, testIdPrefix),
3326
3461
  children: [
3327
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
3328
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.description, children: labels.description }),
3329
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.row, children: [
3330
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.rowLabel, children: labels.usernameLabel }),
3331
- /* @__PURE__ */ jsxRuntime.jsx(
3332
- reactNative.Text,
3333
- {
3334
- selectable: true,
3335
- style: styles3.rowValue,
3336
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsUsername, testIdPrefix),
3337
- children: resolved.username
3338
- }
3339
- )
3340
- ] }),
3341
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.row, children: [
3342
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.rowLabel, children: labels.passwordLabel }),
3343
- /* @__PURE__ */ jsxRuntime.jsx(
3344
- reactNative.Text,
3345
- {
3346
- selectable: true,
3347
- style: styles3.rowValue,
3348
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsPassword, testIdPrefix),
3349
- children: resolved.password
3350
- }
3351
- )
3352
- ] }),
3353
- onUse !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
3462
+ /* @__PURE__ */ jsxRuntime.jsx(
3354
3463
  reactNative.TouchableOpacity,
3355
3464
  {
3356
- accessibilityHint: labels.useCredentialsHint,
3357
- accessibilityLabel: labels.useCredentials,
3465
+ "aria-expanded": expanded,
3466
+ accessibilityHint: labels.toggleHint,
3467
+ accessibilityLabel: labels.toggle,
3358
3468
  accessibilityRole: "button",
3359
- style: authStyles.secondaryButton,
3360
- testID: withTestIdPrefix(AuthTestIds.demoCredentialsUseButton, testIdPrefix),
3361
- onPress: handleUse,
3362
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: authStyles.secondaryButtonText, children: labels.useCredentials })
3469
+ accessibilityState: { expanded },
3470
+ style: styles3.disclosureTrigger,
3471
+ testID: withTestIdPrefix(AuthTestIds.demoCredentialsToggle, testIdPrefix),
3472
+ onPress: handleToggle,
3473
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.disclosureTriggerText, children: labels.toggle })
3363
3474
  }
3364
- ) : null
3475
+ ),
3476
+ expanded ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.disclosureBody, children: body }) : null
3365
3477
  ]
3366
3478
  }
3367
3479
  );
@@ -3637,6 +3749,7 @@ exports.DEFAULT_RESET_PASSWORD_LABELS = DEFAULT_RESET_PASSWORD_LABELS;
3637
3749
  exports.DEVICE_PIN_ALLOWED_DIGITS = DEVICE_PIN_ALLOWED_DIGITS;
3638
3750
  exports.DEVICE_PIN_DEFAULT_DIGITS = DEVICE_PIN_DEFAULT_DIGITS;
3639
3751
  exports.DemoCredentialsHint = DemoCredentialsHint;
3752
+ exports.DemoCredentialsHintVariant = DemoCredentialsHintVariant;
3640
3753
  exports.DevicePinEnrollErrorKey = DevicePinEnrollErrorKey;
3641
3754
  exports.DevicePinEnrollForm = DevicePinEnrollForm;
3642
3755
  exports.DevicePinErrorKey = DevicePinErrorKey;