@marwes-ui/react 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import '@marwes-ui/presets/firstEdition/styles.css';
2
- import { createRichTextRecipe, resolveRichTextAllowedFormats, normalizeRichTextHtml, isRichTextHtmlEmpty, createDividerRecipe, createSpacingRecipe, createSliderRecipe, richTextCommandByFormat, resolveIconSize, resolveIconStrokeWidth, iconRegistry, resolveIconA11y, resolveThemeInput, createSpinnerRecipe, createButtonRecipe, ButtonAction, ButtonVariant, IconName, createInputRecipe, createSelectRecipe, resolveSelectMode, createTextareaRecipe, paragraphRecipe, buildInputFieldA11yIds, sanitizeInputOtpValue, createInputOtpRecipe, buildRichTextFieldA11yIds, buildCurrencyHelperText, getCurrencySymbol, createAvatarRecipe, createPurposeSemanticAttributes, checkboxRecipe, buildCheckboxFieldA11yIds, buildCheckboxGroupFieldA11yIds, headingRecipe, createCardRecipe, createToastRecipe, createTooltipRecipe, createAccordionRecipe, buildAccordionFieldA11yIds, radioRecipe, buildRadioGroupFieldA11yIds, createBadgeRecipe, createSwitchRecipe, buildSwitchFieldA11yIds, buildSliderFieldA11yIds, createTabRecipe, resolveTabValue, buildTabGroupA11yIds, moveTabSelection, createDialogRecipe, sanitizeCurrencyValue, themeToCSSVars, extractUsedWeights, extractFontFamilyName, shouldLoadGoogleFont, buildGoogleFontsUrl } from '@marwes-ui/core';
3
- export { AvatarSize, AvatarType, BadgeVariant, ButtonAction, ButtonSize, ButtonVariant, IconName, Spacings, SwitchSize, createFontStack, mwAvailableFonts, mwFontFallbacks, mwGoogleFontFamilies, mwStyledTheme, mwThemeVarNames, mwThemeVars, mwVar } from '@marwes-ui/core';
4
- import * as React5 from 'react';
2
+ import { createRichTextRecipe, resolveRichTextAllowedFormats, normalizeRichTextHtml, isRichTextHtmlEmpty, createDividerRecipe, createSpacingRecipe, createSliderRecipe, richTextCommandByFormat, resolveIconSize, resolveIconStrokeWidth, iconRegistry, resolveIconA11y, ThemeMode, resolveThemeInput, createSpinnerRecipe, createButtonRecipe, ButtonAction, ButtonVariant, IconName, createInputRecipe, createSelectRecipe, resolveSelectMode, createTextareaRecipe, paragraphRecipe, buildInputFieldA11yIds, sanitizeInputOtpValue, createInputOtpRecipe, buildRichTextFieldA11yIds, buildCurrencyHelperText, getCurrencySymbol, createAvatarRecipe, createPurposeSemanticAttributes, checkboxRecipe, buildCheckboxFieldA11yIds, buildCheckboxGroupFieldA11yIds, headingRecipe, createCardRecipe, createToastRecipe, createTooltipRecipe, createAccordionRecipe, buildAccordionFieldA11yIds, radioRecipe, buildRadioGroupFieldA11yIds, createBadgeRecipe, createSwitchRecipe, buildSwitchFieldA11yIds, buildSliderFieldA11yIds, createTabRecipe, resolveTabValue, buildTabGroupA11yIds, moveTabSelection, createDialogRecipe, sanitizeCurrencyValue, themeToCSSVars, extractUsedWeights, extractFontFamilyName, shouldLoadGoogleFont, buildGoogleFontsUrl } from '@marwes-ui/core';
3
+ export { AvatarSize, AvatarType, BadgeVariant, ButtonAction, ButtonSize, ButtonVariant, IconName, Spacings, SwitchSize, ThemeMode, createFontStack, mwAvailableFonts, mwFontFallbacks, mwGoogleFontFamilies, mwStyledTheme, mwThemeVarNames, mwThemeVars, mwVar } from '@marwes-ui/core';
4
+ import * as React6 from 'react';
5
5
  import { useEffect } from 'react';
6
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
7
  import { createPortal } from 'react-dom';
8
8
 
9
9
  // src/index.ts
10
- var MarwesContext = React5.createContext(null);
10
+ var MarwesContext = React6.createContext(null);
11
11
  var loadedFonts = /* @__PURE__ */ new Set();
12
12
  var preconnected = false;
13
13
  function themeToRootStyle(theme) {
@@ -64,25 +64,45 @@ function loadThemeFonts(theme, config = "auto") {
64
64
  }
65
65
  function MarwesProvider({
66
66
  theme,
67
+ defaultMode = ThemeMode.light,
68
+ mode: controlledMode,
67
69
  fontLoading = "auto",
68
70
  onModeChange,
69
71
  children
70
72
  }) {
71
- const rootRef = React5.useRef(null);
72
- const resolved = React5.useMemo(() => resolveThemeInput(theme ?? {}), [theme]);
73
- const rootStyle = React5.useMemo(
73
+ const rootRef = React6.useRef(null);
74
+ const [internalMode, setInternalMode] = React6.useState(defaultMode);
75
+ const activeMode = controlledMode ?? theme?.mode ?? internalMode;
76
+ const isModeControlled = controlledMode !== void 0 || theme?.mode !== void 0;
77
+ const setMode = React6.useCallback(
78
+ (nextMode) => {
79
+ if (!isModeControlled) {
80
+ setInternalMode(nextMode);
81
+ }
82
+ onModeChange?.(nextMode);
83
+ },
84
+ [isModeControlled, onModeChange]
85
+ );
86
+ const toggleMode = React6.useCallback(() => {
87
+ setMode(activeMode === ThemeMode.dark ? ThemeMode.light : ThemeMode.dark);
88
+ }, [activeMode, setMode]);
89
+ const resolved = React6.useMemo(
90
+ () => resolveThemeInput({ ...theme ?? {}, mode: activeMode }),
91
+ [activeMode, theme]
92
+ );
93
+ const rootStyle = React6.useMemo(
74
94
  () => themeToRootStyle(resolved),
75
95
  [resolved]
76
96
  );
77
- React5.useEffect(() => {
97
+ React6.useEffect(() => {
78
98
  if (rootRef.current) {
79
99
  applyThemeToElement(rootRef.current, resolved);
80
100
  }
81
101
  }, [resolved]);
82
- React5.useEffect(() => {
102
+ React6.useEffect(() => {
83
103
  loadThemeFonts(resolved, fontLoading);
84
104
  }, [resolved, fontLoading]);
85
- return /* @__PURE__ */ jsx(MarwesContext.Provider, { value: { theme: resolved, onModeChange }, children: /* @__PURE__ */ jsx(
105
+ return /* @__PURE__ */ jsx(MarwesContext.Provider, { value: { theme: resolved, mode: activeMode, setMode, toggleMode }, children: /* @__PURE__ */ jsx(
86
106
  "div",
87
107
  {
88
108
  ref: rootRef,
@@ -94,12 +114,25 @@ function MarwesProvider({
94
114
  ) });
95
115
  }
96
116
  function useTheme() {
97
- const ctx = React5.useContext(MarwesContext);
117
+ const ctx = React6.useContext(MarwesContext);
98
118
  if (!ctx) {
99
119
  throw new Error("MarwesProvider is missing. Wrap your app in <MarwesProvider />.");
100
120
  }
101
121
  return ctx.theme;
102
122
  }
123
+ function useThemeMode() {
124
+ const ctx = React6.useContext(MarwesContext);
125
+ if (!ctx) {
126
+ throw new Error("MarwesProvider is missing. Wrap your app in <MarwesProvider />.");
127
+ }
128
+ return {
129
+ mode: ctx.mode,
130
+ setMode: ctx.setMode,
131
+ toggleMode: ctx.toggleMode,
132
+ isDark: ctx.mode === ThemeMode.dark,
133
+ isLight: ctx.mode === ThemeMode.light
134
+ };
135
+ }
103
136
  function Icon({
104
137
  name,
105
138
  size,
@@ -765,7 +798,7 @@ function Select(props) {
765
798
  const kit = createSelectRecipe(props);
766
799
  const mode = resolveSelectMode(props);
767
800
  const isControlled = props.value !== void 0;
768
- const [uncontrolledValue, setUncontrolledValue] = React5.useState(
801
+ const [uncontrolledValue, setUncontrolledValue] = React6.useState(
769
802
  () => getInitialSelectValue(props)
770
803
  );
771
804
  useRenderKitDebug(kit, "Select");
@@ -981,33 +1014,33 @@ function exitActiveFormatAtCaret(editorElement, format) {
981
1014
  selection.addRange(nextRange);
982
1015
  return true;
983
1016
  }
984
- var RichText = React5.forwardRef((props, forwardedRef) => {
1017
+ var RichText = React6.forwardRef((props, forwardedRef) => {
985
1018
  const kit = createRichTextRecipe(props);
986
- const allowedFormats = React5.useMemo(
1019
+ const allowedFormats = React6.useMemo(
987
1020
  () => resolveRichTextAllowedFormats(props.allowedFormats),
988
1021
  [props.allowedFormats]
989
1022
  );
990
- const normalizedControlledValue = React5.useMemo(
1023
+ const normalizedControlledValue = React6.useMemo(
991
1024
  () => normalizeRichTextHtml(props.value),
992
1025
  [props.value]
993
1026
  );
994
- const initialUncontrolledValue = React5.useMemo(
1027
+ const initialUncontrolledValue = React6.useMemo(
995
1028
  () => normalizeRichTextHtml(props.defaultValue),
996
1029
  [props.defaultValue]
997
1030
  );
998
1031
  const isControlled = props.value !== void 0;
999
- const [uncontrolledHtml, setUncontrolledHtml] = React5.useState(initialUncontrolledValue);
1000
- const [isEditorEmpty, setIsEditorEmpty] = React5.useState(
1032
+ const [uncontrolledHtml, setUncontrolledHtml] = React6.useState(initialUncontrolledValue);
1033
+ const [isEditorEmpty, setIsEditorEmpty] = React6.useState(
1001
1034
  isRichTextHtmlEmpty(isControlled ? normalizedControlledValue : initialUncontrolledValue)
1002
1035
  );
1003
- const [activeFormats, setActiveFormats] = React5.useState([]);
1004
- const editorElementRef = React5.useRef(null);
1036
+ const [activeFormats, setActiveFormats] = React6.useState([]);
1037
+ const editorElementRef = React6.useRef(null);
1005
1038
  useRenderKitDebug(kit, "RichText");
1006
1039
  const editorHtml = isControlled ? normalizedControlledValue : uncontrolledHtml;
1007
1040
  const style = kit.vars;
1008
1041
  const className = props.className ? `${kit.className} ${props.className}` : kit.className;
1009
1042
  const showToolbar = !props.readOnly;
1010
- const syncEditorState = React5.useCallback(
1043
+ const syncEditorState = React6.useCallback(
1011
1044
  (nextHtml) => {
1012
1045
  const normalizedHtml = normalizeRichTextHtml(nextHtml);
1013
1046
  const emptyState = isRichTextHtmlEmpty(normalizedHtml);
@@ -1020,10 +1053,10 @@ var RichText = React5.forwardRef((props, forwardedRef) => {
1020
1053
  },
1021
1054
  [isControlled, props]
1022
1055
  );
1023
- const refreshActiveFormats = React5.useCallback(() => {
1056
+ const refreshActiveFormats = React6.useCallback(() => {
1024
1057
  setActiveFormats(getActiveFormatsFromSelection(editorElementRef.current));
1025
1058
  }, []);
1026
- React5.useLayoutEffect(() => {
1059
+ React6.useLayoutEffect(() => {
1027
1060
  const editorElement = editorElementRef.current;
1028
1061
  if (!editorElement) {
1029
1062
  return;
@@ -1034,7 +1067,7 @@ var RichText = React5.forwardRef((props, forwardedRef) => {
1034
1067
  }
1035
1068
  setIsEditorEmpty(isRichTextHtmlEmpty(editorHtml));
1036
1069
  }, [editorHtml]);
1037
- React5.useEffect(() => {
1070
+ React6.useEffect(() => {
1038
1071
  if (typeof document === "undefined") {
1039
1072
  return void 0;
1040
1073
  }
@@ -1179,12 +1212,12 @@ function hasTextContent(value) {
1179
1212
  return value !== void 0 && value.trim().length > 0;
1180
1213
  }
1181
1214
  function InputField(props) {
1182
- const reactId = React5.useId();
1215
+ const reactId = React6.useId();
1183
1216
  const id = props.id ?? `mw-input-${reactId}`;
1184
1217
  const isPasswordField = props.input.type === "password";
1185
- const [showPassword, setShowPassword] = React5.useState(false);
1218
+ const [showPassword, setShowPassword] = React6.useState(false);
1186
1219
  const isSearchField = props.input.type === "search";
1187
- const [searchValue, setSearchValue] = React5.useState(
1220
+ const [searchValue, setSearchValue] = React6.useState(
1188
1221
  props.input.value || props.input.defaultValue || ""
1189
1222
  );
1190
1223
  const hasSearchValue = isSearchField && (props.input.value !== void 0 ? String(props.input.value).length > 0 : String(searchValue).length > 0);
@@ -1279,14 +1312,14 @@ function hasTextContent2(value) {
1279
1312
  return value !== void 0 && value.trim().length > 0;
1280
1313
  }
1281
1314
  function InputOtp(props) {
1282
- const reactId = React5.useId();
1315
+ const reactId = React6.useId();
1283
1316
  const id = props.id ?? `mw-input-otp-${reactId}`;
1284
1317
  const otpLength = Math.max(1, props.length ?? 6);
1285
1318
  const hasHelperText = hasTextContent2(props.helperText);
1286
1319
  const hasError = hasTextContent2(props.error);
1287
1320
  const invalid = hasError || props.invalid === true;
1288
1321
  const isControlled = props.value !== void 0;
1289
- const [uncontrolledValue, setUncontrolledValue] = React5.useState(() => {
1322
+ const [uncontrolledValue, setUncontrolledValue] = React6.useState(() => {
1290
1323
  return sanitizeInputOtpValue(props.defaultValue, otpLength);
1291
1324
  });
1292
1325
  const currentValue = sanitizeInputOtpValue(
@@ -1443,18 +1476,18 @@ function MarwesSelectFieldControl(props) {
1443
1476
  const { id, select } = props;
1444
1477
  const listboxId = `${id}-listbox`;
1445
1478
  const isControlled = select.value !== void 0;
1446
- const [internalValue, setInternalValue] = React5.useState(() => getInitialSelectValue2(select));
1479
+ const [internalValue, setInternalValue] = React6.useState(() => getInitialSelectValue2(select));
1447
1480
  const value = isControlled ? select.value ?? "" : internalValue;
1448
- const [open, setOpen] = React5.useState(false);
1449
- const [activeIndex, setActiveIndex] = React5.useState(
1481
+ const [open, setOpen] = React6.useState(false);
1482
+ const [activeIndex, setActiveIndex] = React6.useState(
1450
1483
  () => getInitialActiveOptionIndex(select.options, value)
1451
1484
  );
1452
- const rootRef = React5.useRef(null);
1453
- const buttonRef = React5.useRef(null);
1485
+ const rootRef = React6.useRef(null);
1486
+ const buttonRef = React6.useRef(null);
1454
1487
  const selectedOption = select.options.find((option) => option.value === value) ?? (select.placeholder === void 0 ? select.options[0] : void 0);
1455
1488
  const placeholderSelected = select.placeholder !== void 0 && value === "";
1456
1489
  const displayText = placeholderSelected ? select.placeholder : selectedOption?.label ?? "";
1457
- React5.useEffect(() => {
1490
+ React6.useEffect(() => {
1458
1491
  if (!open) {
1459
1492
  return;
1460
1493
  }
@@ -1469,13 +1502,13 @@ function MarwesSelectFieldControl(props) {
1469
1502
  document.removeEventListener("pointerdown", handlePointerDown);
1470
1503
  };
1471
1504
  }, [open]);
1472
- React5.useEffect(() => {
1505
+ React6.useEffect(() => {
1473
1506
  if (!open) {
1474
1507
  return;
1475
1508
  }
1476
1509
  setActiveIndex(getInitialActiveOptionIndex(select.options, value));
1477
1510
  }, [open, select.options, value]);
1478
- React5.useEffect(() => {
1511
+ React6.useEffect(() => {
1479
1512
  if (!select.disabled) {
1480
1513
  return;
1481
1514
  }
@@ -1674,7 +1707,7 @@ function MarwesSelectFieldControl(props) {
1674
1707
  );
1675
1708
  }
1676
1709
  function SelectField(props) {
1677
- const reactId = React5.useId();
1710
+ const reactId = React6.useId();
1678
1711
  const id = props.id ?? `mw-select-${reactId}`;
1679
1712
  const mode = resolveSelectMode(props.select);
1680
1713
  const hasHelperText = hasTextContent3(props.helperText);
@@ -1720,7 +1753,7 @@ function hasTextContent4(value) {
1720
1753
  return value !== void 0 && value.trim().length > 0;
1721
1754
  }
1722
1755
  function TextareaField(props) {
1723
- const reactId = React5.useId();
1756
+ const reactId = React6.useId();
1724
1757
  const id = props.id ?? `mw-textarea-${reactId}`;
1725
1758
  const hasHelperText = hasTextContent4(props.helperText);
1726
1759
  const hasError = hasTextContent4(props.error);
@@ -1766,9 +1799,9 @@ function hasTextContent5(value) {
1766
1799
  return value !== void 0 && value.trim().length > 0;
1767
1800
  }
1768
1801
  function RichTextField(props) {
1769
- const reactId = React5.useId();
1802
+ const reactId = React6.useId();
1770
1803
  const id = props.id ?? `mw-rich-text-${reactId}`;
1771
- const editorRef = React5.useRef(null);
1804
+ const editorRef = React6.useRef(null);
1772
1805
  const hasHelperText = hasTextContent5(props.helperText);
1773
1806
  const hasError = hasTextContent5(props.error);
1774
1807
  const { labelId, helperTextId, errorId, describedBy } = buildRichTextFieldA11yIds({
@@ -2135,8 +2168,8 @@ function TeamAvatarGroup(props) {
2135
2168
  function Checkbox(props) {
2136
2169
  const { onCheckedChange, onChange, ...coreProps } = props;
2137
2170
  const kit = checkboxRecipe({ ...coreProps });
2138
- const inputRef = React5.useRef(null);
2139
- React5.useLayoutEffect(() => {
2171
+ const inputRef = React6.useRef(null);
2172
+ React6.useLayoutEffect(() => {
2140
2173
  const el = inputRef.current;
2141
2174
  if (!el) return;
2142
2175
  el.indeterminate = kit.indeterminate;
@@ -2182,7 +2215,7 @@ function hasContent(value) {
2182
2215
  return true;
2183
2216
  }
2184
2217
  function CheckboxField(props) {
2185
- const reactId = React5.useId();
2218
+ const reactId = React6.useId();
2186
2219
  const id = props.id ?? `mw-checkbox-${reactId}`;
2187
2220
  const hasDescription = hasContent(props.description);
2188
2221
  const hasError = hasContent(props.error);
@@ -2236,7 +2269,7 @@ function orderSelectedValues(values, options) {
2236
2269
  return [...knownValues, ...unknownValues];
2237
2270
  }
2238
2271
  function CheckboxGroupField(props) {
2239
- const reactId = React5.useId();
2272
+ const reactId = React6.useId();
2240
2273
  const id = props.id ?? `mw-checkbox-group-${reactId}`;
2241
2274
  const hasDescription = hasContent2(props.description);
2242
2275
  const hasError = hasContent2(props.error);
@@ -2248,7 +2281,7 @@ function CheckboxGroupField(props) {
2248
2281
  externalDescribedBy: props.ariaDescribedBy
2249
2282
  });
2250
2283
  const isControlled = props.value !== void 0;
2251
- const [internalValue, setInternalValue] = React5.useState(
2284
+ const [internalValue, setInternalValue] = React6.useState(
2252
2285
  orderSelectedValues(props.defaultValue ?? [], props.options)
2253
2286
  );
2254
2287
  const selectedValues = orderSelectedValues(
@@ -2318,7 +2351,7 @@ function CheckboxGroupField(props) {
2318
2351
  }
2319
2352
  );
2320
2353
  }
2321
- var Divider = React5.forwardRef((props, ref) => {
2354
+ var Divider = React6.forwardRef((props, ref) => {
2322
2355
  const { className: customClassName, style: customStyle, ...opts } = props;
2323
2356
  const kit = createDividerRecipe(opts);
2324
2357
  const style = { ...kit.vars, ...customStyle };
@@ -2326,7 +2359,7 @@ var Divider = React5.forwardRef((props, ref) => {
2326
2359
  return /* @__PURE__ */ jsx("hr", { ref, ...kit.a11y, ...kit.dataAttributes, className, style });
2327
2360
  });
2328
2361
  Divider.displayName = "Divider";
2329
- var Spacing = React5.forwardRef((props, ref) => {
2362
+ var Spacing = React6.forwardRef((props, ref) => {
2330
2363
  const { className: customClassName, scale, size, spacing, style: customStyle } = props;
2331
2364
  const resolvedSize = spacing ?? size;
2332
2365
  const kit = createSpacingRecipe({
@@ -2561,12 +2594,12 @@ function renderToastByIntent(toast, onDismiss) {
2561
2594
  }
2562
2595
  }
2563
2596
  function ToastViewportItem(props) {
2564
- const timerHandleRef = React5.useRef(null);
2565
- const timerStartedAtRef = React5.useRef(null);
2566
- const remainingDurationRef = React5.useRef(null);
2567
- const pointerInsideRef = React5.useRef(false);
2568
- const focusInsideRef = React5.useRef(false);
2569
- const clearDismissTimer = React5.useCallback(() => {
2597
+ const timerHandleRef = React6.useRef(null);
2598
+ const timerStartedAtRef = React6.useRef(null);
2599
+ const remainingDurationRef = React6.useRef(null);
2600
+ const pointerInsideRef = React6.useRef(false);
2601
+ const focusInsideRef = React6.useRef(false);
2602
+ const clearDismissTimer = React6.useCallback(() => {
2570
2603
  if (timerHandleRef.current === null) {
2571
2604
  return;
2572
2605
  }
@@ -2574,7 +2607,7 @@ function ToastViewportItem(props) {
2574
2607
  timerHandleRef.current = null;
2575
2608
  timerStartedAtRef.current = null;
2576
2609
  }, []);
2577
- const scheduleDismissTimer = React5.useCallback(
2610
+ const scheduleDismissTimer = React6.useCallback(
2578
2611
  (delay) => {
2579
2612
  if (!props.onDismiss || delay <= 0 || pointerInsideRef.current || focusInsideRef.current || timerHandleRef.current !== null) {
2580
2613
  return;
@@ -2589,7 +2622,7 @@ function ToastViewportItem(props) {
2589
2622
  },
2590
2623
  [props.onDismiss, props.toast.id]
2591
2624
  );
2592
- const pauseDismissTimer = React5.useCallback(() => {
2625
+ const pauseDismissTimer = React6.useCallback(() => {
2593
2626
  if (timerHandleRef.current === null || timerStartedAtRef.current === null) {
2594
2627
  return;
2595
2628
  }
@@ -2598,7 +2631,7 @@ function ToastViewportItem(props) {
2598
2631
  remainingDurationRef.current = Math.max(remainingDuration - elapsed, 0);
2599
2632
  clearDismissTimer();
2600
2633
  }, [clearDismissTimer]);
2601
- const resumeDismissTimer = React5.useCallback(() => {
2634
+ const resumeDismissTimer = React6.useCallback(() => {
2602
2635
  if (pointerInsideRef.current || focusInsideRef.current) {
2603
2636
  return;
2604
2637
  }
@@ -2608,7 +2641,7 @@ function ToastViewportItem(props) {
2608
2641
  }
2609
2642
  scheduleDismissTimer(remainingDuration);
2610
2643
  }, [scheduleDismissTimer]);
2611
- React5.useEffect(() => {
2644
+ React6.useEffect(() => {
2612
2645
  clearDismissTimer();
2613
2646
  pointerInsideRef.current = false;
2614
2647
  focusInsideRef.current = false;
@@ -2665,18 +2698,18 @@ function ToastContainer(props) {
2665
2698
  toast.id
2666
2699
  )) });
2667
2700
  }
2668
- var ToastContext = React5.createContext(null);
2701
+ var ToastContext = React6.createContext(null);
2669
2702
  function ToastProvider(props) {
2670
- const [toasts, setToasts] = React5.useState([]);
2671
- const idRef = React5.useRef(0);
2672
- const dismiss = React5.useCallback((id) => {
2703
+ const [toasts, setToasts] = React6.useState([]);
2704
+ const idRef = React6.useRef(0);
2705
+ const dismiss = React6.useCallback((id) => {
2673
2706
  setToasts((currentToasts) => {
2674
2707
  const toast = currentToasts.find((item) => item.id === id);
2675
2708
  toast?.onDismiss?.();
2676
2709
  return currentToasts.filter((item) => item.id !== id);
2677
2710
  });
2678
2711
  }, []);
2679
- const clear = React5.useCallback(() => {
2712
+ const clear = React6.useCallback(() => {
2680
2713
  setToasts((currentToasts) => {
2681
2714
  for (const toast of currentToasts) {
2682
2715
  toast.onDismiss?.();
@@ -2684,7 +2717,7 @@ function ToastProvider(props) {
2684
2717
  return [];
2685
2718
  });
2686
2719
  }, []);
2687
- const show = React5.useCallback(
2720
+ const show = React6.useCallback(
2688
2721
  (toast) => {
2689
2722
  idRef.current += 1;
2690
2723
  const id = `mw-toast-${idRef.current}`;
@@ -2700,7 +2733,7 @@ function ToastProvider(props) {
2700
2733
  },
2701
2734
  [props.defaultDuration]
2702
2735
  );
2703
- const value = React5.useMemo(
2736
+ const value = React6.useMemo(
2704
2737
  () => ({
2705
2738
  show,
2706
2739
  dismiss,
@@ -2723,7 +2756,7 @@ function ToastProvider(props) {
2723
2756
  ] });
2724
2757
  }
2725
2758
  function useToast() {
2726
- const context = React5.useContext(ToastContext);
2759
+ const context = React6.useContext(ToastContext);
2727
2760
  if (!context) {
2728
2761
  throw new Error("ToastProvider is missing. Wrap your app in <ToastProvider />.");
2729
2762
  }
@@ -2757,7 +2790,7 @@ function cx10(...parts) {
2757
2790
  return parts.filter(Boolean).join(" ");
2758
2791
  }
2759
2792
  function TooltipGroup(props) {
2760
- const reactId = React5.useId();
2793
+ const reactId = React6.useId();
2761
2794
  const {
2762
2795
  content,
2763
2796
  icon = IconName.HelpCircle,
@@ -2778,12 +2811,12 @@ function TooltipGroup(props) {
2778
2811
  onKeyDown,
2779
2812
  ...nativeSpanProps
2780
2813
  } = props;
2781
- const [internalOpen, setInternalOpen] = React5.useState(defaultOpen);
2814
+ const [internalOpen, setInternalOpen] = React6.useState(defaultOpen);
2782
2815
  const isControlled = open !== void 0;
2783
2816
  const resolvedOpen = isControlled ? open : internalOpen;
2784
- const [isTooltipMounted, setIsTooltipMounted] = React5.useState(resolvedOpen);
2817
+ const [isTooltipMounted, setIsTooltipMounted] = React6.useState(resolvedOpen);
2785
2818
  const resolvedTooltipId = tooltipId ?? `${id ?? `mw-tooltip-group-${reactId}`}-tooltip`;
2786
- React5.useEffect(() => {
2819
+ React6.useEffect(() => {
2787
2820
  if (resolvedOpen) {
2788
2821
  setIsTooltipMounted(true);
2789
2822
  return;
@@ -2795,7 +2828,7 @@ function TooltipGroup(props) {
2795
2828
  window.clearTimeout(timeoutId);
2796
2829
  };
2797
2830
  }, [resolvedOpen]);
2798
- const updateOpen = React5.useCallback(
2831
+ const updateOpen = React6.useCallback(
2799
2832
  (nextOpen) => {
2800
2833
  if (resolvedOpen === nextOpen) {
2801
2834
  return;
@@ -2869,7 +2902,7 @@ function TooltipGroup(props) {
2869
2902
  }
2870
2903
  function Accordion(props) {
2871
2904
  const { title, children, className, onToggle, id: idProp, open, disabled } = props;
2872
- const autoId = React5.useId();
2905
+ const autoId = React6.useId();
2873
2906
  const resolvedId = idProp ?? autoId.replace(/:/g, "");
2874
2907
  const opts = { id: resolvedId };
2875
2908
  if (open !== void 0) opts.open = open;
@@ -2922,7 +2955,7 @@ function resolveAccordionItemContent(item) {
2922
2955
  return item.content ?? item.children;
2923
2956
  }
2924
2957
  function AccordionField(props) {
2925
- const reactId = React5.useId();
2958
+ const reactId = React6.useId();
2926
2959
  const id = props.id ?? `mw-accordion-field-${reactId}`;
2927
2960
  const multipleAllowed = props.multiple ?? true;
2928
2961
  const hasDescription = hasContent3(props.description);
@@ -2935,7 +2968,7 @@ function AccordionField(props) {
2935
2968
  externalDescribedBy: props.ariaDescribedBy
2936
2969
  });
2937
2970
  const isControlled = props.openItems !== void 0;
2938
- const [internalOpenItems, setInternalOpenItems] = React5.useState(
2971
+ const [internalOpenItems, setInternalOpenItems] = React6.useState(
2939
2972
  props.defaultOpenItems ?? []
2940
2973
  );
2941
2974
  const openItems = isControlled ? props.openItems ?? [] : internalOpenItems;
@@ -3066,7 +3099,7 @@ function cx12(...parts) {
3066
3099
  return parts.filter(Boolean).join(" ");
3067
3100
  }
3068
3101
  function RadioGroupField(props) {
3069
- const reactId = React5.useId();
3102
+ const reactId = React6.useId();
3070
3103
  const id = props.id ?? `mw-radio-group-${reactId}`;
3071
3104
  const hasDescription = hasContent4(props.description);
3072
3105
  const hasError = hasContent4(props.error);
@@ -3078,7 +3111,7 @@ function RadioGroupField(props) {
3078
3111
  externalDescribedBy: props.ariaDescribedBy
3079
3112
  });
3080
3113
  const isControlled = props.value !== void 0;
3081
- const [internalValue, setInternalValue] = React5.useState(props.defaultValue);
3114
+ const [internalValue, setInternalValue] = React6.useState(props.defaultValue);
3082
3115
  const selectedValue = isControlled ? props.value : internalValue;
3083
3116
  const handleSelect = (optionValue) => {
3084
3117
  if (!isControlled) {
@@ -3197,7 +3230,7 @@ function cx13(...parts) {
3197
3230
  return parts.filter(Boolean).join(" ");
3198
3231
  }
3199
3232
  function BadgeGroup(props) {
3200
- const reactId = React5.useId();
3233
+ const reactId = React6.useId();
3201
3234
  const id = props.id ?? `mw-badge-group-${reactId}`;
3202
3235
  const labelId = `${id}-label`;
3203
3236
  const className = cx13("mw-badge-group", props.className);
@@ -3289,7 +3322,7 @@ function hasContent5(value) {
3289
3322
  return true;
3290
3323
  }
3291
3324
  function SwitchField(props) {
3292
- const reactId = React5.useId();
3325
+ const reactId = React6.useId();
3293
3326
  const id = props.id ?? `mw-switch-${reactId}`;
3294
3327
  const hasDescription = hasContent5(props.description);
3295
3328
  const hasError = hasContent5(props.error);
@@ -3389,7 +3422,7 @@ function buildSliderOptions(options) {
3389
3422
  function resolveSliderValue(options) {
3390
3423
  return createSliderRecipe(buildSliderOptions(options)).value;
3391
3424
  }
3392
- var Slider = React5.forwardRef((props, ref) => {
3425
+ var Slider = React6.forwardRef((props, ref) => {
3393
3426
  const {
3394
3427
  id,
3395
3428
  name,
@@ -3414,10 +3447,10 @@ var Slider = React5.forwardRef((props, ref) => {
3414
3447
  ...inputProps
3415
3448
  } = props;
3416
3449
  const isControlled = value !== void 0;
3417
- const [uncontrolledValue, setUncontrolledValue] = React5.useState(
3450
+ const [uncontrolledValue, setUncontrolledValue] = React6.useState(
3418
3451
  () => resolveSliderValue({ min, max, step, value, defaultValue })
3419
3452
  );
3420
- React5.useEffect(() => {
3453
+ React6.useEffect(() => {
3421
3454
  if (!isControlled) {
3422
3455
  setUncontrolledValue(resolveSliderValue({ min, max, step, defaultValue }));
3423
3456
  }
@@ -3503,7 +3536,7 @@ function resolveEdgeValueLabel(value, fallback) {
3503
3536
  return value ?? `${fallback}`;
3504
3537
  }
3505
3538
  function SliderField(props) {
3506
- const reactId = React5.useId();
3539
+ const reactId = React6.useId();
3507
3540
  const id = props.id ?? `mw-slider-${reactId}`;
3508
3541
  const hasDescription = hasContent6(props.description);
3509
3542
  const hasError = hasContent6(props.error);
@@ -3704,29 +3737,29 @@ function TabPanel(props) {
3704
3737
  );
3705
3738
  }
3706
3739
  function TabGroup(props) {
3707
- const reactId = React5.useId();
3740
+ const reactId = React6.useId();
3708
3741
  const id = props.id ?? `mw-tab-group-${reactId}`;
3709
3742
  const hasLabel = hasContent7(props.label);
3710
- const itemStates = React5.useMemo(
3743
+ const itemStates = React6.useMemo(
3711
3744
  () => props.tabs.map((tab) => toItemState(tab)),
3712
3745
  [props.tabs]
3713
3746
  );
3714
3747
  const isControlled = props.activeTab !== void 0;
3715
- const [internalActiveTab, setInternalActiveTab] = React5.useState(
3748
+ const [internalActiveTab, setInternalActiveTab] = React6.useState(
3716
3749
  () => resolveTabValue(itemStates, props.defaultActiveTab)
3717
3750
  );
3718
- const resolvedActiveTab = React5.useMemo(
3751
+ const resolvedActiveTab = React6.useMemo(
3719
3752
  () => resolveTabValue(itemStates, isControlled ? props.activeTab : internalActiveTab),
3720
3753
  [internalActiveTab, isControlled, itemStates, props.activeTab]
3721
3754
  );
3722
- React5.useEffect(() => {
3755
+ React6.useEffect(() => {
3723
3756
  if (!isControlled) {
3724
3757
  setInternalActiveTab(
3725
3758
  (currentValue) => resolveTabValue(itemStates, currentValue ?? props.defaultActiveTab)
3726
3759
  );
3727
3760
  }
3728
3761
  }, [isControlled, itemStates, props.defaultActiveTab]);
3729
- const a11yIds = React5.useMemo(
3762
+ const a11yIds = React6.useMemo(
3730
3763
  () => buildTabGroupA11yIds({
3731
3764
  id,
3732
3765
  itemValues: props.tabs.map((tab) => tab.value),
@@ -3734,7 +3767,7 @@ function TabGroup(props) {
3734
3767
  }),
3735
3768
  [hasLabel, id, props.tabs]
3736
3769
  );
3737
- const selectTab = React5.useCallback(
3770
+ const selectTab = React6.useCallback(
3738
3771
  (nextValue) => {
3739
3772
  const resolvedValue = resolveTabValue(itemStates, nextValue);
3740
3773
  if (!resolvedValue) {
@@ -3749,7 +3782,7 @@ function TabGroup(props) {
3749
3782
  },
3750
3783
  [isControlled, itemStates, props.onActiveTabChange, resolvedActiveTab]
3751
3784
  );
3752
- const handleKeyDown = React5.useCallback(
3785
+ const handleKeyDown = React6.useCallback(
3753
3786
  (event) => {
3754
3787
  let direction;
3755
3788
  switch (event.key) {
@@ -3879,7 +3912,7 @@ function hasContent8(value) {
3879
3912
  return true;
3880
3913
  }
3881
3914
  function Dialog(props) {
3882
- const reactId = React5.useId();
3915
+ const reactId = React6.useId();
3883
3916
  const id = props.id ?? `mw-dialog-${reactId}`;
3884
3917
  const titleId = `${id}-title`;
3885
3918
  const descriptionId = `${id}-description`;
@@ -3998,12 +4031,12 @@ function DialogModal(props) {
3998
4031
  ...dialogProps
3999
4032
  } = props;
4000
4033
  const isControlled = open !== void 0;
4001
- const [internalOpen, setInternalOpen] = React5.useState(defaultOpen);
4034
+ const [internalOpen, setInternalOpen] = React6.useState(defaultOpen);
4002
4035
  const resolvedOpen = isControlled ? open : internalOpen;
4003
- const overlayRef = React5.useRef(null);
4004
- const surfaceRef = React5.useRef(null);
4005
- const lastFocusedElementRef = React5.useRef(null);
4006
- const close = React5.useCallback(() => {
4036
+ const overlayRef = React6.useRef(null);
4037
+ const surfaceRef = React6.useRef(null);
4038
+ const lastFocusedElementRef = React6.useRef(null);
4039
+ const close = React6.useCallback(() => {
4007
4040
  if (!resolvedOpen) {
4008
4041
  return;
4009
4042
  }
@@ -4012,7 +4045,7 @@ function DialogModal(props) {
4012
4045
  }
4013
4046
  onOpenChange?.(false);
4014
4047
  }, [isControlled, onOpenChange, resolvedOpen]);
4015
- React5.useEffect(() => {
4048
+ React6.useEffect(() => {
4016
4049
  if (!resolvedOpen || typeof document === "undefined") {
4017
4050
  return;
4018
4051
  }
@@ -4031,7 +4064,7 @@ function DialogModal(props) {
4031
4064
  }
4032
4065
  };
4033
4066
  }, [resolvedOpen, restoreFocus]);
4034
- React5.useEffect(() => {
4067
+ React6.useEffect(() => {
4035
4068
  if (!resolvedOpen || !closeOnEscape || typeof document === "undefined") {
4036
4069
  return;
4037
4070
  }
@@ -4046,7 +4079,7 @@ function DialogModal(props) {
4046
4079
  document.removeEventListener("keydown", handleKeyDown2);
4047
4080
  };
4048
4081
  }, [close, closeOnEscape, resolvedOpen]);
4049
- const handleKeyDown = React5.useCallback(
4082
+ const handleKeyDown = React6.useCallback(
4050
4083
  (event) => {
4051
4084
  if (event.key === "Escape" && closeOnEscape) {
4052
4085
  event.preventDefault();
@@ -4077,7 +4110,7 @@ function DialogModal(props) {
4077
4110
  },
4078
4111
  [close, closeOnEscape]
4079
4112
  );
4080
- const renderedFooter = React5.useMemo(
4113
+ const renderedFooter = React6.useMemo(
4081
4114
  () => typeof footer === "function" ? footer({ close }) : footer,
4082
4115
  [close, footer]
4083
4116
  );
@@ -4222,6 +4255,6 @@ function InfoDialog(props) {
4222
4255
  );
4223
4256
  }
4224
4257
 
4225
- export { Accordion, AccordionField, Avatar, AvatarBadge, AvatarGroup, Badge, BadgeGroup, BrightnessSlider, Button, ButtonSpinner, CancelButton, Card, Checkbox, CheckboxField, CheckboxGroupField, CloseButton, ConfirmButton, ConfirmDialog, ContentTabs, CopyButton, CreateButton, CurrencyField, DateOfBirthField, DestructiveButton, DestructiveDialog, Dialog, DialogModal, Divider, DownloadButton, DropdownButton, DropdownField, EditButton, EmailField, EmptyStateSpinner, ErrorToast, FAQAccordion, FeatureToggle, FilterButton, H1, H2, H3, Icon, InfoDialog, InfoToast, Input, InputField, InputOtp, LinkButton, MarwesProvider, NavigationTabs, NotificationBadge, OptionRadioGroup, Paragraph, PasswordField, PermissionSwitch, PhoneField, PreferenceSwitch, PresenceAvatar, PrimaryButton, PriorityBadge, ProductCard, ProfileAvatar, ProfileCard, Radio, RadioGroupField, RadiusSlider, RatingRadioGroup, RefreshButton, RichText, RichTextField, SaveButton, SearchButton, SearchField, SecondaryButton, SectionsAccordion, Select, SelectField, SettingsAccordion, SettingsTabs, Slider, SliderField, SortButton, Spacer, Spacing, Spinner, StatCard, StatusBadge, SubmitButton, SuccessButton, SuccessToast, Switch, SwitchField, Tab, TabGroup, TabPanel, TeamAvatarGroup, TextButton, Textarea, TextareaField, Toast, ToastContainer, ToastProvider, Tooltip, TooltipGroup, URLField, UploadButton, VerifyButton, VolumeSlider, WarningToast, YesNoRadioGroup, ZipCodeField, useTheme, useToast };
4258
+ export { Accordion, AccordionField, Avatar, AvatarBadge, AvatarGroup, Badge, BadgeGroup, BrightnessSlider, Button, ButtonSpinner, CancelButton, Card, Checkbox, CheckboxField, CheckboxGroupField, CloseButton, ConfirmButton, ConfirmDialog, ContentTabs, CopyButton, CreateButton, CurrencyField, DateOfBirthField, DestructiveButton, DestructiveDialog, Dialog, DialogModal, Divider, DownloadButton, DropdownButton, DropdownField, EditButton, EmailField, EmptyStateSpinner, ErrorToast, FAQAccordion, FeatureToggle, FilterButton, H1, H2, H3, Icon, InfoDialog, InfoToast, Input, InputField, InputOtp, LinkButton, MarwesProvider, NavigationTabs, NotificationBadge, OptionRadioGroup, Paragraph, PasswordField, PermissionSwitch, PhoneField, PreferenceSwitch, PresenceAvatar, PrimaryButton, PriorityBadge, ProductCard, ProfileAvatar, ProfileCard, Radio, RadioGroupField, RadiusSlider, RatingRadioGroup, RefreshButton, RichText, RichTextField, SaveButton, SearchButton, SearchField, SecondaryButton, SectionsAccordion, Select, SelectField, SettingsAccordion, SettingsTabs, Slider, SliderField, SortButton, Spacer, Spacing, Spinner, StatCard, StatusBadge, SubmitButton, SuccessButton, SuccessToast, Switch, SwitchField, Tab, TabGroup, TabPanel, TeamAvatarGroup, TextButton, Textarea, TextareaField, Toast, ToastContainer, ToastProvider, Tooltip, TooltipGroup, URLField, UploadButton, VerifyButton, VolumeSlider, WarningToast, YesNoRadioGroup, ZipCodeField, useTheme, useThemeMode, useToast };
4226
4259
  //# sourceMappingURL=index.js.map
4227
4260
  //# sourceMappingURL=index.js.map