@reforma/components 0.3.3 → 0.4.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.
Files changed (91) hide show
  1. package/dist/Composer/parts.d.ts +1 -1
  2. package/dist/Composer/parts.d.ts.map +1 -1
  3. package/dist/Composer/parts.js +102 -98
  4. package/dist/Composer/parts.js.map +1 -1
  5. package/dist/Composer/reforma/Composer.module.css +1 -1
  6. package/dist/Composer/reforma/Composer.module.css.js +24 -22
  7. package/dist/Composer/reforma/Composer.module.css.js.map +1 -1
  8. package/dist/Composer/types.d.ts +1 -1
  9. package/dist/Composer/types.d.ts.map +1 -1
  10. package/dist/Modal/Modal.d.ts +2 -2
  11. package/dist/Modal/Modal.d.ts.map +1 -1
  12. package/dist/Modal/Modal.js +6 -3
  13. package/dist/Modal/Modal.js.map +1 -1
  14. package/dist/SettingsLayout/SettingsLayout.d.ts +1 -0
  15. package/dist/SettingsLayout/SettingsLayout.d.ts.map +1 -1
  16. package/dist/SettingsLayout/SettingsLayout.js +332 -292
  17. package/dist/SettingsLayout/SettingsLayout.js.map +1 -1
  18. package/dist/SettingsLayout/SettingsLayout.module.css +1 -1
  19. package/dist/SettingsLayout/SettingsLayout.module.css.js +20 -18
  20. package/dist/SettingsLayout/SettingsLayout.module.css.js.map +1 -1
  21. package/dist/chat/Attachment/Attachment.d.ts.map +1 -1
  22. package/dist/chat/Attachment/Attachment.js +14 -16
  23. package/dist/chat/Attachment/Attachment.js.map +1 -1
  24. package/dist/chat/Attachment/Attachment.module.css +1 -1
  25. package/dist/chat/Tool/Tool.d.ts.map +1 -1
  26. package/dist/chat/Tool/Tool.js +77 -75
  27. package/dist/chat/Tool/Tool.js.map +1 -1
  28. package/dist/chat/Tool/agent/AgentTool.d.ts.map +1 -1
  29. package/dist/chat/Tool/agent/AgentTool.js +18 -17
  30. package/dist/chat/Tool/agent/AgentTool.js.map +1 -1
  31. package/dist/chat/Tool/check-page/CheckPageTool.d.ts +4 -0
  32. package/dist/chat/Tool/check-page/CheckPageTool.d.ts.map +1 -0
  33. package/dist/chat/Tool/check-page/CheckPageTool.js +75 -0
  34. package/dist/chat/Tool/check-page/CheckPageTool.js.map +1 -0
  35. package/dist/chat/Tool/check-page/index.d.ts +2 -0
  36. package/dist/chat/Tool/check-page/index.d.ts.map +1 -0
  37. package/dist/chat/Tool/check-page/index.js +5 -0
  38. package/dist/chat/Tool/check-page/index.js.map +1 -0
  39. package/dist/index.js +156 -155
  40. package/dist/modals/ConfirmModal.d.ts +2 -0
  41. package/dist/modals/ConfirmModal.d.ts.map +1 -1
  42. package/dist/modals/ConfirmModal.js +88 -60
  43. package/dist/modals/ConfirmModal.js.map +1 -1
  44. package/dist/modals/index.d.ts +1 -1
  45. package/dist/modals/index.d.ts.map +1 -1
  46. package/dist/modals/index.js +2 -1
  47. package/dist/openui/functions/index.d.ts +59 -59
  48. package/dist/openui/functions/index.d.ts.map +1 -1
  49. package/package.json +3 -3
  50. package/dist/node_modules/clsx/dist/clsx.js +0 -18
  51. package/dist/node_modules/clsx/dist/clsx.js.map +0 -1
  52. package/dist/node_modules/react-aria/dist/private/interactions/useFocusable.js +0 -17
  53. package/dist/node_modules/react-aria/dist/private/interactions/useFocusable.js.map +0 -1
  54. package/dist/node_modules/react-aria/dist/private/utils/useObjectRef.js +0 -34
  55. package/dist/node_modules/react-aria/dist/private/utils/useObjectRef.js.map +0 -1
  56. package/dist/node_modules/zod/v4/classic/errors.js +0 -38
  57. package/dist/node_modules/zod/v4/classic/errors.js.map +0 -1
  58. package/dist/node_modules/zod/v4/classic/parse.js +0 -21
  59. package/dist/node_modules/zod/v4/classic/parse.js.map +0 -1
  60. package/dist/node_modules/zod/v4/classic/schemas.js +0 -822
  61. package/dist/node_modules/zod/v4/classic/schemas.js.map +0 -1
  62. package/dist/node_modules/zod/v4/core/api.js +0 -561
  63. package/dist/node_modules/zod/v4/core/api.js.map +0 -1
  64. package/dist/node_modules/zod/v4/core/checks.js +0 -262
  65. package/dist/node_modules/zod/v4/core/checks.js.map +0 -1
  66. package/dist/node_modules/zod/v4/core/core.js +0 -97
  67. package/dist/node_modules/zod/v4/core/core.js.map +0 -1
  68. package/dist/node_modules/zod/v4/core/doc.js +0 -35
  69. package/dist/node_modules/zod/v4/core/doc.js.map +0 -1
  70. package/dist/node_modules/zod/v4/core/errors.js +0 -79
  71. package/dist/node_modules/zod/v4/core/errors.js.map +0 -1
  72. package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -308
  73. package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +0 -1
  74. package/dist/node_modules/zod/v4/core/memoizer.js +0 -203
  75. package/dist/node_modules/zod/v4/core/memoizer.js.map +0 -1
  76. package/dist/node_modules/zod/v4/core/parse.js +0 -113
  77. package/dist/node_modules/zod/v4/core/parse.js.map +0 -1
  78. package/dist/node_modules/zod/v4/core/regexes.js +0 -59
  79. package/dist/node_modules/zod/v4/core/regexes.js.map +0 -1
  80. package/dist/node_modules/zod/v4/core/registries.js +0 -41
  81. package/dist/node_modules/zod/v4/core/registries.js.map +0 -1
  82. package/dist/node_modules/zod/v4/core/schemas.js +0 -1104
  83. package/dist/node_modules/zod/v4/core/schemas.js.map +0 -1
  84. package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -380
  85. package/dist/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
  86. package/dist/node_modules/zod/v4/core/util.js +0 -465
  87. package/dist/node_modules/zod/v4/core/util.js.map +0 -1
  88. package/dist/node_modules/zod/v4/core/versions.js +0 -9
  89. package/dist/node_modules/zod/v4/core/versions.js.map +0 -1
  90. package/dist/node_modules/zod/v4/locales/en.js +0 -97
  91. package/dist/node_modules/zod/v4/locales/en.js.map +0 -1
@@ -1,254 +1,281 @@
1
- import { MOTION_EASE_UI as B } from "@reforma/constants";
2
- import { cn as g } from "@reforma/lib";
3
- import { useReducedMotion as I, AnimatePresence as V, motion as A } from "motion/react";
4
- import { use as T, useState as h, createContext as P, useRef as D, useCallback as _, useEffect as M, useMemo as z } from "react";
5
- import { createPortal as nt } from "react-dom";
6
- import { Box as it } from "../Box/Box.js";
7
- import { Breadcrumb as b } from "../Breadcrumb/Breadcrumb.js";
8
- import { Button as E } from "../Button/Button.js";
9
- import { For as H } from "../For/For.js";
10
- import { tooltipWithHotkey as ot } from "../Hotkey/Hotkey.js";
11
- import { ListBox as st, ListBoxItem as rt } from "../List/ListBox.js";
12
- import { Scrollable as at } from "../Scrollable/Scrollable.js";
13
- import { Show as R } from "../Show/Show.js";
14
- import { Text as ct } from "../Text/Text.js";
15
- import { toast as lt } from "../Toast/Toast.js";
16
- import c from "./SettingsLayout.module.css.js";
17
- import { jsx as e, jsxs as w } from "react/jsx-runtime";
18
- const K = A.create(at), U = 0.35, j = 32, dt = -12, ut = ["mod", "s"];
19
- function mt(t) {
20
- return !(t.metaKey || t.ctrlKey) || t.altKey || t.shiftKey ? !1 : t.key === "s" || t.key === "S";
1
+ import { MOTION_EASE_UI as ne } from "@reforma/constants";
2
+ import { AttentionCircle as re } from "@reforma/icons/14";
3
+ import { cn as N } from "@reforma/lib";
4
+ import { useReducedMotion as M, AnimatePresence as ie, motion as oe } from "motion/react";
5
+ import { use as w, useState as y, useRef as E, createContext as I, useCallback as k, useEffect as C, useMemo as j } from "react";
6
+ import { createPortal as se } from "react-dom";
7
+ import { Alert as ae, AlertIcon as ce, AlertTitle as le, AlertAction as de } from "../Alert/Alert.js";
8
+ import { Box as B } from "../Box/Box.js";
9
+ import { Breadcrumb as A } from "../Breadcrumb/Breadcrumb.js";
10
+ import { Button as O } from "../Button/Button.js";
11
+ import { For as V } from "../For/For.js";
12
+ import { tooltipWithHotkey as ue } from "../Hotkey/Hotkey.js";
13
+ import { ListBox as fe, ListBoxItem as me } from "../List/ListBox.js";
14
+ import { ModalContext as ve } from "../Modal/hooks/useModalProvider.js";
15
+ import { confirmDiscardChanges as ge } from "../modals/ConfirmModal.js";
16
+ import { Scrollable as he } from "../Scrollable/Scrollable.js";
17
+ import { Show as _ } from "../Show/Show.js";
18
+ import { Text as ye } from "../Text/Text.js";
19
+ import { toast as pe } from "../Toast/Toast.js";
20
+ import l from "./SettingsLayout.module.css.js";
21
+ import { jsx as t, jsxs as p } from "react/jsx-runtime";
22
+ const H = oe.create(he), K = 0.35, R = 32, Se = -12, be = ["mod", "s"];
23
+ function Ne(e) {
24
+ return !(e.metaKey || e.ctrlKey) || e.altKey || e.shiftKey ? !1 : e.key === "s" || e.key === "S";
21
25
  }
22
- function Y(t) {
26
+ function U(e) {
23
27
  return {
24
- duration: t ? 0 : U,
25
- ease: B
28
+ duration: e ? 0 : K,
29
+ ease: ne
26
30
  };
27
31
  }
28
- function yt(t) {
32
+ function we(e) {
29
33
  return {
30
- duration: t ? 0 : U,
34
+ duration: e ? 0 : K,
31
35
  ease: "easeOut"
32
36
  };
33
37
  }
34
- function F(t, s) {
38
+ function Y(e, r) {
35
39
  return {
36
- opacity: t ? 0 : 1,
37
- x: t && !s ? dt : 0,
40
+ opacity: e ? 0 : 1,
41
+ x: e && !r ? Se : 0,
38
42
  y: 0
39
43
  };
40
44
  }
41
- const W = /* @__PURE__ */ P(null), q = /* @__PURE__ */ P(null);
42
- function x() {
43
- const t = T(W);
44
- if (!t)
45
+ const z = /* @__PURE__ */ I(null), G = /* @__PURE__ */ I(null), F = /* @__PURE__ */ I(null);
46
+ function P(e, r) {
47
+ if (e === !0) {
48
+ r();
49
+ return;
50
+ }
51
+ e !== !1 && e.then((a) => {
52
+ a && r();
53
+ });
54
+ }
55
+ function L() {
56
+ const e = w(z);
57
+ if (!e)
45
58
  throw new Error("useSettingsLayout must be used inside SettingsLayout");
46
- return t;
59
+ return e;
47
60
  }
48
- const G = /* @__PURE__ */ P(null);
49
- function Rt() {
50
- const t = T(G);
51
- if (!t)
61
+ const W = /* @__PURE__ */ I(null);
62
+ function Xe() {
63
+ const e = w(W);
64
+ if (!e)
52
65
  throw new Error("useSettingsSave must be used inside SettingsLayout.Content with saveable prop");
53
- return t;
66
+ return e;
54
67
  }
55
- function J({
56
- items: t,
57
- defaultSelected: s,
58
- defaultStack: l,
59
- className: r,
60
- children: i
68
+ function q({
69
+ items: e,
70
+ defaultSelected: r,
71
+ defaultStack: a,
72
+ className: c,
73
+ children: s
61
74
  }) {
62
- const [o, a] = h(s ?? t[0]?.id ?? ""), [n, d] = h(() => l ? [...l] : []);
63
- return /* @__PURE__ */ e(W, {
64
- value: {
65
- items: t,
66
- selectedId: o,
67
- select: (u) => {
68
- u !== o && a(u), d([]);
75
+ const [i, d] = y(r ?? e[0]?.id ?? ""), [n, o] = y(() => a ? [...a] : []), u = E(null);
76
+ return /* @__PURE__ */ t(F, {
77
+ value: u,
78
+ children: /* @__PURE__ */ t(z, {
79
+ value: {
80
+ items: e,
81
+ selectedId: i,
82
+ select: (f) => {
83
+ const m = f !== i, b = n.length > 0;
84
+ !m && !b || P(u.current?.() ?? !0, () => {
85
+ m && d(f), o([]);
86
+ });
87
+ },
88
+ stack: n,
89
+ push: (f) => o((m) => [...m, f]),
90
+ rename: (f, m) => o((b) => b.map((v) => v.id === f && v.label !== m ? {
91
+ ...v,
92
+ label: m
93
+ } : v)),
94
+ pop: () => {
95
+ n.length !== 0 && P(u.current?.() ?? !0, () => {
96
+ o((f) => f.slice(0, -1));
97
+ });
98
+ },
99
+ reset: () => {
100
+ n.length !== 0 && P(u.current?.() ?? !0, () => {
101
+ o([]);
102
+ });
103
+ }
69
104
  },
70
- stack: n,
71
- push: (u) => d((y) => [...y, u]),
72
- rename: (u, y) => d((L) => L.map((f) => f.id === u && f.label !== y ? {
73
- ...f,
74
- label: y
75
- } : f)),
76
- pop: () => d((u) => u.slice(0, -1)),
77
- reset: () => d([])
78
- },
79
- children: /* @__PURE__ */ e("div", {
80
- className: g(c.root, r),
81
- children: i
105
+ children: /* @__PURE__ */ t("div", {
106
+ className: N(l.root, c),
107
+ children: s
108
+ })
82
109
  })
83
110
  });
84
111
  }
85
- function Q({
86
- title: t,
87
- className: s,
88
- "aria-label": l = "Settings sections",
89
- footer: r
112
+ function J({
113
+ title: e,
114
+ className: r,
115
+ "aria-label": a = "Settings sections",
116
+ footer: c
90
117
  }) {
91
118
  const {
92
- items: i,
93
- selectedId: o,
94
- select: a
95
- } = x();
96
- return /* @__PURE__ */ w("div", {
97
- className: g(c.sidebar, s),
98
- children: [/* @__PURE__ */ e(R, {
99
- when: t,
100
- children: /* @__PURE__ */ e(ct, {
119
+ items: s,
120
+ selectedId: i,
121
+ select: d
122
+ } = L();
123
+ return /* @__PURE__ */ p("div", {
124
+ className: N(l.sidebar, r),
125
+ children: [/* @__PURE__ */ t(_, {
126
+ when: e,
127
+ children: /* @__PURE__ */ t(ye, {
101
128
  variant: "sm",
102
129
  color: "secondary",
103
- className: c.sidebarTitle,
104
- children: t
130
+ className: l.sidebarTitle,
131
+ children: e
105
132
  })
106
- }), /* @__PURE__ */ e(st, {
107
- "aria-label": l,
133
+ }), /* @__PURE__ */ t(fe, {
134
+ "aria-label": a,
108
135
  size: "md",
109
136
  selectionMode: "single",
110
- selectedKeys: [o],
137
+ selectedKeys: [i],
111
138
  disallowEmptySelection: !0,
112
- children: /* @__PURE__ */ e(H, {
113
- each: i,
114
- children: (n) => /* @__PURE__ */ e(rt, {
139
+ children: /* @__PURE__ */ t(V, {
140
+ each: s,
141
+ children: (n) => /* @__PURE__ */ t(me, {
115
142
  id: n.id,
116
143
  icon: n.icon,
117
144
  textValue: n.label,
118
- onPress: () => a(n.id),
145
+ onPress: () => d(n.id),
119
146
  children: n.label
120
147
  }, n.id)
121
148
  })
122
- }), /* @__PURE__ */ e(R, {
123
- when: r,
124
- children: /* @__PURE__ */ e("div", {
125
- className: c.sidebarFooter,
126
- children: r
149
+ }), /* @__PURE__ */ t(_, {
150
+ when: c,
151
+ children: /* @__PURE__ */ t("div", {
152
+ className: l.sidebarFooter,
153
+ children: c
127
154
  })
128
155
  })]
129
156
  });
130
157
  }
131
- function ft() {
158
+ function Le() {
132
159
  const {
133
- items: t,
134
- selectedId: s,
135
- stack: l,
136
- reset: r
137
- } = x(), i = t.find((o) => o.id === s)?.label ?? "";
138
- return /* @__PURE__ */ w(b, {
160
+ items: e,
161
+ selectedId: r,
162
+ stack: a,
163
+ reset: c
164
+ } = L(), s = e.find((i) => i.id === r)?.label ?? "";
165
+ return /* @__PURE__ */ p(A, {
139
166
  variant: "heading-2",
140
- className: c.title,
141
- children: [l.length === 0 ? /* @__PURE__ */ e(b.Page, {
142
- children: i
143
- }, "root") : /* @__PURE__ */ e(b.Link, {
144
- onPress: r,
145
- children: i
146
- }, "root"), /* @__PURE__ */ e(H, {
147
- each: l,
148
- children: (o) => /* @__PURE__ */ e(b.Page, {
149
- children: o.label
150
- }, o.id)
167
+ className: l.title,
168
+ children: [a.length === 0 ? /* @__PURE__ */ t(A.Page, {
169
+ children: s
170
+ }, "root") : /* @__PURE__ */ t(A.Link, {
171
+ onPress: c,
172
+ children: s
173
+ }, "root"), /* @__PURE__ */ t(V, {
174
+ each: a,
175
+ children: (i) => /* @__PURE__ */ t(A.Page, {
176
+ children: i.label
177
+ }, i.id)
151
178
  })]
152
179
  });
153
180
  }
154
- function X({
155
- paneKey: t,
156
- className: s,
157
- children: l
181
+ function Q({
182
+ paneKey: e,
183
+ className: r,
184
+ children: a
158
185
  }) {
159
186
  const {
160
- stack: r
161
- } = x(), i = T(q), o = I(), a = t ? r.findIndex((d) => d.id === t) : -1, n = a >= 0 && a < r.length - 1;
162
- return i ? /* @__PURE__ */ nt(/* @__PURE__ */ e(V, {
187
+ stack: c
188
+ } = L(), s = w(G), i = M(), d = e ? c.findIndex((o) => o.id === e) : -1, n = d >= 0 && d < c.length - 1;
189
+ return s ? /* @__PURE__ */ se(/* @__PURE__ */ t(ie, {
163
190
  initial: !1,
164
- children: t ? /* @__PURE__ */ e(K, {
165
- className: g(c.overlay, s),
166
- contentClass: g(c.scrollContent, c.paneContent),
167
- initial: o ? !1 : {
191
+ children: e ? /* @__PURE__ */ t(H, {
192
+ className: N(l.overlay, r),
193
+ contentClass: N(l.scrollContent, l.paneContent),
194
+ initial: i ? !1 : {
168
195
  opacity: 0,
169
- x: j
196
+ x: R
170
197
  },
171
- animate: F(n, o),
172
- exit: o ? void 0 : {
198
+ animate: Y(n, i),
199
+ exit: i ? void 0 : {
173
200
  opacity: 0,
174
- x: j,
201
+ x: R,
175
202
  pointerEvents: "none"
176
203
  },
177
- transition: Y(o),
204
+ transition: U(i),
178
205
  inert: n,
179
- children: l
180
- }, t) : null
181
- }), i) : null;
206
+ children: a
207
+ }, e) : null
208
+ }), s) : null;
182
209
  }
183
- function Z({
184
- className: t,
185
- action: s,
186
- footer: l,
187
- children: r
210
+ function X({
211
+ className: e,
212
+ action: r,
213
+ footer: a,
214
+ children: c
188
215
  }) {
189
216
  const {
190
- selectedId: i,
191
- stack: o
192
- } = x(), [a, n] = h(null), d = I(), m = o.length > 0, u = z(() => F(m, d), [m, d]);
193
- return /* @__PURE__ */ e(q, {
194
- value: a,
195
- children: /* @__PURE__ */ w("div", {
196
- className: g(c.content, t),
197
- children: [/* @__PURE__ */ w("div", {
198
- className: c.header,
199
- children: [/* @__PURE__ */ e(ft, {}), s]
200
- }), /* @__PURE__ */ e("div", {
217
+ selectedId: s,
218
+ stack: i
219
+ } = L(), [d, n] = y(null), o = M(), u = i.length > 0, S = j(() => Y(u, o), [u, o]);
220
+ return /* @__PURE__ */ t(G, {
221
+ value: d,
222
+ children: /* @__PURE__ */ p("div", {
223
+ className: N(l.content, e),
224
+ children: [/* @__PURE__ */ p("div", {
225
+ className: l.header,
226
+ children: [/* @__PURE__ */ t(Le, {}), r]
227
+ }), /* @__PURE__ */ t("div", {
201
228
  ref: n,
202
- className: c.viewport,
203
- children: /* @__PURE__ */ e(K, {
204
- className: c.scroll,
205
- contentClass: c.scrollContent,
206
- initial: d ? !1 : {
229
+ className: l.viewport,
230
+ children: /* @__PURE__ */ t(H, {
231
+ className: l.scroll,
232
+ contentClass: l.scrollContent,
233
+ initial: o ? !1 : {
207
234
  opacity: 0.6,
208
235
  y: 8
209
236
  },
210
- animate: u,
211
- transition: m ? Y(d) : yt(d),
212
- inert: m,
213
- children: r
214
- }, i)
215
- }), l]
237
+ animate: S,
238
+ transition: u ? U(o) : we(o),
239
+ inert: u,
240
+ children: c
241
+ }, s)
242
+ }), a]
216
243
  })
217
244
  });
218
245
  }
219
- function $({
220
- children: t
246
+ function Z({
247
+ children: e
221
248
  }) {
222
- return /* @__PURE__ */ e(it, {
249
+ return /* @__PURE__ */ t(B, {
223
250
  align: "center",
224
251
  justify: "center",
225
252
  gap: "lg",
226
253
  grow: !0,
227
254
  fullWidth: !0,
228
255
  fullHeight: !0,
229
- children: t
256
+ children: e
230
257
  });
231
258
  }
232
- function tt({
233
- headerRight: t,
234
- footer: s,
235
- saveable: l,
236
- className: r,
237
- children: i
259
+ function $({
260
+ headerRight: e,
261
+ footer: r,
262
+ saveable: a,
263
+ className: c,
264
+ children: s
238
265
  }) {
239
- return l ? /* @__PURE__ */ e(St, {
240
- headerRight: t,
241
- footer: s,
242
- className: r,
243
- children: i
244
- }) : /* @__PURE__ */ e(Z, {
245
- className: r,
246
- action: t,
247
- footer: s,
248
- children: i
266
+ return a ? /* @__PURE__ */ t(Te, {
267
+ headerRight: e,
268
+ footer: r,
269
+ className: c,
270
+ children: s
271
+ }) : /* @__PURE__ */ t(X, {
272
+ className: c,
273
+ action: e,
274
+ footer: r,
275
+ children: s
249
276
  });
250
277
  }
251
- const vt = 1e3, pt = {
278
+ const xe = 1e3, Ce = {
252
279
  save: {
253
280
  dirty: "Save changes",
254
281
  saving: "Saving…",
@@ -262,139 +289,152 @@ const vt = 1e3, pt = {
262
289
  tooltip: "Add"
263
290
  }
264
291
  };
265
- function ht(t) {
266
- return typeof t == "object" ? {
267
- dirty: t.dirty,
268
- saving: t.saving,
269
- saved: t.saved,
270
- tooltip: t.tooltip ?? t.dirty
271
- } : pt[t];
292
+ function Ae(e) {
293
+ return typeof e == "object" ? {
294
+ dirty: e.dirty,
295
+ saving: e.saving,
296
+ saved: e.saved,
297
+ tooltip: e.tooltip ?? e.dirty
298
+ } : Ce[e];
299
+ }
300
+ function Ee(e, r) {
301
+ return e === "saving" ? r.saving : e === "saved" ? r.saved : "You have unsaved changes";
272
302
  }
273
- function St({
274
- headerRight: t,
275
- footer: s,
276
- className: l,
277
- children: r
303
+ function Ie({
304
+ state: e,
305
+ copy: r,
306
+ onSave: a,
307
+ onDiscard: c
308
+ }) {
309
+ const s = Ee(e, r);
310
+ return /* @__PURE__ */ t("div", {
311
+ className: l.saveEnter,
312
+ children: /* @__PURE__ */ t("div", {
313
+ className: l.saveClip,
314
+ children: /* @__PURE__ */ p(ae, {
315
+ children: [/* @__PURE__ */ t(ce, {
316
+ children: /* @__PURE__ */ t(re, {})
317
+ }), /* @__PURE__ */ t(le, {
318
+ children: s
319
+ }), e === "saved" ? null : /* @__PURE__ */ t(de, {
320
+ children: /* @__PURE__ */ p(B, {
321
+ direction: "row",
322
+ align: "center",
323
+ gap: "sm",
324
+ wrap: !1,
325
+ children: [/* @__PURE__ */ t(O, {
326
+ variant: "filling",
327
+ color: "secondary",
328
+ size: "sm",
329
+ isDisabled: e === "saving",
330
+ onPress: c,
331
+ children: "Discard"
332
+ }), /* @__PURE__ */ t(O, {
333
+ color: "primary",
334
+ size: "sm",
335
+ isDisabled: e === "saving",
336
+ tooltip: e === "dirty" ? ue(r.tooltip, be) : void 0,
337
+ onPress: a,
338
+ children: e === "saving" ? r.saving : r.dirty
339
+ })]
340
+ })
341
+ })]
342
+ })
343
+ })
344
+ });
345
+ }
346
+ function Te({
347
+ headerRight: e,
348
+ footer: r,
349
+ className: a,
350
+ children: c
278
351
  }) {
279
352
  const {
280
- selectedId: i
281
- } = x(), o = I(), [a, n] = h("idle"), [d, m] = h("save"), u = D(null), y = D(void 0), [L, f] = h(i);
282
- L !== i && (f(i), n("idle"), m("save"));
283
- const k = _((v) => {
284
- n((p) => v ? "dirty" : p === "dirty" ? "idle" : p);
285
- }, []), C = _(async () => {
286
- if (u.current) {
287
- n("saving");
353
+ selectedId: s
354
+ } = L(), i = w(F), d = w(ve)?.modal, [n, o] = y("idle"), [u, S] = y("save"), x = E(null), T = E(null), f = E(void 0), [m, b] = y(s);
355
+ m !== s && (b(s), o("idle"), S("save"));
356
+ const v = k((g) => {
357
+ o((h) => g ? "dirty" : h === "dirty" ? "idle" : h);
358
+ }, []), D = k(async () => {
359
+ if (x.current) {
360
+ o("saving");
288
361
  try {
289
- const v = await u.current();
290
- n(v ? "saved" : "dirty");
362
+ const g = await x.current();
363
+ o(g ? "saved" : "dirty");
291
364
  } catch {
292
- lt.error({
365
+ pe.error({
293
366
  message: "Something went wrong while saving."
294
- }), n("dirty");
367
+ }), o("dirty");
295
368
  }
296
369
  }
297
370
  }, []);
298
- M(() => {
299
- if (a !== "dirty")
371
+ C(() => {
372
+ if (n !== "dirty")
300
373
  return;
301
- const v = (p) => {
302
- mt(p) && (p.preventDefault(), p.stopPropagation(), C());
374
+ const g = (h) => {
375
+ Ne(h) && (h.preventDefault(), h.stopPropagation(), D());
303
376
  };
304
- return window.addEventListener("keydown", v, !0), () => {
305
- window.removeEventListener("keydown", v, !0);
377
+ return window.addEventListener("keydown", g, !0), () => {
378
+ window.removeEventListener("keydown", g, !0);
306
379
  };
307
- }, [C, a]), M(() => (a === "saved" && (y.current = setTimeout(() => {
308
- n("idle");
309
- }, vt)), () => {
310
- clearTimeout(y.current);
311
- }), [a]);
312
- const et = z(() => ({
313
- saveRef: u,
314
- onDirtyChange: k,
315
- setSaveVerb: m
316
- }), [k]), O = {
317
- duration: o ? 0 : 0.2,
318
- ease: B
319
- }, N = ht(d);
320
- let S = null;
321
- return a === "dirty" ? S = /* @__PURE__ */ e(E, {
322
- color: "contrast",
323
- size: "sm",
324
- onPress: () => {
325
- C();
326
- },
327
- tooltip: ot(N.tooltip, ut),
328
- children: N.dirty
329
- }) : a === "saving" ? S = /* @__PURE__ */ e(E, {
330
- color: "contrast",
331
- size: "sm",
332
- isDisabled: !0,
333
- children: N.saving
334
- }) : a === "saved" && (S = /* @__PURE__ */ e(E, {
335
- color: "success",
336
- size: "sm",
337
- children: N.saved
338
- })), /* @__PURE__ */ e(G, {
339
- value: et,
340
- children: /* @__PURE__ */ e(Z, {
341
- className: l,
342
- footer: s,
343
- action: /* @__PURE__ */ e("div", {
344
- className: c.headerAction,
345
- children: /* @__PURE__ */ e(V, {
346
- mode: "popLayout",
347
- initial: !1,
348
- children: S ? /* @__PURE__ */ e(A.div, {
349
- className: c.saveAction,
350
- initial: {
351
- opacity: 0,
352
- scale: 0.92
353
- },
354
- animate: {
355
- opacity: 1,
356
- scale: 1
357
- },
358
- exit: {
359
- opacity: 0,
360
- scale: 0.92
361
- },
362
- transition: O,
363
- children: S
364
- }, "save") : t ? /* @__PURE__ */ e(A.div, {
365
- className: c.saveAction,
366
- initial: {
367
- opacity: 0
368
- },
369
- animate: {
370
- opacity: 1
371
- },
372
- exit: {
373
- opacity: 0
374
- },
375
- transition: O,
376
- children: t
377
- }, "header-right") : null
378
- })
380
+ }, [D, n]), C(() => (n === "saved" && (f.current = setTimeout(() => {
381
+ o("idle");
382
+ }, xe)), () => {
383
+ clearTimeout(f.current);
384
+ }), [n]), C(() => {
385
+ if (d) {
386
+ if (n === "dirty" || n === "saving") {
387
+ d.unsaved();
388
+ return;
389
+ }
390
+ d.saved();
391
+ }
392
+ }, [d, n]), C(() => {
393
+ if (i)
394
+ return i.current = () => n !== "dirty" && n !== "saving" ? !0 : ge(), () => {
395
+ i.current = null;
396
+ };
397
+ }, [i, n]);
398
+ const ee = j(() => ({
399
+ saveRef: x,
400
+ discardRef: T,
401
+ onDirtyChange: v,
402
+ setSaveVerb: S
403
+ }), [v]), te = Ae(u);
404
+ return /* @__PURE__ */ t(W, {
405
+ value: ee,
406
+ children: /* @__PURE__ */ t(X, {
407
+ className: a,
408
+ footer: n === "idle" ? r : /* @__PURE__ */ t(Ie, {
409
+ state: n,
410
+ copy: te,
411
+ onSave: () => {
412
+ D();
413
+ },
414
+ onDiscard: () => T.current?.()
379
415
  }),
380
- children: r
416
+ action: e ? /* @__PURE__ */ t("div", {
417
+ className: l.headerAction,
418
+ children: e
419
+ }) : void 0,
420
+ children: c
381
421
  })
382
422
  });
383
423
  }
384
- const jt = Object.assign(J, {
385
- Sidebar: Q,
386
- Content: tt,
387
- Pane: X,
388
- Empty: $
424
+ const Ze = Object.assign(q, {
425
+ Sidebar: J,
426
+ Content: $,
427
+ Pane: Q,
428
+ Empty: Z
389
429
  });
390
- J.displayName = "SettingsLayout";
391
- Q.displayName = "SettingsLayout.Sidebar";
392
- tt.displayName = "SettingsLayout.Content";
393
- X.displayName = "SettingsLayout.Pane";
394
- $.displayName = "SettingsLayout.Empty";
430
+ q.displayName = "SettingsLayout";
431
+ J.displayName = "SettingsLayout.Sidebar";
432
+ $.displayName = "SettingsLayout.Content";
433
+ Q.displayName = "SettingsLayout.Pane";
434
+ Z.displayName = "SettingsLayout.Empty";
395
435
  export {
396
- jt as SettingsLayout,
397
- x as useSettingsLayout,
398
- Rt as useSettingsSave
436
+ Ze as SettingsLayout,
437
+ L as useSettingsLayout,
438
+ Xe as useSettingsSave
399
439
  };
400
440
  //# sourceMappingURL=SettingsLayout.js.map