hyperclayjs 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/LICENSE +21 -0
- package/README.md +360 -0
- package/README.template.md +276 -0
- package/communication/behaviorCollector.js +230 -0
- package/communication/sendMessage.js +48 -0
- package/communication/uploadFile.js +348 -0
- package/core/adminContenteditable.js +36 -0
- package/core/adminInputs.js +58 -0
- package/core/adminOnClick.js +31 -0
- package/core/adminResources.js +33 -0
- package/core/adminSystem.js +15 -0
- package/core/editmode.js +8 -0
- package/core/editmodeSystem.js +18 -0
- package/core/enablePersistentFormInputValues.js +62 -0
- package/core/isAdminOfCurrentResource.js +13 -0
- package/core/optionVisibilityRuleGenerator.js +160 -0
- package/core/savePage.js +196 -0
- package/core/savePageCore.js +236 -0
- package/core/setPageTypeOnDocumentElement.js +23 -0
- package/custom-attributes/ajaxElements.js +94 -0
- package/custom-attributes/autosize.js +17 -0
- package/custom-attributes/domHelpers.js +175 -0
- package/custom-attributes/events.js +15 -0
- package/custom-attributes/inputHelpers.js +11 -0
- package/custom-attributes/onclickaway.js +27 -0
- package/custom-attributes/onclone.js +35 -0
- package/custom-attributes/onpagemutation.js +20 -0
- package/custom-attributes/onrender.js +30 -0
- package/custom-attributes/preventEnter.js +13 -0
- package/custom-attributes/sortable.js +76 -0
- package/dom-utilities/All.js +412 -0
- package/dom-utilities/getDataFromForm.js +60 -0
- package/dom-utilities/insertStyleTag.js +28 -0
- package/dom-utilities/onDomReady.js +7 -0
- package/dom-utilities/onLoad.js +7 -0
- package/hyperclay.js +465 -0
- package/module-dependency-graph.json +612 -0
- package/package.json +95 -0
- package/string-utilities/copy-to-clipboard.js +35 -0
- package/string-utilities/emmet-html.js +54 -0
- package/string-utilities/query.js +1 -0
- package/string-utilities/slugify.js +21 -0
- package/ui/info.js +39 -0
- package/ui/prompts.js +179 -0
- package/ui/theModal.js +677 -0
- package/ui/toast.js +273 -0
- package/utilities/cookie.js +45 -0
- package/utilities/debounce.js +12 -0
- package/utilities/mutation.js +403 -0
- package/utilities/nearest.js +97 -0
- package/utilities/pipe.js +1 -0
- package/utilities/throttle.js +21 -0
- package/vendor/Sortable.js +3351 -0
- package/vendor/idiomorph.min.js +8 -0
- package/vendor/tailwind-base.css +1471 -0
- package/vendor/tailwind-play.js +169 -0
package/ui/toast.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// a nice, simple alert
|
|
2
|
+
// ❗️ don't use too much text!
|
|
3
|
+
|
|
4
|
+
// Default modern icons
|
|
5
|
+
const defaultIcons = {
|
|
6
|
+
success: `<svg viewBox="0 0 48 45" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.9404 22.4475L21.9099 29.724L35.1906 14.4045M3 3H44.9804V42.809H3V3Z" stroke="#33D131" stroke-width="4.3"/></svg>`,
|
|
7
|
+
error: `<svg viewBox="0 0 46 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M31.7383 12.4045L13 31.1429M31.7451 31.1429L13.0068 12.4046M2.00977 2H43.9902V41.809H2.00977V2Z" stroke="#FF4450" stroke-width="4"/></svg>`
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Legacy icons for hyperclay.com
|
|
11
|
+
const legacyIcons = {
|
|
12
|
+
success: `<svg viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M32 1h-5v3.5h-2.5V8h-2v3.5H20V15h-2.5v3.5h-2V22H13v3.5H9V22H7v-3.5H6V15H1v3.5h1V22h2v3.5h1.5V29H7v3.5h5V29h3.5v-3.5H18V22h2.5v-3.5h2V15H25v-3.5h2.5V8h2V4.5H32V1Z" fill="#76C824"/></svg>`,
|
|
13
|
+
error: `<svg viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M33 1h-5v3.5h-3.5V8H21v3.5h-3.5V15h-2v-3.5H12V8H8.5V4.5H5V1H0v3.5h3.5V8H7v3.5h3.5V15H14v3.5h-3.5V22H7v3.5H3.5V29H0v3.5h5V29h3.5v-3.5H12V22h3.5v-3.5h2V22H21v3.5h3.5V29H28v3.5h5V29h-3.5v-3.5H26V22h-3.5v-3.5H19V15h3.5v-3.5H26V8h3.5V4.5H33V1Z" fill="#DD304F"/></svg>`
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Default templates
|
|
17
|
+
const defaultTemplates = {
|
|
18
|
+
container: `<div class="toast-container" save-ignore></div>`,
|
|
19
|
+
toast: {
|
|
20
|
+
success: `
|
|
21
|
+
<div class="toast toast-modern hide success noise-texture">
|
|
22
|
+
<div class="toast-icon">{icon}</div>
|
|
23
|
+
<div class="toast-message">{message}</div>
|
|
24
|
+
</div>
|
|
25
|
+
`,
|
|
26
|
+
error: `
|
|
27
|
+
<div class="toast toast-modern hide error noise-texture">
|
|
28
|
+
<div class="toast-icon">{icon}</div>
|
|
29
|
+
<div class="toast-message">{message}</div>
|
|
30
|
+
</div>
|
|
31
|
+
`
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Legacy templates for hyperclay.com
|
|
36
|
+
const legacyTemplates = {
|
|
37
|
+
container: `<div class="toast-container" save-ignore></div>`,
|
|
38
|
+
toast: {
|
|
39
|
+
success: `
|
|
40
|
+
<div class="toast hide success">
|
|
41
|
+
{icon}
|
|
42
|
+
<span class="message">{message}</span>
|
|
43
|
+
</div>
|
|
44
|
+
`,
|
|
45
|
+
error: `
|
|
46
|
+
<div class="toast hide error">
|
|
47
|
+
{icon}
|
|
48
|
+
<span class="message">{message}</span>
|
|
49
|
+
</div>
|
|
50
|
+
`
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Default styles
|
|
55
|
+
const defaultStyles = `
|
|
56
|
+
.toast-container {
|
|
57
|
+
z-index: 9999;
|
|
58
|
+
position: fixed;
|
|
59
|
+
top: 20px;
|
|
60
|
+
right: 20px;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
align-items: end;
|
|
64
|
+
gap: 18px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.toast {
|
|
68
|
+
position: relative;
|
|
69
|
+
right: 0;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
transition: right 0.5s ease-in-out, opacity 0.5s ease-in-out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.toast.hide {
|
|
75
|
+
right: -400px;
|
|
76
|
+
opacity: 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.toast-modern {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: 12px;
|
|
83
|
+
padding: 16px 24px 16px 16px;
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
font-family: monospace;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
color: white;
|
|
88
|
+
border-width: 1px;
|
|
89
|
+
border-style: solid;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.toast-modern.success {
|
|
93
|
+
border-color: #358234;
|
|
94
|
+
background: radial-gradient(85.86% 68.42% at 50% 68.42%, #142419 0%, #1D3927 100%);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.toast-modern.error {
|
|
98
|
+
border-color: #992930;
|
|
99
|
+
background: radial-gradient(85.86% 68.42% at 50% 68.42%, #240A13 0%, #481826 100%);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.toast-icon {
|
|
103
|
+
position: relative;
|
|
104
|
+
top: -1px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.toast-icon svg {
|
|
108
|
+
width: 22px;
|
|
109
|
+
height: 22px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.toast-message {
|
|
113
|
+
position: relative;
|
|
114
|
+
top: -1px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.noise-texture {
|
|
118
|
+
position: relative;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.noise-texture::before {
|
|
122
|
+
content: "";
|
|
123
|
+
position: absolute;
|
|
124
|
+
top: 0;
|
|
125
|
+
left: 0;
|
|
126
|
+
width: 100%;
|
|
127
|
+
height: 100%;
|
|
128
|
+
opacity: 0.12;
|
|
129
|
+
pointer-events: none;
|
|
130
|
+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
|
|
131
|
+
background-repeat: repeat;
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
const legacyStyles = `
|
|
136
|
+
.toast-container {
|
|
137
|
+
z-index: 9999;
|
|
138
|
+
position: fixed;
|
|
139
|
+
top: 20px;
|
|
140
|
+
right: 20px;
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
align-items: end;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.toast-container > * + * {
|
|
147
|
+
margin-top: 18px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.toast {
|
|
151
|
+
position: relative;
|
|
152
|
+
right: 0;
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
padding: 10px 19px 11px 17px;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
color: rgba(255,255,255,.8);
|
|
158
|
+
background-color: #0B0C12;
|
|
159
|
+
border: 2px dashed rgba(255,255,255,.6);
|
|
160
|
+
transition: right 0.5s ease-in-out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.toast svg {
|
|
164
|
+
position: relative;
|
|
165
|
+
top: -1px;
|
|
166
|
+
width: 17px;
|
|
167
|
+
height: 17px;
|
|
168
|
+
margin-right: 13px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.toast.hide {
|
|
172
|
+
right: -300px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.toast.success {
|
|
176
|
+
color: #76C824;
|
|
177
|
+
border: 2px dashed #589E11;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.toast.error {
|
|
181
|
+
color: #DD304F;
|
|
182
|
+
border: 2px dashed #CD2140;
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
// Helper function to inject styles
|
|
187
|
+
function injectStyles(styles) {
|
|
188
|
+
// Remove existing toast styles if present
|
|
189
|
+
const existingStyles = document.querySelectorAll('.toast-styles');
|
|
190
|
+
existingStyles.forEach(style => style.remove());
|
|
191
|
+
|
|
192
|
+
// Add new styles
|
|
193
|
+
const styleSheet = document.createElement('style');
|
|
194
|
+
styleSheet.className = 'toast-styles';
|
|
195
|
+
styleSheet.setAttribute('save-ignore', '');
|
|
196
|
+
styleSheet.textContent = styles;
|
|
197
|
+
document.head.appendChild(styleSheet);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Main toast function
|
|
201
|
+
function toast(message, messageType = "success") {
|
|
202
|
+
messageType = messageType || "success";
|
|
203
|
+
|
|
204
|
+
// Get configuration
|
|
205
|
+
const config = toast.config || {};
|
|
206
|
+
const templates = config.templates || defaultTemplates;
|
|
207
|
+
const icons = config.icons || defaultIcons;
|
|
208
|
+
|
|
209
|
+
// Get or create container
|
|
210
|
+
let toastContainer = document.querySelector(".toast-container");
|
|
211
|
+
if (!toastContainer) {
|
|
212
|
+
const tempDiv = document.createElement('div');
|
|
213
|
+
tempDiv.innerHTML = templates.container;
|
|
214
|
+
toastContainer = tempDiv.firstElementChild;
|
|
215
|
+
document.body.append(toastContainer);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Create toast element
|
|
219
|
+
const icon = icons[messageType] || icons.success;
|
|
220
|
+
const template = templates.toast[messageType] || templates.toast.success;
|
|
221
|
+
const toastHtml = template
|
|
222
|
+
.replace('{icon}', icon)
|
|
223
|
+
.replace('{message}', message);
|
|
224
|
+
|
|
225
|
+
const tempDiv = document.createElement('div');
|
|
226
|
+
tempDiv.innerHTML = toastHtml.trim();
|
|
227
|
+
const toastElement = tempDiv.firstElementChild;
|
|
228
|
+
|
|
229
|
+
// Add click handler
|
|
230
|
+
toastElement.addEventListener('click', () => {
|
|
231
|
+
toastElement.classList.add('hide');
|
|
232
|
+
setTimeout(() => toastElement.remove(), 500);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Add to container and animate in
|
|
236
|
+
toastContainer.append(toastElement);
|
|
237
|
+
setTimeout(() => toastElement.classList.remove('hide'), 10);
|
|
238
|
+
|
|
239
|
+
// Auto-hide after timeout
|
|
240
|
+
setTimeout(() => {
|
|
241
|
+
toastElement.classList.add('hide');
|
|
242
|
+
setTimeout(() => toastElement.remove(), 500);
|
|
243
|
+
}, 6600);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Configuration for legacy hyperclay.com style
|
|
247
|
+
toast.legacyConfig = {
|
|
248
|
+
templates: legacyTemplates,
|
|
249
|
+
icons: legacyIcons,
|
|
250
|
+
styles: legacyStyles
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// Helper to apply legacy config
|
|
254
|
+
toast.useLegacy = function() {
|
|
255
|
+
toast.config = toast.legacyConfig;
|
|
256
|
+
// Replace styles with legacy styles
|
|
257
|
+
injectStyles(legacyStyles);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// Initialize with default styles when script loads
|
|
261
|
+
injectStyles(defaultStyles);
|
|
262
|
+
|
|
263
|
+
// Export to window for global access
|
|
264
|
+
export function exportToWindow() {
|
|
265
|
+
if (!window.hyperclay) {
|
|
266
|
+
window.hyperclay = {};
|
|
267
|
+
}
|
|
268
|
+
window.hyperclay.toast = toast;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// toast("Site copied");
|
|
272
|
+
// toast("Site name taken", "error");
|
|
273
|
+
export default toast;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// e.g. Cookie.get("currentResource")
|
|
2
|
+
function get (cookieName) {
|
|
3
|
+
const cookies = document.cookie.split('; ');
|
|
4
|
+
const cookie = cookies.find(row => row.startsWith(`${cookieName}=`));
|
|
5
|
+
if (!cookie) return null;
|
|
6
|
+
const cookieValue = cookie.split('=')[1];
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(decodeURIComponent(cookieValue));
|
|
9
|
+
} catch (err) {
|
|
10
|
+
return decodeURIComponent(cookieValue);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// e.g. Cookie.remove("currentResource")
|
|
15
|
+
function remove(name) {
|
|
16
|
+
// Clear from current path
|
|
17
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;`
|
|
18
|
+
|
|
19
|
+
// Clear from current domain
|
|
20
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${window.location.hostname};`
|
|
21
|
+
|
|
22
|
+
// Clear from apex domain (e.g., .hyperclay.com or .localhyperclay.com)
|
|
23
|
+
const hostname = window.location.hostname;
|
|
24
|
+
if (hostname.includes('.')) {
|
|
25
|
+
// Get the last two parts for the apex domain (handles .com, .co.uk, etc)
|
|
26
|
+
const parts = hostname.split('.');
|
|
27
|
+
const apexDomain = '.' + parts.slice(-2).join('.');
|
|
28
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${apexDomain};`
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const cookie = {
|
|
33
|
+
get,
|
|
34
|
+
remove
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Export to window for global access
|
|
38
|
+
export function exportToWindow() {
|
|
39
|
+
if (!window.hyperclay) {
|
|
40
|
+
window.hyperclay = {};
|
|
41
|
+
}
|
|
42
|
+
window.hyperclay.cookie = cookie;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default cookie;
|