@frontile/theme 0.18.0-beta.5 → 0.18.1

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
@@ -318,7 +318,7 @@ const alert = tv({
318
318
 
319
319
  const avatar = tv({
320
320
  slots: {
321
- base: ['flex', 'relative', 'justify-center', 'items-center', 'box-border', 'overflow-hidden', 'align-middle', 'text-neutral-strong', 'z-0', 'bg-neutral-subtle', 'ring-1 ring-default ring-offset-1 ring-offset-background'],
321
+ base: ['flex', 'relative', 'justify-center', 'items-center', 'box-border', 'overflow-hidden', 'align-middle', 'text-neutral-strong', 'z-0', 'bg-neutral-subtle'],
322
322
  img: 'size-full',
323
323
  name: ['w-full', 'font-label', 'text-center', 'text-inherit', 'absolute', 'top-1/2', 'left-1/2', '-translate-x-1/2', '-translate-y-1/2', 'select-none']
324
324
  },
@@ -343,11 +343,72 @@ const avatar = tv({
343
343
  xl: {
344
344
  base: 'size-12 text-label-lg'
345
345
  }
346
+ },
347
+ /**
348
+ * How the image fills the avatar. `cover` crops to fill, which suits
349
+ * photos. `contain` shows the whole image inset from the edge, which suits
350
+ * logos and wordmarks that must not be cropped.
351
+ */
352
+ fit: {
353
+ cover: {
354
+ img: 'object-cover'
355
+ },
356
+ contain: {
357
+ img: 'object-contain'
358
+ }
359
+ },
360
+ /**
361
+ * Draws a hairline just inside the edge, so the avatar's shape holds
362
+ * against a page or photo of the same colour.
363
+ */
364
+ isBordered: {
365
+ true: {
366
+ // On ::after so it paints over the image; an inset box-shadow on the
367
+ // root would sit beneath the <img>. A single translucent line, not an
368
+ // offset ring, so an image does not get a gap and a second edge.
369
+ base: ['after:absolute after:inset-0 after:rounded-[inherit]', 'after:pointer-events-none', 'after:ring-1 after:ring-inset after:ring-surface-overlay-mild']
370
+ }
346
371
  }
347
372
  },
373
+ compoundVariants: [
374
+ // The inset keeps a contained image off the round edge. It lives on the
375
+ // img, so padding shrinks the box `object-contain` fits into.
376
+ {
377
+ fit: 'contain',
378
+ size: 'xs',
379
+ class: {
380
+ img: 'p-px'
381
+ }
382
+ }, {
383
+ fit: 'contain',
384
+ size: 'sm',
385
+ class: {
386
+ img: 'p-0.5'
387
+ }
388
+ }, {
389
+ fit: 'contain',
390
+ size: 'md',
391
+ class: {
392
+ img: 'p-0.5'
393
+ }
394
+ }, {
395
+ fit: 'contain',
396
+ size: 'lg',
397
+ class: {
398
+ img: 'p-1'
399
+ }
400
+ }, {
401
+ fit: 'contain',
402
+ size: 'xl',
403
+ class: {
404
+ img: 'p-1'
405
+ }
406
+ }],
348
407
  defaultVariants: {
349
408
  size: 'md',
350
- shape: 'circle'
409
+ shape: 'circle',
410
+ fit: 'cover',
411
+ isBordered: true
351
412
  }
352
413
  });
353
414
 
@@ -835,6 +896,17 @@ const chip = tv({
835
896
  }
836
897
  },
837
898
  size: {
899
+ // For dense UI — table cells, list rows, multi-select fields. It keeps
900
+ // `sm`'s text size and loses height and padding instead: 12px is about
901
+ // as small as a label stays readable. The close button drops to
902
+ // `label-micro` so its circle (icon plus `p-0.5`) still fits the 20px
903
+ // chip.
904
+ xs: {
905
+ base: 'text-label-2xs px-0.5 h-5',
906
+ content: 'px-1',
907
+ dot: 'size-1.5',
908
+ closeButton: 'text-label-micro'
909
+ },
838
910
  sm: {
839
911
  base: 'text-label-2xs px-1 h-6',
840
912
  content: 'px-1',
@@ -3321,11 +3393,38 @@ const notificationCard = tv({
3321
3393
  }
3322
3394
  });
3323
3395
 
3396
+ /**
3397
+ * A note on the colour levels used for text and borders below.
3398
+ *
3399
+ * The `soft` level is a *translucent* fill (10-25% alpha) -- it exists to tint
3400
+ * a surface, and composites to ~1.1-1.5:1 against whatever is behind it. Used
3401
+ * as a border or a text colour it is effectively invisible, which is what the
3402
+ * invalid field state used to be in dark mode. Borders and rings here take an
3403
+ * opaque level instead, and the translucent-halo job is left to `muted`, which
3404
+ * is what `ring-focus` (`--color-primary-muted`) already resolves to.
3405
+ *
3406
+ * For text, the `DEFAULT` level of the tint-shaped categories (`secondary`,
3407
+ * `tertiary`, `success`, `warning`) is a light fill colour, not an ink: in
3408
+ * light mode it lands at 1.3-2.6:1, well under AA. `alert.ts` hit the same
3409
+ * thing first and settled on `bolder` for success/warning, `firm` for danger
3410
+ * and `neutral`, and plain `DEFAULT` for primary; the levels below match it so
3411
+ * that the same status reads the same weight in an Alert and in form feedback.
3412
+ *
3413
+ * Two known failures are deliberately left alone, because changing either one
3414
+ * restyles every field in the library and is a design decision rather than a
3415
+ * bug:
3416
+ * - the resting `border-neutral-soft` is 1.37:1 in light mode, against the
3417
+ * 3:1 WCAG 1.4.11 asks of a control's visual boundary (and in light mode
3418
+ * `surface-input` equals `surface-app`, so the border is the only boundary);
3419
+ * - `placeholder-neutral` is 3.13:1 in light mode, against AA's 4.5:1.
3420
+ * `tests/unit/forms/forms-contrast-test.ts` in test-app asserts everything
3421
+ * else, and documents these two as the deliberate gaps.
3422
+ */
3324
3423
  const label = tv({
3325
3424
  slots: {
3326
3425
  // label text role (Open Sans semibold, tight leading)
3327
3426
  base: 'text-neutral-bolder inline-block font-label text-label-sm pb-2',
3328
- asterisk: 'text-danger'
3427
+ asterisk: 'text-danger-firm'
3329
3428
  },
3330
3429
  variants: {
3331
3430
  size: {
@@ -3343,8 +3442,10 @@ const label = tv({
3343
3442
  }
3344
3443
  });
3345
3444
  const formDescription = tv({
3346
- // help/description text — body role
3347
- base: 'text-neutral font-body text-body-2xs pb-1 last:pb-0',
3445
+ // help/description text — body role. `text-neutral` (the DEFAULT level) is
3446
+ // only ~3:1 on a light surface; `firm` clears AA in both modes, and is the
3447
+ // same level `alert.ts` uses for its description.
3448
+ base: 'text-neutral-firm font-body text-body-2xs pb-1 last:pb-0',
3348
3449
  variants: {
3349
3450
  size: {
3350
3451
  sm: 'text-body-2xs',
@@ -3363,12 +3464,15 @@ const formFeedback = tv({
3363
3464
  // `status`, not `color`: this value also decides whether the message is
3364
3465
  // announced assertively. See `isError` in form-feedback.gts.
3365
3466
  status: {
3467
+ // Levels, not bare categories: see the note above `label`. Each one is
3468
+ // the lightest level that clears AA against both `surface-app` and
3469
+ // `surface-card` in light *and* dark mode.
3366
3470
  primary: 'text-primary',
3367
- secondary: 'text-secondary',
3368
- tertiary: 'text-tertiary',
3369
- success: 'text-success',
3370
- danger: 'text-danger',
3371
- warning: 'text-warning'
3471
+ secondary: 'text-secondary-bolder',
3472
+ tertiary: 'text-tertiary-strong',
3473
+ success: 'text-success-bolder',
3474
+ danger: 'text-danger-firm',
3475
+ warning: 'text-warning-bolder'
3372
3476
  },
3373
3477
  size: {
3374
3478
  sm: 'text-body-2xs',
@@ -3385,6 +3489,40 @@ const formFeedback = tv({
3385
3489
  // invalid/disabled treatments. Shared by the `input` slot and by `select`'s
3386
3490
  // `chipsField`, which becomes the shell when chips render beside the trigger.
3387
3491
  const fieldShell = ['bg-surface-input', 'border', 'border-neutral-soft', 'rounded-xl', 'selection:bg-surface-overlay-soft'];
3492
+
3493
+ /**
3494
+ * The field shell for a segmented date field.
3495
+ *
3496
+ * It goes on the container rather than on the segment row, so the clear and
3497
+ * calendar buttons sit inside the border with the segments. Focus lands on an
3498
+ * individual segment, never on the container, so the ring is `focus-within`;
3499
+ * and `role="group"` supports neither `aria-invalid` nor `aria-readonly`, so
3500
+ * the invalid and disabled states are read from data attributes the host
3501
+ * writes instead of from ARIA.
3502
+ */
3503
+ const segmentedFieldShell = ['relative flex items-center w-full', ...fieldShell, 'font-body text-base leading-tight text-neutral-strong', 'focus-within:ring-3', 'focus-within:ring-focus', 'focus-within:border-primary', 'data-[invalid=true]:border-danger', 'data-[invalid=true]:focus-within:ring-danger-muted', 'data-[disabled=true]:border-neutral-subtle', 'data-[disabled=true]:text-neutral-soft'];
3504
+
3505
+ /**
3506
+ * The segment row, shared by `dateInput` and `datePicker`.
3507
+ *
3508
+ * Spread into both rather than duplicated: the tv() note below excuses
3509
+ * restating slots *inherited from `input`*, which is a typing constraint --
3510
+ * these are new strings, and keeping two copies had already let `gap-0` land
3511
+ * in one and not the other.
3512
+ */
3513
+ const segmentRowSlots = {
3514
+ // `tabular-nums` stops the field twitching as digits change width;
3515
+ // `select-none` keeps a drag across segments from starting a text selection
3516
+ // that spans them.
3517
+ group: 'flex items-center flex-1 min-w-0 gap-0 tabular-nums select-none',
3518
+ segment: ['rounded-xs px-px outline-none caret-transparent', 'focus:bg-primary focus:text-on-primary', 'data-[placeholder=true]:text-neutral',
3519
+ // The focused segment is filled with `primary`, so a placeholder sitting
3520
+ // in it has to take the contrast colour too. Stated as a combined variant
3521
+ // rather than relying on source order: both rules are one class deep
3522
+ // otherwise, and whichever Tailwind emits last would win.
3523
+ 'focus:data-[placeholder=true]:text-on-primary', 'data-[disabled=true]:pointer-events-none'],
3524
+ literal: 'text-neutral-soft px-px'
3525
+ };
3388
3526
  const input = tv({
3389
3527
  slots: {
3390
3528
  base: '',
@@ -3393,7 +3531,9 @@ const input = tv({
3393
3531
  endContent: 'absolute inset-y-0 right-0 flex items-center',
3394
3532
  input: ['appearance-none', 'flex-1', 'w-full', ...fieldShell, 'text-neutral-strong', 'placeholder-neutral',
3395
3533
  // body role family; single-line controls keep tight leading (not the body relaxed leading)
3396
- 'font-body text-base text-left', 'leading-tight', 'focus:ring-3', 'focus:ring-focus', 'focus:outline-hidden', 'focus:border-primary-soft', 'disabled:border-neutral-subtle disabled:text-neutral-soft', 'aria-invalid:border-danger-soft', 'aria-invalid:focus:ring-danger-soft']
3534
+ 'font-body text-base text-left', 'leading-tight', 'focus:ring-3', 'focus:ring-focus', 'focus:outline-hidden', 'focus:border-primary', 'disabled:border-neutral-subtle disabled:text-neutral-soft', 'aria-invalid:border-danger',
3535
+ // The invalid counterpart of `ring-focus`, which is `primary-muted`.
3536
+ 'aria-invalid:focus:ring-danger-muted']
3397
3537
  },
3398
3538
  variants: {
3399
3539
  size: {
@@ -3538,14 +3678,14 @@ const inputOtp = tv({
3538
3678
  // z-10 keeps the active cell's ring from being clipped by its neighbour.
3539
3679
  isActive: {
3540
3680
  true: {
3541
- cell: 'z-10 border-primary-soft ring-3 ring-focus'
3681
+ cell: 'z-10 border-primary ring-3 ring-focus'
3542
3682
  }
3543
3683
  },
3544
- // Mirrors `input`'s `aria-invalid:focus:ring-danger-soft`: a focused invalid
3545
- // cell must ring red, not keep the neutral focus ring.
3684
+ // Mirrors `input`'s `aria-invalid:focus:ring-danger-muted`: a focused
3685
+ // invalid cell must ring red, not keep the neutral focus ring.
3546
3686
  isInvalid: {
3547
3687
  true: {
3548
- cell: 'border-danger-soft ring-danger-soft'
3688
+ cell: 'border-danger ring-danger-muted'
3549
3689
  }
3550
3690
  },
3551
3691
  isDisabled: {
@@ -3671,7 +3811,7 @@ const select = tv({
3671
3811
  // `aria-invalid:` and `disabled:` only match the element carrying them.
3672
3812
  hasChips: {
3673
3813
  true: {
3674
- chipsField: [...fieldShell, 'flex', 'flex-wrap', 'items-center', 'gap-1', 'w-full', 'cursor-default', 'focus-within:ring-3', 'focus-within:ring-focus', 'focus-within:border-primary-soft', 'data-[invalid=true]:border-danger-soft', 'data-[invalid=true]:focus-within:ring-danger-soft', 'data-[disabled=true]:border-neutral-subtle', 'data-[disabled=true]:text-neutral-soft']
3814
+ chipsField: [...fieldShell, 'flex', 'flex-wrap', 'items-center', 'gap-1', 'w-full', 'cursor-default', 'focus-within:ring-3', 'focus-within:ring-focus', 'focus-within:border-primary', 'data-[invalid=true]:border-danger', 'data-[invalid=true]:focus-within:ring-danger-muted', 'data-[disabled=true]:border-neutral-subtle', 'data-[disabled=true]:text-neutral-soft']
3675
3815
  },
3676
3816
  false: {
3677
3817
  chipsField: 'flex w-full min-w-0'
@@ -3771,6 +3911,11 @@ const datePicker = tv({
3771
3911
  base: [],
3772
3912
  placeholder: 'text-neutral',
3773
3913
  input: 'cursor-default text-left',
3914
+ // Restated from `input` rather than inherited: tv() drops inherited slot
3915
+ // names from the variant type, and `isSegmented` below has to target
3916
+ // both of these.
3917
+ innerContainer: 'relative flex',
3918
+ endContent: 'absolute inset-y-0 right-0 flex items-center',
3774
3919
  // The calendar sits in the popover, which supplies its own surface and
3775
3920
  // padding, so this only reserves room around the grid.
3776
3921
  calendar: 'p-2',
@@ -3784,7 +3929,13 @@ const datePicker = tv({
3784
3929
  // calendar decide how wide the popover is, and the buttons wrap within it.
3785
3930
  footer: ['flex flex-wrap items-center gap-2', 'w-0 min-w-full', 'border-t border-neutral-soft p-2'],
3786
3931
  icon: 'w-5 h-5',
3787
- clearButton: 'pointer-events-auto'
3932
+ clearButton: 'pointer-events-auto',
3933
+ ...segmentRowSlots,
3934
+ // Sits between the two groups of a `@mode="range"` field. `DatePicker`
3935
+ // renders it, not `SegmentGroup` -- it separates groups rather than
3936
+ // living inside one.
3937
+ separator: 'text-neutral px-1',
3938
+ calendarButton: 'pointer-events-auto'
3788
3939
  },
3789
3940
  variants: {
3790
3941
  // The trigger is a `<button>` whose text *is* the value, so with neither a
@@ -3808,6 +3959,89 @@ const datePicker = tv({
3808
3959
  lg: {
3809
3960
  input: 'min-h-[calc(1.25rem+2rem+2px)]'
3810
3961
  }
3962
+ },
3963
+ // The segmented trigger renders no `<button>`, so nothing carries the
3964
+ // field shell. It moves onto the container, which is also what puts the
3965
+ // clear and calendar buttons inside the border rather than beyond it.
3966
+ isSegmented: {
3967
+ true: {
3968
+ innerContainer: segmentedFieldShell,
3969
+ // With no trigger underneath to click through to, the cluster sits in
3970
+ // flow beside the segments instead of floating over the field's right
3971
+ // edge.
3972
+ // `ms-auto` rather than relying on the group's `flex-1` to push it:
3973
+ // in range mode the groups no longer grow (see `isRange`), so without
3974
+ // this the cluster would sit tight against the end group instead of
3975
+ // at the field's right edge.
3976
+ endContent: 'static top-auto bottom-auto right-auto p-0 gap-1 shrink-0 ms-auto'
3977
+ }
3978
+ },
3979
+ // Two groups sharing one shell must not each claim half of it -- growing
3980
+ // would strand the separator in the middle of the field with a gap of
3981
+ // dead space on either side, instead of reading as one `start - end`
3982
+ // phrase. The end content takes the slack instead.
3983
+ // `flex-none`, not `grow-0`: the group's `flex-1` is `flex: 1 1 0%`, so
3984
+ // removing only the grow leaves a 0% basis with shrink still on and the
3985
+ // group collapses to zero width with its segments overflowing it.
3986
+ isRange: {
3987
+ true: {
3988
+ group: 'flex-none'
3989
+ }
3990
+ }
3991
+ },
3992
+ compoundVariants: [
3993
+ // Padding follows the shell onto the container, for the same reason.
3994
+ {
3995
+ isSegmented: true,
3996
+ size: 'sm',
3997
+ class: {
3998
+ innerContainer: 'p-2'
3999
+ }
4000
+ }, {
4001
+ isSegmented: true,
4002
+ size: 'md',
4003
+ class: {
4004
+ innerContainer: 'p-3'
4005
+ }
4006
+ }, {
4007
+ isSegmented: true,
4008
+ size: 'lg',
4009
+ class: {
4010
+ innerContainer: 'p-4'
4011
+ }
4012
+ }],
4013
+ defaultVariants: {
4014
+ size: 'md'
4015
+ }
4016
+ });
4017
+
4018
+ // Extends `input` directly, not `datePicker`: tv() loses slot types across a
4019
+ // two-level extend, which is why `datePicker` extends `input` too.
4020
+ const dateInput = tv({
4021
+ extend: input,
4022
+ slots: {
4023
+ base: [],
4024
+ innerContainer: segmentedFieldShell,
4025
+ ...segmentRowSlots,
4026
+ endContent: 'flex items-center gap-1 shrink-0',
4027
+ icon: 'w-5 h-5',
4028
+ clearButton: 'pointer-events-auto',
4029
+ calendarButton: 'pointer-events-auto'
4030
+ },
4031
+ variants: {
4032
+ // `input`'s size variant pads the `input` slot, which a segmented field
4033
+ // does not render -- the padding has to move onto the container that
4034
+ // actually draws the shell.
4035
+ size: {
4036
+ sm: {
4037
+ innerContainer: 'p-2'
4038
+ },
4039
+ md: {
4040
+ innerContainer: 'p-3'
4041
+ },
4042
+ lg: {
4043
+ innerContainer: 'p-4'
4044
+ }
3811
4045
  }
3812
4046
  },
3813
4047
  defaultVariants: {
@@ -4071,6 +4305,7 @@ var components = /*#__PURE__*/Object.freeze({
4071
4305
  closeButton: closeButton,
4072
4306
  command: command,
4073
4307
  commandDialog: commandDialog,
4308
+ dateInput: dateInput,
4074
4309
  datePicker: datePicker,
4075
4310
  divider: divider,
4076
4311
  drawer: drawer,