@sanity/ui 2.0.0-alpha.12 → 2.0.0-alpha.13

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.ts CHANGED
@@ -460,7 +460,7 @@ export declare interface BreadcrumbsProps {
460
460
  * @public
461
461
  */
462
462
  export declare const Button: ForwardRefExoticComponent<
463
- Omit<ButtonProps & Omit<HTMLProps<HTMLButtonElement>, 'as'>, 'ref'> &
463
+ Omit<ButtonProps & Omit<HTMLProps<HTMLButtonElement>, 'width' | 'as'>, 'ref'> &
464
464
  RefAttributes<HTMLButtonElement>
465
465
  >
466
466
 
@@ -490,6 +490,7 @@ export declare interface ButtonProps extends ResponsivePaddingProps, ResponsiveR
490
490
  text?: React.ReactNode
491
491
  tone?: ButtonTone
492
492
  type?: 'button' | 'reset' | 'submit'
493
+ width?: ButtonWidth
493
494
  }
494
495
 
495
496
  /**
@@ -502,6 +503,11 @@ export declare type ButtonTextAlign = 'left' | 'right' | 'center'
502
503
  */
503
504
  export declare type ButtonTone = 'default' | 'primary' | 'positive' | 'caution' | 'critical'
504
505
 
506
+ /**
507
+ * @public
508
+ */
509
+ export declare type ButtonWidth = 'fill'
510
+
505
511
  /**
506
512
  * @public
507
513
  */
@@ -2217,7 +2223,11 @@ export declare interface SwitchProps {
2217
2223
  */
2218
2224
  export declare const Tab: ForwardRefExoticComponent<
2219
2225
  Omit<
2220
- TabProps & Omit<HTMLProps<HTMLButtonElement>, 'label' | 'id' | 'aria-controls' | 'as' | 'type'>,
2226
+ TabProps &
2227
+ Omit<
2228
+ HTMLProps<HTMLButtonElement>,
2229
+ 'label' | 'width' | 'id' | 'aria-controls' | 'as' | 'type'
2230
+ >,
2221
2231
  'ref'
2222
2232
  > &
2223
2233
  RefAttributes<HTMLButtonElement>
package/dist/index.esm.js CHANGED
@@ -3883,7 +3883,7 @@ var __defProp$E = Object.defineProperty;
3883
3883
  var __template$D = (cooked, raw) => __freeze$D(__defProp$E(cooked, "raw", {
3884
3884
  value: __freeze$D(raw || cooked.slice())
3885
3885
  }));
3886
- var _a$D, _b$m, _c$d;
3886
+ var _a$D, _b$n, _c$d;
3887
3887
  const ROOT_STYLE = css(_a$D || (_a$D = __template$D(["\n &:not([hidden]) {\n display: flex;\n }\n\n align-items: center;\n"])));
3888
3888
  function textInputRootStyle() {
3889
3889
  return ROOT_STYLE;
@@ -3897,7 +3897,7 @@ function textInputBaseStyle(props) {
3897
3897
  } = props;
3898
3898
  const font = theme.sanity.fonts.text;
3899
3899
  const color = theme.sanity.color.input;
3900
- return css(_b$m || (_b$m = __template$D(["\n appearance: none;\n background: none;\n border: 0;\n border-radius: 0;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n font-family: ", ";\n font-weight: ", ";\n margin: 0;\n position: relative;\n z-index: 1;\n display: block;\n\n /* NOTE: This is a hack to disable Chrome\u2019s autofill styles */\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-text-fill-color: var(--input-fg-color) !important;\n transition: background-color 5000s;\n transition-delay: 86400s /* 24h */;\n }\n\n /* &:is(textarea) */\n &[data-as='textarea'] {\n resize: none;\n }\n\n color: var(--input-fg-color);\n\n &::placeholder {\n color: var(--input-placeholder-color);\n }\n\n &[data-scheme='", "'][data-tone='", "'] {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n\n /* enabled */\n &:not(:invalid):not(:disabled):not(:read-only) {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* disabled */\n &:not(:invalid):disabled {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* invalid */\n &:invalid {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* readOnly */\n &:read-only {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n }\n "])), font.family, $weight && font.weights[$weight] || font.weights.regular, $scheme, $tone, color.default.enabled.fg, color.default.enabled.placeholder, color.default.enabled.fg, color.default.enabled.placeholder, color.default.disabled.fg, color.default.disabled.placeholder, color.invalid.enabled.fg, color.invalid.enabled.placeholder, color.default.readOnly.fg, color.default.readOnly.placeholder);
3900
+ return css(_b$n || (_b$n = __template$D(["\n appearance: none;\n background: none;\n border: 0;\n border-radius: 0;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n font-family: ", ";\n font-weight: ", ";\n margin: 0;\n position: relative;\n z-index: 1;\n display: block;\n\n /* NOTE: This is a hack to disable Chrome\u2019s autofill styles */\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-text-fill-color: var(--input-fg-color) !important;\n transition: background-color 5000s;\n transition-delay: 86400s /* 24h */;\n }\n\n /* &:is(textarea) */\n &[data-as='textarea'] {\n resize: none;\n }\n\n color: var(--input-fg-color);\n\n &::placeholder {\n color: var(--input-placeholder-color);\n }\n\n &[data-scheme='", "'][data-tone='", "'] {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n\n /* enabled */\n &:not(:invalid):not(:disabled):not(:read-only) {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* disabled */\n &:not(:invalid):disabled {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* invalid */\n &:invalid {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* readOnly */\n &:read-only {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n }\n "])), font.family, $weight && font.weights[$weight] || font.weights.regular, $scheme, $tone, color.default.enabled.fg, color.default.enabled.placeholder, color.default.enabled.fg, color.default.enabled.placeholder, color.default.disabled.fg, color.default.disabled.placeholder, color.invalid.enabled.fg, color.invalid.enabled.placeholder, color.default.readOnly.fg, color.default.readOnly.placeholder);
3901
3901
  }
3902
3902
  function textInputFontSizeStyle(props) {
3903
3903
  const {
@@ -4013,7 +4013,7 @@ var __defProp$D = Object.defineProperty;
4013
4013
  var __template$C = (cooked, raw) => __freeze$C(__defProp$D(cooked, "raw", {
4014
4014
  value: __freeze$C(raw || cooked.slice())
4015
4015
  }));
4016
- var _a$C, _b$l, _c$c;
4016
+ var _a$C, _b$m, _c$c;
4017
4017
  function textBaseStyle(props) {
4018
4018
  const {
4019
4019
  $accent,
@@ -4023,7 +4023,7 @@ function textBaseStyle(props) {
4023
4023
  const {
4024
4024
  weights
4025
4025
  } = theme.sanity.fonts.text;
4026
- return css(_c$c || (_c$c = __template$C(["\n color: var(--card-fg-color);\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n background-color: var(--card-code-bg-color);\n color: var(--card-code-fg-color);\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & strong {\n font-weight: ", ";\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n color: var(--card-icon-color);\n }\n "])), $accent && css(_a$C || (_a$C = __template$C(["\n color: var(--card-accent-fg-color);\n "]))), $muted && css(_b$l || (_b$l = __template$C(["\n color: var(--card-muted-fg-color);\n "]))), theme.sanity.fonts.code.family, weights.bold);
4026
+ return css(_c$c || (_c$c = __template$C(["\n color: var(--card-fg-color);\n\n ", "\n\n ", "\n\n & code {\n font-family: ", ";\n border-radius: 1px;\n background-color: var(--card-code-bg-color);\n color: var(--card-code-fg-color);\n }\n\n & a {\n text-decoration: none;\n border-radius: 1px;\n color: var(--card-link-color);\n outline: none;\n\n @media (hover: hover) {\n &:hover {\n text-decoration: underline;\n }\n }\n\n &:focus {\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n 0 0 0 3px var(--card-focus-ring-color);\n }\n\n &:focus:not(:focus-visible) {\n box-shadow: none;\n }\n }\n\n & strong {\n font-weight: ", ";\n }\n\n & svg {\n /* Certain popular CSS libraries changes the defaults for SVG display */\n /* Make sure SVGs are rendered as inline elements */\n display: inline;\n }\n\n & [data-sanity-icon] {\n vertical-align: baseline;\n color: var(--card-icon-color);\n }\n "])), $accent && css(_a$C || (_a$C = __template$C(["\n color: var(--card-accent-fg-color);\n "]))), $muted && css(_b$m || (_b$m = __template$C(["\n color: var(--card-muted-fg-color);\n "]))), theme.sanity.fonts.code.family, weights.bold);
4027
4027
  }
4028
4028
  var __freeze$B = Object.freeze;
4029
4029
  var __defProp$C = Object.defineProperty;
@@ -4588,9 +4588,9 @@ var __defProp$z = Object.defineProperty;
4588
4588
  var __template$y = (cooked, raw) => __freeze$y(__defProp$z(cooked, "raw", {
4589
4589
  value: __freeze$y(raw || cooked.slice())
4590
4590
  }));
4591
- var _a$y, _b$k;
4591
+ var _a$y, _b$l;
4592
4592
  const rotate$1 = keyframes(_a$y || (_a$y = __template$y(["\n from {\n transform: rotate(0deg);\n }\n\n to {\n transform: rotate(360deg);\n }\n"])));
4593
- const Root$x = styled(Text)(_b$k || (_b$k = __template$y(["\n & > span > svg {\n animation: ", " 500ms linear infinite;\n }\n"])), rotate$1);
4593
+ const Root$x = styled(Text)(_b$l || (_b$l = __template$y(["\n & > span > svg {\n animation: ", " 500ms linear infinite;\n }\n"])), rotate$1);
4594
4594
  const Spinner = forwardRef(function Spinner2(props, ref) {
4595
4595
  return /* @__PURE__ */jsx(Root$x, {
4596
4596
  "data-ui": "Spinner",
@@ -4635,9 +4635,12 @@ var __defProp$y = Object.defineProperty;
4635
4635
  var __template$x = (cooked, raw) => __freeze$x(__defProp$y(cooked, "raw", {
4636
4636
  value: __freeze$x(raw || cooked.slice())
4637
4637
  }));
4638
- var _a$x;
4639
- function buttonBaseStyles() {
4640
- return css(_a$x || (_a$x = __template$x(["\n -webkit-font-smoothing: inherit;\n appearance: none;\n display: inline-flex;\n align-items: center;\n font: inherit;\n border: 0;\n outline: none;\n user-select: none;\n text-decoration: none;\n border: 0;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n text-align: left;\n position: relative;\n\n & > span {\n display: block;\n flex: 1;\n min-width: 0;\n border-radius: inherit;\n }\n\n &::-moz-focus-inner {\n border: 0;\n padding: 0;\n }\n "])));
4638
+ var _a$x, _b$k;
4639
+ function buttonBaseStyles(_ref20) {
4640
+ let {
4641
+ $width
4642
+ } = _ref20;
4643
+ return css(_b$k || (_b$k = __template$x(["\n -webkit-font-smoothing: inherit;\n appearance: none;\n display: inline-flex;\n align-items: center;\n font: inherit;\n border: 0;\n outline: none;\n user-select: none;\n text-decoration: none;\n border: 0;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n text-align: left;\n position: relative;\n\n ", "\n\n & > span {\n display: block;\n flex: 1;\n min-width: 0;\n border-radius: inherit;\n }\n\n &::-moz-focus-inner {\n border: 0;\n padding: 0;\n }\n "])), $width === "fill" && css(_a$x || (_a$x = __template$x(["\n width: -webkit-fill-available;\n width: stretch;\n "]))));
4641
4644
  }
4642
4645
  const buttonTheme = {
4643
4646
  border: {
@@ -4652,7 +4655,7 @@ function combineBoxShadow() {
4652
4655
  return boxShadows.filter(Boolean).join(",");
4653
4656
  }
4654
4657
  function buttonColorStyles(props) {
4655
- var _a2, _b;
4658
+ var _a2, _b2;
4656
4659
  const {
4657
4660
  $mode,
4658
4661
  theme
@@ -4695,7 +4698,7 @@ function buttonColorStyles(props) {
4695
4698
  },
4696
4699
  "&[data-selected]": _colorVarsStyle(base, color.pressed)
4697
4700
  }
4698
- }, (_b = (_a2 = theme.sanity.styles) == null ? void 0 : _a2.button) == null ? void 0 : _b.root].filter(Boolean);
4701
+ }, (_b2 = (_a2 = theme.sanity.styles) == null ? void 0 : _a2.button) == null ? void 0 : _b2.root].filter(Boolean);
4699
4702
  }
4700
4703
  var __freeze$w = Object.freeze;
4701
4704
  var __defProp$x = Object.defineProperty;
@@ -4730,6 +4733,7 @@ const Button = forwardRef(function Button2(props, ref) {
4730
4733
  tone = "default",
4731
4734
  type = "button",
4732
4735
  muted = false,
4736
+ width,
4733
4737
  ...restProps
4734
4738
  } = props;
4735
4739
  const justify = useArrayProp(justifyProp);
@@ -4764,6 +4768,7 @@ const Button = forwardRef(function Button2(props, ref) {
4764
4768
  disabled: Boolean(loading || disabled),
4765
4769
  ref,
4766
4770
  type,
4771
+ $width: width,
4767
4772
  children: [Boolean(loading) && /* @__PURE__ */jsx(LoadingBox, {
4768
4773
  children: /* @__PURE__ */jsx(Spinner, {})
4769
4774
  }), (icon || text || iconRight) && /* @__PURE__ */jsx(Box, {
@@ -4992,10 +4997,10 @@ var __template$t = (cooked, raw) => __freeze$t(__defProp$u(cooked, "raw", {
4992
4997
  value: __freeze$t(raw || cooked.slice())
4993
4998
  }));
4994
4999
  var _a$t;
4995
- function codeSyntaxHighlightingStyle(_ref20) {
5000
+ function codeSyntaxHighlightingStyle(_ref21) {
4996
5001
  let {
4997
5002
  theme
4998
- } = _ref20;
5003
+ } = _ref21;
4999
5004
  const color = theme.sanity.color.syntax;
5000
5005
  return {
5001
5006
  "&.atrule": {
@@ -6303,13 +6308,13 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
6303
6308
  }));
6304
6309
  if (constrainSize || matchReferenceWidth) {
6305
6310
  ret.push(size({
6306
- apply(_ref21) {
6311
+ apply(_ref22) {
6307
6312
  let {
6308
6313
  availableWidth,
6309
6314
  availableHeight,
6310
6315
  elements,
6311
6316
  referenceWidth
6312
- } = _ref21;
6317
+ } = _ref22;
6313
6318
  referenceWidthRef.current = referenceWidth;
6314
6319
  const _currentWidth = widthRef.current;
6315
6320
  const _maxWidth = maxWidthRef.current;
@@ -7118,12 +7123,12 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
7118
7123
  mainAxis: 3
7119
7124
  }));
7120
7125
  ret.push(size$2({
7121
- apply(_ref22) {
7126
+ apply(_ref23) {
7122
7127
  let {
7123
7128
  availableWidth,
7124
7129
  availableHeight,
7125
7130
  elements
7126
- } = _ref22;
7131
+ } = _ref23;
7127
7132
  Object.assign(elements.floating.style, {
7128
7133
  maxWidth: "".concat(availableWidth - 4 * 2, "px"),
7129
7134
  // the padding is `4px`
@@ -7429,10 +7434,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
7429
7434
  query,
7430
7435
  value
7431
7436
  } = state;
7432
- const defaultRenderOption = useCallback(_ref23 => {
7437
+ const defaultRenderOption = useCallback(_ref24 => {
7433
7438
  let {
7434
7439
  value: value2
7435
- } = _ref23;
7440
+ } = _ref24;
7436
7441
  return /* @__PURE__ */jsx(Card, {
7437
7442
  "data-as": "button",
7438
7443
  padding: paddingProp,
@@ -7886,10 +7891,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
7886
7891
  });
7887
7892
  });
7888
7893
  const BORDER_OFFSET_X = 12;
7889
- function dialogStyle(_ref24) {
7894
+ function dialogStyle(_ref25) {
7890
7895
  let {
7891
7896
  theme
7892
- } = _ref24;
7897
+ } = _ref25;
7893
7898
  const color = theme.sanity.color.base;
7894
7899
  return {
7895
7900
  "&:not([hidden])": {
@@ -8974,15 +8979,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
8974
8979
  var _a$6, _b$3, _c$1, _d;
8975
8980
  const keyframe = keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
8976
8981
  const animation = css(_b$3 || (_b$3 = __template$6(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
8977
- const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref25 => {
8982
+ const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref26 => {
8978
8983
  let {
8979
8984
  $visible
8980
- } = _ref25;
8985
+ } = _ref26;
8981
8986
  return $visible ? 1 : 0;
8982
- }, _ref26 => {
8987
+ }, _ref27 => {
8983
8988
  let {
8984
8989
  $animated
8985
- } = _ref26;
8990
+ } = _ref27;
8986
8991
  return $animated ? animation : css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
8987
8992
  });
8988
8993
  const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
@@ -9013,12 +9018,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
9013
9018
  ref
9014
9019
  });
9015
9020
  });
9016
- const Root$3 = styled(Skeleton)(_ref27 => {
9021
+ const Root$3 = styled(Skeleton)(_ref28 => {
9017
9022
  let {
9018
9023
  $size,
9019
9024
  $style,
9020
9025
  theme
9021
- } = _ref27;
9026
+ } = _ref28;
9022
9027
  const {
9023
9028
  media
9024
9029
  } = theme.sanity;
@@ -9366,12 +9371,12 @@ function ToastProvider(props) {
9366
9371
  paddingY,
9367
9372
  children: /* @__PURE__ */jsx(AnimatePresence, {
9368
9373
  initial: false,
9369
- children: state.map(_ref28 => {
9374
+ children: state.map(_ref29 => {
9370
9375
  let {
9371
9376
  dismiss,
9372
9377
  id,
9373
9378
  params
9374
- } = _ref28;
9379
+ } = _ref29;
9375
9380
  return /* @__PURE__ */jsx(motion.div, {
9376
9381
  animate: {
9377
9382
  opacity: 1,