@pol-studios/ui 1.0.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.
- package/dist/adapters/index.js +359 -0
- package/dist/auth/index.js +588 -0
- package/dist/canvas-UVNDA54X.node +0 -0
- package/dist/cards/index.js +872 -0
- package/dist/charts/index.js +54148 -0
- package/dist/components/chat-agent/index.js +21434 -0
- package/dist/components/index.js +148416 -0
- package/dist/contexts/index.js +188 -0
- package/dist/crud/index.js +6550 -0
- package/dist/data/index.js +372 -0
- package/dist/feedback/index.js +9534 -0
- package/dist/file/index.js +256 -0
- package/dist/forms/index.js +504 -0
- package/dist/hooks/index.js +345 -0
- package/dist/index.js +15650 -0
- package/dist/nav/index.js +1556 -0
- package/dist/navbar/index.js +45262 -0
- package/dist/primitives/index.js +15646 -0
- package/dist/providers/index.js +1927 -0
- package/dist/types/index.js +1 -0
- package/package.json +226 -0
- package/src/styles/globals.css +157 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/contexts/AlertContext.tsx
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var Context = class {
|
|
7
|
+
showAlert;
|
|
8
|
+
hideAlert;
|
|
9
|
+
alertState = new AlertState();
|
|
10
|
+
};
|
|
11
|
+
var AlertState = class {
|
|
12
|
+
isOpen = false;
|
|
13
|
+
title;
|
|
14
|
+
description;
|
|
15
|
+
confirmTitle = "Confirm";
|
|
16
|
+
cancelTitle = "Cancel";
|
|
17
|
+
variant = "default";
|
|
18
|
+
onConfirm;
|
|
19
|
+
onCancel;
|
|
20
|
+
};
|
|
21
|
+
var AlertContext = createContext(new Context());
|
|
22
|
+
var useAlert = () => {
|
|
23
|
+
const context = useContext(AlertContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error("useAlert must be used within an AlertProvider");
|
|
26
|
+
}
|
|
27
|
+
return { hideAlert: context.hideAlert, showAlert: context.showAlert };
|
|
28
|
+
};
|
|
29
|
+
var AlertProvider = ({ children }) => {
|
|
30
|
+
const [alertState, setAlertState] = useState(new AlertState());
|
|
31
|
+
async function showAlert({ title, description, confirmTitle, cancelTitle, variant = "default" }) {
|
|
32
|
+
const result = await new Promise(
|
|
33
|
+
(resolve, reject) => setAlertState({
|
|
34
|
+
isOpen: true,
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
confirmTitle,
|
|
38
|
+
cancelTitle,
|
|
39
|
+
variant,
|
|
40
|
+
onConfirm: () => resolve(true),
|
|
41
|
+
onCancel: () => resolve(false)
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
const hideAlert = () => {
|
|
47
|
+
setAlertState({ ...alertState, isOpen: false });
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ jsx(AlertContext.Provider, { value: { alertState, showAlert, hideAlert }, children });
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// src/contexts/NavContext.tsx
|
|
53
|
+
import { createContext as createContext2, useEffect, useState as useState2 } from "react";
|
|
54
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
55
|
+
var NavContext = createContext2({
|
|
56
|
+
currentPage: { title: "", location: "" },
|
|
57
|
+
currentCallStack: /* @__PURE__ */ new Map(),
|
|
58
|
+
setCurrentPage: (url, title) => {
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function isChildPath(parentPath, childPath) {
|
|
62
|
+
const normalizedParent = parentPath?.endsWith("/") ? parentPath : parentPath + "/";
|
|
63
|
+
const normalizedChild = childPath?.endsWith("/") ? childPath : childPath + "/";
|
|
64
|
+
return normalizedChild.startsWith(normalizedParent);
|
|
65
|
+
}
|
|
66
|
+
function NavContextProvider({ children }) {
|
|
67
|
+
const [currentPage, setCurrentPage] = useState2({ title: "", location: "" });
|
|
68
|
+
const [currentCallStack, setCurrentCallStack] = useState2(/* @__PURE__ */ new Map());
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setCurrentCallStack((prev) => {
|
|
71
|
+
const newMap = /* @__PURE__ */ new Map();
|
|
72
|
+
for (const [location, title] of prev.entries()) {
|
|
73
|
+
if (isChildPath(location, currentPage.location) && location !== "") {
|
|
74
|
+
newMap.set(location, title);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
newMap.set(currentPage.location, currentPage.title);
|
|
78
|
+
return newMap;
|
|
79
|
+
});
|
|
80
|
+
}, [currentPage]);
|
|
81
|
+
return /* @__PURE__ */ jsx2(
|
|
82
|
+
NavContext.Provider,
|
|
83
|
+
{
|
|
84
|
+
value: {
|
|
85
|
+
currentPage,
|
|
86
|
+
currentCallStack,
|
|
87
|
+
setCurrentPage: (title, url) => setCurrentPage({ title, location: url })
|
|
88
|
+
},
|
|
89
|
+
children
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/contexts/contexts/core/SelectedItemsContext.tsx
|
|
95
|
+
import { createContext as createContext3, useEffect as useEffect2, useState as useState3 } from "react";
|
|
96
|
+
import { isUsable } from "@pol-studios/utils";
|
|
97
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
98
|
+
var defaultContextValue = {
|
|
99
|
+
Items: [],
|
|
100
|
+
SelectedItems: [],
|
|
101
|
+
AddItem: () => {
|
|
102
|
+
},
|
|
103
|
+
// Empty function as placeholder
|
|
104
|
+
RemoveItem: () => {
|
|
105
|
+
},
|
|
106
|
+
// Empty function as placeholder
|
|
107
|
+
SetSelectedItems: () => {
|
|
108
|
+
},
|
|
109
|
+
// Corrected function as placeholder
|
|
110
|
+
UpdateItem: () => {
|
|
111
|
+
}
|
|
112
|
+
// Corrected function as placeholder
|
|
113
|
+
};
|
|
114
|
+
function createSelectedItemsContext() {
|
|
115
|
+
const context = createContext3(defaultContextValue);
|
|
116
|
+
const Provider = ({ children, Items, initialSelectedItems = [] }) => {
|
|
117
|
+
const [selectedItems, setSelectedItems] = useState3(initialSelectedItems);
|
|
118
|
+
const [items, setItems] = useState3([]);
|
|
119
|
+
useEffect2(() => {
|
|
120
|
+
setItems(Items);
|
|
121
|
+
}, [Items]);
|
|
122
|
+
useEffect2(() => {
|
|
123
|
+
setSelectedItems(
|
|
124
|
+
(previousItems) => previousItems.map((x) => Items.find((i) => i.id == x.id)).filter((x) => x != null)
|
|
125
|
+
);
|
|
126
|
+
}, [Items]);
|
|
127
|
+
function addSelectedItem(item) {
|
|
128
|
+
setSelectedItems([...selectedItems, item]);
|
|
129
|
+
}
|
|
130
|
+
function removeSelectedItem(item) {
|
|
131
|
+
setSelectedItems(selectedItems.filter((x) => x !== item));
|
|
132
|
+
}
|
|
133
|
+
function updateItem(item, newProperties) {
|
|
134
|
+
if (isUsable(item)) {
|
|
135
|
+
const newValue = { ...item, ...newProperties ?? {} };
|
|
136
|
+
setItems(items.map((x) => x.id == item.id ? newValue : x));
|
|
137
|
+
setSelectedItems(selectedItems.map((x) => x.id == item.id ? newValue : x));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return /* @__PURE__ */ jsx3(
|
|
141
|
+
context.Provider,
|
|
142
|
+
{
|
|
143
|
+
value: {
|
|
144
|
+
Items: items,
|
|
145
|
+
SelectedItems: selectedItems,
|
|
146
|
+
AddItem: addSelectedItem,
|
|
147
|
+
RemoveItem: removeSelectedItem,
|
|
148
|
+
SetSelectedItems: setSelectedItems,
|
|
149
|
+
UpdateItem: updateItem
|
|
150
|
+
},
|
|
151
|
+
children
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
return { context, Provider };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/contexts/contexts/SelectedFixturesContext.tsx
|
|
159
|
+
var {
|
|
160
|
+
context: SelectedFixturesContext,
|
|
161
|
+
Provider: SelectedFixturesProvider
|
|
162
|
+
} = createSelectedItemsContext();
|
|
163
|
+
|
|
164
|
+
// src/contexts/contexts/TimeActivityDropdownContext.ts
|
|
165
|
+
import { createContext as createContext4 } from "react";
|
|
166
|
+
var TimeActivityDropdowns = class {
|
|
167
|
+
Clients;
|
|
168
|
+
Projects;
|
|
169
|
+
WorkingPhases;
|
|
170
|
+
Roles;
|
|
171
|
+
Tasks;
|
|
172
|
+
SubTasks;
|
|
173
|
+
};
|
|
174
|
+
var TimeActivityDropdownContext = createContext4(
|
|
175
|
+
new TimeActivityDropdowns()
|
|
176
|
+
);
|
|
177
|
+
export {
|
|
178
|
+
AlertContext,
|
|
179
|
+
AlertProvider,
|
|
180
|
+
NavContext,
|
|
181
|
+
NavContextProvider,
|
|
182
|
+
SelectedFixturesContext,
|
|
183
|
+
SelectedFixturesProvider,
|
|
184
|
+
TimeActivityDropdownContext,
|
|
185
|
+
TimeActivityDropdowns,
|
|
186
|
+
createSelectedItemsContext,
|
|
187
|
+
useAlert
|
|
188
|
+
};
|