@parallelworks/ui 0.4.0 → 0.5.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.
Files changed (35) hide show
  1. package/dist/chunks/BareModal-DBa84JZO.js +80 -0
  2. package/dist/chunks/{CodePreviewEditor-B3688Fx4.js → CodePreviewEditor-CBtYRZi6.js} +2 -1
  3. package/dist/chunks/CreateModal-6zZZHxCI.js +595 -0
  4. package/dist/chunks/Loader-BXoXTZGc.js +47 -0
  5. package/dist/chunks/{Monaco-BEj--GTx.js → Monaco-CvFXoW3r.js} +3 -2
  6. package/dist/chunks/{Provider-uUHgWOWc.js → Provider-jQCAN3NN.js} +18 -0
  7. package/dist/chunks/{SwitchToggle-BqD0dE-L.js → SwitchToggle-D0ud8cd5.js} +1 -1
  8. package/dist/chunks/{Table-C5z6qWjM.js → Table-ByziK93x.js} +1 -1
  9. package/dist/chunks/{editor-CdQbKtYO.js → editor-CEXg6C8X.js} +5 -41
  10. package/dist/chunks/{list-D5f5Fq-O.js → list-CvDWt0TC.js} +2 -2
  11. package/dist/chunks/useCssIsDark-DHr05dG2.js +38 -0
  12. package/dist/components/AddMenu.d.ts +17 -0
  13. package/dist/components/BareModal.d.ts +17 -0
  14. package/dist/components/ConfirmModal.d.ts +17 -0
  15. package/dist/components/CreateModal.d.ts +92 -0
  16. package/dist/components/Loader.d.ts +2 -1
  17. package/dist/components/Provider.d.ts +14 -12
  18. package/dist/components/ghostButton.d.ts +4 -0
  19. package/dist/editor/index.d.ts +0 -1
  20. package/dist/editor/index.js +2 -2
  21. package/dist/file-explorer/index.js +23 -25
  22. package/dist/form/index.js +4 -4
  23. package/dist/index.d.ts +6 -1
  24. package/dist/index.js +8 -7
  25. package/dist/list/index.js +1 -1
  26. package/dist/logviewer/index.js +1 -1
  27. package/dist/styles/theme.css +21 -0
  28. package/dist/styles.css +1 -1
  29. package/dist/workflow/index.js +8 -8
  30. package/package.json +1 -1
  31. package/dist/chunks/Loader-DQiZ75fa.js +0 -25
  32. package/dist/chunks/Markdown-iFhq8Gb0.js +0 -101
  33. package/dist/chunks/Modal-sOUEwebV.js +0 -121
  34. package/dist/components/Modal.d.ts +0 -26
  35. /package/dist/{editor → components}/useCssIsDark.d.ts +0 -0
@@ -1,121 +0,0 @@
1
- import cx from "classnames";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useCallback, useEffect, useId, useRef, useState } from "react";
4
- import { createPortal } from "react-dom";
5
- //#region src/components/Modal.tsx
6
- var FOCUSABLE = "a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex=\"-1\"])";
7
- var noop = () => {};
8
- var actionClasses = {
9
- destructive: "bg-red-600 text-white hover:bg-red-700",
10
- warning: "bg-yellow-500 text-white hover:bg-yellow-700",
11
- info: "bg-(--theme-element,#06354f) text-(--theme-element-text,#ffffff) hover:opacity-90"
12
- };
13
- function Modal({ isOpen, close, cancelAction = noop, children, title = "", text = "", actionLabel = "", cancelLabel = "Cancel", action, closeAfterAction = true, type = "destructive", className = "", showButtons = true, disableAction = false, loading = false, padding = true, fitWidth = false, dimScreen = true, ignoreOutsideClickClose = false }) {
14
- const [pending, setPending] = useState(false);
15
- const actionFiredRef = useRef(false);
16
- const panelRef = useRef(null);
17
- const titleId = useId();
18
- const inFlight = loading || pending;
19
- const inFlightRef = useRef(inFlight);
20
- inFlightRef.current = inFlight;
21
- useEffect(() => {
22
- if (isOpen) actionFiredRef.current = false;
23
- }, [isOpen]);
24
- useEffect(() => {
25
- if (!isOpen) return;
26
- const previouslyFocused = document.activeElement;
27
- const previousOverflow = document.body.style.overflow;
28
- document.body.style.overflow = "hidden";
29
- panelRef.current?.focus();
30
- return () => {
31
- document.body.style.overflow = previousOverflow;
32
- previouslyFocused?.focus?.();
33
- };
34
- }, [isOpen]);
35
- const trapFocus = useCallback((e) => {
36
- if (e.key !== "Tab" || !panelRef.current) return;
37
- const focusable = panelRef.current.querySelectorAll(FOCUSABLE);
38
- if (focusable.length === 0) {
39
- e.preventDefault();
40
- return;
41
- }
42
- const first = focusable[0];
43
- const last = focusable[focusable.length - 1];
44
- if (e.shiftKey && document.activeElement === first) {
45
- e.preventDefault();
46
- last.focus();
47
- } else if (!e.shiftKey && document.activeElement === last) {
48
- e.preventDefault();
49
- first.focus();
50
- }
51
- }, []);
52
- const closeRef = useRef(close);
53
- closeRef.current = close;
54
- useEffect(() => {
55
- if (!isOpen) return;
56
- const onKey = (e) => {
57
- if (e.key === "Escape" && !inFlightRef.current) closeRef.current();
58
- };
59
- window.addEventListener("keydown", onKey);
60
- return () => window.removeEventListener("keydown", onKey);
61
- }, [isOpen]);
62
- const runAction = useCallback(async () => {
63
- if (actionFiredRef.current) return;
64
- actionFiredRef.current = true;
65
- setPending(true);
66
- try {
67
- await action?.();
68
- if (closeAfterAction) closeRef.current();
69
- else actionFiredRef.current = false;
70
- } finally {
71
- setPending(false);
72
- }
73
- }, [action, closeAfterAction]);
74
- if (!isOpen) return null;
75
- return createPortal(/* @__PURE__ */ jsxs("div", {
76
- className: "fixed z-250 inset-0 flex w-screen items-center justify-center p-4",
77
- role: "dialog",
78
- "aria-modal": "true",
79
- ...title ? { "aria-labelledby": titleId } : {},
80
- onKeyDown: trapFocus,
81
- children: [/* @__PURE__ */ jsx("div", {
82
- className: cx("fixed inset-0", dimScreen && "bg-gray-500/75"),
83
- onClick: inFlight || ignoreOutsideClickClose ? void 0 : close
84
- }), /* @__PURE__ */ jsxs("div", {
85
- ref: panelRef,
86
- tabIndex: -1,
87
- className: cx(className, "relative inline-block align-bottom rounded-lg text-left shadow-xl z-50 sm:my-8 sm:align-middle max-h-full overflow-y-auto", "bg-(--theme-panel-bg,#ffffff) text-(--theme-panel,#000000)", padding && "px-4 pt-5 pb-4 sm:p-6", fitWidth ? "sm:w-min-[32rem]" : "sm:max-w-lg sm:w-full"),
88
- children: [/* @__PURE__ */ jsxs("div", { children: [title && /* @__PURE__ */ jsx("h3", {
89
- id: titleId,
90
- className: "text-center text-xl leading-6 font-semibold",
91
- children: title
92
- }), /* @__PURE__ */ jsxs("div", {
93
- className: cx(title.length !== 0 && "mt-2"),
94
- children: [text && /* @__PURE__ */ jsx("p", {
95
- className: "text-sm text-center",
96
- children: text
97
- }), children]
98
- })] }), showButtons && /* @__PURE__ */ jsxs("div", {
99
- className: "mt-5 sm:mt-6 grid grid-cols-2 gap-3 grid-flow-row-dense",
100
- children: [/* @__PURE__ */ jsx("button", {
101
- type: "button",
102
- className: cx("self-center cursor-pointer px-3 py-1.5 rounded-md text-xs font-medium whitespace-nowrap flex items-center justify-center", "border border-(--theme-border,#d1d5db) hover:bg-(--theme-hover,#f3f4f6)", inFlight && "cursor-wait"),
103
- onClick: () => {
104
- cancelAction();
105
- close();
106
- },
107
- disabled: inFlight,
108
- children: cancelLabel
109
- }), /* @__PURE__ */ jsx("button", {
110
- type: "button",
111
- className: cx("self-center cursor-pointer px-3 py-1.5 rounded-md text-xs font-medium whitespace-nowrap flex items-center justify-center", "disabled:opacity-50 disabled:cursor-not-allowed", actionClasses[type], loading && "cursor-wait"),
112
- onClick: runAction,
113
- disabled: disableAction || inFlight,
114
- children: actionLabel
115
- })]
116
- })]
117
- })]
118
- }), document.body);
119
- }
120
- //#endregion
121
- export { Modal as t };
@@ -1,26 +0,0 @@
1
- export interface ModalProps {
2
- isOpen: boolean;
3
- close: () => void;
4
- cancelAction?: () => void;
5
- closeAfterAction?: boolean;
6
- className?: string;
7
- actionLabel?: string;
8
- cancelLabel?: string;
9
- action?: () => void | Promise<unknown>;
10
- title?: string;
11
- text?: string;
12
- type?: 'destructive' | 'info' | 'warning';
13
- showButtons?: boolean;
14
- children?: React.ReactNode;
15
- disableAction?: boolean;
16
- loading?: boolean;
17
- /** When false, drops the panel's default padding. */
18
- padding?: boolean;
19
- /** Makes modal width fit to content instead of regular width. */
20
- fitWidth?: boolean;
21
- /** When false, the backdrop stays transparent. */
22
- dimScreen?: boolean;
23
- /** When true, clicking the backdrop does not close the modal. */
24
- ignoreOutsideClickClose?: boolean;
25
- }
26
- export default function Modal({ isOpen, close, cancelAction, children, title, text, actionLabel, cancelLabel, action, closeAfterAction, type, className, showButtons, disableAction, loading, padding, fitWidth, dimScreen, ignoreOutsideClickClose, }: ModalProps): import("react").ReactPortal | null;
File without changes