@ecohouse/ui 0.1.50 → 0.1.52

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.cjs CHANGED
@@ -35090,6 +35090,7 @@ var Drawer = react.forwardRef(function Drawer2({
35090
35090
  className
35091
35091
  }, forwardedRef) {
35092
35092
  const panelRef = react.useRef(null);
35093
+ const shellRef = react.useRef(null);
35093
35094
  const setPanelRef = react.useMemo(() => mergeRefs(panelRef, forwardedRef), [forwardedRef]);
35094
35095
  const resolvedClassName = className?.trim() || void 0;
35095
35096
  const closeTimeoutRef = react.useRef(null);
@@ -35111,6 +35112,22 @@ var Drawer = react.forwardRef(function Drawer2({
35111
35112
  document.removeEventListener("keydown", onKeyDown);
35112
35113
  };
35113
35114
  }, [mounted, onClose]);
35115
+ const targetWidth = Math.min(width, typeof window !== "undefined" ? window.innerWidth : width);
35116
+ const playWidth = react.useCallback(
35117
+ (target) => {
35118
+ const shell = shellRef.current;
35119
+ if (!shell) return;
35120
+ const reduced = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
35121
+ const duration = reduced ? 0 : animationDuration;
35122
+ const from = shell.getBoundingClientRect().width;
35123
+ shell.style.transition = "none";
35124
+ shell.style.width = `${from}px`;
35125
+ void shell.offsetWidth;
35126
+ shell.style.transition = `width ${duration}ms cubic-bezier(0.32, 0.72, 0, 1)`;
35127
+ shell.style.width = `${target}px`;
35128
+ },
35129
+ [animationDuration]
35130
+ );
35114
35131
  react.useEffect(() => {
35115
35132
  if (reactNative.Platform.OS !== "web") return void 0;
35116
35133
  if (closeTimeoutRef.current) {
@@ -35119,12 +35136,10 @@ var Drawer = react.forwardRef(function Drawer2({
35119
35136
  }
35120
35137
  if (open) {
35121
35138
  setMounted(true);
35122
- const frame = requestAnimationFrame(() => {
35123
- requestAnimationFrame(() => setEntered(true));
35124
- });
35125
- return () => cancelAnimationFrame(frame);
35139
+ return void 0;
35126
35140
  }
35127
35141
  setEntered(false);
35142
+ playWidth(0);
35128
35143
  closeTimeoutRef.current = setTimeout(() => {
35129
35144
  setMounted(false);
35130
35145
  closeTimeoutRef.current = null;
@@ -35135,7 +35150,22 @@ var Drawer = react.forwardRef(function Drawer2({
35135
35150
  closeTimeoutRef.current = null;
35136
35151
  }
35137
35152
  };
35138
- }, [open, animationDuration]);
35153
+ }, [open, animationDuration, playWidth]);
35154
+ react.useEffect(() => {
35155
+ if (reactNative.Platform.OS !== "web" || !mounted || !open) return void 0;
35156
+ const shell = shellRef.current;
35157
+ if (shell) {
35158
+ shell.style.transition = "none";
35159
+ shell.style.width = "0px";
35160
+ }
35161
+ const frame = requestAnimationFrame(() => {
35162
+ requestAnimationFrame(() => {
35163
+ setEntered(true);
35164
+ playWidth(targetWidth);
35165
+ });
35166
+ });
35167
+ return () => cancelAnimationFrame(frame);
35168
+ }, [mounted, open, targetWidth, playWidth]);
35139
35169
  react.useEffect(() => {
35140
35170
  if (reactNative.Platform.OS === "web") return void 0;
35141
35171
  if (open) {
@@ -35262,16 +35292,16 @@ var Drawer = react.forwardRef(function Drawer2({
35262
35292
  /* @__PURE__ */ jsxRuntime.jsx(
35263
35293
  "div",
35264
35294
  {
35295
+ ref: shellRef,
35265
35296
  onTransitionEnd: handleWebTransitionEnd,
35266
35297
  style: {
35267
35298
  position: "relative",
35268
35299
  zIndex: 1,
35269
35300
  height: "100%",
35270
- width: entered ? Math.min(width, typeof window !== "undefined" ? window.innerWidth : width) : 0,
35301
+ flex: "0 0 auto",
35271
35302
  minWidth: 0,
35272
35303
  maxWidth: "100%",
35273
35304
  overflow: "hidden",
35274
- transition: `width ${animationDuration}ms cubic-bezier(0.32, 0.72, 0, 1)`,
35275
35305
  willChange: "width",
35276
35306
  boxSizing: "border-box"
35277
35307
  },
@@ -35279,10 +35309,12 @@ var Drawer = react.forwardRef(function Drawer2({
35279
35309
  "div",
35280
35310
  {
35281
35311
  style: {
35282
- width,
35312
+ position: "absolute",
35313
+ top: 0,
35314
+ right: 0,
35315
+ bottom: 0,
35316
+ width: targetWidth,
35283
35317
  maxWidth: "100%",
35284
- height: "100%",
35285
- marginLeft: "auto",
35286
35318
  display: "flex",
35287
35319
  flexDirection: "column"
35288
35320
  },
@@ -35860,11 +35892,14 @@ var styles31 = reactNative.StyleSheet.create({
35860
35892
  borderColor: colors.grey700,
35861
35893
  borderRadius: 16,
35862
35894
  backgroundColor: colors.grey700,
35863
- shadowColor: colors.black,
35864
- shadowOffset: { width: 0, height: 8 },
35865
- shadowOpacity: 0.4,
35866
- shadowRadius: 18,
35867
- elevation: 12
35895
+ ...reactNative.Platform.select({
35896
+ web: {
35897
+ boxShadow: `0 8px 18px ${colors.black}66`
35898
+ },
35899
+ default: {
35900
+ elevation: 12
35901
+ }
35902
+ })
35868
35903
  },
35869
35904
  list: {
35870
35905
  maxHeight: MENU_MAX_HEIGHT