motile-ui 1.0.4 → 1.1.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.
@@ -1,15 +1,15 @@
1
1
  import { jsx as u, jsxs as $ } from "react/jsx-runtime";
2
- import { useCallback as v, useState as S, useEffect as k, useId as F, useRef as x, useMemo as A, createContext as T, useContext as w } from "react";
3
- import { createPortal as K } from "react-dom";
2
+ import { useCallback as b, useState as S, useEffect as v, useId as A, useRef as x, useMemo as F, createContext as N, useContext as T } from "react";
3
+ import { createPortal as w } from "react-dom";
4
4
  import { Slot as g } from "../../utils/Slot.js";
5
- import { useScrollLock as N } from "../../hooks/useScrollLock.js";
5
+ import { useScrollLock as K } from "../../hooks/useScrollLock.js";
6
6
  import { useClickOutside as H } from "../../hooks/useClickOutside.js";
7
7
  import { useEscapeKey as V } from "../../hooks/useEscapeKey.js";
8
8
  import { useHistoryClose as q } from "../../hooks/useHistoryClose.js";
9
9
  import './Sheet.css';/* empty css */
10
- const I = T(null);
11
- function _() {
12
- const e = w(I);
10
+ const I = N(null);
11
+ function k() {
12
+ const e = T(I);
13
13
  if (!e)
14
14
  throw new Error("Sheet components must be used within Sheet.Root");
15
15
  return e;
@@ -19,7 +19,7 @@ function z({
19
19
  defaultValue: n = !1,
20
20
  onChange: o
21
21
  }) {
22
- const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l = v(
22
+ const t = e !== void 0, [i, a] = S(n), s = t ? e : i, l = b(
23
23
  (r) => {
24
24
  const f = typeof r == "function" ? r(s) : r;
25
25
  t || a(f), o == null || o(f);
@@ -38,14 +38,14 @@ function B({
38
38
  defaultOpen: s = !1,
39
39
  onOpenChange: l
40
40
  }) {
41
- const r = F().replace(/:/g, ""), f = x(null), h = x(null), [d, c] = z({
41
+ const r = A().replace(/:/g, ""), f = x(null), h = x(null), [d, c] = z({
42
42
  value: a,
43
43
  defaultValue: s,
44
44
  onChange: l
45
45
  }), { isClosingFromHistory: p, navigateAndClose: y } = q({
46
46
  isOpen: d,
47
47
  onClose: () => c(!1)
48
- }), m = A(
48
+ }), m = F(
49
49
  () => ({
50
50
  open: d,
51
51
  setOpen: c,
@@ -79,7 +79,7 @@ function B({
79
79
  return /* @__PURE__ */ u(I.Provider, { value: m, children: e });
80
80
  }
81
81
  function P({ children: e, asChild: n = !1 }) {
82
- const { open: o, setOpen: t, triggerId: i, contentId: a } = _(), s = v(() => {
82
+ const { open: o, setOpen: t, triggerId: i, contentId: a } = k(), s = b(() => {
83
83
  t((l) => !l);
84
84
  }, [t]);
85
85
  return n ? /* @__PURE__ */ u(
@@ -104,17 +104,17 @@ function P({ children: e, asChild: n = !1 }) {
104
104
  );
105
105
  }
106
106
  function j({ children: e, container: n }) {
107
- const { open: o } = _(), [t, i] = S(!1);
108
- return k(() => {
107
+ const { open: o } = k(), [t, i] = S(!1);
108
+ return v(() => {
109
109
  i(!0);
110
- }, []), !t || !o ? null : K(e, n || document.body);
110
+ }, []), !t || !o ? null : w(e, n || document.body);
111
111
  }
112
112
  function E({ className: e = "", style: n }) {
113
- const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } = _(), [r, f] = S(!1), [h, d] = S(!1), c = typeof a == "boolean" ? { clickOutside: a } : {
113
+ const { open: o, setOpen: t, position: i, closeOnBackdrop: a, zIndex: s, overlayRef: l } = k(), [r, f] = S(!1), [h, d] = S(!1), c = typeof a == "boolean" ? { clickOutside: a } : {
114
114
  escapeKey: a.escapeKey ?? !1,
115
115
  clickOutside: a.clickOutside ?? !1
116
116
  };
117
- k(() => {
117
+ v(() => {
118
118
  if (o)
119
119
  f(!0);
120
120
  else if (r) {
@@ -124,17 +124,17 @@ function E({ className: e = "", style: n }) {
124
124
  }, 300);
125
125
  return () => clearTimeout(m);
126
126
  }
127
- }, [o, r]), k(() => {
127
+ }, [o, r]), v(() => {
128
128
  if (!r || !o) return;
129
129
  const m = requestAnimationFrame(() => {
130
- const b = requestAnimationFrame(() => {
130
+ const _ = requestAnimationFrame(() => {
131
131
  d(!0);
132
132
  });
133
- return () => cancelAnimationFrame(b);
133
+ return () => cancelAnimationFrame(_);
134
134
  });
135
135
  return () => cancelAnimationFrame(m);
136
136
  }, [r, o]);
137
- const p = v(
137
+ const p = b(
138
138
  (m) => {
139
139
  c.clickOutside && m.target === l.current && t(!1);
140
140
  },
@@ -168,21 +168,21 @@ function L({ children: e, className: n = "", style: o }) {
168
168
  contentId: f,
169
169
  sheetRef: h,
170
170
  isClosingFromHistory: d
171
- } = _(), [c, p] = S(!1), [y, m] = S(!1), b = typeof s == "boolean" ? { escapeKey: s, clickOutside: s } : {
171
+ } = k(), [c, p] = S(!1), [y, m] = S(!1), _ = typeof s == "boolean" ? { escapeKey: s, clickOutside: s } : {
172
172
  escapeKey: s.escapeKey ?? !1,
173
173
  clickOutside: s.clickOutside ?? !1
174
174
  };
175
- if (N({
175
+ if (K({
176
176
  enabled: t,
177
177
  allowedSelectors: [".motile-sheet__body"]
178
178
  }), H({
179
179
  refs: [h],
180
180
  handler: () => i(!1),
181
- enabled: t && b.clickOutside
181
+ enabled: t && _.clickOutside
182
182
  }), V({
183
183
  handler: () => i(!1),
184
- enabled: t && b.escapeKey
185
- }), k(() => {
184
+ enabled: t && _.escapeKey
185
+ }), v(() => {
186
186
  if (t)
187
187
  p(!0);
188
188
  else if (c) {
@@ -192,7 +192,7 @@ function L({ children: e, className: n = "", style: o }) {
192
192
  }, d ? 0 : 300);
193
193
  return () => clearTimeout(C);
194
194
  }
195
- }, [t, c, d]), k(() => {
195
+ }, [t, c, d]), v(() => {
196
196
  if (!c || !t || d) return;
197
197
  const O = requestAnimationFrame(() => {
198
198
  const C = requestAnimationFrame(() => {
@@ -231,7 +231,7 @@ function W({ children: e, className: n = "" }) {
231
231
  return /* @__PURE__ */ u("div", { className: `motile-sheet__body ${n}`, children: e });
232
232
  }
233
233
  function G({ children: e, asChild: n = !1 }) {
234
- const { setOpen: o } = _(), t = v(() => {
234
+ const { setOpen: o } = k(), t = b(() => {
235
235
  o(!1);
236
236
  }, [o]);
237
237
  return n ? /* @__PURE__ */ u(
@@ -269,7 +269,11 @@ function G({ children: e, asChild: n = !1 }) {
269
269
  }
270
270
  );
271
271
  }
272
- const ne = {
272
+ function ne() {
273
+ const { navigateAndClose: e } = k();
274
+ return e;
275
+ }
276
+ const se = {
273
277
  Root: B,
274
278
  Trigger: P,
275
279
  Portal: j,
@@ -281,5 +285,6 @@ const ne = {
281
285
  Close: G
282
286
  };
283
287
  export {
284
- ne as Sheet
288
+ se as Sheet,
289
+ ne as useSheetNavigation
285
290
  };
@@ -0,0 +1 @@
1
+ export { useSheetNavigation } from './Sheet';
@@ -0,0 +1,4 @@
1
+ import { useSheetNavigation as t } from "./Sheet.js";
2
+ export {
3
+ t as useSheetNavigation
4
+ };
@@ -0,0 +1,5 @@
1
+ export { useScrollLock } from './useScrollLock';
2
+ export { useClickOutside } from './useClickOutside';
3
+ export type { UseClickOutsideOptions } from './useClickOutside';
4
+ export { useEscapeKey } from './useEscapeKey';
5
+ export type { UseEscapeKeyOptions } from './useEscapeKey';
@@ -0,0 +1,8 @@
1
+ import { useScrollLock as r } from "./useScrollLock.js";
2
+ import { useClickOutside as c } from "./useClickOutside.js";
3
+ import { useEscapeKey as t } from "./useEscapeKey.js";
4
+ export {
5
+ c as useClickOutside,
6
+ t as useEscapeKey,
7
+ r as useScrollLock
8
+ };
package/dist/index.d.ts CHANGED
@@ -30,8 +30,3 @@ export { Dock } from './components/Dock';
30
30
  export type { DockRootProps, DockItemProps, DockSeparatorProps, DockPosition, } from './components/Dock';
31
31
  export { SpeedDial } from './components/SpeedDial';
32
32
  export type { SpeedDialDirection, SpeedDialRootProps, SpeedDialTriggerProps, SpeedDialActionsProps, SpeedDialActionProps, } from './components/SpeedDial';
33
- export { useScrollLock } from './hooks/useScrollLock';
34
- export { useClickOutside } from './hooks/useClickOutside';
35
- export type { UseClickOutsideOptions } from './hooks/useClickOutside';
36
- export { useEscapeKey } from './hooks/useEscapeKey';
37
- export type { UseEscapeKeyOptions } from './hooks/useEscapeKey';
package/dist/index.js CHANGED
@@ -1,42 +1,36 @@
1
- import { useScrollLock as e } from "./hooks/useScrollLock.js";
2
- import { useClickOutside as p } from "./hooks/useClickOutside.js";
3
- import { useEscapeKey as f } from "./hooks/useEscapeKey.js";
4
- import { Button as a } from "./components/Button/Button.js";
5
- import { Input as s } from "./components/Input/Input.js";
6
- import { Textarea as l } from "./components/Textarea/Textarea.js";
7
- import { Checkbox as d } from "./components/Checkbox/Checkbox.js";
8
- import { Switch as S } from "./components/Switch/Switch.js";
9
- import { Accordion as T } from "./components/Accordion/Accordion.js";
10
- import { Skeleton as D } from "./components/Skeleton/Skeleton.js";
11
- import { Badge as w } from "./components/Badge/Badge.js";
12
- import { Tooltip as C } from "./components/Tooltip/Tooltip.js";
13
- import { Popover as b } from "./components/Popover/Popover.js";
14
- import { Drawer as y } from "./components/Drawer/Drawer.js";
15
- import { Sheet as E } from "./components/Sheet/Sheet.js";
16
- import { Modal as K } from "./components/Modal/Modal.js";
17
- import { ToastProvider as M } from "./components/Toast/Toast.js";
18
- import { useToast as j } from "./components/Toast/useToast.js";
19
- import { Dock as z } from "./components/Dock/Dock.js";
20
- import { SpeedDial as G } from "./components/SpeedDial/SpeedDial.js";
1
+ import { Button as e } from "./components/Button/Button.js";
2
+ import { Input as p } from "./components/Input/Input.js";
3
+ import { Textarea as f } from "./components/Textarea/Textarea.js";
4
+ import { Checkbox as a } from "./components/Checkbox/Checkbox.js";
5
+ import { Switch as d } from "./components/Switch/Switch.js";
6
+ import { Accordion as l } from "./components/Accordion/Accordion.js";
7
+ import { Skeleton as S } from "./components/Skeleton/Skeleton.js";
8
+ import { Badge as h } from "./components/Badge/Badge.js";
9
+ import { Tooltip as s } from "./components/Tooltip/Tooltip.js";
10
+ import { Popover as D } from "./components/Popover/Popover.js";
11
+ import { Drawer as w } from "./components/Drawer/Drawer.js";
12
+ import { Sheet as P } from "./components/Sheet/Sheet.js";
13
+ import { Modal as g } from "./components/Modal/Modal.js";
14
+ import { ToastProvider as C } from "./components/Toast/Toast.js";
15
+ import { useToast as M } from "./components/Toast/useToast.js";
16
+ import { Dock as q } from "./components/Dock/Dock.js";
17
+ import { SpeedDial as z } from "./components/SpeedDial/SpeedDial.js";
21
18
  export {
22
- T as Accordion,
23
- w as Badge,
24
- a as Button,
25
- d as Checkbox,
26
- z as Dock,
27
- y as Drawer,
28
- s as Input,
29
- K as Modal,
30
- b as Popover,
31
- E as Sheet,
32
- D as Skeleton,
33
- G as SpeedDial,
34
- S as Switch,
35
- l as Textarea,
36
- M as ToastProvider,
37
- C as Tooltip,
38
- p as useClickOutside,
39
- f as useEscapeKey,
40
- e as useScrollLock,
41
- j as useToast
19
+ l as Accordion,
20
+ h as Badge,
21
+ e as Button,
22
+ a as Checkbox,
23
+ q as Dock,
24
+ w as Drawer,
25
+ p as Input,
26
+ g as Modal,
27
+ D as Popover,
28
+ P as Sheet,
29
+ S as Skeleton,
30
+ z as SpeedDial,
31
+ d as Switch,
32
+ f as Textarea,
33
+ C as ToastProvider,
34
+ s as Tooltip,
35
+ M as useToast
42
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motile-ui",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "description": "A modern React component library for webview applications",
6
6
  "main": "./dist/index.js",
@@ -48,8 +48,8 @@
48
48
  "import": "./dist/components/Popover/Popover.js"
49
49
  },
50
50
  "./Sheet": {
51
- "types": "./dist/components/Sheet/Sheet.d.ts",
52
- "import": "./dist/components/Sheet/Sheet.js"
51
+ "types": "./dist/components/Sheet/useSheetNavigation.d.ts",
52
+ "import": "./dist/components/Sheet/useSheetNavigation.js"
53
53
  },
54
54
  "./Skeleton": {
55
55
  "types": "./dist/components/Skeleton/Skeleton.d.ts",
@@ -83,17 +83,9 @@
83
83
  "types": "./dist/components/Toast/useToast.d.ts",
84
84
  "import": "./dist/components/Toast/useToast.js"
85
85
  },
86
- "./useScrollLock": {
87
- "types": "./dist/hooks/useScrollLock.d.ts",
88
- "import": "./dist/hooks/useScrollLock.js"
89
- },
90
- "./useClickOutside": {
91
- "types": "./dist/hooks/useClickOutside.d.ts",
92
- "import": "./dist/hooks/useClickOutside.js"
93
- },
94
- "./useEscapeKey": {
95
- "types": "./dist/hooks/useEscapeKey.d.ts",
96
- "import": "./dist/hooks/useEscapeKey.js"
86
+ "./hooks": {
87
+ "types": "./dist/hooks/index.d.ts",
88
+ "import": "./dist/hooks/index.js"
97
89
  }
98
90
  },
99
91
  "files": [