@strapi/design-system 2.0.0-beta.5 → 2.0.0-beta.6

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.mjs CHANGED
@@ -26,7 +26,9 @@ import * as Dialog$1 from "@radix-ui/react-dialog";
26
26
  import * as ScrollArea from "@radix-ui/react-scroll-area";
27
27
  import { NumberParser, NumberFormatter } from "@internationalized/number";
28
28
  import * as Popover$1 from "@radix-ui/react-popover";
29
+ import * as Progress from "@radix-ui/react-progress";
29
30
  import * as RadioGroup from "@radix-ui/react-radio-group";
31
+ import * as Switch from "@radix-ui/react-switch";
30
32
  import * as Tabs$1 from "@radix-ui/react-tabs";
31
33
  const createContext = (rootComponentName, defaultContext) => {
32
34
  const Context = React.createContext(defaultContext);
@@ -1485,7 +1487,7 @@ const ButtonWrapper = styled(BaseButton)`
1485
1487
  }
1486
1488
  `;
1487
1489
  const Link = forwardRef(
1488
- ({ children, href, disabled = false, startIcon, endIcon, isExternal = true, ...props }, ref) => {
1490
+ ({ children, href, disabled = false, startIcon, endIcon, isExternal = false, ...props }, ref) => {
1489
1491
  return /* @__PURE__ */ jsxs(LinkWrapper$2, { ref, href, disabled, isExternal, ...props, children: [
1490
1492
  startIcon,
1491
1493
  /* @__PURE__ */ jsx(Typography, { textColor: disabled ? "neutral600" : "primary600", children }),
@@ -7832,6 +7834,7 @@ const Input$2 = React.forwardRef(
7832
7834
  hasError: hasErrorProp,
7833
7835
  required: requiredProp,
7834
7836
  className,
7837
+ size = "M",
7835
7838
  ...props
7836
7839
  }, ref) => {
7837
7840
  const { id, error, hint, name, required } = useField("Input");
@@ -7850,10 +7853,6 @@ const Input$2 = React.forwardRef(
7850
7853
  return /* @__PURE__ */ jsxs(
7851
7854
  InputWrapper,
7852
7855
  {
7853
- paddingLeft: 3,
7854
- paddingRight: 3,
7855
- paddingTop: 2,
7856
- paddingBottom: 2,
7857
7856
  gap: 2,
7858
7857
  justifyContent: "space-between",
7859
7858
  $hasError: hasError || hasErrorProp,
@@ -7867,13 +7866,14 @@ const Input$2 = React.forwardRef(
7867
7866
  id,
7868
7867
  name,
7869
7868
  ref,
7869
+ $hasLeftAction: Boolean(startAction),
7870
+ $hasRightAction: Boolean(endAction),
7871
+ $size: size,
7870
7872
  "aria-describedby": ariaDescription,
7871
7873
  "aria-invalid": hasError || hasErrorProp,
7872
7874
  "aria-disabled": disabled,
7873
7875
  disabled,
7874
7876
  "data-disabled": disabled ? "" : void 0,
7875
- $hasLeftAction: Boolean(startAction),
7876
- $hasRightAction: Boolean(endAction),
7877
7877
  onChange: handleChange,
7878
7878
  "aria-required": required || requiredProp,
7879
7879
  ...props
@@ -7898,6 +7898,23 @@ const InputElement = styled.input`
7898
7898
  width: 100%;
7899
7899
  background: inherit;
7900
7900
 
7901
+ ${(props) => {
7902
+ switch (props.$size) {
7903
+ case "S":
7904
+ return css`
7905
+ padding-inline-start: ${props.$hasLeftAction ? props.theme.spaces[3] : props.theme.spaces[4]};
7906
+ padding-inline-end: ${props.$hasRightAction ? props.theme.spaces[3] : props.theme.spaces[4]};
7907
+ padding-block: ${props.theme.spaces[1]};
7908
+ `;
7909
+ default:
7910
+ return css`
7911
+ padding-inline-start: ${props.$hasLeftAction ? props.theme.spaces[3] : props.theme.spaces[4]};
7912
+ padding-inline-end: ${props.$hasRightAction ? props.theme.spaces[3] : props.theme.spaces[4]};
7913
+ padding-block: ${props.theme.spaces[2]};
7914
+ `;
7915
+ }
7916
+ }};
7917
+
7901
7918
  ::placeholder {
7902
7919
  color: ${({ theme }) => theme.colors.neutral500};
7903
7920
  opacity: 1;
@@ -8101,6 +8118,7 @@ const Combobox = React.forwardRef(
8101
8118
  onLoadMore,
8102
8119
  placeholder = "Select or enter a value",
8103
8120
  required: requiredProp = false,
8121
+ size = "M",
8104
8122
  startIcon,
8105
8123
  textValue,
8106
8124
  value,
@@ -8200,7 +8218,7 @@ const Combobox = React.forwardRef(
8200
8218
  onFilterValueChange: handleFilterValueChange,
8201
8219
  isPrintableCharacter: isPrintableCharacter2,
8202
8220
  children: [
8203
- /* @__PURE__ */ jsxs(Trigger$5, { $hasError: hasError, className, children: [
8221
+ /* @__PURE__ */ jsxs(Trigger$5, { $hasError: hasError, $size: size, className, children: [
8204
8222
  /* @__PURE__ */ jsxs(Flex, { flex: "1", tag: "span", gap: 3, children: [
8205
8223
  startIcon ? /* @__PURE__ */ jsx(Box, { flex: "0 0 1.6rem", tag: "span", "aria-hidden": true, children: startIcon }) : null,
8206
8224
  /* @__PURE__ */ jsx(
@@ -8265,10 +8283,6 @@ const IconBox$3 = styled(Box)`
8265
8283
  const Trigger$5 = styled(Combobox$1.Trigger)`
8266
8284
  position: relative;
8267
8285
  border: 1px solid ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
8268
- padding-right: ${({ theme }) => theme.spaces[3]};
8269
- padding-left: ${({ theme }) => theme.spaces[3]};
8270
- padding-top: ${({ theme }) => theme.spaces[2]};
8271
- padding-bottom: ${({ theme }) => theme.spaces[2]};
8272
8286
  border-radius: ${({ theme }) => theme.borderRadius};
8273
8287
  background: ${({ theme }) => theme.colors.neutral0};
8274
8288
  overflow: hidden;
@@ -8277,6 +8291,23 @@ const Trigger$5 = styled(Combobox$1.Trigger)`
8277
8291
  justify-content: space-between;
8278
8292
  gap: ${({ theme }) => theme.spaces[4]};
8279
8293
 
8294
+ ${(props) => {
8295
+ switch (props.$size) {
8296
+ case "S":
8297
+ return css`
8298
+ padding-inline-start: ${({ theme }) => theme.spaces[4]};
8299
+ padding-inline-end: ${({ theme }) => theme.spaces[3]};
8300
+ padding-block: ${({ theme }) => theme.spaces[1]};
8301
+ `;
8302
+ default:
8303
+ return css`
8304
+ padding-inline-start: ${({ theme }) => theme.spaces[4]};
8305
+ padding-inline-end: ${({ theme }) => theme.spaces[3]};
8306
+ padding-block: ${({ theme }) => theme.spaces[2]};
8307
+ `;
8308
+ }
8309
+ }}
8310
+
8280
8311
  &[data-disabled] {
8281
8312
  color: ${({ theme }) => theme.colors.neutral600};
8282
8313
  background: ${({ theme }) => theme.colors.neutral150};
@@ -8737,7 +8768,7 @@ const Portal$1 = React.forwardRef(
8737
8768
  );
8738
8769
  Portal$1.displayName = "Portal";
8739
8770
  const SelectTrigger = React.forwardRef(
8740
- ({ onClear, clearLabel = "Clear", startIcon, disabled, hasError, children, id, ...restProps }, ref) => {
8771
+ ({ onClear, clearLabel = "Clear", startIcon, disabled, hasError, children, id, size = "M", withTags, ...restProps }, ref) => {
8741
8772
  const triggerRef = React.useRef(null);
8742
8773
  const handleClearClick = (e) => {
8743
8774
  if (onClear && !disabled) {
@@ -8759,13 +8790,11 @@ const SelectTrigger = React.forwardRef(
8759
8790
  overflow: "hidden",
8760
8791
  hasRadius: true,
8761
8792
  background: disabled ? "neutral150" : "neutral0",
8762
- paddingLeft: 3,
8763
- paddingRight: 3,
8764
- paddingTop: 2,
8765
- paddingBottom: 2,
8766
8793
  gap: 4,
8767
8794
  cursor: "default",
8768
8795
  "aria-labelledby": labelNode ? `${id}-label` : void 0,
8796
+ $size: size,
8797
+ $withTags: withTags,
8769
8798
  ...restProps,
8770
8799
  children: [
8771
8800
  /* @__PURE__ */ jsxs(Flex, { flex: "1", tag: "span", gap: 3, children: [
@@ -8810,6 +8839,22 @@ const IconBox$2 = styled(Box)`
8810
8839
  `;
8811
8840
  const StyledTrigger = styled(Flex)`
8812
8841
  border: 1px solid ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
8842
+ ${(props) => {
8843
+ switch (props.$size) {
8844
+ case "S":
8845
+ return css`
8846
+ padding-block: ${props.theme.spaces[1]};
8847
+ padding-inline-start: ${props.$withTags ? props.theme.spaces[1] : props.theme.spaces[4]};
8848
+ padding-inline-end: ${props.theme.spaces[3]};
8849
+ `;
8850
+ default:
8851
+ return css`
8852
+ padding-block: ${props.$withTags ? "0.3rem" : props.theme.spaces[2]};
8853
+ padding-inline-start: ${props.$withTags ? props.theme.spaces[1] : props.theme.spaces[4]};
8854
+ padding-inline-end: ${props.theme.spaces[3]};
8855
+ `;
8856
+ }
8857
+ }}
8813
8858
 
8814
8859
  &[aria-disabled='true'] {
8815
8860
  color: ${(props) => props.theme.colors.neutral600};
@@ -8929,6 +8974,7 @@ const SingleSelect = React.forwardRef(
8929
8974
  onReachEnd,
8930
8975
  placeholder,
8931
8976
  required: requiredProp,
8977
+ size,
8932
8978
  startIcon,
8933
8979
  value: passedValue,
8934
8980
  ...restProps
@@ -9004,6 +9050,7 @@ const SingleSelect = React.forwardRef(
9004
9050
  onClear: value && onClear ? handleOnClear : void 0,
9005
9051
  "aria-label": restProps["aria-label"],
9006
9052
  "aria-describedby": ariaDescription ?? restProps["aria-describedby"],
9053
+ size,
9007
9054
  children: /* @__PURE__ */ jsx(Value, { placeholder, textColor: value ? "neutral800" : "neutral600", children: value && customizeContent ? customizeContent(value) : void 0 })
9008
9055
  }
9009
9056
  ),
@@ -9052,6 +9099,7 @@ const DatePicker$1 = React.forwardRef(
9052
9099
  required: requiredProp = false,
9053
9100
  onClear,
9054
9101
  clearLabel = "Clear",
9102
+ size = "M",
9055
9103
  ...restProps
9056
9104
  }, ref) => {
9057
9105
  const timeZone = getLocalTimeZone();
@@ -9162,7 +9210,7 @@ const DatePicker$1 = React.forwardRef(
9162
9210
  trigger,
9163
9211
  value,
9164
9212
  children: [
9165
- /* @__PURE__ */ jsxs(DatePickerTrigger, { className, hasError, children: [
9213
+ /* @__PURE__ */ jsxs(DatePickerTrigger, { className, hasError, size, children: [
9166
9214
  /* @__PURE__ */ jsx(Calendar, { fill: "neutral500", "aria-hidden": true }),
9167
9215
  /* @__PURE__ */ jsx(DatePickerTextInput, { ref, "aria-describedby": ariaDescription, id, name, ...restProps }),
9168
9216
  textValue && onClear ? /* @__PURE__ */ jsx(
@@ -9208,7 +9256,7 @@ const makeInitialCalendarDate = ({ currentValue, minDate: minDate$1, maxDate: ma
9208
9256
  };
9209
9257
  const DATE_PICKER_TRIGGER_NAME = "DatePickerTrigger";
9210
9258
  const DatePickerTrigger = React.forwardRef(
9211
- ({ hasError, ...restProps }, forwardedRef) => {
9259
+ ({ hasError, size, ...restProps }, forwardedRef) => {
9212
9260
  const context = useDatePickerContext(DATE_PICKER_TRIGGER_NAME);
9213
9261
  const composedRefs = useComposedRefs(forwardedRef, (node) => context.onTriggerChange(node));
9214
9262
  const handleOpenChange = () => {
@@ -9233,9 +9281,8 @@ const DatePickerTrigger = React.forwardRef(
9233
9281
  {
9234
9282
  ref: composedRefs,
9235
9283
  $hasError: hasError,
9284
+ $size: size,
9236
9285
  ...restProps,
9237
- paddingLeft: 3,
9238
- paddingRight: 3,
9239
9286
  hasRadius: true,
9240
9287
  gap: 3,
9241
9288
  overflow: "hidden",
@@ -9265,7 +9312,20 @@ const DatePickerTrigger = React.forwardRef(
9265
9312
  );
9266
9313
  const TriggerElement = styled(Flex)`
9267
9314
  border: 1px solid ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
9268
- padding-block: ${({ theme }) => theme.spaces[2]};
9315
+ ${(props) => {
9316
+ switch (props.$size) {
9317
+ case "S":
9318
+ return css`
9319
+ padding-block: ${props.theme.spaces[1]};
9320
+ padding-inline: ${props.theme.spaces[3]};
9321
+ `;
9322
+ default:
9323
+ return css`
9324
+ padding-block: ${props.theme.spaces[2]};
9325
+ padding-inline: ${props.theme.spaces[3]};
9326
+ `;
9327
+ }
9328
+ }}
9269
9329
 
9270
9330
  & > svg {
9271
9331
  flex: 1 0 auto;
@@ -9882,6 +9942,7 @@ const DateTimePicker = React.forwardRef(
9882
9942
  step,
9883
9943
  value,
9884
9944
  initialDate,
9945
+ size,
9885
9946
  ...props
9886
9947
  }, forwardedRef) => {
9887
9948
  const DatePickerElement2 = React.useRef(null);
@@ -9941,6 +10002,7 @@ const DateTimePicker = React.forwardRef(
9941
10002
  DatePicker,
9942
10003
  {
9943
10004
  ...props,
10005
+ size,
9944
10006
  value: dateValue?.toDate("UTC"),
9945
10007
  onChange: handleDateChange,
9946
10008
  required,
@@ -9954,6 +10016,7 @@ const DateTimePicker = React.forwardRef(
9954
10016
  /* @__PURE__ */ jsx(Root$6, { children: /* @__PURE__ */ jsx(
9955
10017
  TimePicker,
9956
10018
  {
10019
+ size,
9957
10020
  hasError,
9958
10021
  value: timeValue,
9959
10022
  onChange: handleTimeChange,
@@ -10430,7 +10493,7 @@ const LinkButton = forwardRef(
10430
10493
  ...props,
10431
10494
  children: [
10432
10495
  startIcon && /* @__PURE__ */ jsx(Flex, { "aria-hidden": true, children: startIcon }),
10433
- /* @__PURE__ */ jsx(Typography, { variant: size === "S" ? "pi" : void 0, fontWeight: "bold", textColor: "buttonNeutral0", children }),
10496
+ /* @__PURE__ */ jsx(Typography, { variant: size === "S" ? "pi" : void 0, fontWeight: "bold", children }),
10434
10497
  endIcon && /* @__PURE__ */ jsx(Flex, { "aria-hidden": true, children: endIcon })
10435
10498
  ]
10436
10499
  }
@@ -10517,7 +10580,7 @@ const ScrollAreaRoot = styled(ScrollArea.Root)`
10517
10580
  `;
10518
10581
  const ScrollAreaViewport = styled(ScrollArea.Viewport)`
10519
10582
  min-width: 100%;
10520
- padding-inline-end: 4px;
10583
+ padding-inline: 4px;
10521
10584
  `;
10522
10585
  const Scrollbar = styled(ScrollArea.Scrollbar)`
10523
10586
  display: flex;
@@ -10764,7 +10827,7 @@ const NumberInput = React.forwardRef(
10764
10827
  onKeyDown: handleKeyDown,
10765
10828
  onBlur: handleBlur,
10766
10829
  value: inputValue,
10767
- endAction: /* @__PURE__ */ jsxs(Fragment, { children: [
10830
+ endAction: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
10768
10831
  /* @__PURE__ */ jsx(
10769
10832
  ArrowButton,
10770
10833
  {
@@ -10798,13 +10861,14 @@ const NumberInput = React.forwardRef(
10798
10861
  );
10799
10862
  const ArrowButton = styled.button`
10800
10863
  display: flex;
10801
- height: 1rem;
10802
- align-items: ${({ $reverse }) => $reverse ? "flex-end" : "flex-start"};
10864
+ justify-content: center;
10865
+ align-items: center;
10803
10866
  transform: translateY(${({ $reverse }) => $reverse ? `-2px` : `2px`});
10804
10867
  cursor: ${({ disabled }) => disabled ? "not-allowed" : void 0};
10868
+ height: 1.1rem;
10869
+
10805
10870
  svg {
10806
- display: block;
10807
- height: 0.4rem;
10871
+ width: 1.2rem;
10808
10872
  transform: ${({ $reverse }) => $reverse ? "rotateX(180deg)" : void 0};
10809
10873
  }
10810
10874
  `;
@@ -10980,36 +11044,34 @@ const Popover = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
10980
11044
  ScrollArea: ScrollAreaImpl,
10981
11045
  Trigger: Trigger$1
10982
11046
  }, Symbol.toStringTag, { value: "Module" }));
10983
- const ProgressbarBase = styled(Box)`
10984
- &:before {
10985
- background-color: ${({ theme }) => theme.colors.neutral0};
10986
- border-radius: ${({ theme }) => theme.borderRadius};
10987
- bottom: 0;
10988
- content: '';
10989
- position: absolute;
10990
- top: 0;
10991
- width: ${({ $value }) => `${$value}%`};
11047
+ const ProgressBar = React.forwardRef(
11048
+ ({ size = "M", value, ...restProps }, forwardedRef) => {
11049
+ return /* @__PURE__ */ jsx(ProgressRoot, { ref: forwardedRef, $size: size, ...restProps, children: /* @__PURE__ */ jsx(ProgressIndicator, { style: { transform: `translate3D(-${100 - (value ?? 0)}%, 0, 0)` } }) });
11050
+ }
11051
+ );
11052
+ const ProgressRoot = styled(Progress.Root)`
11053
+ position: relative;
11054
+ overflow: hidden;
11055
+ width: ${(props) => props.$size === "S" ? "7.8rem" : "10.2rem"};
11056
+ height: ${(props) => props.$size === "S" ? "0.4rem" : "0.8rem"};
11057
+ background-color: ${(props) => props.theme.colors.neutral600};
11058
+ border-radius: ${(props) => props.theme.borderRadius};
11059
+
11060
+ /* Fix overflow clipping in Safari */
11061
+ /* https://gist.github.com/domske/b66047671c780a238b51c51ffde8d3a0 */
11062
+ transform: translateZ(0);
11063
+ `;
11064
+ const ProgressIndicator = styled(Progress.Indicator)`
11065
+ background-color: ${({ theme }) => theme.colors.neutral0};
11066
+ border-radius: ${({ theme }) => theme.borderRadius};
11067
+ width: 100%;
11068
+ height: 100%;
11069
+
11070
+ @media (prefers-reduced-motion: no-preference) {
11071
+ transition: transform ${(props) => props.theme.motion.timings["320"]}
11072
+ ${(props) => props.theme.motion.easings.authenticMotion};
10992
11073
  }
10993
11074
  `;
10994
- const ProgressBar = ({ min = 0, max = 100, value = 0, children, size = "M", ...props }) => {
10995
- return /* @__PURE__ */ jsx(
10996
- ProgressbarBase,
10997
- {
10998
- background: "neutral600",
10999
- hasRadius: true,
11000
- "aria-label": children,
11001
- "aria-valuemax": max,
11002
- "aria-valuemin": min,
11003
- "aria-valuenow": value,
11004
- height: size === "S" ? 1 : 2,
11005
- position: "relative",
11006
- role: "progressbar",
11007
- $value: value,
11008
- width: size === "S" ? "78px" : "102px",
11009
- ...props
11010
- }
11011
- );
11012
- };
11013
11075
  const Group = React.forwardRef((props, forwardedRef) => {
11014
11076
  return /* @__PURE__ */ jsx(RadioGroupRoot, { ref: forwardedRef, ...props });
11015
11077
  });
@@ -11415,6 +11477,7 @@ const MultiSelect = React.forwardRef(
11415
11477
  onReachEnd,
11416
11478
  placeholder,
11417
11479
  required: requiredProp,
11480
+ size,
11418
11481
  startIcon,
11419
11482
  value: passedValue,
11420
11483
  withTags,
@@ -11498,7 +11561,8 @@ const MultiSelect = React.forwardRef(
11498
11561
  disabled,
11499
11562
  clearLabel,
11500
11563
  onClear: value?.length ? onClear : void 0,
11501
- paddingLeft: withTags && value?.length ? 1 : 3,
11564
+ withTags: Boolean(withTags && (value?.length ?? 0 > 0)),
11565
+ size,
11502
11566
  children: /* @__PURE__ */ jsx(Value, { placeholder, textColor: value?.length ? "neutral800" : "neutral600", children: value?.length ? withTags ? renderTags : customizeContent ? customizeContent(value) : void 0 : void 0 })
11503
11567
  }
11504
11568
  ),
@@ -11690,6 +11754,12 @@ const SubNavLink = forwardRef(
11690
11754
  );
11691
11755
  }
11692
11756
  );
11757
+ const CustomBullet = styled.span`
11758
+ width: 0.4rem;
11759
+ height: 0.4rem;
11760
+ background-color: ${({ theme, $active }) => $active ? theme.colors.primary600 : theme.colors.neutral600};
11761
+ border-radius: 50%;
11762
+ `;
11693
11763
  const SubNavLinkWrapper = styled(BaseLink)`
11694
11764
  display: flex;
11695
11765
  align-items: center;
@@ -11709,18 +11779,16 @@ const SubNavLinkWrapper = styled(BaseLink)`
11709
11779
  font-weight: 500;
11710
11780
  `;
11711
11781
  }}
11782
+
11783
+ ${CustomBullet} {
11784
+ background-color: ${({ theme }) => theme.colors.primary600};
11785
+ }
11712
11786
  }
11713
11787
 
11714
11788
  &:focus-visible {
11715
11789
  outline-offset: -2px;
11716
11790
  }
11717
11791
  `;
11718
- const CustomBullet = styled.span`
11719
- width: 0.4rem;
11720
- height: 0.4rem;
11721
- background-color: ${({ theme, $active }) => $active ? theme.colors.primary600 : theme.colors.neutral600};
11722
- border-radius: 50%;
11723
- `;
11724
11792
  const IconWrapper = styled.div`
11725
11793
  svg {
11726
11794
  height: 1.6rem;
@@ -11851,70 +11919,84 @@ const SubNavSections = ({ children, spacing = 2, horizontal = false, ...props })
11851
11919
  }
11852
11920
  ) });
11853
11921
  };
11854
- const Switch = React.forwardRef(
11855
- ({ label, onChange, onLabel = "On", offLabel = "Off", selected, visibleLabels = false, ...props }, ref) => {
11856
- return /* @__PURE__ */ jsx(
11857
- SwitchButton,
11858
- {
11859
- ref,
11860
- role: "switch",
11861
- "aria-checked": selected,
11862
- "aria-label": label,
11863
- onClick: onChange,
11864
- type: "button",
11865
- ...props,
11866
- children: /* @__PURE__ */ jsxs(Flex, { children: [
11867
- /* @__PURE__ */ jsxs(SwitchContent, { $visibleLabels: visibleLabels, children: [
11868
- /* @__PURE__ */ jsx("span", { children: onLabel }),
11869
- /* @__PURE__ */ jsx("span", { children: offLabel })
11870
- ] }),
11871
- visibleLabels && /* @__PURE__ */ jsx(Box, { tag: "span", "aria-hidden": true, paddingLeft: 2, color: selected ? "success600" : "danger600", children: selected ? onLabel : offLabel })
11872
- ] })
11873
- }
11874
- );
11922
+ const SwitchImpl = React.forwardRef(
11923
+ ({
11924
+ visibleLabels,
11925
+ onLabel = "On",
11926
+ offLabel = "Off",
11927
+ onCheckedChange: onCheckedChangeProp,
11928
+ checked: checkedProp,
11929
+ defaultChecked,
11930
+ disabled,
11931
+ ...restProps
11932
+ }, forwardedRef) => {
11933
+ const [internalChecked, setInternalChecked] = useControllableState$1({
11934
+ prop: checkedProp,
11935
+ defaultProp: defaultChecked
11936
+ });
11937
+ const handleCheckChange = (checked) => {
11938
+ setInternalChecked(checked);
11939
+ };
11940
+ return /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
11941
+ /* @__PURE__ */ jsx(
11942
+ SwitchRoot,
11943
+ {
11944
+ ref: forwardedRef,
11945
+ onCheckedChange: composeEventHandlers(onCheckedChangeProp, handleCheckChange),
11946
+ checked: internalChecked,
11947
+ disabled,
11948
+ ...restProps,
11949
+ children: /* @__PURE__ */ jsx(SwitchThumb, {})
11950
+ }
11951
+ ),
11952
+ visibleLabels ? /* @__PURE__ */ jsx(LabelTypography, { "aria-hidden": true, "data-disabled": disabled, "data-state": internalChecked ? "checked" : "unchecked", children: internalChecked ? onLabel : offLabel }) : null
11953
+ ] });
11875
11954
  }
11876
11955
  );
11877
- const SwitchContent = styled.div`
11878
- background: ${({ theme }) => theme.colors.danger500};
11879
- border: none;
11880
- border-radius: 16px;
11881
- position: relative;
11882
- height: 2.4rem;
11956
+ const SwitchRoot = styled(Switch.Root)`
11883
11957
  width: 4rem;
11958
+ height: 2.4rem;
11959
+ border-radius: 1.2rem;
11960
+ background-color: ${({ theme }) => theme.colors.danger500};
11884
11961
 
11885
- & > span {
11886
- font-size: ${({ $visibleLabels }) => $visibleLabels ? "1rem" : 0};
11962
+ &[data-state='checked'] {
11963
+ background-color: ${({ theme }) => theme.colors.success500};
11887
11964
  }
11888
11965
 
11889
- &:before {
11890
- content: '';
11891
- background: ${({ theme }) => theme.colors.neutral0};
11892
- width: 1rem;
11893
- height: 1rem;
11894
- border-radius: 50%;
11895
- position: absolute;
11896
- transition: all 0.5s;
11897
- left: ${({ theme }) => theme.spaces[1]};
11898
- top: ${({ theme }) => theme.spaces[1]};
11966
+ &[data-disabled] {
11967
+ background-color: ${({ theme }) => theme.colors.neutral300};
11899
11968
  }
11900
11969
 
11901
- @media (prefers-reduced-motion: reduce) {
11902
- &:before {
11903
- transition: none;
11904
- }
11970
+ @media (prefers-reduced-motion: no-preference) {
11971
+ transition: ${(props) => props.theme.transitions.backgroundColor};
11905
11972
  }
11906
11973
  `;
11907
- const SwitchButton = styled.button`
11908
- background: transparent;
11909
- padding: 0;
11910
- border: none;
11974
+ const SwitchThumb = styled(Switch.Thumb)`
11975
+ display: block;
11976
+ height: 1.6rem;
11977
+ width: 1.6rem;
11978
+ border-radius: 50%;
11979
+ background-color: ${({ theme }) => theme.colors.neutral0};
11980
+ transform: translateX(4px);
11911
11981
 
11912
- &[aria-checked='true'] ${SwitchContent} {
11913
- background: ${({ theme }) => theme.colors.success500};
11982
+ &[data-state='checked'] {
11983
+ transform: translateX(20px);
11914
11984
  }
11915
11985
 
11916
- &[aria-checked='true'] ${SwitchContent}:before {
11917
- transform: translateX(1rem);
11986
+ @media (prefers-reduced-motion: no-preference) {
11987
+ transition: transform ${(props) => props.theme.motion.timings["120"]}
11988
+ ${(props) => props.theme.motion.easings.authenticMotion};
11989
+ }
11990
+ `;
11991
+ const LabelTypography = styled(Typography)`
11992
+ color: ${(props) => props.theme.colors.danger600};
11993
+
11994
+ &[data-state='checked'] {
11995
+ color: ${(props) => props.theme.colors.success600};
11996
+ }
11997
+
11998
+ &[data-disabled='true'] {
11999
+ color: ${({ theme }) => theme.colors.neutral500};
11918
12000
  }
11919
12001
  `;
11920
12002
  const [TabsProvider, useTabs] = createContext("Tabs");
@@ -12628,7 +12710,7 @@ export {
12628
12710
  SubNavLinkSection,
12629
12711
  SubNavSection,
12630
12712
  SubNavSections,
12631
- Switch,
12713
+ SwitchImpl as Switch,
12632
12714
  TFooter,
12633
12715
  Table,
12634
12716
  Tabs,