@raketa-builder/ui 0.9.0 → 0.11.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.11.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.07 KB
11
+ CJS ⚡️ Build success in 56ms
package/dist/index.js CHANGED
@@ -191,6 +191,7 @@ var Button = (_a) => {
191
191
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
192
192
  Component,
193
193
  __spreadValues({
194
+ type,
194
195
  className: cn(
195
196
  "r-reset",
196
197
  "r-reset-button",
@@ -445,6 +446,7 @@ var CloseButton = (_a) => {
445
446
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
446
447
  "button",
447
448
  __spreadValues({
449
+ type: "button",
448
450
  className: cn("r-reset-button r-modal-close-btn", className)
449
451
  }, props)
450
452
  );
@@ -457,37 +459,47 @@ var Content = (_a) => {
457
459
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
458
460
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", __spreadValues({ className: cn("r-reset", "r-modal-content", className) }, props));
459
461
  };
462
+ function checkForChanges(hasChanges, onClose) {
463
+ if (!hasChanges) {
464
+ onClose();
465
+ return;
466
+ }
467
+ if (!confirm(
468
+ "You\u2019ve made changes to the widget. Are you sure you want to cancel?"
469
+ ))
470
+ return;
471
+ onClose();
472
+ }
460
473
  var Modal = (_a) => {
461
474
  var _b = _a, {
462
475
  title,
463
476
  children,
464
477
  customWrapper,
465
478
  FooterContent,
466
- onClose
479
+ onClose,
480
+ areChanges
467
481
  } = _b, rest = __objRest(_b, [
468
482
  "title",
469
483
  "children",
470
484
  "customWrapper",
471
485
  "FooterContent",
472
- "onClose"
486
+ "onClose",
487
+ "areChanges"
473
488
  ]);
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
489
  const ModalWrapper = customWrapper ? customWrapper : Wrapper;
485
490
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react17.default.Fragment, { children: [
486
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, { onClick: onClose }),
491
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Overlay, {}),
487
492
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ModalWrapper, __spreadProps(__spreadValues({}, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Inner, { children: [
488
493
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TitleBar, { children: [
489
494
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Title, { children: title }),
490
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CloseButton, { type: "button", onClick: onClose, children: "\xD7" })
495
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
496
+ CloseButton,
497
+ {
498
+ type: "button",
499
+ onClick: () => checkForChanges(areChanges, onClose),
500
+ children: "\xD7"
501
+ }
502
+ )
491
503
  ] }),
492
504
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Content, { children }),
493
505
  FooterContent && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterBar, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FooterContent, {}) })
@@ -827,7 +839,7 @@ var CategoriesInner = (_a) => {
827
839
  var props = __objRest(_a, []);
828
840
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", __spreadProps(__spreadValues({}, props), { className: "r-reset r-categories-inner" }));
829
841
  };
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 })) });
842
+ 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
843
  var CategoriesMenuWrapper = (_a) => {
832
844
  var props = __objRest(_a, []);
833
845
  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.11.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
package/src/Button.jsx CHANGED
@@ -13,6 +13,7 @@ const Button = ({
13
13
 
14
14
  return (
15
15
  <Component
16
+ type={type}
16
17
  className={cn(
17
18
  "r-reset",
18
19
  "r-reset-button",
@@ -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
@@ -23,6 +23,7 @@ const Title = ({ className, ...props }) => (
23
23
 
24
24
  const CloseButton = ({ className, ...props }) => (
25
25
  <button
26
+ type="button"
26
27
  className={cn("r-reset-button r-modal-close-btn", className)}
27
28
  {...props}
28
29
  />
@@ -36,37 +37,45 @@ const Content = ({ className, ...props }) => (
36
37
  <div className={cn("r-reset", "r-modal-content", className)} {...props} />
37
38
  );
38
39
 
40
+ function checkForChanges(hasChanges, onClose) {
41
+ if (!hasChanges) {
42
+ onClose();
43
+ return;
44
+ }
45
+
46
+ if (
47
+ !confirm(
48
+ "You’ve made changes to the widget. Are you sure you want to cancel?"
49
+ )
50
+ )
51
+ return;
52
+
53
+ onClose();
54
+ }
55
+
39
56
  const Modal = ({
40
57
  title,
41
58
  children,
42
59
  customWrapper,
43
60
  FooterContent,
44
61
  onClose,
62
+ areChanges,
45
63
  ...rest
46
64
  }) => {
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
65
  const ModalWrapper = customWrapper ? customWrapper : Wrapper;
60
66
 
61
67
  return (
62
68
  <React.Fragment>
63
- <Overlay onClick={onClose} />
69
+ <Overlay />
64
70
 
65
71
  <ModalWrapper {...rest}>
66
72
  <Inner>
67
73
  <TitleBar>
68
74
  <Title>{title}</Title>
69
- <CloseButton type="button" onClick={onClose}>
75
+ <CloseButton
76
+ type="button"
77
+ onClick={() => checkForChanges(areChanges, onClose)}
78
+ >
70
79
  &times;
71
80
  </CloseButton>
72
81
  </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 {