@raketa-builder/ui 0.9.0 → 0.10.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,5 +1,5 @@
1
1
 
2
- > @raketa-builder/ui@0.9.0 build
2
+ > @raketa-builder/ui@0.10.0 build
3
3
  > tsup src/index.js --format cjs --loader ".js=jsx"
4
4
 
5
5
  CLI Building entry: src/index.js
@@ -7,5 +7,5 @@ CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v6.5.0
8
8
  CLI Target: es6
9
9
  CJS Build start
10
- CJS dist/index.js 30.93 KB
11
- CJS ⚡️ Build success in 121ms
10
+ CJS dist/index.js 31.03 KB
11
+ CJS ⚡️ Build success in 227ms
package/dist/index.js CHANGED
@@ -457,37 +457,47 @@ var Content = (_a) => {
457
457
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
458
458
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues({ className: cn("r-reset", "r-modal-content", className) }, props));
459
459
  };
460
+ function checkForChanges(hasChanges, onClose) {
461
+ if (!hasChanges) {
462
+ onClose();
463
+ return;
464
+ }
465
+ if (!confirm(
466
+ "You\u2019ve made changes to the widget. Are you sure you want to cancel?"
467
+ ))
468
+ return;
469
+ onClose();
470
+ }
460
471
  var Modal = (_a) => {
461
472
  var _b = _a, {
462
473
  title,
463
474
  children,
464
475
  customWrapper,
465
476
  FooterContent,
466
- onClose
477
+ onClose,
478
+ areChanges
467
479
  } = _b, rest = __objRest(_b, [
468
480
  "title",
469
481
  "children",
470
482
  "customWrapper",
471
483
  "FooterContent",
472
- "onClose"
484
+ "onClose",
485
+ "areChanges"
473
486
  ]);
474
- const handleKeyUp = ({ key }) => {
475
- if (key === "Escape")
476
- onClose();
477
- };
478
- import_react17.default.useEffect(() => {
479
- document.addEventListener("keyup", handleKeyUp);
480
- return () => {
481
- document.removeEventListener("keyup", handleKeyUp);
482
- };
483
- });
484
487
  const ModalWrapper = customWrapper ? customWrapper : Wrapper;
485
488
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react17.default.Fragment, { children: [
486
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, { onClick: onClose }),
489
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, {}),
487
490
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalWrapper, __spreadProps(__spreadValues({}, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Inner, { children: [
488
491
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TitleBar, { children: [
489
492
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { children: title }),
490
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CloseButton, { type: "button", onClick: onClose, children: "\xD7" })
493
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
494
+ CloseButton,
495
+ {
496
+ type: "button",
497
+ onClick: () => checkForChanges(areChanges, onClose),
498
+ children: "\xD7"
499
+ }
500
+ )
491
501
  ] }),
492
502
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children }),
493
503
  FooterContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterBar, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterContent, {}) })
@@ -827,7 +837,7 @@ var CategoriesInner = (_a) => {
827
837
  var props = __objRest(_a, []);
828
838
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", __spreadProps(__spreadValues({}, props), { className: "r-reset r-categories-inner" }));
829
839
  };
830
- var CategoriesHiddenMenu = ({ paths }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "r-reset r-categories-hidden-menu", children: paths.map(({ title, link }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("a", { href: link, className: "r-reset r-category-link", children: title })) });
840
+ var CategoriesHiddenMenu = ({ paths }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "r-reset r-categories-hidden-menu", children: paths.map(({ title, link }, idx) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("a", { href: link, className: "r-reset r-category-link", children: title }, `${idx}-${link}`)) });
831
841
  var CategoriesMenuWrapper = (_a) => {
832
842
  var props = __objRest(_a, []);
833
843
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", __spreadValues({ className: "r-reset r-categories-menu" }, props));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/ui",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -27,8 +27,8 @@ const CategoriesInner = ({ ...props }) => (
27
27
 
28
28
  const CategoriesHiddenMenu = ({ paths }) => (
29
29
  <div className="r-reset r-categories-hidden-menu">
30
- {paths.map(({ title, link }) => (
31
- <a href={link} className="r-reset r-category-link">
30
+ {paths.map(({ title, link }, idx) => (
31
+ <a key={`${idx}-${link}`} href={link} className="r-reset r-category-link">
32
32
  {title}
33
33
  </a>
34
34
  ))}
package/src/Modal.jsx CHANGED
@@ -36,37 +36,45 @@ const Content = ({ className, ...props }) => (
36
36
  <div className={cn("r-reset", "r-modal-content", className)} {...props} />
37
37
  );
38
38
 
39
+ function checkForChanges(hasChanges, onClose) {
40
+ if (!hasChanges) {
41
+ onClose();
42
+ return;
43
+ }
44
+
45
+ if (
46
+ !confirm(
47
+ "You’ve made changes to the widget. Are you sure you want to cancel?"
48
+ )
49
+ )
50
+ return;
51
+
52
+ onClose();
53
+ }
54
+
39
55
  const Modal = ({
40
56
  title,
41
57
  children,
42
58
  customWrapper,
43
59
  FooterContent,
44
60
  onClose,
61
+ areChanges,
45
62
  ...rest
46
63
  }) => {
47
- const handleKeyUp = ({ key }) => {
48
- if (key === "Escape") onClose();
49
- };
50
-
51
- React.useEffect(() => {
52
- document.addEventListener("keyup", handleKeyUp);
53
-
54
- return () => {
55
- document.removeEventListener("keyup", handleKeyUp);
56
- };
57
- });
58
-
59
64
  const ModalWrapper = customWrapper ? customWrapper : Wrapper;
60
65
 
61
66
  return (
62
67
  <React.Fragment>
63
- <Overlay onClick={onClose} />
68
+ <Overlay />
64
69
 
65
70
  <ModalWrapper {...rest}>
66
71
  <Inner>
67
72
  <TitleBar>
68
73
  <Title>{title}</Title>
69
- <CloseButton type="button" onClick={onClose}>
74
+ <CloseButton
75
+ type="button"
76
+ onClick={() => checkForChanges(areChanges, onClose)}
77
+ >
70
78
  &times;
71
79
  </CloseButton>
72
80
  </TitleBar>
package/src/styles.css CHANGED
@@ -645,7 +645,6 @@
645
645
  left: 0;
646
646
  z-index: 1100;
647
647
  background-color: rgba(0, 0, 0, 0.6);
648
- cursor: pointer;
649
648
  }
650
649
 
651
650
  .r-modal-inner {