@marwes-ui/react 1.0.0 → 1.0.2
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/README.md +181 -29
- package/dist/index.d.ts +24 -4
- package/dist/index.js +227 -101
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
|
2
|
+
import { createRichTextRecipe, resolveRichTextAllowedFormats, normalizeRichTextHtml, isRichTextHtmlEmpty, createDividerRecipe, createSpacingRecipe, createSliderRecipe, richTextCommandByFormat, resolveIconSize, resolveIconStrokeWidth, iconRegistry, resolveIconA11y, ThemeMode, resolveThemePreference, nextThemeMode, 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, isThemePreference, 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 React2 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 =
|
|
10
|
+
var MarwesContext = React2.createContext(null);
|
|
11
11
|
var loadedFonts = /* @__PURE__ */ new Set();
|
|
12
12
|
var preconnected = false;
|
|
13
13
|
function themeToRootStyle(theme) {
|
|
@@ -62,27 +62,136 @@ function loadThemeFonts(theme, config = "auto") {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
var mediaQuery = "(prefers-color-scheme: dark)";
|
|
66
|
+
function getSystemThemeMode() {
|
|
67
|
+
if (typeof window === "undefined") return ThemeMode.light;
|
|
68
|
+
return window.matchMedia?.(mediaQuery).matches ? ThemeMode.dark : ThemeMode.light;
|
|
69
|
+
}
|
|
70
|
+
function subscribeToSystemThemeMode(onChange) {
|
|
71
|
+
if (typeof window === "undefined" || !window.matchMedia) return () => {
|
|
72
|
+
};
|
|
73
|
+
const media = window.matchMedia(mediaQuery);
|
|
74
|
+
const listener = (event) => {
|
|
75
|
+
onChange(event.matches ? ThemeMode.dark : ThemeMode.light);
|
|
76
|
+
};
|
|
77
|
+
if (media.addEventListener) {
|
|
78
|
+
media.addEventListener("change", listener);
|
|
79
|
+
} else {
|
|
80
|
+
media.addListener?.(listener);
|
|
81
|
+
}
|
|
82
|
+
return () => {
|
|
83
|
+
if (media.removeEventListener) {
|
|
84
|
+
media.removeEventListener("change", listener);
|
|
85
|
+
} else {
|
|
86
|
+
media.removeListener?.(listener);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function readStoredThemePreference(storageKey) {
|
|
91
|
+
if (!storageKey || typeof window === "undefined") return void 0;
|
|
92
|
+
try {
|
|
93
|
+
const value = window.localStorage.getItem(storageKey);
|
|
94
|
+
return isThemePreference(value) ? value : void 0;
|
|
95
|
+
} catch {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function writeStoredThemePreference(storageKey, preference) {
|
|
100
|
+
if (!storageKey || typeof window === "undefined") return;
|
|
101
|
+
try {
|
|
102
|
+
window.localStorage.setItem(storageKey, preference);
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
}
|
|
65
106
|
function MarwesProvider({
|
|
66
107
|
theme,
|
|
108
|
+
defaultPreference,
|
|
109
|
+
preference: controlledPreference,
|
|
110
|
+
defaultMode,
|
|
111
|
+
mode: controlledMode,
|
|
67
112
|
fontLoading = "auto",
|
|
113
|
+
onPreferenceChange,
|
|
68
114
|
onModeChange,
|
|
115
|
+
storageKey = false,
|
|
116
|
+
enableSystem = true,
|
|
69
117
|
children
|
|
70
118
|
}) {
|
|
71
|
-
const rootRef =
|
|
72
|
-
const
|
|
73
|
-
|
|
119
|
+
const rootRef = React2.useRef(null);
|
|
120
|
+
const [internalPreference, setInternalPreference] = React2.useState(
|
|
121
|
+
defaultPreference ?? defaultMode ?? ThemeMode.light
|
|
122
|
+
);
|
|
123
|
+
const [systemMode, setSystemMode] = React2.useState(
|
|
124
|
+
() => enableSystem ? getSystemThemeMode() : ThemeMode.light
|
|
125
|
+
);
|
|
126
|
+
const activePreference = controlledPreference ?? controlledMode ?? theme?.mode ?? internalPreference;
|
|
127
|
+
const activeMode = resolveThemePreference(activePreference, systemMode);
|
|
128
|
+
const isPreferenceControlled = controlledPreference !== void 0 || controlledMode !== void 0 || theme?.mode !== void 0;
|
|
129
|
+
React2.useEffect(() => {
|
|
130
|
+
const storedPreference = readStoredThemePreference(storageKey);
|
|
131
|
+
if (storedPreference !== void 0 && !isPreferenceControlled) {
|
|
132
|
+
setInternalPreference(storedPreference);
|
|
133
|
+
}
|
|
134
|
+
}, [isPreferenceControlled, storageKey]);
|
|
135
|
+
React2.useEffect(() => {
|
|
136
|
+
if (!enableSystem) {
|
|
137
|
+
setSystemMode(ThemeMode.light);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
setSystemMode(getSystemThemeMode());
|
|
141
|
+
if (activePreference !== "system") {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return subscribeToSystemThemeMode(setSystemMode);
|
|
145
|
+
}, [activePreference, enableSystem]);
|
|
146
|
+
const setPreference = React2.useCallback(
|
|
147
|
+
(nextPreference) => {
|
|
148
|
+
if (!isPreferenceControlled) {
|
|
149
|
+
setInternalPreference(nextPreference);
|
|
150
|
+
}
|
|
151
|
+
writeStoredThemePreference(storageKey, nextPreference);
|
|
152
|
+
onPreferenceChange?.(nextPreference);
|
|
153
|
+
},
|
|
154
|
+
[isPreferenceControlled, onPreferenceChange, storageKey]
|
|
155
|
+
);
|
|
156
|
+
const setMode = React2.useCallback(
|
|
157
|
+
(nextMode) => {
|
|
158
|
+
setPreference(nextMode);
|
|
159
|
+
onModeChange?.(nextMode);
|
|
160
|
+
},
|
|
161
|
+
[onModeChange, setPreference]
|
|
162
|
+
);
|
|
163
|
+
const toggleMode = React2.useCallback(() => {
|
|
164
|
+
setMode(nextThemeMode(activeMode));
|
|
165
|
+
}, [activeMode, setMode]);
|
|
166
|
+
const resolved = React2.useMemo(
|
|
167
|
+
() => resolveThemeInput({ ...theme ?? {}, mode: activeMode }),
|
|
168
|
+
[activeMode, theme]
|
|
169
|
+
);
|
|
170
|
+
const rootStyle = React2.useMemo(
|
|
74
171
|
() => themeToRootStyle(resolved),
|
|
75
172
|
[resolved]
|
|
76
173
|
);
|
|
77
|
-
|
|
174
|
+
React2.useEffect(() => {
|
|
78
175
|
if (rootRef.current) {
|
|
79
176
|
applyThemeToElement(rootRef.current, resolved);
|
|
80
177
|
}
|
|
81
178
|
}, [resolved]);
|
|
82
|
-
|
|
179
|
+
React2.useEffect(() => {
|
|
83
180
|
loadThemeFonts(resolved, fontLoading);
|
|
84
181
|
}, [resolved, fontLoading]);
|
|
85
|
-
|
|
182
|
+
const contextValue = React2.useMemo(
|
|
183
|
+
() => ({
|
|
184
|
+
theme: resolved,
|
|
185
|
+
mode: activeMode,
|
|
186
|
+
preference: activePreference,
|
|
187
|
+
systemMode,
|
|
188
|
+
setMode,
|
|
189
|
+
setPreference,
|
|
190
|
+
toggleMode
|
|
191
|
+
}),
|
|
192
|
+
[activeMode, activePreference, resolved, setMode, setPreference, systemMode, toggleMode]
|
|
193
|
+
);
|
|
194
|
+
return /* @__PURE__ */ jsx(MarwesContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
86
195
|
"div",
|
|
87
196
|
{
|
|
88
197
|
ref: rootRef,
|
|
@@ -94,12 +203,29 @@ function MarwesProvider({
|
|
|
94
203
|
) });
|
|
95
204
|
}
|
|
96
205
|
function useTheme() {
|
|
97
|
-
const ctx =
|
|
206
|
+
const ctx = React2.useContext(MarwesContext);
|
|
98
207
|
if (!ctx) {
|
|
99
208
|
throw new Error("MarwesProvider is missing. Wrap your app in <MarwesProvider />.");
|
|
100
209
|
}
|
|
101
210
|
return ctx.theme;
|
|
102
211
|
}
|
|
212
|
+
function useThemeMode() {
|
|
213
|
+
const ctx = React2.useContext(MarwesContext);
|
|
214
|
+
if (!ctx) {
|
|
215
|
+
throw new Error("MarwesProvider is missing. Wrap your app in <MarwesProvider />.");
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
mode: ctx.mode,
|
|
219
|
+
preference: ctx.preference,
|
|
220
|
+
systemMode: ctx.systemMode,
|
|
221
|
+
setMode: ctx.setMode,
|
|
222
|
+
setPreference: ctx.setPreference,
|
|
223
|
+
toggleMode: ctx.toggleMode,
|
|
224
|
+
isDark: ctx.mode === ThemeMode.dark,
|
|
225
|
+
isLight: ctx.mode === ThemeMode.light,
|
|
226
|
+
isSystem: ctx.preference === "system"
|
|
227
|
+
};
|
|
228
|
+
}
|
|
103
229
|
function Icon({
|
|
104
230
|
name,
|
|
105
231
|
size,
|
|
@@ -765,7 +891,7 @@ function Select(props) {
|
|
|
765
891
|
const kit = createSelectRecipe(props);
|
|
766
892
|
const mode = resolveSelectMode(props);
|
|
767
893
|
const isControlled = props.value !== void 0;
|
|
768
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
894
|
+
const [uncontrolledValue, setUncontrolledValue] = React2.useState(
|
|
769
895
|
() => getInitialSelectValue(props)
|
|
770
896
|
);
|
|
771
897
|
useRenderKitDebug(kit, "Select");
|
|
@@ -981,33 +1107,33 @@ function exitActiveFormatAtCaret(editorElement, format) {
|
|
|
981
1107
|
selection.addRange(nextRange);
|
|
982
1108
|
return true;
|
|
983
1109
|
}
|
|
984
|
-
var RichText =
|
|
1110
|
+
var RichText = React2.forwardRef((props, forwardedRef) => {
|
|
985
1111
|
const kit = createRichTextRecipe(props);
|
|
986
|
-
const allowedFormats =
|
|
1112
|
+
const allowedFormats = React2.useMemo(
|
|
987
1113
|
() => resolveRichTextAllowedFormats(props.allowedFormats),
|
|
988
1114
|
[props.allowedFormats]
|
|
989
1115
|
);
|
|
990
|
-
const normalizedControlledValue =
|
|
1116
|
+
const normalizedControlledValue = React2.useMemo(
|
|
991
1117
|
() => normalizeRichTextHtml(props.value),
|
|
992
1118
|
[props.value]
|
|
993
1119
|
);
|
|
994
|
-
const initialUncontrolledValue =
|
|
1120
|
+
const initialUncontrolledValue = React2.useMemo(
|
|
995
1121
|
() => normalizeRichTextHtml(props.defaultValue),
|
|
996
1122
|
[props.defaultValue]
|
|
997
1123
|
);
|
|
998
1124
|
const isControlled = props.value !== void 0;
|
|
999
|
-
const [uncontrolledHtml, setUncontrolledHtml] =
|
|
1000
|
-
const [isEditorEmpty, setIsEditorEmpty] =
|
|
1125
|
+
const [uncontrolledHtml, setUncontrolledHtml] = React2.useState(initialUncontrolledValue);
|
|
1126
|
+
const [isEditorEmpty, setIsEditorEmpty] = React2.useState(
|
|
1001
1127
|
isRichTextHtmlEmpty(isControlled ? normalizedControlledValue : initialUncontrolledValue)
|
|
1002
1128
|
);
|
|
1003
|
-
const [activeFormats, setActiveFormats] =
|
|
1004
|
-
const editorElementRef =
|
|
1129
|
+
const [activeFormats, setActiveFormats] = React2.useState([]);
|
|
1130
|
+
const editorElementRef = React2.useRef(null);
|
|
1005
1131
|
useRenderKitDebug(kit, "RichText");
|
|
1006
1132
|
const editorHtml = isControlled ? normalizedControlledValue : uncontrolledHtml;
|
|
1007
1133
|
const style = kit.vars;
|
|
1008
1134
|
const className = props.className ? `${kit.className} ${props.className}` : kit.className;
|
|
1009
1135
|
const showToolbar = !props.readOnly;
|
|
1010
|
-
const syncEditorState =
|
|
1136
|
+
const syncEditorState = React2.useCallback(
|
|
1011
1137
|
(nextHtml) => {
|
|
1012
1138
|
const normalizedHtml = normalizeRichTextHtml(nextHtml);
|
|
1013
1139
|
const emptyState = isRichTextHtmlEmpty(normalizedHtml);
|
|
@@ -1020,10 +1146,10 @@ var RichText = React5.forwardRef((props, forwardedRef) => {
|
|
|
1020
1146
|
},
|
|
1021
1147
|
[isControlled, props]
|
|
1022
1148
|
);
|
|
1023
|
-
const refreshActiveFormats =
|
|
1149
|
+
const refreshActiveFormats = React2.useCallback(() => {
|
|
1024
1150
|
setActiveFormats(getActiveFormatsFromSelection(editorElementRef.current));
|
|
1025
1151
|
}, []);
|
|
1026
|
-
|
|
1152
|
+
React2.useLayoutEffect(() => {
|
|
1027
1153
|
const editorElement = editorElementRef.current;
|
|
1028
1154
|
if (!editorElement) {
|
|
1029
1155
|
return;
|
|
@@ -1034,7 +1160,7 @@ var RichText = React5.forwardRef((props, forwardedRef) => {
|
|
|
1034
1160
|
}
|
|
1035
1161
|
setIsEditorEmpty(isRichTextHtmlEmpty(editorHtml));
|
|
1036
1162
|
}, [editorHtml]);
|
|
1037
|
-
|
|
1163
|
+
React2.useEffect(() => {
|
|
1038
1164
|
if (typeof document === "undefined") {
|
|
1039
1165
|
return void 0;
|
|
1040
1166
|
}
|
|
@@ -1179,12 +1305,12 @@ function hasTextContent(value) {
|
|
|
1179
1305
|
return value !== void 0 && value.trim().length > 0;
|
|
1180
1306
|
}
|
|
1181
1307
|
function InputField(props) {
|
|
1182
|
-
const reactId =
|
|
1308
|
+
const reactId = React2.useId();
|
|
1183
1309
|
const id = props.id ?? `mw-input-${reactId}`;
|
|
1184
1310
|
const isPasswordField = props.input.type === "password";
|
|
1185
|
-
const [showPassword, setShowPassword] =
|
|
1311
|
+
const [showPassword, setShowPassword] = React2.useState(false);
|
|
1186
1312
|
const isSearchField = props.input.type === "search";
|
|
1187
|
-
const [searchValue, setSearchValue] =
|
|
1313
|
+
const [searchValue, setSearchValue] = React2.useState(
|
|
1188
1314
|
props.input.value || props.input.defaultValue || ""
|
|
1189
1315
|
);
|
|
1190
1316
|
const hasSearchValue = isSearchField && (props.input.value !== void 0 ? String(props.input.value).length > 0 : String(searchValue).length > 0);
|
|
@@ -1279,14 +1405,14 @@ function hasTextContent2(value) {
|
|
|
1279
1405
|
return value !== void 0 && value.trim().length > 0;
|
|
1280
1406
|
}
|
|
1281
1407
|
function InputOtp(props) {
|
|
1282
|
-
const reactId =
|
|
1408
|
+
const reactId = React2.useId();
|
|
1283
1409
|
const id = props.id ?? `mw-input-otp-${reactId}`;
|
|
1284
1410
|
const otpLength = Math.max(1, props.length ?? 6);
|
|
1285
1411
|
const hasHelperText = hasTextContent2(props.helperText);
|
|
1286
1412
|
const hasError = hasTextContent2(props.error);
|
|
1287
1413
|
const invalid = hasError || props.invalid === true;
|
|
1288
1414
|
const isControlled = props.value !== void 0;
|
|
1289
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
1415
|
+
const [uncontrolledValue, setUncontrolledValue] = React2.useState(() => {
|
|
1290
1416
|
return sanitizeInputOtpValue(props.defaultValue, otpLength);
|
|
1291
1417
|
});
|
|
1292
1418
|
const currentValue = sanitizeInputOtpValue(
|
|
@@ -1443,18 +1569,18 @@ function MarwesSelectFieldControl(props) {
|
|
|
1443
1569
|
const { id, select } = props;
|
|
1444
1570
|
const listboxId = `${id}-listbox`;
|
|
1445
1571
|
const isControlled = select.value !== void 0;
|
|
1446
|
-
const [internalValue, setInternalValue] =
|
|
1572
|
+
const [internalValue, setInternalValue] = React2.useState(() => getInitialSelectValue2(select));
|
|
1447
1573
|
const value = isControlled ? select.value ?? "" : internalValue;
|
|
1448
|
-
const [open, setOpen] =
|
|
1449
|
-
const [activeIndex, setActiveIndex] =
|
|
1574
|
+
const [open, setOpen] = React2.useState(false);
|
|
1575
|
+
const [activeIndex, setActiveIndex] = React2.useState(
|
|
1450
1576
|
() => getInitialActiveOptionIndex(select.options, value)
|
|
1451
1577
|
);
|
|
1452
|
-
const rootRef =
|
|
1453
|
-
const buttonRef =
|
|
1578
|
+
const rootRef = React2.useRef(null);
|
|
1579
|
+
const buttonRef = React2.useRef(null);
|
|
1454
1580
|
const selectedOption = select.options.find((option) => option.value === value) ?? (select.placeholder === void 0 ? select.options[0] : void 0);
|
|
1455
1581
|
const placeholderSelected = select.placeholder !== void 0 && value === "";
|
|
1456
1582
|
const displayText = placeholderSelected ? select.placeholder : selectedOption?.label ?? "";
|
|
1457
|
-
|
|
1583
|
+
React2.useEffect(() => {
|
|
1458
1584
|
if (!open) {
|
|
1459
1585
|
return;
|
|
1460
1586
|
}
|
|
@@ -1469,13 +1595,13 @@ function MarwesSelectFieldControl(props) {
|
|
|
1469
1595
|
document.removeEventListener("pointerdown", handlePointerDown);
|
|
1470
1596
|
};
|
|
1471
1597
|
}, [open]);
|
|
1472
|
-
|
|
1598
|
+
React2.useEffect(() => {
|
|
1473
1599
|
if (!open) {
|
|
1474
1600
|
return;
|
|
1475
1601
|
}
|
|
1476
1602
|
setActiveIndex(getInitialActiveOptionIndex(select.options, value));
|
|
1477
1603
|
}, [open, select.options, value]);
|
|
1478
|
-
|
|
1604
|
+
React2.useEffect(() => {
|
|
1479
1605
|
if (!select.disabled) {
|
|
1480
1606
|
return;
|
|
1481
1607
|
}
|
|
@@ -1674,7 +1800,7 @@ function MarwesSelectFieldControl(props) {
|
|
|
1674
1800
|
);
|
|
1675
1801
|
}
|
|
1676
1802
|
function SelectField(props) {
|
|
1677
|
-
const reactId =
|
|
1803
|
+
const reactId = React2.useId();
|
|
1678
1804
|
const id = props.id ?? `mw-select-${reactId}`;
|
|
1679
1805
|
const mode = resolveSelectMode(props.select);
|
|
1680
1806
|
const hasHelperText = hasTextContent3(props.helperText);
|
|
@@ -1720,7 +1846,7 @@ function hasTextContent4(value) {
|
|
|
1720
1846
|
return value !== void 0 && value.trim().length > 0;
|
|
1721
1847
|
}
|
|
1722
1848
|
function TextareaField(props) {
|
|
1723
|
-
const reactId =
|
|
1849
|
+
const reactId = React2.useId();
|
|
1724
1850
|
const id = props.id ?? `mw-textarea-${reactId}`;
|
|
1725
1851
|
const hasHelperText = hasTextContent4(props.helperText);
|
|
1726
1852
|
const hasError = hasTextContent4(props.error);
|
|
@@ -1766,9 +1892,9 @@ function hasTextContent5(value) {
|
|
|
1766
1892
|
return value !== void 0 && value.trim().length > 0;
|
|
1767
1893
|
}
|
|
1768
1894
|
function RichTextField(props) {
|
|
1769
|
-
const reactId =
|
|
1895
|
+
const reactId = React2.useId();
|
|
1770
1896
|
const id = props.id ?? `mw-rich-text-${reactId}`;
|
|
1771
|
-
const editorRef =
|
|
1897
|
+
const editorRef = React2.useRef(null);
|
|
1772
1898
|
const hasHelperText = hasTextContent5(props.helperText);
|
|
1773
1899
|
const hasError = hasTextContent5(props.error);
|
|
1774
1900
|
const { labelId, helperTextId, errorId, describedBy } = buildRichTextFieldA11yIds({
|
|
@@ -2135,8 +2261,8 @@ function TeamAvatarGroup(props) {
|
|
|
2135
2261
|
function Checkbox(props) {
|
|
2136
2262
|
const { onCheckedChange, onChange, ...coreProps } = props;
|
|
2137
2263
|
const kit = checkboxRecipe({ ...coreProps });
|
|
2138
|
-
const inputRef =
|
|
2139
|
-
|
|
2264
|
+
const inputRef = React2.useRef(null);
|
|
2265
|
+
React2.useLayoutEffect(() => {
|
|
2140
2266
|
const el = inputRef.current;
|
|
2141
2267
|
if (!el) return;
|
|
2142
2268
|
el.indeterminate = kit.indeterminate;
|
|
@@ -2182,7 +2308,7 @@ function hasContent(value) {
|
|
|
2182
2308
|
return true;
|
|
2183
2309
|
}
|
|
2184
2310
|
function CheckboxField(props) {
|
|
2185
|
-
const reactId =
|
|
2311
|
+
const reactId = React2.useId();
|
|
2186
2312
|
const id = props.id ?? `mw-checkbox-${reactId}`;
|
|
2187
2313
|
const hasDescription = hasContent(props.description);
|
|
2188
2314
|
const hasError = hasContent(props.error);
|
|
@@ -2236,7 +2362,7 @@ function orderSelectedValues(values, options) {
|
|
|
2236
2362
|
return [...knownValues, ...unknownValues];
|
|
2237
2363
|
}
|
|
2238
2364
|
function CheckboxGroupField(props) {
|
|
2239
|
-
const reactId =
|
|
2365
|
+
const reactId = React2.useId();
|
|
2240
2366
|
const id = props.id ?? `mw-checkbox-group-${reactId}`;
|
|
2241
2367
|
const hasDescription = hasContent2(props.description);
|
|
2242
2368
|
const hasError = hasContent2(props.error);
|
|
@@ -2248,7 +2374,7 @@ function CheckboxGroupField(props) {
|
|
|
2248
2374
|
externalDescribedBy: props.ariaDescribedBy
|
|
2249
2375
|
});
|
|
2250
2376
|
const isControlled = props.value !== void 0;
|
|
2251
|
-
const [internalValue, setInternalValue] =
|
|
2377
|
+
const [internalValue, setInternalValue] = React2.useState(
|
|
2252
2378
|
orderSelectedValues(props.defaultValue ?? [], props.options)
|
|
2253
2379
|
);
|
|
2254
2380
|
const selectedValues = orderSelectedValues(
|
|
@@ -2318,7 +2444,7 @@ function CheckboxGroupField(props) {
|
|
|
2318
2444
|
}
|
|
2319
2445
|
);
|
|
2320
2446
|
}
|
|
2321
|
-
var Divider =
|
|
2447
|
+
var Divider = React2.forwardRef((props, ref) => {
|
|
2322
2448
|
const { className: customClassName, style: customStyle, ...opts } = props;
|
|
2323
2449
|
const kit = createDividerRecipe(opts);
|
|
2324
2450
|
const style = { ...kit.vars, ...customStyle };
|
|
@@ -2326,7 +2452,7 @@ var Divider = React5.forwardRef((props, ref) => {
|
|
|
2326
2452
|
return /* @__PURE__ */ jsx("hr", { ref, ...kit.a11y, ...kit.dataAttributes, className, style });
|
|
2327
2453
|
});
|
|
2328
2454
|
Divider.displayName = "Divider";
|
|
2329
|
-
var Spacing =
|
|
2455
|
+
var Spacing = React2.forwardRef((props, ref) => {
|
|
2330
2456
|
const { className: customClassName, scale, size, spacing, style: customStyle } = props;
|
|
2331
2457
|
const resolvedSize = spacing ?? size;
|
|
2332
2458
|
const kit = createSpacingRecipe({
|
|
@@ -2561,12 +2687,12 @@ function renderToastByIntent(toast, onDismiss) {
|
|
|
2561
2687
|
}
|
|
2562
2688
|
}
|
|
2563
2689
|
function ToastViewportItem(props) {
|
|
2564
|
-
const timerHandleRef =
|
|
2565
|
-
const timerStartedAtRef =
|
|
2566
|
-
const remainingDurationRef =
|
|
2567
|
-
const pointerInsideRef =
|
|
2568
|
-
const focusInsideRef =
|
|
2569
|
-
const clearDismissTimer =
|
|
2690
|
+
const timerHandleRef = React2.useRef(null);
|
|
2691
|
+
const timerStartedAtRef = React2.useRef(null);
|
|
2692
|
+
const remainingDurationRef = React2.useRef(null);
|
|
2693
|
+
const pointerInsideRef = React2.useRef(false);
|
|
2694
|
+
const focusInsideRef = React2.useRef(false);
|
|
2695
|
+
const clearDismissTimer = React2.useCallback(() => {
|
|
2570
2696
|
if (timerHandleRef.current === null) {
|
|
2571
2697
|
return;
|
|
2572
2698
|
}
|
|
@@ -2574,7 +2700,7 @@ function ToastViewportItem(props) {
|
|
|
2574
2700
|
timerHandleRef.current = null;
|
|
2575
2701
|
timerStartedAtRef.current = null;
|
|
2576
2702
|
}, []);
|
|
2577
|
-
const scheduleDismissTimer =
|
|
2703
|
+
const scheduleDismissTimer = React2.useCallback(
|
|
2578
2704
|
(delay) => {
|
|
2579
2705
|
if (!props.onDismiss || delay <= 0 || pointerInsideRef.current || focusInsideRef.current || timerHandleRef.current !== null) {
|
|
2580
2706
|
return;
|
|
@@ -2589,7 +2715,7 @@ function ToastViewportItem(props) {
|
|
|
2589
2715
|
},
|
|
2590
2716
|
[props.onDismiss, props.toast.id]
|
|
2591
2717
|
);
|
|
2592
|
-
const pauseDismissTimer =
|
|
2718
|
+
const pauseDismissTimer = React2.useCallback(() => {
|
|
2593
2719
|
if (timerHandleRef.current === null || timerStartedAtRef.current === null) {
|
|
2594
2720
|
return;
|
|
2595
2721
|
}
|
|
@@ -2598,7 +2724,7 @@ function ToastViewportItem(props) {
|
|
|
2598
2724
|
remainingDurationRef.current = Math.max(remainingDuration - elapsed, 0);
|
|
2599
2725
|
clearDismissTimer();
|
|
2600
2726
|
}, [clearDismissTimer]);
|
|
2601
|
-
const resumeDismissTimer =
|
|
2727
|
+
const resumeDismissTimer = React2.useCallback(() => {
|
|
2602
2728
|
if (pointerInsideRef.current || focusInsideRef.current) {
|
|
2603
2729
|
return;
|
|
2604
2730
|
}
|
|
@@ -2608,7 +2734,7 @@ function ToastViewportItem(props) {
|
|
|
2608
2734
|
}
|
|
2609
2735
|
scheduleDismissTimer(remainingDuration);
|
|
2610
2736
|
}, [scheduleDismissTimer]);
|
|
2611
|
-
|
|
2737
|
+
React2.useEffect(() => {
|
|
2612
2738
|
clearDismissTimer();
|
|
2613
2739
|
pointerInsideRef.current = false;
|
|
2614
2740
|
focusInsideRef.current = false;
|
|
@@ -2665,18 +2791,18 @@ function ToastContainer(props) {
|
|
|
2665
2791
|
toast.id
|
|
2666
2792
|
)) });
|
|
2667
2793
|
}
|
|
2668
|
-
var ToastContext =
|
|
2794
|
+
var ToastContext = React2.createContext(null);
|
|
2669
2795
|
function ToastProvider(props) {
|
|
2670
|
-
const [toasts, setToasts] =
|
|
2671
|
-
const idRef =
|
|
2672
|
-
const dismiss =
|
|
2796
|
+
const [toasts, setToasts] = React2.useState([]);
|
|
2797
|
+
const idRef = React2.useRef(0);
|
|
2798
|
+
const dismiss = React2.useCallback((id) => {
|
|
2673
2799
|
setToasts((currentToasts) => {
|
|
2674
2800
|
const toast = currentToasts.find((item) => item.id === id);
|
|
2675
2801
|
toast?.onDismiss?.();
|
|
2676
2802
|
return currentToasts.filter((item) => item.id !== id);
|
|
2677
2803
|
});
|
|
2678
2804
|
}, []);
|
|
2679
|
-
const clear =
|
|
2805
|
+
const clear = React2.useCallback(() => {
|
|
2680
2806
|
setToasts((currentToasts) => {
|
|
2681
2807
|
for (const toast of currentToasts) {
|
|
2682
2808
|
toast.onDismiss?.();
|
|
@@ -2684,7 +2810,7 @@ function ToastProvider(props) {
|
|
|
2684
2810
|
return [];
|
|
2685
2811
|
});
|
|
2686
2812
|
}, []);
|
|
2687
|
-
const show =
|
|
2813
|
+
const show = React2.useCallback(
|
|
2688
2814
|
(toast) => {
|
|
2689
2815
|
idRef.current += 1;
|
|
2690
2816
|
const id = `mw-toast-${idRef.current}`;
|
|
@@ -2700,7 +2826,7 @@ function ToastProvider(props) {
|
|
|
2700
2826
|
},
|
|
2701
2827
|
[props.defaultDuration]
|
|
2702
2828
|
);
|
|
2703
|
-
const value =
|
|
2829
|
+
const value = React2.useMemo(
|
|
2704
2830
|
() => ({
|
|
2705
2831
|
show,
|
|
2706
2832
|
dismiss,
|
|
@@ -2723,7 +2849,7 @@ function ToastProvider(props) {
|
|
|
2723
2849
|
] });
|
|
2724
2850
|
}
|
|
2725
2851
|
function useToast() {
|
|
2726
|
-
const context =
|
|
2852
|
+
const context = React2.useContext(ToastContext);
|
|
2727
2853
|
if (!context) {
|
|
2728
2854
|
throw new Error("ToastProvider is missing. Wrap your app in <ToastProvider />.");
|
|
2729
2855
|
}
|
|
@@ -2757,7 +2883,7 @@ function cx10(...parts) {
|
|
|
2757
2883
|
return parts.filter(Boolean).join(" ");
|
|
2758
2884
|
}
|
|
2759
2885
|
function TooltipGroup(props) {
|
|
2760
|
-
const reactId =
|
|
2886
|
+
const reactId = React2.useId();
|
|
2761
2887
|
const {
|
|
2762
2888
|
content,
|
|
2763
2889
|
icon = IconName.HelpCircle,
|
|
@@ -2778,12 +2904,12 @@ function TooltipGroup(props) {
|
|
|
2778
2904
|
onKeyDown,
|
|
2779
2905
|
...nativeSpanProps
|
|
2780
2906
|
} = props;
|
|
2781
|
-
const [internalOpen, setInternalOpen] =
|
|
2907
|
+
const [internalOpen, setInternalOpen] = React2.useState(defaultOpen);
|
|
2782
2908
|
const isControlled = open !== void 0;
|
|
2783
2909
|
const resolvedOpen = isControlled ? open : internalOpen;
|
|
2784
|
-
const [isTooltipMounted, setIsTooltipMounted] =
|
|
2910
|
+
const [isTooltipMounted, setIsTooltipMounted] = React2.useState(resolvedOpen);
|
|
2785
2911
|
const resolvedTooltipId = tooltipId ?? `${id ?? `mw-tooltip-group-${reactId}`}-tooltip`;
|
|
2786
|
-
|
|
2912
|
+
React2.useEffect(() => {
|
|
2787
2913
|
if (resolvedOpen) {
|
|
2788
2914
|
setIsTooltipMounted(true);
|
|
2789
2915
|
return;
|
|
@@ -2795,7 +2921,7 @@ function TooltipGroup(props) {
|
|
|
2795
2921
|
window.clearTimeout(timeoutId);
|
|
2796
2922
|
};
|
|
2797
2923
|
}, [resolvedOpen]);
|
|
2798
|
-
const updateOpen =
|
|
2924
|
+
const updateOpen = React2.useCallback(
|
|
2799
2925
|
(nextOpen) => {
|
|
2800
2926
|
if (resolvedOpen === nextOpen) {
|
|
2801
2927
|
return;
|
|
@@ -2869,7 +2995,7 @@ function TooltipGroup(props) {
|
|
|
2869
2995
|
}
|
|
2870
2996
|
function Accordion(props) {
|
|
2871
2997
|
const { title, children, className, onToggle, id: idProp, open, disabled } = props;
|
|
2872
|
-
const autoId =
|
|
2998
|
+
const autoId = React2.useId();
|
|
2873
2999
|
const resolvedId = idProp ?? autoId.replace(/:/g, "");
|
|
2874
3000
|
const opts = { id: resolvedId };
|
|
2875
3001
|
if (open !== void 0) opts.open = open;
|
|
@@ -2922,7 +3048,7 @@ function resolveAccordionItemContent(item) {
|
|
|
2922
3048
|
return item.content ?? item.children;
|
|
2923
3049
|
}
|
|
2924
3050
|
function AccordionField(props) {
|
|
2925
|
-
const reactId =
|
|
3051
|
+
const reactId = React2.useId();
|
|
2926
3052
|
const id = props.id ?? `mw-accordion-field-${reactId}`;
|
|
2927
3053
|
const multipleAllowed = props.multiple ?? true;
|
|
2928
3054
|
const hasDescription = hasContent3(props.description);
|
|
@@ -2935,7 +3061,7 @@ function AccordionField(props) {
|
|
|
2935
3061
|
externalDescribedBy: props.ariaDescribedBy
|
|
2936
3062
|
});
|
|
2937
3063
|
const isControlled = props.openItems !== void 0;
|
|
2938
|
-
const [internalOpenItems, setInternalOpenItems] =
|
|
3064
|
+
const [internalOpenItems, setInternalOpenItems] = React2.useState(
|
|
2939
3065
|
props.defaultOpenItems ?? []
|
|
2940
3066
|
);
|
|
2941
3067
|
const openItems = isControlled ? props.openItems ?? [] : internalOpenItems;
|
|
@@ -3066,7 +3192,7 @@ function cx12(...parts) {
|
|
|
3066
3192
|
return parts.filter(Boolean).join(" ");
|
|
3067
3193
|
}
|
|
3068
3194
|
function RadioGroupField(props) {
|
|
3069
|
-
const reactId =
|
|
3195
|
+
const reactId = React2.useId();
|
|
3070
3196
|
const id = props.id ?? `mw-radio-group-${reactId}`;
|
|
3071
3197
|
const hasDescription = hasContent4(props.description);
|
|
3072
3198
|
const hasError = hasContent4(props.error);
|
|
@@ -3078,7 +3204,7 @@ function RadioGroupField(props) {
|
|
|
3078
3204
|
externalDescribedBy: props.ariaDescribedBy
|
|
3079
3205
|
});
|
|
3080
3206
|
const isControlled = props.value !== void 0;
|
|
3081
|
-
const [internalValue, setInternalValue] =
|
|
3207
|
+
const [internalValue, setInternalValue] = React2.useState(props.defaultValue);
|
|
3082
3208
|
const selectedValue = isControlled ? props.value : internalValue;
|
|
3083
3209
|
const handleSelect = (optionValue) => {
|
|
3084
3210
|
if (!isControlled) {
|
|
@@ -3197,7 +3323,7 @@ function cx13(...parts) {
|
|
|
3197
3323
|
return parts.filter(Boolean).join(" ");
|
|
3198
3324
|
}
|
|
3199
3325
|
function BadgeGroup(props) {
|
|
3200
|
-
const reactId =
|
|
3326
|
+
const reactId = React2.useId();
|
|
3201
3327
|
const id = props.id ?? `mw-badge-group-${reactId}`;
|
|
3202
3328
|
const labelId = `${id}-label`;
|
|
3203
3329
|
const className = cx13("mw-badge-group", props.className);
|
|
@@ -3289,7 +3415,7 @@ function hasContent5(value) {
|
|
|
3289
3415
|
return true;
|
|
3290
3416
|
}
|
|
3291
3417
|
function SwitchField(props) {
|
|
3292
|
-
const reactId =
|
|
3418
|
+
const reactId = React2.useId();
|
|
3293
3419
|
const id = props.id ?? `mw-switch-${reactId}`;
|
|
3294
3420
|
const hasDescription = hasContent5(props.description);
|
|
3295
3421
|
const hasError = hasContent5(props.error);
|
|
@@ -3389,7 +3515,7 @@ function buildSliderOptions(options) {
|
|
|
3389
3515
|
function resolveSliderValue(options) {
|
|
3390
3516
|
return createSliderRecipe(buildSliderOptions(options)).value;
|
|
3391
3517
|
}
|
|
3392
|
-
var Slider =
|
|
3518
|
+
var Slider = React2.forwardRef((props, ref) => {
|
|
3393
3519
|
const {
|
|
3394
3520
|
id,
|
|
3395
3521
|
name,
|
|
@@ -3414,10 +3540,10 @@ var Slider = React5.forwardRef((props, ref) => {
|
|
|
3414
3540
|
...inputProps
|
|
3415
3541
|
} = props;
|
|
3416
3542
|
const isControlled = value !== void 0;
|
|
3417
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
3543
|
+
const [uncontrolledValue, setUncontrolledValue] = React2.useState(
|
|
3418
3544
|
() => resolveSliderValue({ min, max, step, value, defaultValue })
|
|
3419
3545
|
);
|
|
3420
|
-
|
|
3546
|
+
React2.useEffect(() => {
|
|
3421
3547
|
if (!isControlled) {
|
|
3422
3548
|
setUncontrolledValue(resolveSliderValue({ min, max, step, defaultValue }));
|
|
3423
3549
|
}
|
|
@@ -3503,7 +3629,7 @@ function resolveEdgeValueLabel(value, fallback) {
|
|
|
3503
3629
|
return value ?? `${fallback}`;
|
|
3504
3630
|
}
|
|
3505
3631
|
function SliderField(props) {
|
|
3506
|
-
const reactId =
|
|
3632
|
+
const reactId = React2.useId();
|
|
3507
3633
|
const id = props.id ?? `mw-slider-${reactId}`;
|
|
3508
3634
|
const hasDescription = hasContent6(props.description);
|
|
3509
3635
|
const hasError = hasContent6(props.error);
|
|
@@ -3704,29 +3830,29 @@ function TabPanel(props) {
|
|
|
3704
3830
|
);
|
|
3705
3831
|
}
|
|
3706
3832
|
function TabGroup(props) {
|
|
3707
|
-
const reactId =
|
|
3833
|
+
const reactId = React2.useId();
|
|
3708
3834
|
const id = props.id ?? `mw-tab-group-${reactId}`;
|
|
3709
3835
|
const hasLabel = hasContent7(props.label);
|
|
3710
|
-
const itemStates =
|
|
3836
|
+
const itemStates = React2.useMemo(
|
|
3711
3837
|
() => props.tabs.map((tab) => toItemState(tab)),
|
|
3712
3838
|
[props.tabs]
|
|
3713
3839
|
);
|
|
3714
3840
|
const isControlled = props.activeTab !== void 0;
|
|
3715
|
-
const [internalActiveTab, setInternalActiveTab] =
|
|
3841
|
+
const [internalActiveTab, setInternalActiveTab] = React2.useState(
|
|
3716
3842
|
() => resolveTabValue(itemStates, props.defaultActiveTab)
|
|
3717
3843
|
);
|
|
3718
|
-
const resolvedActiveTab =
|
|
3844
|
+
const resolvedActiveTab = React2.useMemo(
|
|
3719
3845
|
() => resolveTabValue(itemStates, isControlled ? props.activeTab : internalActiveTab),
|
|
3720
3846
|
[internalActiveTab, isControlled, itemStates, props.activeTab]
|
|
3721
3847
|
);
|
|
3722
|
-
|
|
3848
|
+
React2.useEffect(() => {
|
|
3723
3849
|
if (!isControlled) {
|
|
3724
3850
|
setInternalActiveTab(
|
|
3725
3851
|
(currentValue) => resolveTabValue(itemStates, currentValue ?? props.defaultActiveTab)
|
|
3726
3852
|
);
|
|
3727
3853
|
}
|
|
3728
3854
|
}, [isControlled, itemStates, props.defaultActiveTab]);
|
|
3729
|
-
const a11yIds =
|
|
3855
|
+
const a11yIds = React2.useMemo(
|
|
3730
3856
|
() => buildTabGroupA11yIds({
|
|
3731
3857
|
id,
|
|
3732
3858
|
itemValues: props.tabs.map((tab) => tab.value),
|
|
@@ -3734,7 +3860,7 @@ function TabGroup(props) {
|
|
|
3734
3860
|
}),
|
|
3735
3861
|
[hasLabel, id, props.tabs]
|
|
3736
3862
|
);
|
|
3737
|
-
const selectTab =
|
|
3863
|
+
const selectTab = React2.useCallback(
|
|
3738
3864
|
(nextValue) => {
|
|
3739
3865
|
const resolvedValue = resolveTabValue(itemStates, nextValue);
|
|
3740
3866
|
if (!resolvedValue) {
|
|
@@ -3749,7 +3875,7 @@ function TabGroup(props) {
|
|
|
3749
3875
|
},
|
|
3750
3876
|
[isControlled, itemStates, props.onActiveTabChange, resolvedActiveTab]
|
|
3751
3877
|
);
|
|
3752
|
-
const handleKeyDown =
|
|
3878
|
+
const handleKeyDown = React2.useCallback(
|
|
3753
3879
|
(event) => {
|
|
3754
3880
|
let direction;
|
|
3755
3881
|
switch (event.key) {
|
|
@@ -3879,7 +4005,7 @@ function hasContent8(value) {
|
|
|
3879
4005
|
return true;
|
|
3880
4006
|
}
|
|
3881
4007
|
function Dialog(props) {
|
|
3882
|
-
const reactId =
|
|
4008
|
+
const reactId = React2.useId();
|
|
3883
4009
|
const id = props.id ?? `mw-dialog-${reactId}`;
|
|
3884
4010
|
const titleId = `${id}-title`;
|
|
3885
4011
|
const descriptionId = `${id}-description`;
|
|
@@ -3998,12 +4124,12 @@ function DialogModal(props) {
|
|
|
3998
4124
|
...dialogProps
|
|
3999
4125
|
} = props;
|
|
4000
4126
|
const isControlled = open !== void 0;
|
|
4001
|
-
const [internalOpen, setInternalOpen] =
|
|
4127
|
+
const [internalOpen, setInternalOpen] = React2.useState(defaultOpen);
|
|
4002
4128
|
const resolvedOpen = isControlled ? open : internalOpen;
|
|
4003
|
-
const overlayRef =
|
|
4004
|
-
const surfaceRef =
|
|
4005
|
-
const lastFocusedElementRef =
|
|
4006
|
-
const close =
|
|
4129
|
+
const overlayRef = React2.useRef(null);
|
|
4130
|
+
const surfaceRef = React2.useRef(null);
|
|
4131
|
+
const lastFocusedElementRef = React2.useRef(null);
|
|
4132
|
+
const close = React2.useCallback(() => {
|
|
4007
4133
|
if (!resolvedOpen) {
|
|
4008
4134
|
return;
|
|
4009
4135
|
}
|
|
@@ -4012,7 +4138,7 @@ function DialogModal(props) {
|
|
|
4012
4138
|
}
|
|
4013
4139
|
onOpenChange?.(false);
|
|
4014
4140
|
}, [isControlled, onOpenChange, resolvedOpen]);
|
|
4015
|
-
|
|
4141
|
+
React2.useEffect(() => {
|
|
4016
4142
|
if (!resolvedOpen || typeof document === "undefined") {
|
|
4017
4143
|
return;
|
|
4018
4144
|
}
|
|
@@ -4031,7 +4157,7 @@ function DialogModal(props) {
|
|
|
4031
4157
|
}
|
|
4032
4158
|
};
|
|
4033
4159
|
}, [resolvedOpen, restoreFocus]);
|
|
4034
|
-
|
|
4160
|
+
React2.useEffect(() => {
|
|
4035
4161
|
if (!resolvedOpen || !closeOnEscape || typeof document === "undefined") {
|
|
4036
4162
|
return;
|
|
4037
4163
|
}
|
|
@@ -4046,7 +4172,7 @@ function DialogModal(props) {
|
|
|
4046
4172
|
document.removeEventListener("keydown", handleKeyDown2);
|
|
4047
4173
|
};
|
|
4048
4174
|
}, [close, closeOnEscape, resolvedOpen]);
|
|
4049
|
-
const handleKeyDown =
|
|
4175
|
+
const handleKeyDown = React2.useCallback(
|
|
4050
4176
|
(event) => {
|
|
4051
4177
|
if (event.key === "Escape" && closeOnEscape) {
|
|
4052
4178
|
event.preventDefault();
|
|
@@ -4077,7 +4203,7 @@ function DialogModal(props) {
|
|
|
4077
4203
|
},
|
|
4078
4204
|
[close, closeOnEscape]
|
|
4079
4205
|
);
|
|
4080
|
-
const renderedFooter =
|
|
4206
|
+
const renderedFooter = React2.useMemo(
|
|
4081
4207
|
() => typeof footer === "function" ? footer({ close }) : footer,
|
|
4082
4208
|
[close, footer]
|
|
4083
4209
|
);
|
|
@@ -4222,6 +4348,6 @@ function InfoDialog(props) {
|
|
|
4222
4348
|
);
|
|
4223
4349
|
}
|
|
4224
4350
|
|
|
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 };
|
|
4351
|
+
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
4352
|
//# sourceMappingURL=index.js.map
|
|
4227
4353
|
//# sourceMappingURL=index.js.map
|