arco-clone-react 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -9160,12 +9160,141 @@ var Carousel = ({
9160
9160
  );
9161
9161
  };
9162
9162
  Carousel.displayName = "Carousel";
9163
+
9164
+ // src/components/Drawer/Drawer.tsx
9165
+ import { useEffect as useEffect3, useRef as useRef3, useCallback as useCallback3 } from "react";
9166
+
9167
+ // src/components/Drawer/Drawer.module.css
9168
+ var Drawer_default = {};
9169
+
9170
+ // src/components/Drawer/Drawer.tsx
9171
+ import { jsx as jsx265, jsxs as jsxs7 } from "react/jsx-runtime";
9172
+ var Drawer = ({
9173
+ open,
9174
+ onClose,
9175
+ title,
9176
+ children,
9177
+ placement = "right",
9178
+ size = "medium",
9179
+ showCloseButton = true,
9180
+ showOverlay = true,
9181
+ closeOnOverlayClick = true,
9182
+ closeOnEscape = true,
9183
+ footer,
9184
+ className = "",
9185
+ headerClassName = "",
9186
+ bodyClassName = "",
9187
+ footerClassName = "",
9188
+ overlayClassName = "",
9189
+ zIndex = 1e3,
9190
+ lockBodyScroll = true,
9191
+ ...rest
9192
+ }) => {
9193
+ const drawerRef = useRef3(null);
9194
+ const previousActiveElement = useRef3(null);
9195
+ useEffect3(() => {
9196
+ if (!open || !closeOnEscape) return;
9197
+ const handleEscape = (e) => {
9198
+ if (e.key === "Escape") {
9199
+ onClose();
9200
+ }
9201
+ };
9202
+ document.addEventListener("keydown", handleEscape);
9203
+ return () => document.removeEventListener("keydown", handleEscape);
9204
+ }, [open, closeOnEscape, onClose]);
9205
+ useEffect3(() => {
9206
+ if (!open || !lockBodyScroll) return;
9207
+ const originalOverflow = document.body.style.overflow;
9208
+ const originalPaddingRight = document.body.style.paddingRight;
9209
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
9210
+ document.body.style.overflow = "hidden";
9211
+ if (scrollbarWidth > 0) {
9212
+ document.body.style.paddingRight = `${scrollbarWidth}px`;
9213
+ }
9214
+ return () => {
9215
+ document.body.style.overflow = originalOverflow;
9216
+ document.body.style.paddingRight = originalPaddingRight;
9217
+ };
9218
+ }, [open, lockBodyScroll]);
9219
+ useEffect3(() => {
9220
+ if (open) {
9221
+ previousActiveElement.current = document.activeElement;
9222
+ drawerRef.current?.focus();
9223
+ } else {
9224
+ previousActiveElement.current?.focus();
9225
+ }
9226
+ }, [open]);
9227
+ const handleOverlayClick = useCallback3(
9228
+ (e) => {
9229
+ if (closeOnOverlayClick && e.target === e.currentTarget) {
9230
+ onClose();
9231
+ }
9232
+ },
9233
+ [closeOnOverlayClick, onClose]
9234
+ );
9235
+ if (!open) return null;
9236
+ const drawerClasses = [Drawer_default.drawer, Drawer_default[placement], Drawer_default[size], className].filter(Boolean).join(" ");
9237
+ const overlayClasses = [Drawer_default.overlay, overlayClassName].filter(Boolean).join(" ");
9238
+ const headerClasses = [Drawer_default.header, headerClassName].filter(Boolean).join(" ");
9239
+ const bodyClasses = [Drawer_default.body, bodyClassName].filter(Boolean).join(" ");
9240
+ const footerClasses = [Drawer_default.footer, footerClassName].filter(Boolean).join(" ");
9241
+ return /* @__PURE__ */ jsxs7("div", { className: Drawer_default.drawerContainer, style: { zIndex }, role: "presentation", children: [
9242
+ showOverlay && /* @__PURE__ */ jsx265("div", { className: overlayClasses, onClick: handleOverlayClick, "aria-hidden": "true" }),
9243
+ /* @__PURE__ */ jsxs7(
9244
+ "div",
9245
+ {
9246
+ ref: drawerRef,
9247
+ className: drawerClasses,
9248
+ role: "dialog",
9249
+ "aria-modal": "true",
9250
+ "aria-label": typeof title === "string" ? title : void 0,
9251
+ tabIndex: -1,
9252
+ ...rest,
9253
+ children: [
9254
+ (title || showCloseButton) && /* @__PURE__ */ jsxs7("div", { className: headerClasses, children: [
9255
+ title && /* @__PURE__ */ jsx265("h2", { className: Drawer_default.title, children: title }),
9256
+ showCloseButton && /* @__PURE__ */ jsx265(
9257
+ "button",
9258
+ {
9259
+ type: "button",
9260
+ className: Drawer_default.closeButton,
9261
+ onClick: onClose,
9262
+ "aria-label": "Close drawer",
9263
+ children: /* @__PURE__ */ jsxs7(
9264
+ "svg",
9265
+ {
9266
+ width: "24",
9267
+ height: "24",
9268
+ viewBox: "0 0 24 24",
9269
+ fill: "none",
9270
+ stroke: "currentColor",
9271
+ strokeWidth: "2",
9272
+ strokeLinecap: "round",
9273
+ strokeLinejoin: "round",
9274
+ children: [
9275
+ /* @__PURE__ */ jsx265("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
9276
+ /* @__PURE__ */ jsx265("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
9277
+ ]
9278
+ }
9279
+ )
9280
+ }
9281
+ )
9282
+ ] }),
9283
+ /* @__PURE__ */ jsx265("div", { className: bodyClasses, children }),
9284
+ footer && /* @__PURE__ */ jsx265("div", { className: footerClasses, children: footer })
9285
+ ]
9286
+ }
9287
+ )
9288
+ ] });
9289
+ };
9290
+ Drawer.displayName = "Drawer";
9163
9291
  export {
9164
9292
  Badge,
9165
9293
  Button,
9166
9294
  Carousel,
9167
9295
  Collapse,
9168
9296
  Container,
9297
+ Drawer,
9169
9298
  Flex,
9170
9299
  Grid,
9171
9300
  GridItem,