@sanity/ui 0.36.17 → 0.37.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.
@@ -3567,11 +3567,11 @@ function responsiveInputPaddingIconRightStyle(props) {
3567
3567
  }));
3568
3568
  }
3569
3569
 
3570
- let _$D = t => t,
3571
- _t$E,
3570
+ let _$C = t => t,
3571
+ _t$D,
3572
3572
  _t2$n,
3573
3573
  _t3$e;
3574
- const ROOT_STYLE = css(_t$E || (_t$E = _$D`
3574
+ const ROOT_STYLE = css(_t$D || (_t$D = _$C`
3575
3575
  &:not([hidden]) {
3576
3576
  display: flex;
3577
3577
  }
@@ -3586,7 +3586,7 @@ function textInputBaseStyle(props) {
3586
3586
  } = props;
3587
3587
  const font = theme.sanity.fonts.text;
3588
3588
  const color = theme.sanity.color.input;
3589
- return css(_t2$n || (_t2$n = _$D`
3589
+ return css(_t2$n || (_t2$n = _$C`
3590
3590
  --input-fg-color: ${0};
3591
3591
  --input-placeholder-color: ${0};
3592
3592
 
@@ -3677,7 +3677,7 @@ function textInputRepresentationStyle(props) {
3677
3677
  input
3678
3678
  } = theme.sanity;
3679
3679
  const color = theme.sanity.color.input;
3680
- return css(_t3$e || (_t3$e = _$D`
3680
+ return css(_t3$e || (_t3$e = _$C`
3681
3681
  --card-bg-color: ${0};
3682
3682
  --card-fg-color: ${0};
3683
3683
  --input-box-shadow: none;
@@ -3813,8 +3813,8 @@ function responsiveShadowStyle(props) {
3813
3813
  return responsive(media, getResponsiveProp(props.$shadow), shadow => shadowStyle(shadows[shadow]));
3814
3814
  }
3815
3815
 
3816
- let _$C = t => t,
3817
- _t$D,
3816
+ let _$B = t => t,
3817
+ _t$C,
3818
3818
  _t2$m,
3819
3819
  _t3$d;
3820
3820
  function textBaseStyle(props) {
@@ -3826,7 +3826,7 @@ function textBaseStyle(props) {
3826
3826
  const {
3827
3827
  weights
3828
3828
  } = theme.sanity.fonts.text;
3829
- return css(_t$D || (_t$D = _$C`
3829
+ return css(_t$C || (_t$C = _$B`
3830
3830
  color: var(--card-fg-color);
3831
3831
 
3832
3832
  ${0}
@@ -3868,19 +3868,19 @@ function textBaseStyle(props) {
3868
3868
  & [data-sanity-icon] {
3869
3869
  vertical-align: baseline;
3870
3870
  }
3871
- `), $accent && css(_t2$m || (_t2$m = _$C`
3871
+ `), $accent && css(_t2$m || (_t2$m = _$B`
3872
3872
  color: var(--card-accent-fg-color);
3873
- `)), $muted && css(_t3$d || (_t3$d = _$C`
3873
+ `)), $muted && css(_t3$d || (_t3$d = _$B`
3874
3874
  color: var(--card-muted-fg-color);
3875
3875
  `)), theme.sanity.fonts.code.family, weights.bold);
3876
3876
  }
3877
3877
 
3878
3878
  const _excluded$G = ["accent", "align", "children", "muted", "size", "textOverflow", "weight"];
3879
3879
 
3880
- let _$B = t => t,
3881
- _t$C;
3880
+ let _$A = t => t,
3881
+ _t$B;
3882
3882
  const Root$E = styled.div(responsiveTextFont, responsiveTextAlignStyle, textBaseStyle);
3883
- const SpanWithTextOverflow$2 = styled.span(_t$C || (_t$C = _$B`
3883
+ const SpanWithTextOverflow$2 = styled.span(_t$B || (_t$B = _$A`
3884
3884
  display: block;
3885
3885
  white-space: nowrap;
3886
3886
  text-overflow: ellipsis;
@@ -4183,8 +4183,8 @@ const Avatar = /*#__PURE__*/forwardRef(function Avatar(props, ref) {
4183
4183
  }, /*#__PURE__*/React.createElement("strong", null, initials)))));
4184
4184
  });
4185
4185
 
4186
- let _$A = t => t,
4187
- _t$B;
4186
+ let _$z = t => t,
4187
+ _t$A;
4188
4188
 
4189
4189
  function responsiveAvatarCounterSizeStyle(props) {
4190
4190
  const {
@@ -4209,7 +4209,7 @@ function avatarCounterBaseStyle(props) {
4209
4209
  const {
4210
4210
  theme
4211
4211
  } = props;
4212
- return css(_t$B || (_t$B = _$A`
4212
+ return css(_t$A || (_t$A = _$z`
4213
4213
  align-items: center;
4214
4214
  justify-content: center;
4215
4215
  box-sizing: border-box;
@@ -4255,9 +4255,9 @@ function childrenToElementArray(children) {
4255
4255
 
4256
4256
  const _excluded$E = ["children", "maxLength", "size", "tone"];
4257
4257
 
4258
- let _$z = t => t,
4259
- _t$A;
4260
- const BASE_STYLES = css(_t$A || (_t$A = _$z`
4258
+ let _$y = t => t,
4259
+ _t$z;
4260
+ const BASE_STYLES = css(_t$z || (_t$z = _$y`
4261
4261
  white-space: nowrap;
4262
4262
 
4263
4263
  & > div {
@@ -4403,8 +4403,8 @@ const Box = /*#__PURE__*/forwardRef(function Box(props, ref) {
4403
4403
  }), props.children);
4404
4404
  });
4405
4405
 
4406
- let _$y = t => t,
4407
- _t$z,
4406
+ let _$x = t => t,
4407
+ _t$y,
4408
4408
  _t2$l,
4409
4409
  _t3$c;
4410
4410
  function labelBaseStyle(props) {
@@ -4416,7 +4416,7 @@ function labelBaseStyle(props) {
4416
4416
  const {
4417
4417
  fonts
4418
4418
  } = theme.sanity;
4419
- return css(_t$z || (_t$z = _$y`
4419
+ return css(_t$y || (_t$y = _$x`
4420
4420
  text-transform: uppercase;
4421
4421
 
4422
4422
  ${0}
@@ -4436,19 +4436,19 @@ function labelBaseStyle(props) {
4436
4436
  & [data-sanity-icon] {
4437
4437
  vertical-align: baseline;
4438
4438
  }
4439
- `), $accent && css(_t2$l || (_t2$l = _$y`
4439
+ `), $accent && css(_t2$l || (_t2$l = _$x`
4440
4440
  color: var(--card-accent-fg-color);
4441
- `)), $muted && css(_t3$c || (_t3$c = _$y`
4441
+ `)), $muted && css(_t3$c || (_t3$c = _$x`
4442
4442
  color: var(--card-muted-fg-color);
4443
4443
  `)), fonts.code.family);
4444
4444
  }
4445
4445
 
4446
4446
  const _excluded$C = ["accent", "align", "children", "muted", "size", "textOverflow", "weight"];
4447
4447
 
4448
- let _$x = t => t,
4449
- _t$y;
4448
+ let _$w = t => t,
4449
+ _t$x;
4450
4450
  const Root$z = styled.div(responsiveLabelFont, responsiveTextAlignStyle, labelBaseStyle);
4451
- const SpanWithTextOverflow$1 = styled.span(_t$y || (_t$y = _$x`
4451
+ const SpanWithTextOverflow$1 = styled.span(_t$x || (_t$x = _$w`
4452
4452
  display: block;
4453
4453
  white-space: nowrap;
4454
4454
  text-overflow: ellipsis;
@@ -4569,10 +4569,10 @@ const Flex = /*#__PURE__*/forwardRef(function Flex(props, ref) {
4569
4569
  }));
4570
4570
  });
4571
4571
 
4572
- let _$w = t => t,
4573
- _t$x,
4572
+ let _$v = t => t,
4573
+ _t$w,
4574
4574
  _t2$k;
4575
- const rotate$1 = keyframes(_t$x || (_t$x = _$w`
4575
+ const rotate$1 = keyframes(_t$w || (_t$w = _$v`
4576
4576
  from {
4577
4577
  transform: rotate(0deg);
4578
4578
  }
@@ -4581,7 +4581,7 @@ const rotate$1 = keyframes(_t$x || (_t$x = _$w`
4581
4581
  transform: rotate(360deg);
4582
4582
  }
4583
4583
  `));
4584
- const Root$w = styled(Text)(_t2$k || (_t2$k = _$w`
4584
+ const Root$w = styled(Text)(_t2$k || (_t2$k = _$v`
4585
4585
  & > span > svg {
4586
4586
  animation: ${0} 500ms linear infinite;
4587
4587
  }
@@ -4631,14 +4631,14 @@ function _colorVarsStyle(base, color, checkered = false) {
4631
4631
  };
4632
4632
  }
4633
4633
 
4634
- let _$v = t => t,
4635
- _t$w;
4634
+ let _$u = t => t,
4635
+ _t$v;
4636
4636
  /**
4637
4637
  * @internal
4638
4638
  */
4639
4639
 
4640
4640
  function buttonBaseStyles() {
4641
- return css(_t$w || (_t$w = _$v`
4641
+ return css(_t$v || (_t$v = _$u`
4642
4642
  -webkit-font-smoothing: inherit;
4643
4643
  appearance: none;
4644
4644
  display: inline-flex;
@@ -4722,10 +4722,10 @@ function buttonColorStyles(props) {
4722
4722
 
4723
4723
  const _excluded$z = ["children", "disabled", "fontSize", "icon", "iconRight", "justify", "loading", "mode", "padding", "paddingX", "paddingY", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "radius", "selected", "space", "text", "textAlign", "tone", "type"];
4724
4724
 
4725
- let _$u = t => t,
4726
- _t$v;
4725
+ let _$t = t => t,
4726
+ _t$u;
4727
4727
  const Root$v = styled.button(responsiveRadiusStyle, buttonBaseStyles, buttonColorStyles);
4728
- const LoadingBox = styled.div(_t$v || (_t$v = _$u`
4728
+ const LoadingBox = styled.div(_t$u || (_t$u = _$t`
4729
4729
  position: absolute;
4730
4730
  top: 0;
4731
4731
  left: 0;
@@ -4815,8 +4815,8 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
4815
4815
  }, boxProps), children));
4816
4816
  });
4817
4817
 
4818
- let _$t = t => t,
4819
- _t$u,
4818
+ let _$s = t => t,
4819
+ _t$t,
4820
4820
  _t2$j,
4821
4821
  _t3$b;
4822
4822
  function cardStyle(props) {
@@ -4828,7 +4828,7 @@ function cardBaseStyle(props) {
4828
4828
  theme
4829
4829
  } = props;
4830
4830
  const space = theme.sanity.space;
4831
- return css(_t$u || (_t$u = _$t`
4831
+ return css(_t$t || (_t$t = _$s`
4832
4832
  ${0}
4833
4833
 
4834
4834
  &[data-as='button'] {
@@ -4851,7 +4851,7 @@ function cardBaseStyle(props) {
4851
4851
  &[data-as='pre'] {
4852
4852
  font: inherit;
4853
4853
  }
4854
- `), $checkered && css(_t2$j || (_t2$j = _$t`
4854
+ `), $checkered && css(_t2$j || (_t2$j = _$s`
4855
4855
  background-size: ${0}px ${0}px;
4856
4856
  background-position: 50% 50%;
4857
4857
  background-image: var(--card-bg-image);
@@ -4876,7 +4876,7 @@ function cardColorStyle(props) {
4876
4876
  width: 0,
4877
4877
  color: 'var(--card-border-color)'
4878
4878
  };
4879
- return css(_t3$b || (_t3$b = _$t`
4879
+ return css(_t3$b || (_t3$b = _$s`
4880
4880
  ${0}
4881
4881
 
4882
4882
  background-color: var(--card-bg-color);
@@ -5032,11 +5032,11 @@ const Card = /*#__PURE__*/forwardRef(function Card(props, ref) {
5032
5032
  })));
5033
5033
  });
5034
5034
 
5035
- let _$s = t => t,
5036
- _t$t,
5035
+ let _$r = t => t,
5036
+ _t$s,
5037
5037
  _t2$i;
5038
5038
  function checkboxBaseStyles() {
5039
- return css(_t$t || (_t$t = _$s`
5039
+ return css(_t$s || (_t$s = _$r`
5040
5040
  position: relative;
5041
5041
  display: inline-block;
5042
5042
  `));
@@ -5051,7 +5051,7 @@ function inputElementStyles(props) {
5051
5051
  input,
5052
5052
  radius
5053
5053
  } = theme.sanity;
5054
- return css(_t2$i || (_t2$i = _$s`
5054
+ return css(_t2$i || (_t2$i = _$r`
5055
5055
  position: absolute;
5056
5056
  top: 0;
5057
5057
  left: 0;
@@ -5178,8 +5178,8 @@ const Checkbox = /*#__PURE__*/forwardRef(function Checkbox(props, forwardedRef)
5178
5178
  })), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(CheckmarkIcon, null), /*#__PURE__*/React.createElement(RemoveIcon, null)));
5179
5179
  });
5180
5180
 
5181
- let _$r = t => t,
5182
- _t$s;
5181
+ let _$q = t => t,
5182
+ _t$r;
5183
5183
 
5184
5184
  function codeSyntaxHighlightingStyle({
5185
5185
  theme
@@ -5298,7 +5298,7 @@ function codeSyntaxHighlightingStyle({
5298
5298
  }
5299
5299
 
5300
5300
  function codeBaseStyle() {
5301
- return css(_t$s || (_t$s = _$r`
5301
+ return css(_t$r || (_t$r = _$q`
5302
5302
  color: var(--card-code-fg-color);
5303
5303
 
5304
5304
  & code {
@@ -5431,8 +5431,8 @@ const Grid = /*#__PURE__*/forwardRef(function Grid(props, ref) {
5431
5431
  }), children);
5432
5432
  });
5433
5433
 
5434
- let _$q = t => t,
5435
- _t$r,
5434
+ let _$p = t => t,
5435
+ _t$q,
5436
5436
  _t2$h,
5437
5437
  _t3$a;
5438
5438
  function headingBaseStyle(props) {
@@ -5441,7 +5441,7 @@ function headingBaseStyle(props) {
5441
5441
  $muted,
5442
5442
  theme
5443
5443
  } = props;
5444
- return css(_t$r || (_t$r = _$q`
5444
+ return css(_t$q || (_t$q = _$p`
5445
5445
  ${0}
5446
5446
 
5447
5447
  ${0}
@@ -5475,19 +5475,19 @@ function headingBaseStyle(props) {
5475
5475
  & [data-sanity-icon] {
5476
5476
  vertical-align: baseline;
5477
5477
  }
5478
- `), $accent && css(_t2$h || (_t2$h = _$q`
5478
+ `), $accent && css(_t2$h || (_t2$h = _$p`
5479
5479
  color: var(--card-accent-fg-color);
5480
- `)), $muted && css(_t3$a || (_t3$a = _$q`
5480
+ `)), $muted && css(_t3$a || (_t3$a = _$p`
5481
5481
  color: var(--card-muted-fg-color);
5482
5482
  `)), theme.sanity.fonts.code.family);
5483
5483
  }
5484
5484
 
5485
5485
  const _excluded$t = ["accent", "align", "children", "muted", "size", "textOverflow", "weight"];
5486
5486
 
5487
- let _$p = t => t,
5488
- _t$q;
5487
+ let _$o = t => t,
5488
+ _t$p;
5489
5489
  const Root$p = styled.div(headingBaseStyle, responsiveTextAlignStyle, responsiveHeadingFont);
5490
- const SpanWithTextOverflow = styled.span(_t$q || (_t$q = _$p`
5490
+ const SpanWithTextOverflow = styled.span(_t$p || (_t$p = _$o`
5491
5491
  display: block;
5492
5492
  white-space: nowrap;
5493
5493
  text-overflow: ellipsis;
@@ -5582,11 +5582,11 @@ const Inline = /*#__PURE__*/forwardRef(function Inline(props, ref) {
5582
5582
 
5583
5583
  const _excluded$r = ["children", "fontSize", "padding", "radius"];
5584
5584
 
5585
- let _$o = t => t,
5586
- _t$p;
5585
+ let _$n = t => t,
5586
+ _t$o;
5587
5587
 
5588
5588
  function kbdStyle() {
5589
- return css(_t$p || (_t$p = _$o`
5589
+ return css(_t$o || (_t$o = _$n`
5590
5590
  background: var(--card-bg-color);
5591
5591
  font: inherit;
5592
5592
  box-shadow: inset 0 0 0 1px var(--card-hairline-hard-color);
@@ -5850,9 +5850,9 @@ function LayerProvider(props) {
5850
5850
  const _excluded$p = ["children", "style"],
5851
5851
  _excluded2$1 = ["children", "zOffset"];
5852
5852
 
5853
- let _$n = t => t,
5854
- _t$o;
5855
- const Root$m = styled.div(_t$o || (_t$o = _$n`
5853
+ let _$m = t => t,
5854
+ _t$n;
5855
+ const Root$m = styled.div(_t$n || (_t$n = _$m`
5856
5856
  position: relative;
5857
5857
  `));
5858
5858
  const LayerChildren = /*#__PURE__*/forwardRef(function LayerChildren(props, ref) {
@@ -6002,9 +6002,9 @@ function PortalProvider(props) {
6002
6002
  }, children);
6003
6003
  }
6004
6004
 
6005
- let _$m = t => t,
6006
- _t$n;
6007
- const Root$l = styled.div(_t$n || (_t$n = _$m`
6005
+ let _$l = t => t,
6006
+ _t$m;
6007
+ const Root$l = styled.div(_t$m || (_t$m = _$l`
6008
6008
  display: block;
6009
6009
  width: 0;
6010
6010
  height: 0;
@@ -6196,13 +6196,13 @@ function _isScrollable(el) {
6196
6196
 
6197
6197
  const _excluded$o = ["as", "gap", "getItemKey", "items", "onChange", "renderItem"];
6198
6198
 
6199
- let _$l = t => t,
6200
- _t$m,
6199
+ let _$k = t => t,
6200
+ _t$l,
6201
6201
  _t2$g;
6202
- const Root$k = styled.div(_t$m || (_t$m = _$l`
6202
+ const Root$k = styled.div(_t$l || (_t$l = _$k`
6203
6203
  position: relative;
6204
6204
  `));
6205
- const ItemWrapper = styled.div(_t2$g || (_t2$g = _$l`
6205
+ const ItemWrapper = styled.div(_t2$g || (_t2$g = _$k`
6206
6206
  position: absolute;
6207
6207
  left: 0;
6208
6208
  right: 0;
@@ -6340,11 +6340,11 @@ const VirtualList = /*#__PURE__*/forwardRef(function VirtualList(props, ref) {
6340
6340
  }, children));
6341
6341
  });
6342
6342
 
6343
- let _$k = t => t,
6344
- _t$l,
6343
+ let _$j = t => t,
6344
+ _t$k,
6345
6345
  _t2$f,
6346
6346
  _t3$9;
6347
- const Root$j = styled.div(_t$l || (_t$l = _$k`
6347
+ const Root$j = styled.div(_t$k || (_t$k = _$j`
6348
6348
  position: absolute;
6349
6349
  pointer-events: none;
6350
6350
  width: 27px;
@@ -6388,10 +6388,10 @@ const Root$j = styled.div(_t$l || (_t$l = _$k`
6388
6388
  }
6389
6389
  }
6390
6390
  `));
6391
- const BorderPath = styled.path(_t2$f || (_t2$f = _$k`
6391
+ const BorderPath = styled.path(_t2$f || (_t2$f = _$j`
6392
6392
  fill: var(--card-shadow-outline-color);
6393
6393
  `));
6394
- const ShapePath = styled.path(_t3$9 || (_t3$9 = _$k`
6394
+ const ShapePath = styled.path(_t3$9 || (_t3$9 = _$j`
6395
6395
  fill: var(--card-bg-color);
6396
6396
  `));
6397
6397
  const PopoverArrow = /*#__PURE__*/forwardRef(function PopoverArrow(props, ref) {
@@ -6588,12 +6588,12 @@ function usePopoverModifiers(props) {
6588
6588
  const _excluded$n = ["__unstable_margins", "allowedAutoPlacements", "arrow", "boundaryElement", "children", "content", "constrainSize", "disabled", "fallbackPlacements", "open", "padding", "placement", "portal", "preventOverflow", "radius", "referenceElement", "matchReferenceWidth", "shadow", "scheme", "style", "tether", "tetherOffset", "tone", "width", "zOffset"];
6589
6589
 
6590
6590
  let _2 = t => t,
6591
- _t$k,
6591
+ _t$j,
6592
6592
  _t2$e,
6593
6593
  _t3$8;
6594
6594
  const Root$i = styled(Layer)(({
6595
6595
  $preventOverflow
6596
- }) => css(_t$k || (_t$k = _2`
6596
+ }) => css(_t$j || (_t$j = _2`
6597
6597
  pointer-events: none;
6598
6598
  display: flex;
6599
6599
  flex-direction: column;
@@ -6754,11 +6754,11 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6754
6754
  }, node), !portalProp && node));
6755
6755
  });
6756
6756
 
6757
- let _$j = t => t,
6758
- _t$j,
6757
+ let _$i = t => t,
6758
+ _t$i,
6759
6759
  _t2$d;
6760
6760
  function radioBaseStyle() {
6761
- return css(_t$j || (_t$j = _$j`
6761
+ return css(_t$i || (_t$i = _$i`
6762
6762
  position: relative;
6763
6763
 
6764
6764
  &:not([hidden]) {
@@ -6780,7 +6780,7 @@ function inputElementStyle(props) {
6780
6780
  } = theme.sanity;
6781
6781
  const color = theme.sanity.color.input;
6782
6782
  const dist = (input.radio.size - input.radio.markSize) / 2;
6783
- return css(_t2$d || (_t2$d = _$j`
6783
+ return css(_t2$d || (_t2$d = _$i`
6784
6784
  appearance: none;
6785
6785
  position: absolute;
6786
6786
  top: 0;
@@ -6898,14 +6898,14 @@ const Radio = /*#__PURE__*/forwardRef(function Radio(props, forwardedRef) {
6898
6898
  })), /*#__PURE__*/React.createElement("span", null));
6899
6899
  });
6900
6900
 
6901
- let _$i = t => t,
6902
- _t$i,
6901
+ let _$h = t => t,
6902
+ _t$h,
6903
6903
  _t2$c,
6904
6904
  _t3$7,
6905
6905
  _t4$5;
6906
6906
 
6907
6907
  function rootStyle() {
6908
- return css(_t$i || (_t$i = _$i`
6908
+ return css(_t$h || (_t$h = _$h`
6909
6909
  position: relative;
6910
6910
  width: stretch;
6911
6911
 
@@ -6920,7 +6920,7 @@ function inputBaseStyle(props) {
6920
6920
  theme
6921
6921
  } = props;
6922
6922
  const font = theme.sanity.fonts.text;
6923
- return css(_t2$c || (_t2$c = _$i`
6923
+ return css(_t2$c || (_t2$c = _$h`
6924
6924
  -webkit-font-smoothing: antialiased;
6925
6925
  appearance: none;
6926
6926
  border: 0;
@@ -6945,7 +6945,7 @@ function inputColorStyle(props) {
6945
6945
  input
6946
6946
  } = theme.sanity;
6947
6947
  const color = theme.sanity.color.input;
6948
- return css(_t3$7 || (_t3$7 = _$i`
6948
+ return css(_t3$7 || (_t3$7 = _$h`
6949
6949
  /* enabled */
6950
6950
  background-color: ${0};
6951
6951
  color: ${0};
@@ -7026,7 +7026,7 @@ function iconBoxStyle(props) {
7026
7026
  theme
7027
7027
  } = props;
7028
7028
  const color = theme.sanity.color.input;
7029
- return css(_t4$5 || (_t4$5 = _$i`
7029
+ return css(_t4$5 || (_t4$5 = _$h`
7030
7030
  pointer-events: none;
7031
7031
  position: absolute;
7032
7032
  top: 0;
@@ -7151,8 +7151,8 @@ const Stack = /*#__PURE__*/forwardRef(function Stack(props, ref) {
7151
7151
  }));
7152
7152
  });
7153
7153
 
7154
- let _$h = t => t,
7155
- _t$h,
7154
+ let _$g = t => t,
7155
+ _t$g,
7156
7156
  _t2$b,
7157
7157
  _t3$6,
7158
7158
  _t4$4,
@@ -7162,7 +7162,7 @@ let _$h = t => t,
7162
7162
  /* Root */
7163
7163
 
7164
7164
  function switchBaseStyles() {
7165
- return css(_t$h || (_t$h = _$h`
7165
+ return css(_t$g || (_t$g = _$g`
7166
7166
  position: relative;
7167
7167
  &:not([hidden]) {
7168
7168
  display: inline-block;
@@ -7173,7 +7173,7 @@ function switchBaseStyles() {
7173
7173
 
7174
7174
  function switchInputStyles() {
7175
7175
  // Visually hide the input element while keeping it interactive
7176
- return css(_t2$b || (_t2$b = _$h`
7176
+ return css(_t2$b || (_t2$b = _$g`
7177
7177
  position: absolute;
7178
7178
  top: 0;
7179
7179
  right: 0;
@@ -7201,7 +7201,7 @@ function switchRepresentationStyles(props) {
7201
7201
  input
7202
7202
  } = theme.sanity;
7203
7203
  const color = theme.sanity.color.button.default;
7204
- return css(_t3$6 || (_t3$6 = _$h`
7204
+ return css(_t3$6 || (_t3$6 = _$g`
7205
7205
  --switch-bg-color: ${0};
7206
7206
  --switch-fg-color: ${0};
7207
7207
  --switch-box-shadow: none;
@@ -7273,7 +7273,7 @@ function switchTrackStyles(props) {
7273
7273
  const {
7274
7274
  input
7275
7275
  } = theme.sanity;
7276
- return css(_t4$4 || (_t4$4 = _$h`
7276
+ return css(_t4$4 || (_t4$4 = _$g`
7277
7277
  &:not([hidden]) {
7278
7278
  display: block;
7279
7279
  }
@@ -7303,7 +7303,7 @@ function switchThumbStyles(props) {
7303
7303
  const checkedOffset = trackWidth - trackPadding * 2 - size;
7304
7304
  const indeterminateOffset = trackWidth / 2 - size / 2 - trackPadding;
7305
7305
  const checked = $indeterminate !== true && props.$checked === true;
7306
- return css(_t5$3 || (_t5$3 = _$h`
7306
+ return css(_t5$3 || (_t5$3 = _$g`
7307
7307
  &:not([hidden]) {
7308
7308
  display: block;
7309
7309
  }
@@ -7322,9 +7322,9 @@ function switchThumbStyles(props) {
7322
7322
  ${0}
7323
7323
 
7324
7324
  ${0}
7325
- `), rem(trackPadding), rem(trackPadding), rem(size), rem(size), rem(size / 2), input.switch.transitionDurationMs, input.switch.transitionTimingFunction, checked && css(_t6$1 || (_t6$1 = _$h`
7325
+ `), rem(trackPadding), rem(trackPadding), rem(size), rem(size), rem(size / 2), input.switch.transitionDurationMs, input.switch.transitionTimingFunction, checked && css(_t6$1 || (_t6$1 = _$g`
7326
7326
  transform: translate3d(${0}px, 0, 0);
7327
- `), checkedOffset), $indeterminate && css(_t7 || (_t7 = _$h`
7327
+ `), checkedOffset), $indeterminate && css(_t7 || (_t7 = _$g`
7328
7328
  transform: translate3d(${0}px, 0, 0);
7329
7329
  `), indeterminateOffset));
7330
7330
  }
@@ -7379,10 +7379,10 @@ const Switch = /*#__PURE__*/forwardRef(function Switch(props, forwardedRef) {
7379
7379
 
7380
7380
  const _excluded$i = ["border", "customValidity", "disabled", "fontSize", "padding", "radius"];
7381
7381
 
7382
- let _$g = t => t,
7383
- _t$g;
7382
+ let _$f = t => t,
7383
+ _t$f;
7384
7384
  const Root$d = styled.span(textInputRootStyle);
7385
- const InputRoot$1 = styled.span(_t$g || (_t$g = _$g`
7385
+ const InputRoot$1 = styled.span(_t$f || (_t$f = _$f`
7386
7386
  flex: 1;
7387
7387
  min-width: 0;
7388
7388
  display: block;
@@ -7424,8 +7424,8 @@ const TextArea = /*#__PURE__*/forwardRef(function TextArea(props, forwardedRef)
7424
7424
 
7425
7425
  const _excluded$h = ["border", "clearButton", "disabled", "fontSize", "icon", "iconRight", "onClear", "padding", "prefix", "radius", "readOnly", "space", "suffix", "customValidity", "type"];
7426
7426
 
7427
- let _$f = t => t,
7428
- _t$f,
7427
+ let _$e = t => t,
7428
+ _t$e,
7429
7429
  _t2$a,
7430
7430
  _t3$5,
7431
7431
  _t4$3,
@@ -7434,7 +7434,7 @@ const CLEAR_BUTTON_BOX_STYLE = {
7434
7434
  zIndex: 2
7435
7435
  };
7436
7436
  const Root$c = styled.span(textInputRootStyle);
7437
- const InputRoot = styled.span(_t$f || (_t$f = _$f`
7437
+ const InputRoot = styled.span(_t$e || (_t$e = _$e`
7438
7438
  flex: 1;
7439
7439
  min-width: 0;
7440
7440
  display: block;
@@ -7442,7 +7442,7 @@ const InputRoot = styled.span(_t$f || (_t$f = _$f`
7442
7442
  `));
7443
7443
  const Prefix = styled(Card).attrs({
7444
7444
  forwardedAs: 'span'
7445
- })(_t2$a || (_t2$a = _$f`
7445
+ })(_t2$a || (_t2$a = _$e`
7446
7446
  border-top-right-radius: 0;
7447
7447
  border-bottom-right-radius: 0;
7448
7448
 
@@ -7453,7 +7453,7 @@ const Prefix = styled(Card).attrs({
7453
7453
  `));
7454
7454
  const Suffix = styled(Card).attrs({
7455
7455
  forwardedAs: 'span'
7456
- })(_t3$5 || (_t3$5 = _$f`
7456
+ })(_t3$5 || (_t3$5 = _$e`
7457
7457
  border-top-left-radius: 0;
7458
7458
  border-bottom-left-radius: 0;
7459
7459
 
@@ -7464,12 +7464,12 @@ const Suffix = styled(Card).attrs({
7464
7464
  `));
7465
7465
  const Input = styled.input(responsiveInputPaddingStyle, textInputBaseStyle, textInputFontSizeStyle);
7466
7466
  const Presentation = styled.span(responsiveRadiusStyle, textInputRepresentationStyle);
7467
- const LeftBox = styled(Box)(_t4$3 || (_t4$3 = _$f`
7467
+ const LeftBox = styled(Box)(_t4$3 || (_t4$3 = _$e`
7468
7468
  position: absolute;
7469
7469
  top: 0;
7470
7470
  left: 0;
7471
7471
  `));
7472
- const RightCard = styled(Card)(_t5$2 || (_t5$2 = _$f`
7472
+ const RightCard = styled(Card)(_t5$2 || (_t5$2 = _$e`
7473
7473
  background-color: transparent;
7474
7474
  position: absolute;
7475
7475
  top: 0;
@@ -7593,11 +7593,11 @@ const TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef
7593
7593
  })), presentationNode, clearButtonNode), suffixNode);
7594
7594
  });
7595
7595
 
7596
- let _$e = t => t,
7597
- _t$e,
7596
+ let _$d = t => t,
7597
+ _t$d,
7598
7598
  _t2$9,
7599
7599
  _t3$4;
7600
- const Root$b = styled.div(_t$e || (_t$e = _$e`
7600
+ const Root$b = styled.div(_t$d || (_t$d = _$d`
7601
7601
  position: absolute;
7602
7602
  width: 15px;
7603
7603
  height: 15px;
@@ -7642,10 +7642,10 @@ const Root$b = styled.div(_t$e || (_t$e = _$e`
7642
7642
  }
7643
7643
  }
7644
7644
  `));
7645
- const Border = styled.path(_t2$9 || (_t2$9 = _$e`
7645
+ const Border = styled.path(_t2$9 || (_t2$9 = _$d`
7646
7646
  fill: var(--card-shadow-outline-color);
7647
7647
  `));
7648
- const Shape = styled.path(_t3$4 || (_t3$4 = _$e`
7648
+ const Shape = styled.path(_t3$4 || (_t3$4 = _$d`
7649
7649
  fill: var(--card-bg-color);
7650
7650
  `));
7651
7651
  const TooltipArrow = /*#__PURE__*/forwardRef(function TooltipArrow(props, ref) {
@@ -7666,9 +7666,9 @@ const TooltipArrow = /*#__PURE__*/forwardRef(function TooltipArrow(props, ref) {
7666
7666
 
7667
7667
  const _excluded$g = ["allowedAutoPlacements", "boundaryElement", "children", "content", "disabled", "fallbackPlacements", "placement", "portal", "scheme", "zOffset"];
7668
7668
 
7669
- let _$d = t => t,
7670
- _t$d;
7671
- const Root$a = styled(Layer)(_t$d || (_t$d = _$d`
7669
+ let _$c = t => t,
7670
+ _t$c;
7671
+ const Root$a = styled(Layer)(_t$c || (_t$c = _$c`
7672
7672
  pointer-events: none;
7673
7673
  `));
7674
7674
  /**
@@ -7802,8 +7802,8 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
7802
7802
  }, popperNode), !portal && popperNode));
7803
7803
  });
7804
7804
 
7805
- let _$c = t => t,
7806
- _t$c,
7805
+ let _$b = t => t,
7806
+ _t$b,
7807
7807
  _t2$8,
7808
7808
  _t3$3,
7809
7809
  _t4$2,
@@ -7812,14 +7812,14 @@ let _$c = t => t,
7812
7812
  * @internal
7813
7813
  */
7814
7814
 
7815
- const Root$9 = styled.div(_t$c || (_t$c = _$c`
7815
+ const Root$9 = styled.div(_t$b || (_t$b = _$b`
7816
7816
  /* position: relative; */
7817
7817
  `));
7818
7818
  /**
7819
7819
  * @internal
7820
7820
  */
7821
7821
 
7822
- const ListBox = styled(Box)(_t2$8 || (_t2$8 = _$c`
7822
+ const ListBox = styled(Box)(_t2$8 || (_t2$8 = _$b`
7823
7823
  & > ul {
7824
7824
  list-style: none;
7825
7825
  padding: 0;
@@ -7830,7 +7830,7 @@ const ListBox = styled(Box)(_t2$8 || (_t2$8 = _$c`
7830
7830
  * @internal
7831
7831
  */
7832
7832
 
7833
- const ResultsPopover = styled(Popover)(_t3$3 || (_t3$3 = _$c`
7833
+ const ResultsPopover = styled(Popover)(_t3$3 || (_t3$3 = _$b`
7834
7834
  & > div {
7835
7835
  overflow: auto;
7836
7836
  -webkit-overflow-scrolling: touch;
@@ -7840,7 +7840,7 @@ const ResultsPopover = styled(Popover)(_t3$3 || (_t3$3 = _$c`
7840
7840
  display: none;
7841
7841
  }
7842
7842
  `));
7843
- const rotate = keyframes(_t4$2 || (_t4$2 = _$c`
7843
+ const rotate = keyframes(_t4$2 || (_t4$2 = _$b`
7844
7844
  from {
7845
7845
  transform: rotate(0deg);
7846
7846
  }
@@ -7853,7 +7853,7 @@ const rotate = keyframes(_t4$2 || (_t4$2 = _$c`
7853
7853
  * @internal
7854
7854
  */
7855
7855
 
7856
- const AnimatedSpinnerIcon = styled(SpinnerIcon)(_t5$1 || (_t5$1 = _$c`
7856
+ const AnimatedSpinnerIcon = styled(SpinnerIcon)(_t5$1 || (_t5$1 = _$b`
7857
7857
  animation: ${0} 500ms linear infinite;
7858
7858
  `), rotate);
7859
7859
 
@@ -8438,10 +8438,10 @@ const InnerAutocomplete = /*#__PURE__*/forwardRef(function InnerAutocomplete(pro
8438
8438
 
8439
8439
  const Autocomplete = InnerAutocomplete;
8440
8440
 
8441
- let _$b = t => t,
8442
- _t$b,
8441
+ let _$a = t => t,
8442
+ _t$a,
8443
8443
  _t2$7;
8444
- const Root$8 = styled.ol(_t$b || (_t$b = _$b`
8444
+ const Root$8 = styled.ol(_t$a || (_t$a = _$a`
8445
8445
  margin: 0;
8446
8446
  padding: 0;
8447
8447
  display: flex;
@@ -8450,7 +8450,7 @@ const Root$8 = styled.ol(_t$b || (_t$b = _$b`
8450
8450
  white-space: nowrap;
8451
8451
  line-height: 0;
8452
8452
  `));
8453
- const ExpandButton = styled(Button)(_t2$7 || (_t2$7 = _$b`
8453
+ const ExpandButton = styled(Button)(_t2$7 || (_t2$7 = _$a`
8454
8454
  appearance: none;
8455
8455
  margin: -4px;
8456
8456
  `));
@@ -8580,15 +8580,15 @@ function useDialog() {
8580
8580
 
8581
8581
  const _excluded$d = ["__unstable_autoFocus", "__unstable_hideCloseButton", "cardRadius", "cardShadow", "children", "contentRef", "footer", "header", "id", "onClickOutside", "onClose", "padding", "portal", "position", "scheme", "width", "zOffset"];
8582
8582
 
8583
- let _$a = t => t,
8584
- _t$a,
8583
+ let _$9 = t => t,
8584
+ _t$9,
8585
8585
  _t2$6,
8586
8586
  _t3$2,
8587
8587
  _t4$1,
8588
8588
  _t5,
8589
8589
  _t6;
8590
8590
  const Root$7 = styled(Layer)(responsivePaddingStyle, dialogStyle, responsiveDialogPositionStyle);
8591
- const DialogContainer = styled(Container)(_t$a || (_t$a = _$a`
8591
+ const DialogContainer = styled(Container)(_t$9 || (_t$9 = _$9`
8592
8592
  &:not([hidden]) {
8593
8593
  display: flex;
8594
8594
  }
@@ -8598,7 +8598,7 @@ const DialogContainer = styled(Container)(_t$a || (_t$a = _$a`
8598
8598
  align-items: center;
8599
8599
  justify-content: center;
8600
8600
  `));
8601
- const DialogCardRoot = styled(Card)(_t2$6 || (_t2$6 = _$a`
8601
+ const DialogCardRoot = styled(Card)(_t2$6 || (_t2$6 = _$9`
8602
8602
  &:not([hidden]) {
8603
8603
  display: flex;
8604
8604
  }
@@ -8607,12 +8607,12 @@ const DialogCardRoot = styled(Card)(_t2$6 || (_t2$6 = _$a`
8607
8607
  max-height: 100%;
8608
8608
  overflow: hidden;
8609
8609
  `));
8610
- const DialogLayout = styled(Flex)(_t3$2 || (_t3$2 = _$a`
8610
+ const DialogLayout = styled(Flex)(_t3$2 || (_t3$2 = _$9`
8611
8611
  flex: 1;
8612
8612
  min-height: 0;
8613
8613
  width: 100%;
8614
8614
  `));
8615
- const DialogHeader = styled(Card)(_t4$1 || (_t4$1 = _$a`
8615
+ const DialogHeader = styled(Card)(_t4$1 || (_t4$1 = _$9`
8616
8616
  position: relative;
8617
8617
  z-index: 2;
8618
8618
 
@@ -8626,13 +8626,13 @@ const DialogHeader = styled(Card)(_t4$1 || (_t4$1 = _$a`
8626
8626
  border-bottom: 1px solid var(--card-hairline-soft-color);
8627
8627
  }
8628
8628
  `));
8629
- const DialogContent = styled(Box)(_t5 || (_t5 = _$a`
8629
+ const DialogContent = styled(Box)(_t5 || (_t5 = _$9`
8630
8630
  position: relative;
8631
8631
  z-index: 1;
8632
8632
  overflow: auto;
8633
8633
  outline: none;
8634
8634
  `));
8635
- const DialogFooter = styled(Box)(_t6 || (_t6 = _$a`
8635
+ const DialogFooter = styled(Box)(_t6 || (_t6 = _$9`
8636
8636
  position: relative;
8637
8637
  z-index: 3;
8638
8638
  border-top: 1px solid var(--card-hairline-soft-color);
@@ -8834,16 +8834,16 @@ function DialogProvider(props) {
8834
8834
 
8835
8835
  const _excluded$c = ["fontSize", "keys", "padding", "radius", "space"];
8836
8836
 
8837
- let _$9 = t => t,
8838
- _t$9,
8837
+ let _$8 = t => t,
8838
+ _t$8,
8839
8839
  _t2$5;
8840
- const Root$6 = styled.kbd(_t$9 || (_t$9 = _$9`
8840
+ const Root$6 = styled.kbd(_t$8 || (_t$8 = _$8`
8841
8841
  &:not([hidden]) {
8842
8842
  display: block;
8843
8843
  }
8844
8844
  font: inherit;
8845
8845
  `));
8846
- const Key = styled(KBD)(_t2$5 || (_t2$5 = _$9`
8846
+ const Key = styled(KBD)(_t2$5 || (_t2$5 = _$8`
8847
8847
  &:not([hidden]) {
8848
8848
  display: block;
8849
8849
  }
@@ -8881,6 +8881,10 @@ const Hotkeys = /*#__PURE__*/forwardRef(function Hotkeys(props, ref) {
8881
8881
  }, key))));
8882
8882
  });
8883
8883
 
8884
+ const key$2 = Symbol.for('@sanity/ui/context/menu');
8885
+ globalScope[key$2] = globalScope[key$2] || /*#__PURE__*/createContext(null);
8886
+ const MenuContext = globalScope[key$2];
8887
+
8884
8888
  /**
8885
8889
  * @internal
8886
8890
  */
@@ -8955,52 +8959,29 @@ function _sortElements(rootElement, elements) {
8955
8959
  elements.sort(_sort);
8956
8960
  }
8957
8961
 
8958
- const key$2 = Symbol.for('@sanity/ui/context/menu');
8959
- globalScope[key$2] = globalScope[key$2] || /*#__PURE__*/createContext(null);
8960
- const MenuContext = globalScope[key$2];
8961
-
8962
- const _excluded$b = ["children", "focusFirst", "focusLast", "onClickOutside", "onEscape", "onItemClick", "onItemSelect", "onKeyDown", "originElement", "padding", "registerElement", "shouldFocus", "space"];
8963
-
8964
- let _$8 = t => t,
8965
- _t$8;
8966
- const Root$5 = styled(Box)(_t$8 || (_t$8 = _$8`
8967
- outline: none;
8968
- overflow: auto;
8969
- `));
8970
8962
  /**
8971
- * @public
8963
+ * This controller is responsible for controlling UI menu state.
8964
+ *
8965
+ * @internal
8972
8966
  */
8973
8967
 
8974
- const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
8968
+ function useMenuController(props) {
8975
8969
  const {
8976
- children,
8977
- onClickOutside,
8978
- onEscape,
8979
- onItemClick,
8980
- onItemSelect,
8981
8970
  onKeyDown,
8982
8971
  originElement,
8983
- padding = 1,
8984
- registerElement,
8985
- shouldFocus = props.focusFirst && 'first' || props.focusLast && 'last' || null,
8986
- space = 1
8987
- } = props,
8988
- restProps = _objectWithoutPropertiesLoose(props, _excluded$b);
8989
-
8990
- const {
8991
- isTopLayer
8992
- } = useLayer();
8993
- const [rootElement, setRootElement] = useState(null);
8972
+ shouldFocus
8973
+ } = props;
8994
8974
  const elementsRef = useRef([]);
8995
- const [activeIndex, setActiveIndex] = useState(-1);
8996
- const activeIndexRef = useRef(activeIndex);
8975
+ const [rootElement, setRootElement] = useState(null);
8976
+ const [activeIndex, _setActiveIndex] = useState(-1);
8997
8977
  const activeElement = elementsRef.current[activeIndex] || null;
8998
- const activeElementRef = useRef(activeElement);
8978
+ const activeIndexRef = useRef(activeIndex);
8999
8979
  const mounted = Boolean(rootElement);
9000
- const setRef = useCallback(el => {
9001
- setRootElement(el);
9002
- if (typeof ref === 'function') ref(el);else if (ref) ref.current = el;
9003
- }, [ref]);
8980
+ const setActiveIndex = useCallback(nextActiveIndex => {
8981
+ _setActiveIndex(nextActiveIndex);
8982
+
8983
+ activeIndexRef.current = nextActiveIndex;
8984
+ }, []);
9004
8985
  const mount = useCallback((element, selected) => {
9005
8986
  if (!element) return () => undefined;
9006
8987
 
@@ -9013,7 +8994,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9013
8994
  if (selected) {
9014
8995
  const selectedIndex = elementsRef.current.indexOf(element);
9015
8996
  setActiveIndex(selectedIndex);
9016
- activeIndexRef.current = selectedIndex;
9017
8997
  }
9018
8998
 
9019
8999
  return () => {
@@ -9023,7 +9003,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9023
9003
  elementsRef.current.splice(idx, 1);
9024
9004
  }
9025
9005
  };
9026
- }, [rootElement]);
9006
+ }, [rootElement, setActiveIndex]);
9027
9007
  const handleKeyDown = useCallback(event => {
9028
9008
  // Move focus to the element that opened the menu before handling the `Tab` press
9029
9009
  if (event.key === 'Tab') {
@@ -9045,7 +9025,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9045
9025
  if (!el) return;
9046
9026
  const currentIndex = elementsRef.current.indexOf(el);
9047
9027
  setActiveIndex(currentIndex);
9048
- activeIndexRef.current = currentIndex;
9049
9028
  return;
9050
9029
  } // Move focus to the last focusable menuitem
9051
9030
 
@@ -9060,7 +9039,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9060
9039
  if (!el) return;
9061
9040
  const currentIndex = elementsRef.current.indexOf(el);
9062
9041
  setActiveIndex(currentIndex);
9063
- activeIndexRef.current = currentIndex;
9064
9042
  return;
9065
9043
  }
9066
9044
 
@@ -9078,7 +9056,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9078
9056
  const el = focusableElements[focusedIndex];
9079
9057
  const currentIndex = elementsRef.current.indexOf(el);
9080
9058
  setActiveIndex(currentIndex);
9081
- activeIndexRef.current = currentIndex;
9082
9059
  return;
9083
9060
  }
9084
9061
 
@@ -9096,32 +9073,22 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9096
9073
  const el = focusableElements[focusedIndex];
9097
9074
  const currentIndex = elementsRef.current.indexOf(el);
9098
9075
  setActiveIndex(currentIndex);
9099
- activeIndexRef.current = currentIndex;
9100
9076
  return;
9101
9077
  }
9102
9078
 
9103
9079
  if (onKeyDown) {
9104
9080
  onKeyDown(event);
9105
9081
  }
9106
- }, [activeIndex, onKeyDown, originElement]);
9082
+ }, [activeIndex, onKeyDown, originElement, setActiveIndex]);
9107
9083
  const handleItemMouseEnter = useCallback(event => {
9108
9084
  const element = event.currentTarget;
9109
9085
  const currentIndex = elementsRef.current.indexOf(element);
9110
9086
  setActiveIndex(currentIndex);
9111
- activeIndexRef.current = currentIndex;
9112
- }, []);
9087
+ }, [setActiveIndex]);
9113
9088
  const handleItemMouseLeave = useCallback(() => {
9114
9089
  rootElement == null ? void 0 : rootElement.focus();
9115
9090
  setActiveIndex(-1);
9116
- activeIndexRef.current = -1;
9117
- }, [rootElement]); // Trigger `onItemSelect` when active index changes
9118
-
9119
- useEffect(() => {
9120
- if (onItemSelect) onItemSelect(activeIndex);
9121
- }, [activeIndex, onItemSelect]);
9122
- useEffect(() => {
9123
- activeElementRef.current = activeElement;
9124
- }, [activeElement]); // Set focus on the currently active element
9091
+ }, [rootElement, setActiveIndex]); // Set focus on the currently active element
9125
9092
 
9126
9093
  useEffect(() => {
9127
9094
  if (!mounted) return;
@@ -9162,8 +9129,76 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9162
9129
  return () => {
9163
9130
  window.cancelAnimationFrame(rafId);
9164
9131
  };
9165
- }, [activeIndex, mounted, shouldFocus]);
9166
- useClickOutside(useCallback(event => isTopLayer && onClickOutside && onClickOutside(event), [isTopLayer, onClickOutside]), [rootElement]);
9132
+ }, [activeIndex, mounted, setActiveIndex, shouldFocus]);
9133
+ return {
9134
+ activeElement,
9135
+ activeIndex,
9136
+ handleItemMouseEnter,
9137
+ handleItemMouseLeave,
9138
+ handleKeyDown,
9139
+ mount,
9140
+ rootElement,
9141
+ setRootElement
9142
+ };
9143
+ }
9144
+
9145
+ const _excluded$b = ["children", "focusFirst", "focusLast", "onClickOutside", "onEscape", "onItemClick", "onItemSelect", "onKeyDown", "originElement", "padding", "registerElement", "shouldFocus", "space"];
9146
+
9147
+ let _$7 = t => t,
9148
+ _t$7;
9149
+ const Root$5 = styled(Box)(_t$7 || (_t$7 = _$7`
9150
+ outline: none;
9151
+ overflow: auto;
9152
+ `));
9153
+ /**
9154
+ * @public
9155
+ */
9156
+
9157
+ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9158
+ const {
9159
+ children,
9160
+ onClickOutside,
9161
+ onEscape,
9162
+ onItemClick,
9163
+ onItemSelect,
9164
+ onKeyDown,
9165
+ originElement,
9166
+ padding = 1,
9167
+ registerElement,
9168
+ shouldFocus = props.focusFirst && 'first' || props.focusLast && 'last' || null,
9169
+ space = 1
9170
+ } = props,
9171
+ restProps = _objectWithoutPropertiesLoose(props, _excluded$b);
9172
+
9173
+ const forwardedRef = useForwardedRef(ref);
9174
+ const {
9175
+ isTopLayer
9176
+ } = useLayer();
9177
+ const {
9178
+ activeElement,
9179
+ activeIndex,
9180
+ handleItemMouseEnter,
9181
+ handleItemMouseLeave,
9182
+ handleKeyDown,
9183
+ mount,
9184
+ rootElement,
9185
+ setRootElement
9186
+ } = useMenuController({
9187
+ onKeyDown,
9188
+ originElement,
9189
+ shouldFocus
9190
+ });
9191
+ const handleRefChange = useCallback(el => {
9192
+ setRootElement(el);
9193
+ forwardedRef.current = el;
9194
+ }, [forwardedRef, setRootElement]); // Trigger `onItemSelect` when active index changes
9195
+
9196
+ useEffect(() => {
9197
+ if (onItemSelect) onItemSelect(activeIndex);
9198
+ }, [activeIndex, onItemSelect]); // Close menu when clicking outside
9199
+
9200
+ useClickOutside(useCallback(event => isTopLayer && onClickOutside && onClickOutside(event), [isTopLayer, onClickOutside]), [rootElement]); // Close menu when pressing Escape
9201
+
9167
9202
  useGlobalKeyDown(useCallback(event => {
9168
9203
  if (!isTopLayer) return;
9169
9204
 
@@ -9171,7 +9206,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9171
9206
  event.stopPropagation();
9172
9207
  if (onEscape) onEscape();
9173
9208
  }
9174
- }, [isTopLayer, onEscape]));
9209
+ }, [isTopLayer, onEscape])); // Register root element (for nested menus)
9210
+
9175
9211
  useEffect(() => {
9176
9212
  if (!rootElement || !registerElement) return;
9177
9213
  return registerElement(rootElement);
@@ -9183,9 +9219,9 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9183
9219
  mount,
9184
9220
  onClickOutside,
9185
9221
  onEscape,
9186
- onMouseEnter: handleItemMouseEnter,
9187
- onMouseLeave: handleItemMouseLeave,
9188
9222
  onItemClick,
9223
+ onItemMouseEnter: handleItemMouseEnter,
9224
+ onItemMouseLeave: handleItemMouseLeave,
9189
9225
  registerElement
9190
9226
  }), [activeElement, activeIndex, mount, handleItemMouseEnter, handleItemMouseLeave, onClickOutside, onEscape, onItemClick, registerElement]);
9191
9227
  return /*#__PURE__*/React.createElement(MenuContext.Provider, {
@@ -9195,7 +9231,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(props, ref) {
9195
9231
  }, restProps, {
9196
9232
  onKeyDown: handleKeyDown,
9197
9233
  padding: padding,
9198
- ref: setRef,
9234
+ ref: handleRefChange,
9199
9235
  role: "menu",
9200
9236
  tabIndex: -1
9201
9237
  }), /*#__PURE__*/React.createElement(Stack, {
@@ -9357,24 +9393,24 @@ const MenuButton = /*#__PURE__*/forwardRef(function MenuButton(props, ref) {
9357
9393
  }), button || /*#__PURE__*/React.createElement(React.Fragment, null));
9358
9394
  });
9359
9395
 
9360
- let _$7 = t => t,
9361
- _t$7;
9396
+ let _$6 = t => t,
9397
+ _t$6;
9362
9398
  /**
9363
9399
  * @public
9364
9400
  */
9365
9401
 
9366
- const MenuDivider = styled.hr(_t$7 || (_t$7 = _$7`
9402
+ const MenuDivider = styled.hr(_t$6 || (_t$6 = _$6`
9367
9403
  height: 1px;
9368
9404
  border: 0;
9369
9405
  background: var(--card-hairline-soft-color);
9370
9406
  margin: 0;
9371
9407
  `));
9372
9408
 
9373
- let _$6 = t => t,
9374
- _t$6,
9409
+ let _$5 = t => t,
9410
+ _t$5,
9375
9411
  _t2$4;
9376
9412
  function selectableBaseStyle() {
9377
- return css(_t$6 || (_t$6 = _$6`
9413
+ return css(_t$5 || (_t$5 = _$5`
9378
9414
  background-color: inherit;
9379
9415
  color: inherit;
9380
9416
 
@@ -9408,7 +9444,7 @@ function selectableColorStyle(props) {
9408
9444
  } = theme.sanity.color; // @todo: remove use of `muted` here
9409
9445
 
9410
9446
  const tone = selectable ? selectable[$tone] || selectable.default : muted[$tone] || muted.default;
9411
- return css(_t2$4 || (_t2$4 = _$6`
9447
+ return css(_t2$4 || (_t2$4 = _$5`
9412
9448
  ${0}
9413
9449
 
9414
9450
  background-color: var(--card-bg-color);
@@ -9501,21 +9537,7 @@ function useMenu() {
9501
9537
  return value;
9502
9538
  }
9503
9539
 
9504
- const _excluded$a = ["as", "children", "fontSize", "onClick", "padding", "popover", "radius", "text", "tone"];
9505
-
9506
- let _$5 = t => t,
9507
- _t$5;
9508
- const MOUSE_LEAVE_TIMEOUT = 1000;
9509
- const TextContainer = styled.span(_t$5 || (_t$5 = _$5`
9510
- &:not([hidden]) {
9511
- display: flex;
9512
- }
9513
-
9514
- & > div:first-child {
9515
- flex: 1;
9516
- min-width: 0;
9517
- }
9518
- `));
9540
+ const _excluded$a = ["as", "children", "fontSize", "icon", "onClick", "padding", "popover", "radius", "space", "text", "tone"];
9519
9541
  /**
9520
9542
  * @public
9521
9543
  */
@@ -9525,48 +9547,36 @@ function MenuGroup(props) {
9525
9547
  as = 'button',
9526
9548
  children,
9527
9549
  fontSize,
9550
+ icon,
9528
9551
  onClick,
9529
9552
  padding = 3,
9530
9553
  popover = {},
9531
9554
  radius = 2,
9555
+ space = 3,
9532
9556
  text,
9533
9557
  tone = 'default'
9534
9558
  } = props,
9535
9559
  restProps = _objectWithoutPropertiesLoose(props, _excluded$a);
9536
9560
 
9537
- const [open, setOpen] = useState(false);
9538
9561
  const {
9539
9562
  activeElement,
9540
9563
  mount,
9541
9564
  onClickOutside,
9542
9565
  onEscape,
9543
9566
  onItemClick,
9544
- onMouseEnter,
9545
- onMouseLeave,
9567
+ onItemMouseEnter,
9546
9568
  registerElement
9547
9569
  } = useMenu();
9548
9570
  const [rootElement, setRootElement] = useState(null);
9549
- const mouseLeaveTimeoutRef = useRef(null);
9571
+ const [open, setOpen] = useState(false);
9550
9572
  const shouldFocusRef = useRef(null);
9551
- const active = Boolean(activeElement) && activeElement === rootElement; // const selected = active || open
9552
- // Register the element
9553
-
9554
- useEffect(() => mount(rootElement), [mount, rootElement]);
9573
+ const active = Boolean(activeElement) && activeElement === rootElement;
9574
+ const [withinMenu, setWithinMenu] = useState(false);
9555
9575
  const handleMouseEnter = useCallback(event => {
9556
- if (mouseLeaveTimeoutRef.current) {
9557
- clearTimeout(mouseLeaveTimeoutRef.current);
9558
- mouseLeaveTimeoutRef.current = null;
9559
- }
9560
-
9561
- onMouseEnter(event);
9576
+ setWithinMenu(false);
9577
+ onItemMouseEnter(event);
9562
9578
  setOpen(true);
9563
- }, [onMouseEnter]);
9564
- const handleMouseLeave = useCallback(event => {
9565
- onMouseLeave(event);
9566
- mouseLeaveTimeoutRef.current = setTimeout(() => {
9567
- setOpen(false);
9568
- }, MOUSE_LEAVE_TIMEOUT);
9569
- }, [onMouseLeave]);
9579
+ }, [onItemMouseEnter]);
9570
9580
  const handleMenuKeyDown = useCallback(event => {
9571
9581
  if (event.key === 'ArrowLeft') {
9572
9582
  event.stopPropagation();
@@ -9576,17 +9586,6 @@ function MenuGroup(props) {
9576
9586
  });
9577
9587
  }
9578
9588
  }, [rootElement]);
9579
- const handleMenuMouseEnter = useCallback(() => {
9580
- if (mouseLeaveTimeoutRef.current) {
9581
- clearTimeout(mouseLeaveTimeoutRef.current);
9582
- mouseLeaveTimeoutRef.current = null;
9583
- }
9584
- }, []);
9585
- const handleMenuMouseLeave = useCallback(() => {
9586
- mouseLeaveTimeoutRef.current = setTimeout(() => {
9587
- setOpen(false);
9588
- }, MOUSE_LEAVE_TIMEOUT);
9589
- }, []);
9590
9589
  const handleClick = useCallback(event => {
9591
9590
  if (onClick) onClick(event);
9592
9591
  shouldFocusRef.current = 'first';
@@ -9595,25 +9594,27 @@ function MenuGroup(props) {
9595
9594
  shouldFocusRef.current = null;
9596
9595
  });
9597
9596
  }, [onClick]);
9598
- const handleItemClick = useCallback(() => {
9597
+ const handleChildItemClick = useCallback(() => {
9599
9598
  setOpen(false);
9600
9599
  if (onItemClick) onItemClick();
9601
9600
  }, [onItemClick]);
9601
+ const handleMenuMouseEnter = useCallback(() => setWithinMenu(true), []); // Register the menu item element
9602
+
9603
+ useEffect(() => mount(rootElement), [mount, rootElement]); // Close child menu when a sibling item becomes active
9604
+
9602
9605
  useEffect(() => {
9603
- return () => {
9604
- if (mouseLeaveTimeoutRef.current !== null) {
9605
- clearTimeout(mouseLeaveTimeoutRef.current);
9606
- mouseLeaveTimeoutRef.current = null;
9607
- }
9608
- };
9609
- }, []);
9610
- const content = /*#__PURE__*/React.createElement(Menu, {
9606
+ if (!active) setOpen(false);
9607
+ }, [active]); // Update state when child menu is no longer open
9608
+
9609
+ useEffect(() => {
9610
+ if (!open) setWithinMenu(false);
9611
+ }, [open]);
9612
+ const childMenu = /*#__PURE__*/React.createElement(Menu, {
9611
9613
  onClickOutside: onClickOutside,
9612
9614
  onEscape: onEscape,
9613
- onItemClick: handleItemClick,
9615
+ onItemClick: handleChildItemClick,
9614
9616
  onKeyDown: handleMenuKeyDown,
9615
9617
  onMouseEnter: handleMenuMouseEnter,
9616
- onMouseLeave: handleMenuMouseLeave,
9617
9618
  registerElement: registerElement,
9618
9619
  shouldFocus: shouldFocusRef.current
9619
9620
  }, children);
@@ -9627,6 +9628,7 @@ function MenuGroup(props) {
9627
9628
  if (event.key === 'ArrowRight') {
9628
9629
  shouldFocusRef.current = 'first';
9629
9630
  setOpen(true);
9631
+ setWithinMenu(true);
9630
9632
  requestAnimationFrame(() => {
9631
9633
  shouldFocusRef.current = null;
9632
9634
  });
@@ -9634,7 +9636,7 @@ function MenuGroup(props) {
9634
9636
  }
9635
9637
  }, []);
9636
9638
  return /*#__PURE__*/React.createElement(Popover, _extends({}, popover, {
9637
- content: content,
9639
+ content: childMenu,
9638
9640
  "data-ui": "MenuGroup__popover",
9639
9641
  open: open
9640
9642
  }), /*#__PURE__*/React.createElement(Selectable, _extends({
@@ -9642,25 +9644,32 @@ function MenuGroup(props) {
9642
9644
  "data-ui": "MenuGroup",
9643
9645
  forwardedAs: as
9644
9646
  }, restProps, {
9645
- "aria-pressed": as === 'button' ? !active && open : undefined,
9646
- "data-pressed": as !== 'button' ? !active && open : undefined,
9647
- "data-selected": active ? '' : undefined,
9647
+ "aria-pressed": as === 'button' ? withinMenu : undefined,
9648
+ "data-pressed": as !== 'button' ? withinMenu : undefined,
9649
+ "data-selected": !withinMenu && active ? '' : undefined,
9648
9650
  "$radius": radius,
9649
9651
  "$tone": tone,
9650
9652
  onClick: handleClick,
9651
9653
  onKeyDown: handleKeyDown,
9652
9654
  onMouseEnter: handleMouseEnter,
9653
- onMouseLeave: handleMouseLeave,
9654
9655
  ref: setRootElement,
9655
9656
  tabIndex: -1,
9656
9657
  type: as === 'button' ? 'button' : undefined
9657
9658
  }), /*#__PURE__*/React.createElement(Box, {
9658
9659
  padding: padding
9659
- }, /*#__PURE__*/React.createElement(TextContainer, null, /*#__PURE__*/React.createElement(Text, {
9660
+ }, /*#__PURE__*/React.createElement(Flex, null, icon && /*#__PURE__*/React.createElement(Text, {
9660
9661
  size: fontSize
9661
- }, text), /*#__PURE__*/React.createElement(Text, {
9662
+ }, /*#__PURE__*/isValidElement(icon) && icon, isValidElementType(icon) && /*#__PURE__*/createElement(icon)), /*#__PURE__*/React.createElement(Box, {
9663
+ flex: 1,
9664
+ marginLeft: icon ? space : undefined
9665
+ }, /*#__PURE__*/React.createElement(Text, {
9666
+ size: fontSize,
9667
+ textOverflow: "ellipsis"
9668
+ }, text)), /*#__PURE__*/React.createElement(Box, {
9669
+ marginLeft: space
9670
+ }, /*#__PURE__*/React.createElement(Text, {
9662
9671
  size: fontSize
9663
- }, /*#__PURE__*/React.createElement(ChevronRightIcon, null))))));
9672
+ }, /*#__PURE__*/React.createElement(ChevronRightIcon, null)))))));
9664
9673
  }
9665
9674
 
9666
9675
  const _excluded$9 = ["as", "children", "disabled", "fontSize", "hotkeys", "icon", "iconRight", "onClick", "padding", "paddingX", "paddingY", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "pressed", "radius", "selected", "space", "text", "tone"];
@@ -9698,11 +9707,11 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwardedRef)
9698
9707
  activeElement,
9699
9708
  mount,
9700
9709
  onItemClick,
9701
- onMouseEnter,
9702
- onMouseLeave
9710
+ onItemMouseEnter,
9711
+ onItemMouseLeave
9703
9712
  } = useMenu();
9704
9713
  const [rootElement, setRootElement] = useState(null);
9705
- const selected = Boolean(activeElement) && rootElement === activeElement;
9714
+ const active = Boolean(activeElement) && activeElement === rootElement;
9706
9715
  useEffect(() => mount(rootElement, selectedProp), [mount, rootElement, selectedProp]);
9707
9716
  const ref = useForwardedRef(forwardedRef);
9708
9717
  const handleClick = useCallback(event => {
@@ -9730,14 +9739,14 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(props, forwardedRef)
9730
9739
  }, restProps, {
9731
9740
  "aria-pressed": as === 'button' && pressed,
9732
9741
  "data-pressed": as !== 'button' && pressed ? '' : undefined,
9733
- "data-selected": selected ? '' : undefined,
9742
+ "data-selected": active ? '' : undefined,
9734
9743
  "data-disabled": disabled ? '' : undefined,
9735
9744
  "$radius": radius,
9736
9745
  "$tone": tone,
9737
9746
  disabled: disabled,
9738
9747
  onClick: handleClick,
9739
- onMouseEnter: onMouseEnter,
9740
- onMouseLeave: onMouseLeave,
9748
+ onMouseEnter: onItemMouseEnter,
9749
+ onMouseLeave: onItemMouseLeave,
9741
9750
  padding: 0,
9742
9751
  ref: setRef,
9743
9752
  role: "menuitem",