@nobertdev/react-confirm-dialog 1.1.0 → 1.1.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.
package/dist/index.js CHANGED
@@ -49,18 +49,6 @@ var import_react_dom = require("react-dom");
49
49
  // src/components/BuildinDialog.tsx
50
50
  var import_react = require("react");
51
51
  var import_jsx_runtime = require("react/jsx-runtime");
52
- function usePrefersDark() {
53
- const [dark, setDark] = (0, import_react.useState)(
54
- () => typeof window !== "undefined" ? window.matchMedia("(prefers-color-scheme: dark)").matches : false
55
- );
56
- (0, import_react.useEffect)(() => {
57
- const mq = window.matchMedia("(prefers-color-scheme: dark)");
58
- const handler = (e) => setDark(e.matches);
59
- mq.addEventListener("change", handler);
60
- return () => mq.removeEventListener("change", handler);
61
- }, []);
62
- return dark;
63
- }
64
52
  var VARIANT_STYLES = {
65
53
  default: {
66
54
  confirmBg: "#111",
@@ -195,11 +183,11 @@ function BuiltInDialog({
195
183
  providerProps,
196
184
  onConfirm,
197
185
  onCancel,
198
- isClosing
186
+ isClosing,
187
+ isDark
199
188
  }) {
200
189
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
201
190
  const confirmRef = (0, import_react.useRef)(null);
202
- const isDark = usePrefersDark();
203
191
  const variant = (_a = state.variant) != null ? _a : "default";
204
192
  const v = VARIANT_STYLES[variant];
205
193
  (0, import_react.useEffect)(() => {
@@ -409,6 +397,18 @@ var DEFAULT_STATE = {
409
397
  variant: "default",
410
398
  icon: void 0
411
399
  };
400
+ function usePrefersDark() {
401
+ const [dark, setDark] = (0, import_react3.useState)(
402
+ () => typeof window !== "undefined" ? window.matchMedia("(prefers-color-scheme: dark)").matches : false
403
+ );
404
+ (0, import_react3.useEffect)(() => {
405
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
406
+ const handler = (e) => setDark(e.matches);
407
+ mq.addEventListener("change", handler);
408
+ return () => mq.removeEventListener("change", handler);
409
+ }, []);
410
+ return dark;
411
+ }
412
412
  function ConfirmDialogProvider({
413
413
  children,
414
414
  defaultOptions,
@@ -419,6 +419,7 @@ function ConfirmDialogProvider({
419
419
  const [state, setState] = (0, import_react3.useState)(DEFAULT_STATE);
420
420
  const [isClosing, setIsClosing] = (0, import_react3.useState)(false);
421
421
  const resolveRef = (0, import_react3.useRef)(null);
422
+ const isDark = usePrefersDark();
422
423
  const close = (0, import_react3.useCallback)((result) => {
423
424
  setIsClosing(true);
424
425
  setTimeout(() => {
@@ -457,7 +458,8 @@ function ConfirmDialogProvider({
457
458
  providerProps: { classNames, styles, defaultOptions },
458
459
  onConfirm,
459
460
  onCancel,
460
- isClosing
461
+ isClosing,
462
+ isDark
461
463
  }
462
464
  );
463
465
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(ConfirmDialogContext.Provider, { value: contextValue, children: [
package/dist/index.mjs CHANGED
@@ -19,24 +19,12 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
 
21
21
  // src/components/ConfirmDialogProvider.tsx
22
- import { useState as useState2, useCallback, useRef as useRef2, useMemo } from "react";
22
+ import { useState as useState2, useCallback, useRef as useRef2, useMemo, useEffect as useEffect2 } from "react";
23
23
  import { createPortal } from "react-dom";
24
24
 
25
25
  // src/components/BuildinDialog.tsx
26
26
  import { useEffect, useRef, useState } from "react";
27
27
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
- function usePrefersDark() {
29
- const [dark, setDark] = useState(
30
- () => typeof window !== "undefined" ? window.matchMedia("(prefers-color-scheme: dark)").matches : false
31
- );
32
- useEffect(() => {
33
- const mq = window.matchMedia("(prefers-color-scheme: dark)");
34
- const handler = (e) => setDark(e.matches);
35
- mq.addEventListener("change", handler);
36
- return () => mq.removeEventListener("change", handler);
37
- }, []);
38
- return dark;
39
- }
40
28
  var VARIANT_STYLES = {
41
29
  default: {
42
30
  confirmBg: "#111",
@@ -171,11 +159,11 @@ function BuiltInDialog({
171
159
  providerProps,
172
160
  onConfirm,
173
161
  onCancel,
174
- isClosing
162
+ isClosing,
163
+ isDark
175
164
  }) {
176
165
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
177
166
  const confirmRef = useRef(null);
178
- const isDark = usePrefersDark();
179
167
  const variant = (_a = state.variant) != null ? _a : "default";
180
168
  const v = VARIANT_STYLES[variant];
181
169
  useEffect(() => {
@@ -385,6 +373,18 @@ var DEFAULT_STATE = {
385
373
  variant: "default",
386
374
  icon: void 0
387
375
  };
376
+ function usePrefersDark() {
377
+ const [dark, setDark] = useState2(
378
+ () => typeof window !== "undefined" ? window.matchMedia("(prefers-color-scheme: dark)").matches : false
379
+ );
380
+ useEffect2(() => {
381
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
382
+ const handler = (e) => setDark(e.matches);
383
+ mq.addEventListener("change", handler);
384
+ return () => mq.removeEventListener("change", handler);
385
+ }, []);
386
+ return dark;
387
+ }
388
388
  function ConfirmDialogProvider({
389
389
  children,
390
390
  defaultOptions,
@@ -395,6 +395,7 @@ function ConfirmDialogProvider({
395
395
  const [state, setState] = useState2(DEFAULT_STATE);
396
396
  const [isClosing, setIsClosing] = useState2(false);
397
397
  const resolveRef = useRef2(null);
398
+ const isDark = usePrefersDark();
398
399
  const close = useCallback((result) => {
399
400
  setIsClosing(true);
400
401
  setTimeout(() => {
@@ -433,7 +434,8 @@ function ConfirmDialogProvider({
433
434
  providerProps: { classNames, styles, defaultOptions },
434
435
  onConfirm,
435
436
  onCancel,
436
- isClosing
437
+ isClosing,
438
+ isDark
437
439
  }
438
440
  );
439
441
  return /* @__PURE__ */ jsxs2(ConfirmDialogContext.Provider, { value: contextValue, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nobertdev/react-confirm-dialog",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A lightweight, fully customizable confirmation dialog hook (useConfirm()) that replaces window.confirm() with beautiful async modals. Zero dependencies.",
5
5
  "keywords": [
6
6
  "react",