@rnaga/wp-next-ui 1.0.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 (190) hide show
  1. package/Accordion.d.ts +4 -0
  2. package/Accordion.d.ts.map +1 -0
  3. package/Accordion.js +13 -0
  4. package/Accordions.d.ts +19 -0
  5. package/Accordions.d.ts.map +1 -0
  6. package/Accordions.js +39 -0
  7. package/Background.d.ts +5 -0
  8. package/Background.d.ts.map +1 -0
  9. package/Background.js +18 -0
  10. package/BadgeOnMouseOver.d.ts +12 -0
  11. package/BadgeOnMouseOver.d.ts.map +1 -0
  12. package/BadgeOnMouseOver.js +40 -0
  13. package/BasicMenuButton.d.ts +17 -0
  14. package/BasicMenuButton.d.ts.map +1 -0
  15. package/BasicMenuButton.js +61 -0
  16. package/Button.d.ts +10 -0
  17. package/Button.d.ts.map +1 -0
  18. package/Button.js +15 -0
  19. package/Card.d.ts +6 -0
  20. package/Card.d.ts.map +1 -0
  21. package/Card.js +13 -0
  22. package/CardImage.d.ts +10 -0
  23. package/CardImage.d.ts.map +1 -0
  24. package/CardImage.js +34 -0
  25. package/Checkbox.d.ts +6 -0
  26. package/Checkbox.d.ts.map +1 -0
  27. package/Checkbox.js +13 -0
  28. package/Chip.d.ts +10 -0
  29. package/Chip.d.ts.map +1 -0
  30. package/Chip.js +41 -0
  31. package/DateTimePicker.d.ts +6 -0
  32. package/DateTimePicker.d.ts.map +1 -0
  33. package/DateTimePicker.js +45 -0
  34. package/DraggableBox.d.ts +39 -0
  35. package/DraggableBox.d.ts.map +1 -0
  36. package/DraggableBox.js +171 -0
  37. package/Form.d.ts +4 -0
  38. package/Form.d.ts.map +1 -0
  39. package/Form.js +8 -0
  40. package/FormDataProvider.d.ts +5 -0
  41. package/FormDataProvider.d.ts.map +1 -0
  42. package/FormDataProvider.js +6 -0
  43. package/IconButtonDelete.d.ts +6 -0
  44. package/IconButtonDelete.d.ts.map +1 -0
  45. package/IconButtonDelete.js +14 -0
  46. package/Input.d.ts +14 -0
  47. package/Input.d.ts.map +1 -0
  48. package/Input.js +84 -0
  49. package/InputClickField.d.ts +13 -0
  50. package/InputClickField.d.ts.map +1 -0
  51. package/InputClickField.js +21 -0
  52. package/InputColor.d.ts +12 -0
  53. package/InputColor.d.ts.map +1 -0
  54. package/InputColor.js +141 -0
  55. package/InputMultiple.d.ts +15 -0
  56. package/InputMultiple.d.ts.map +1 -0
  57. package/InputMultiple.js +55 -0
  58. package/InputSearch.d.ts +7 -0
  59. package/InputSearch.d.ts.map +1 -0
  60. package/InputSearch.js +28 -0
  61. package/Link.d.ts +6 -0
  62. package/Link.d.ts.map +1 -0
  63. package/Link.js +15 -0
  64. package/LinkCopy.d.ts +6 -0
  65. package/LinkCopy.d.ts.map +1 -0
  66. package/LinkCopy.js +17 -0
  67. package/Loading.d.ts +7 -0
  68. package/Loading.d.ts.map +1 -0
  69. package/Loading.js +29 -0
  70. package/LoadingBox.d.ts +12 -0
  71. package/LoadingBox.d.ts.map +1 -0
  72. package/LoadingBox.js +30 -0
  73. package/MediaTag.d.ts +9 -0
  74. package/MediaTag.d.ts.map +1 -0
  75. package/MediaTag.js +19 -0
  76. package/Modal.d.ts +11 -0
  77. package/Modal.d.ts.map +1 -0
  78. package/Modal.js +65 -0
  79. package/ModalConfirm.d.ts +8 -0
  80. package/ModalConfirm.d.ts.map +1 -0
  81. package/ModalConfirm.js +58 -0
  82. package/PopperMenu.d.ts +7 -0
  83. package/PopperMenu.d.ts.map +1 -0
  84. package/PopperMenu.js +6 -0
  85. package/README.md +292 -0
  86. package/Select.d.ts +21 -0
  87. package/Select.d.ts.map +1 -0
  88. package/Select.js +23 -0
  89. package/SelectAutocomplete.d.ts +1208 -0
  90. package/SelectAutocomplete.d.ts.map +1 -0
  91. package/SelectAutocomplete.js +113 -0
  92. package/SelectMultiple.d.ts +16 -0
  93. package/SelectMultiple.d.ts.map +1 -0
  94. package/SelectMultiple.js +28 -0
  95. package/SelectWPPost.d.ts +17 -0
  96. package/SelectWPPost.d.ts.map +1 -0
  97. package/SelectWPPost.js +98 -0
  98. package/SelectWPTaxonomy.d.ts +9 -0
  99. package/SelectWPTaxonomy.d.ts.map +1 -0
  100. package/SelectWPTaxonomy.js +35 -0
  101. package/SelectWPTerm.d.ts +13 -0
  102. package/SelectWPTerm.d.ts.map +1 -0
  103. package/SelectWPTerm.js +92 -0
  104. package/SelectWPTerms.d.ts +27 -0
  105. package/SelectWPTerms.d.ts.map +1 -0
  106. package/SelectWPTerms.js +105 -0
  107. package/SelectWPUser.d.ts +16 -0
  108. package/SelectWPUser.d.ts.map +1 -0
  109. package/SelectWPUser.js +101 -0
  110. package/SortableList.d.ts +28 -0
  111. package/SortableList.d.ts.map +1 -0
  112. package/SortableList.js +195 -0
  113. package/Tabs.d.ts +17 -0
  114. package/Tabs.d.ts.map +1 -0
  115. package/Tabs.js +35 -0
  116. package/ThemeRegistry.d.ts +13 -0
  117. package/ThemeRegistry.d.ts.map +1 -0
  118. package/ThemeRegistry.js +36 -0
  119. package/Typography.d.ts +9 -0
  120. package/Typography.d.ts.map +1 -0
  121. package/Typography.js +12 -0
  122. package/Viewport.d.ts +6 -0
  123. package/Viewport.d.ts.map +1 -0
  124. package/Viewport.js +10 -0
  125. package/hooks/use-form-data.d.ts +39 -0
  126. package/hooks/use-form-data.d.ts.map +1 -0
  127. package/hooks/use-form-data.js +91 -0
  128. package/hooks/use-media-selector.d.ts +10 -0
  129. package/hooks/use-media-selector.d.ts.map +1 -0
  130. package/hooks/use-media-selector.js +33 -0
  131. package/hooks/use-mouse-move.d.ts +18 -0
  132. package/hooks/use-mouse-move.d.ts.map +1 -0
  133. package/hooks/use-mouse-move.js +112 -0
  134. package/hooks/use-scheme-toggle.d.ts +6 -0
  135. package/hooks/use-scheme-toggle.d.ts.map +1 -0
  136. package/hooks/use-scheme-toggle.js +16 -0
  137. package/hooks/use-viewport.d.ts +5 -0
  138. package/hooks/use-viewport.d.ts.map +1 -0
  139. package/hooks/use-viewport.js +9 -0
  140. package/list/ListGrid.d.ts +12 -0
  141. package/list/ListGrid.d.ts.map +1 -0
  142. package/list/ListGrid.js +15 -0
  143. package/list/ListTable.d.ts +43 -0
  144. package/list/ListTable.d.ts.map +1 -0
  145. package/list/ListTable.js +143 -0
  146. package/list/Pagination.d.ts +5 -0
  147. package/list/Pagination.d.ts.map +1 -0
  148. package/list/Pagination.js +24 -0
  149. package/list/index.d.ts +4 -0
  150. package/list/index.d.ts.map +1 -0
  151. package/list/index.js +3 -0
  152. package/media/MediaGridForm.d.ts +5 -0
  153. package/media/MediaGridForm.d.ts.map +1 -0
  154. package/media/MediaGridForm.js +128 -0
  155. package/media/MediaThumbnail.d.ts +4 -0
  156. package/media/MediaThumbnail.d.ts.map +1 -0
  157. package/media/MediaThumbnail.js +17 -0
  158. package/media/MediaUpload.d.ts +7 -0
  159. package/media/MediaUpload.d.ts.map +1 -0
  160. package/media/MediaUpload.js +76 -0
  161. package/media/index.d.ts +4 -0
  162. package/media/index.d.ts.map +1 -0
  163. package/media/index.js +3 -0
  164. package/media-selector/MediaSelectorList.d.ts +2 -0
  165. package/media-selector/MediaSelectorList.d.ts.map +1 -0
  166. package/media-selector/MediaSelectorList.js +43 -0
  167. package/media-selector/MediaSelectorPreview.d.ts +2 -0
  168. package/media-selector/MediaSelectorPreview.d.ts.map +1 -0
  169. package/media-selector/MediaSelectorPreview.js +80 -0
  170. package/media-selector/index.d.ts +2 -0
  171. package/media-selector/index.d.ts.map +1 -0
  172. package/media-selector/index.js +49 -0
  173. package/package.json +33 -0
  174. package/portal/Portal.d.ts +6 -0
  175. package/portal/Portal.d.ts.map +1 -0
  176. package/portal/Portal.js +7 -0
  177. package/portal/index.d.ts +3 -0
  178. package/portal/index.d.ts.map +1 -0
  179. package/portal/index.js +2 -0
  180. package/portal/use-portal.d.ts +4 -0
  181. package/portal/use-portal.d.ts.map +1 -0
  182. package/portal/use-portal.js +11 -0
  183. package/types/global-state.d.ts +27 -0
  184. package/types/hooks/filters.d.ts +20 -0
  185. package/types/hooks/index.d.ts +1 -0
  186. package/types/index.d.ts +3 -0
  187. package/types/wp-theme.d.ts +49 -0
  188. package/wp-theme/index.d.ts +3 -0
  189. package/wp-theme/index.d.ts.map +1 -0
  190. package/wp-theme/index.js +86 -0
@@ -0,0 +1,33 @@
1
+ import { useWP } from "@rnaga/wp-next-core/client/wp";
2
+ export const useMediaSelector = () => {
3
+ const { globalState } = useWP();
4
+ const selector = globalState.get("media-selector-modal");
5
+ const open = (...args) => {
6
+ const onSelected = args.length === 1 ? args[0] : args[1];
7
+ const mimeTypes = args.length === 1 ? undefined : args[0];
8
+ globalState.set({
9
+ "media-selector-modal": {
10
+ open: true,
11
+ onSelected,
12
+ mimeTypes,
13
+ },
14
+ });
15
+ };
16
+ const close = () => {
17
+ globalState.set({
18
+ "media-selector-modal": {
19
+ open: false,
20
+ onSelected: undefined,
21
+ },
22
+ });
23
+ };
24
+ const select = (post) => {
25
+ selector?.onSelected && selector.onSelected(post);
26
+ };
27
+ return {
28
+ open,
29
+ close,
30
+ select,
31
+ isOpen: selector?.open ?? false,
32
+ };
33
+ };
@@ -0,0 +1,18 @@
1
+ interface Props {
2
+ onDeltaChange: (e: MouseEvent, delta: {
3
+ x: number;
4
+ y: number;
5
+ }) => void;
6
+ onMouseUp?: (e: MouseEvent) => void;
7
+ onMouseDown?: (e: MouseEvent) => void;
8
+ onContextMenu?: (e: MouseEvent) => void;
9
+ onClick?: (e: MouseEvent) => void;
10
+ threshold?: number;
11
+ debounceTime?: number;
12
+ cursor?: string;
13
+ }
14
+ export declare const useMouseMove: ({ onDeltaChange, onMouseUp, onMouseDown, onContextMenu, onClick, threshold, debounceTime, cursor, }: Props) => {
15
+ initMouseMove: (elementOrRef: HTMLElement | React.RefObject<HTMLElement | null>) => (e: React.MouseEvent) => void;
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=use-mouse-move.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-mouse-move.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mouse-move.ts"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACb,aAAa,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,qGAS1B,KAAK;kCA2DU,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,MAKvD,GAAG,KAAK,CAAC,UAAU;CA0E9B,CAAC"}
@@ -0,0 +1,112 @@
1
+ import { useEffect, useRef } from "react";
2
+ export const useMouseMove = ({ onDeltaChange, onMouseUp, onMouseDown, onContextMenu, onClick, threshold = 0.5, debounceTime = 500, cursor = "grabbing", // Default cursor
3
+ }) => {
4
+ const elementRef = useRef(null);
5
+ const eventStateRef = useRef(null);
6
+ const clickDurationTimerRef = useRef(0);
7
+ const handleMouseMove = (e) => {
8
+ //const target = e.target as HTMLElement;
9
+ e.stopPropagation();
10
+ e.preventDefault();
11
+ const state = eventStateRef.current;
12
+ if (!state || !state.isMouseDown)
13
+ return;
14
+ const deltaX = e.clientX - (state.initialX ?? e.clientX);
15
+ const deltaY = e.clientY - (state.initialY ?? e.clientY);
16
+ if (Math.abs(deltaX) > threshold || Math.abs(deltaY) > threshold) {
17
+ onDeltaChange(e, { x: deltaX, y: deltaY });
18
+ state.initialX = e.clientX;
19
+ state.initialY = e.clientY;
20
+ }
21
+ };
22
+ const handleMouseUp = (e) => {
23
+ const state = eventStateRef.current;
24
+ if (state?.isMouseDown) {
25
+ const clickDuration = Date.now() - clickDurationTimerRef.current;
26
+ // Check if the click duration is less than 150ms, then it's a click
27
+ if (clickDuration < 150) {
28
+ // Call the onClick handler
29
+ onClick?.(e);
30
+ }
31
+ else if (onMouseUp) {
32
+ onMouseUp(e);
33
+ }
34
+ state.isMouseDown = false;
35
+ state.initialX = null;
36
+ state.initialY = null;
37
+ // Remove the overlay
38
+ if (state.overlay) {
39
+ state.overlay.removeEventListener("mousemove", handleMouseMove);
40
+ state.overlay.removeEventListener("mouseup", handleMouseUp);
41
+ document.body.removeChild(state.overlay);
42
+ state.overlay = null;
43
+ }
44
+ eventStateRef.current = null;
45
+ }
46
+ };
47
+ const initMouseMove = (elementOrRef) => {
48
+ elementRef.current =
49
+ elementOrRef instanceof HTMLElement ? elementOrRef : elementOrRef.current;
50
+ return (e) => {
51
+ const element = elementOrRef instanceof HTMLElement
52
+ ? elementOrRef
53
+ : elementOrRef.current;
54
+ if (!element)
55
+ return;
56
+ clickDurationTimerRef.current = Date.now(); // milliseconds
57
+ if (onMouseDown) {
58
+ onMouseDown(e);
59
+ }
60
+ let state = eventStateRef.current;
61
+ if (!state) {
62
+ state = {
63
+ isMouseDown: false,
64
+ initialX: null,
65
+ initialY: null,
66
+ };
67
+ eventStateRef.current = state;
68
+ }
69
+ state.isMouseDown = true;
70
+ state.initialX = e.clientX;
71
+ state.initialY = e.clientY;
72
+ // Create and show the overlay
73
+ if (!state.overlay) {
74
+ const overlay = document.createElement("div");
75
+ overlay.style.position = "fixed";
76
+ overlay.style.top = "0";
77
+ overlay.style.left = "0";
78
+ overlay.style.width = "100vw";
79
+ overlay.style.height = "100vh";
80
+ overlay.style.zIndex = "2000";
81
+ overlay.style.cursor = cursor;
82
+ overlay.style.background = "transparent"; // Keep transparent
83
+ document.body.appendChild(overlay);
84
+ state.overlay = overlay;
85
+ // Attach global mousemove and mouseup to the overlay
86
+ overlay.addEventListener("mousemove", handleMouseMove);
87
+ overlay.addEventListener("mouseup", handleMouseUp);
88
+ if (onContextMenu) {
89
+ overlay.addEventListener("contextmenu", onContextMenu);
90
+ }
91
+ eventStateRef.current = state;
92
+ }
93
+ };
94
+ };
95
+ useEffect(() => {
96
+ return () => {
97
+ // Cleanup overlays and event listeners on unmount
98
+ const state = eventStateRef.current;
99
+ if (state?.overlay) {
100
+ state.overlay.removeEventListener("mousemove", handleMouseMove);
101
+ state.overlay.removeEventListener("mouseup", handleMouseUp);
102
+ if (onContextMenu) {
103
+ state.overlay.removeEventListener("contextmenu", onContextMenu);
104
+ }
105
+ if (state.overlay && state.overlay.parentNode === document.body) {
106
+ document.body.removeChild(state.overlay);
107
+ }
108
+ }
109
+ };
110
+ }, []);
111
+ return { initMouseMove };
112
+ };
@@ -0,0 +1,6 @@
1
+ export declare const useSchemeToggle: () => {
2
+ mode: "dark" | "light" | "system";
3
+ toggle: () => void;
4
+ updateMode: (value: "light" | "dark") => void;
5
+ };
6
+ //# sourceMappingURL=use-scheme-toggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-scheme-toggle.d.ts","sourceRoot":"","sources":["../../src/hooks/use-scheme-toggle.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;wBAWC,OAAO,GAAG,MAAM;CAK5C,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { useColorScheme as useMaterialColorScheme } from "@mui/material/styles";
2
+ export const useSchemeToggle = () => {
3
+ const { mode: muiMode, setMode: setMaterialMode } = useMaterialColorScheme();
4
+ const toggle = () => {
5
+ if (muiMode === "light") {
6
+ setMaterialMode("dark");
7
+ }
8
+ else {
9
+ setMaterialMode("light");
10
+ }
11
+ };
12
+ const updateMode = (value) => {
13
+ setMaterialMode(value);
14
+ };
15
+ return { mode: muiMode, toggle, updateMode };
16
+ };
@@ -0,0 +1,5 @@
1
+ export declare const useViewport: () => {
2
+ isMobile: boolean;
3
+ isDesktop: boolean;
4
+ };
5
+ //# sourceMappingURL=use-viewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-viewport.d.ts","sourceRoot":"","sources":["../../src/hooks/use-viewport.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;CAOvB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { useMediaQuery } from "@mui/material";
2
+ export const useViewport = () => {
3
+ const isUpMd = useMediaQuery((theme) => theme?.breakpoints.up("md"));
4
+ const viewport = {
5
+ isMobile: !isUpMd,
6
+ isDesktop: isUpMd,
7
+ };
8
+ return viewport;
9
+ };
@@ -0,0 +1,12 @@
1
+ export declare const ListGridTitle: (props: {
2
+ title: string;
3
+ defaultTitle?: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ListGrid: (props: {
6
+ children: React.ReactNode;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const ListGridItem: (props: {
9
+ title: string;
10
+ children: React.ReactNode;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=ListGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListGrid.d.ts","sourceRoot":"","sources":["../../src/list/ListGrid.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,GAAI,OAAO;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,4CASA,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,4CAM5D,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,4CAaA,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Grid } from "@mui/material";
3
+ import { AccordionSummary } from "../Accordion";
4
+ import { Typography } from "../Typography";
5
+ export const ListGridTitle = (props) => {
6
+ const { title, defaultTitle = "(No Title)" } = props;
7
+ return (_jsx(AccordionSummary, { children: _jsx(Typography, { sx: { wordWrap: "break-word", maxWidth: "90%" }, children: title || defaultTitle }) }));
8
+ };
9
+ export const ListGrid = (props) => {
10
+ return (_jsx(Grid, { container: true, rowSpacing: 1, sx: { width: "100%", mt: 2 }, children: props.children }));
11
+ };
12
+ export const ListGridItem = (props) => {
13
+ const { title, children } = props;
14
+ return (_jsxs(_Fragment, { children: [" ", _jsx(Grid, { size: { xs: 3 }, children: _jsx(Typography, { sx: { fontWeight: 600 }, children: title }) }), _jsx(Grid, { size: { xs: 9 }, children: _jsx(Typography, { component: "span", children: children }) })] }));
15
+ };
@@ -0,0 +1,43 @@
1
+ import { CSSProperties, ReactNode } from "react";
2
+ import { SxProps } from "@mui/material";
3
+ export declare const Table: (props: {
4
+ children: ReactNode;
5
+ sx?: SxProps | undefined;
6
+ stripe?: "even" | "odd" | "none" | undefined;
7
+ ariaLabel?: string;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const THead: (props: {
10
+ children: ReactNode;
11
+ }) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const Th: (props: {
13
+ show?: boolean;
14
+ viewport?: "desktop" | "mobile";
15
+ children?: React.ReactNode;
16
+ style?: CSSProperties | undefined;
17
+ [x: string]: any;
18
+ }) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const Td: (props: {
20
+ show?: boolean;
21
+ viewport?: "desktop" | "mobile";
22
+ children: React.ReactNode;
23
+ style?: CSSProperties | undefined;
24
+ size?: "small" | "medium" | "large";
25
+ colSpan?: number;
26
+ }) => import("react/jsx-runtime").JSX.Element;
27
+ export declare const SortableTh: (props: {
28
+ name: string | ReactNode;
29
+ orderby: string;
30
+ viewport?: "desktop" | "mobile";
31
+ show?: boolean;
32
+ style?: CSSProperties | undefined;
33
+ }) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const Tr: (props: {
35
+ children: ReactNode;
36
+ style?: CSSProperties;
37
+ }) => import("react/jsx-runtime").JSX.Element;
38
+ export declare const ActionTd: (props: {
39
+ viewport?: "desktop" | "mobile";
40
+ style?: CSSProperties | undefined;
41
+ children: ReactNode[];
42
+ }) => import("react/jsx-runtime").JSX.Element;
43
+ //# sourceMappingURL=ListTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListTable.d.ts","sourceRoot":"","sources":["../../src/list/ListTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,SAAS,EAGV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAa,OAAO,EAAE,MAAM,eAAe,CAAC;AAmCnD,eAAO,MAAM,KAAK,GAAI,OAAO;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,4CAiBA,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,OAAO;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,4CAMnD,CAAC;AAEF,eAAO,MAAM,EAAE,GAAI,OAAO;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAChC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB,4CAmCA,CAAC;AAEF,eAAO,MAAM,EAAE,GAAI,OAAO;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,4CAsCA,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC,4CAkDA,CAAC;AAMF,eAAO,MAAM,EAAE,GAAI,OAAO;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,4CAqBvE,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO;IAC9B,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB,4CAwBA,CAAC"}
@@ -0,0 +1,143 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState, } from "react";
3
+ import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
4
+ import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp";
5
+ import { Box, Link } from "@mui/material";
6
+ import { styled } from "@mui/material/styles";
7
+ import MuiTable from "@mui/material/Table";
8
+ import TableCell, { tableCellClasses } from "@mui/material/TableCell";
9
+ import TableHead from "@mui/material/TableHead";
10
+ import TableRow from "@mui/material/TableRow";
11
+ import { useWPTheme } from "../ThemeRegistry";
12
+ import { useNavigation } from "@rnaga/wp-next-core/client/hooks/use-navigation";
13
+ import { useViewport } from "../hooks/use-viewport";
14
+ const StyledTableCell = styled(TableCell)(({ theme }) => ({
15
+ [`&.${tableCellClasses.head}`]: {
16
+ // backgroundColor: theme.palette.common.black,
17
+ // color: theme.palette.common.white,
18
+ },
19
+ [`&.${tableCellClasses.body}`]: {
20
+ fontSize: 14,
21
+ },
22
+ }));
23
+ const StyledTableRow = styled(TableRow)(({ theme }) => ({
24
+ "&:nth-of-type(even)": {
25
+ backgroundColor: theme.palette.action.hover,
26
+ },
27
+ // hide last border
28
+ "&:last-child td, &:last-child th": {
29
+ border: 0,
30
+ },
31
+ // Apply left padding to the first cell of every row
32
+ "& td:first-of-type, & th:first-of-type": {
33
+ paddingLeft: 10,
34
+ },
35
+ }));
36
+ export const Table = (props) => {
37
+ const { sx, stripe, ariaLabel } = props;
38
+ return (_jsx(MuiTable
39
+ // stripe={stripe ?? "odd"}
40
+ , {
41
+ // stripe={stripe ?? "odd"}
42
+ sx: {
43
+ // "& th": (theme) => theme.variants.soft.neutral,
44
+ borderCollapse: "collapse",
45
+ "& *": {
46
+ wordWrap: "break-word",
47
+ },
48
+ ...sx,
49
+ }, children: props.children }));
50
+ };
51
+ export const THead = (props) => {
52
+ return (_jsx(TableHead, { children: _jsx(StyledTableRow, { children: props.children }) }));
53
+ };
54
+ export const Th = (props) => {
55
+ const { viewport, show = true, children, style = {}, ...rest } = props;
56
+ const currentViewport = useViewport();
57
+ const { wpTheme } = useWPTheme();
58
+ if (!show ||
59
+ (viewport &&
60
+ ((viewport == "mobile" && !currentViewport.isMobile) ||
61
+ (viewport == "desktop" && !currentViewport.isDesktop)))) {
62
+ return null;
63
+ }
64
+ return (_jsx(StyledTableCell, { sx: {
65
+ [`&.${tableCellClasses.head}`]: {
66
+ backgroundColor: wpTheme.table.header.backgroundColor, //(theme) => theme.palette.common.black,
67
+ color: wpTheme.table.header.color, //(theme) => theme.palette.common.white,
68
+ px: 0,
69
+ py: 1.5,
70
+ mb: 1,
71
+ fontWeight: "bold",
72
+ // For the first cell
73
+ "&:first-of-type": {
74
+ pl: 1,
75
+ },
76
+ },
77
+ }, style: { ...style, overflowWrap: "break-word" }, ...rest, children: children }));
78
+ };
79
+ export const Td = (props) => {
80
+ const { show = true, viewport, children, style = {}, size = "small", colSpan = 1, ...rest } = props;
81
+ const currentViewport = useViewport();
82
+ if (!show ||
83
+ (viewport &&
84
+ ((viewport == "mobile" && !currentViewport.isMobile) ||
85
+ (viewport == "desktop" && !currentViewport.isDesktop)))) {
86
+ return null;
87
+ }
88
+ return (_jsx(StyledTableCell, { colSpan: colSpan, style: {
89
+ overflowWrap: "break-word",
90
+ padding: 2,
91
+ maxWidth: 250,
92
+ ...style,
93
+ },
94
+ ...rest, children: children }));
95
+ };
96
+ export const SortableTh = (props) => {
97
+ const { updateRouter, queryObject } = useNavigation();
98
+ const { wpTheme } = useWPTheme();
99
+ return (_jsx(Th, { show: props.show, style: { ...props.style, alignItems: "center" }, viewport: props.viewport, children: _jsx(Link, { component: "button", underline: "none", onClick: () => updateRouter({
100
+ orderby: props.orderby,
101
+ order: queryObject.orderby !== props.orderby ||
102
+ queryObject.order == "asc"
103
+ ? "desc"
104
+ : "asc",
105
+ }), sx: {
106
+ "&:hover": {
107
+ backgroundColor: wpTheme.text.linkHoverColor,
108
+ },
109
+ }, children: _jsxs(Box, { sx: {
110
+ display: "flex",
111
+ alignItems: "center",
112
+ gap: 1,
113
+ width: "100%",
114
+ justifyContent: "space-between",
115
+ }, children: [props.name, " ", queryObject.orderby !== props.orderby ? (_jsx(ArrowDropDownIcon, {})) : queryObject.order === "desc" ? (_jsx(ArrowDropDownIcon, {})) : (_jsx(ArrowDropUpIcon, {}))] }) }) }));
116
+ };
117
+ const TableContext = createContext({
118
+ mouseOver: false,
119
+ });
120
+ export const Tr = (props) => {
121
+ const { children, style } = props;
122
+ const [mouseOver, setMouseOver] = useState(false);
123
+ return (_jsx(TableContext.Provider, { value: { mouseOver }, children: _jsx(StyledTableRow, { sx: {
124
+ verticalAlign: "top",
125
+ borderBottom: "10px solid transparent",
126
+ ...style,
127
+ }, onMouseOver: () => {
128
+ setMouseOver(true);
129
+ }, onMouseLeave: () => setMouseOver(false), children: children }) }));
130
+ };
131
+ export const ActionTd = (props) => {
132
+ let { viewport = "desktop", style, children } = props;
133
+ const currentViewport = useViewport();
134
+ const { mouseOver } = useContext(TableContext);
135
+ if ((viewport == "mobile" && !currentViewport.isMobile) ||
136
+ (viewport == "desktop" && !currentViewport.isDesktop)) {
137
+ return null;
138
+ }
139
+ const show = viewport == "mobile" || mouseOver;
140
+ const [first, ...rest] = children;
141
+ children = show ? children : children?.filter((item, index) => index === 0);
142
+ return (_jsxs("td", { style: { ...style }, children: [first, _jsx(Box, { sx: { minHeight: 20 }, children: show ? rest : "" })] }));
143
+ };
@@ -0,0 +1,5 @@
1
+ import type * as wpTypes from "@rnaga/wp-node/types";
2
+ export declare const Pagination: (props: {
3
+ pagination?: wpTypes.crud.Pagination;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=Pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../../src/list/Pagination.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,UAAU,GAAI,OAAO;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAA;CAAE,4CAuCzE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, Pagination as MuiPagination } from "@mui/material";
3
+ import { Typography } from "../Typography";
4
+ import { Viewport } from "../Viewport";
5
+ import { useNavigation } from "@rnaga/wp-next-core/client/hooks/use-navigation";
6
+ export const Pagination = (props) => {
7
+ const { pagination } = props;
8
+ const { queryObject, updateRouter } = useNavigation();
9
+ if (!pagination) {
10
+ return null;
11
+ }
12
+ const total = pagination?.totalPage ?? 0;
13
+ const count = pagination.count ?? 0;
14
+ const page = !queryObject.page ? 1 : parseInt(queryObject.page?.toString());
15
+ return (_jsxs(Box, { sx: (theme) => ({
16
+ display: "flex",
17
+ gap: 1,
18
+ justifyContent: "flex-end",
19
+ alignItems: "center",
20
+ [theme.breakpoints.down("md")]: {
21
+ justifyContent: "center",
22
+ },
23
+ }), children: [_jsx(Viewport, { device: "desktop", children: _jsxs(Typography, { bold: true, children: [count, " items"] }) }), _jsx(Box, { sx: { maxHeight: 30 }, children: _jsx(MuiPagination, { page: page, count: total, siblingCount: 0, onChange: (e, page) => updateRouter({ page }), variant: "outlined", shape: "rounded" }) })] }));
24
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./ListGrid";
2
+ export * from "./Pagination";
3
+ export * from "./ListTable";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/list/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
package/list/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./ListGrid";
2
+ export * from "./Pagination";
3
+ export * from "./ListTable";
@@ -0,0 +1,5 @@
1
+ import * as wpCoreTypes from "@rnaga/wp-next-core/types";
2
+ export declare const MediaGridForm: (props?: Partial<{
3
+ onChange: (post: Partial<wpCoreTypes.actions.Post>) => void;
4
+ }>) => import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=MediaGridForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaGridForm.d.ts","sourceRoot":"","sources":["../../src/media/MediaGridForm.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAUzD,eAAO,MAAM,aAAa,GACxB,QAAQ,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;CAC7D,CAAC,4CAuPH,CAAC"}
@@ -0,0 +1,128 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import CheckIcon from "@mui/icons-material/Check";
4
+ import ContentCopyIcon from "@mui/icons-material/ContentCopy";
5
+ import { Box, Grid, IconButton, Tooltip } from "@mui/material";
6
+ import { Input } from "../Input";
7
+ import { Typography } from "../Typography";
8
+ import { useServerActions } from "@rnaga/wp-next-core/client/hooks/use-server-actions";
9
+ import { mediaMetakeys } from "@rnaga/wp-next-core/client/utils/media";
10
+ import { useWP } from "@rnaga/wp-next-core/client/wp";
11
+ export const MediaGridForm = (props) => {
12
+ const { onChange } = props ?? {};
13
+ const { error, globalState } = useWP();
14
+ const { actions, safeParse, parse } = useServerActions();
15
+ //const { setFormData } = useFormData<wpTypes.trx.PostUpsert>("post");
16
+ const mediaTargetItemState = globalState.get("media-target-item");
17
+ const post = mediaTargetItemState?.post;
18
+ const [metas, setMetas] = useState();
19
+ const [canEdit, setCanEdit] = useState(false);
20
+ const [actionStateText, setActionStateText] = useState();
21
+ const [guidCopied, setGuidCopied] = useState(false);
22
+ const setActionState = (text) => {
23
+ if (text == "Saved") {
24
+ setActionStateText("Saved");
25
+ setTimeout(() => {
26
+ setActionStateText(undefined);
27
+ }, 2000);
28
+ return;
29
+ }
30
+ setActionStateText(text);
31
+ };
32
+ useEffect(() => {
33
+ if (!post?.ID)
34
+ return;
35
+ const postId = post.ID;
36
+ actions.meta
37
+ .get("post", postId, mediaMetakeys)
38
+ .then((response) => {
39
+ const [metas] = parse(response);
40
+ setMetas(metas);
41
+ });
42
+ Promise.all([
43
+ actions.user.can("edit_posts"),
44
+ actions.user.can("edit_post", postId),
45
+ ]).then((responses) => {
46
+ if (responses.filter((response) => true === safeParse(response).data)
47
+ .length > 0) {
48
+ setCanEdit(true);
49
+ actions.post.get(postId).then((response) => {
50
+ const result = safeParse(response);
51
+ if (!result.success || result.data.post_status !== "inherit") {
52
+ error.throw("You cannot edit this item because it is not a valid item.");
53
+ return;
54
+ }
55
+ //setFormData(response.data);
56
+ onChange?.(response.data);
57
+ });
58
+ }
59
+ });
60
+ }, [post?.ID]);
61
+ const handleUpdate = (...args) => {
62
+ const [postId, data] = args;
63
+ setActionState("Saving...");
64
+ actions.media
65
+ .update(postId, data)
66
+ .then((response) => {
67
+ const result = safeParse(response);
68
+ if (result.success && post) {
69
+ globalState.set("media-target-item", {
70
+ post: { ...post, ...data },
71
+ });
72
+ }
73
+ })
74
+ .finally(() => {
75
+ setActionState("Saved");
76
+ });
77
+ };
78
+ const handleAltUpdate = (value) => {
79
+ if (!post?.ID)
80
+ return;
81
+ const postId = post.ID;
82
+ setActionState("Saving...");
83
+ actions.media
84
+ .updateAlt(postId, value)
85
+ .then((response) => {
86
+ const result = safeParse(response);
87
+ if (result.success && metas) {
88
+ setMetas({
89
+ ...metas,
90
+ _wp_attachment_image_alt: value,
91
+ });
92
+ }
93
+ })
94
+ .finally(() => {
95
+ setActionState("Saved");
96
+ });
97
+ };
98
+ if (!post) {
99
+ return null;
100
+ }
101
+ return (_jsxs(Grid, { container: true, spacing: 2, sx: {
102
+ flexGrow: 1,
103
+ }, children: [_jsx(Grid, { size: { xs: 12 }, sx: { position: "absolute" }, children: _jsx(Box, { sx: {
104
+ position: "relative",
105
+ top: -30,
106
+ display: "flex",
107
+ justifyContent: "flex-end",
108
+ mx: 2,
109
+ }, children: _jsx(Typography, { children: actionStateText }) }) }), _jsx(Grid, { size: { xs: 4 }, children: _jsx(Typography, { children: "Alternative Text" }) }), _jsx(Grid, { size: { xs: 8 }, children: _jsx(Input, { size: "medium", multiline: true, minRows: 3, maxRows: 3, value: metas?._wp_attachment_image_alt, onBlur: (value) => canEdit && handleAltUpdate(value), disabled: !canEdit, sx: {
110
+ width: "100%",
111
+ } }, "alt-text") }), _jsx(Grid, { size: { xs: 4 }, children: _jsx(Typography, { children: "Title" }) }), _jsx(Grid, { size: { xs: 8 }, children: _jsx(Input, { size: "medium", value: post?.post_title, onBlur: (value) => canEdit && handleUpdate(post.ID, { post_title: value }), disabled: !canEdit, sx: { width: "100%" } }, "title") }), _jsx(Grid, { size: { xs: 4 }, children: _jsx(Typography, { children: "Caption" }) }), _jsx(Grid, { size: { xs: 8 }, children: _jsx(Input, { size: "medium", multiline: true, minRows: 2, maxRows: 2, value: post?.post_excerpt, disabled: !canEdit, onBlur: (value) => canEdit &&
112
+ handleUpdate(post.ID, {
113
+ post_excerpt: value,
114
+ }), sx: { width: "100%" } }, "excerpt") }), _jsx(Grid, { size: { xs: 4 }, children: _jsx(Typography, { children: "Description" }) }), _jsx(Grid, { size: { xs: 8 }, children: _jsx(Input, { size: "medium", multiline: true, minRows: 2, maxRows: 2, value: post?.post_content, disabled: !canEdit, onBlur: (value) => canEdit &&
115
+ handleUpdate(post.ID, {
116
+ post_content: value,
117
+ }), sx: { width: "100%" } }, "description") }), _jsxs(Grid, { size: { xs: 4 }, sx: {
118
+ display: "flex",
119
+ alignItems: "center",
120
+ justifyContent: "space-between",
121
+ }, children: [_jsx(Typography, { children: "File URL" }), guidCopied ? (_jsx(CheckIcon, {})) : (_jsx(Tooltip, { title: "Copy to clipboard", placement: "top", children: _jsx(IconButton, { size: "small", onClick: () => {
122
+ navigator.clipboard.writeText(post.guid);
123
+ setGuidCopied(true);
124
+ setTimeout(() => {
125
+ setGuidCopied(false);
126
+ }, 1000);
127
+ }, children: _jsx(ContentCopyIcon, {}) }) }))] }), _jsx(Grid, { size: { xs: 8 }, children: _jsx(Input, { disabled: true, size: "medium", value: post?.guid, sx: { width: "100%" } }, "title") })] }));
128
+ };
@@ -0,0 +1,4 @@
1
+ export declare const MediaThumbnail: (props: {
2
+ uri: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=MediaThumbnail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaThumbnail.d.ts","sourceRoot":"","sources":["../../src/media/MediaThumbnail.tsx"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,GAAI,OAAO;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,4CAuBpD,CAAC"}