hyperclayjs 1.6.0 → 1.8.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/README.md +14 -14
- package/package.json +17 -25
- package/src/core/adminContenteditable.js +51 -0
- package/{core → src/core}/adminInputs.js +29 -8
- package/src/core/adminOnClick.js +54 -0
- package/{core → src/core}/adminResources.js +25 -5
- package/src/core/optionVisibility.js +216 -0
- package/{core → src/core}/savePage.js +1 -1
- package/{core → src/core}/savePageCore.js +13 -3
- package/{custom-attributes → src/custom-attributes}/domHelpers.js +17 -4
- package/{custom-attributes → src/custom-attributes}/events.js +2 -0
- package/src/custom-attributes/onmutation.js +90 -0
- package/src/custom-attributes/onpagemutation.js +32 -0
- package/{custom-attributes → src/custom-attributes}/sortable.js +16 -1
- package/{dom-utilities → src/dom-utilities}/All.js +22 -0
- package/{hyperclay.js → src/hyperclay.js} +4 -4
- package/{module-dependency-graph.json → src/module-dependency-graph.json} +16 -26
- package/{ui → src/ui}/prompts.js +13 -18
- package/{ui → src/ui}/theModal.js +101 -0
- package/{ui → src/ui}/toast.js +4 -3
- package/core/adminContenteditable.js +0 -36
- package/core/adminOnClick.js +0 -31
- package/core/optionVisibilityRuleGenerator.js +0 -171
- package/custom-attributes/onpagemutation.js +0 -20
- /package/{communication → src/communication}/behaviorCollector.js +0 -0
- /package/{communication → src/communication}/sendMessage.js +0 -0
- /package/{communication → src/communication}/uploadFile.js +0 -0
- /package/{core → src/core}/adminSystem.js +0 -0
- /package/{core → src/core}/autosave.js +0 -0
- /package/{core → src/core}/editmode.js +0 -0
- /package/{core → src/core}/editmodeSystem.js +0 -0
- /package/{core → src/core}/enablePersistentFormInputValues.js +0 -0
- /package/{core → src/core}/exportToWindow.js +0 -0
- /package/{core → src/core}/isAdminOfCurrentResource.js +0 -0
- /package/{core → src/core}/saveToast.js +0 -0
- /package/{core → src/core}/setPageTypeOnDocumentElement.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/ajaxElements.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/autosize.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/inputHelpers.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/onaftersave.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/onclickaway.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/onclone.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/onrender.js +0 -0
- /package/{custom-attributes → src/custom-attributes}/preventEnter.js +0 -0
- /package/{dom-utilities → src/dom-utilities}/getDataFromForm.js +0 -0
- /package/{dom-utilities → src/dom-utilities}/insertStyleTag.js +0 -0
- /package/{dom-utilities → src/dom-utilities}/onDomReady.js +0 -0
- /package/{dom-utilities → src/dom-utilities}/onLoad.js +0 -0
- /package/{string-utilities → src/string-utilities}/copy-to-clipboard.js +0 -0
- /package/{string-utilities → src/string-utilities}/query.js +0 -0
- /package/{string-utilities → src/string-utilities}/slugify.js +0 -0
- /package/{ui → src/ui}/toast-hyperclay.js +0 -0
- /package/{utilities → src/utilities}/cookie.js +0 -0
- /package/{utilities → src/utilities}/debounce.js +0 -0
- /package/{utilities → src/utilities}/loadVendorScript.js +0 -0
- /package/{utilities → src/utilities}/mutation.js +0 -0
- /package/{utilities → src/utilities}/nearest.js +0 -0
- /package/{utilities → src/utilities}/pipe.js +0 -0
- /package/{utilities → src/utilities}/throttle.js +0 -0
- /package/{vendor → src/vendor}/Sortable.vendor.js +0 -0
- /package/{vendor → src/vendor}/idiomorph.min.js +0 -0
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Automatically show/hide elements with "option" attributes based on ancestors' attributes.
|
|
4
|
-
*
|
|
5
|
-
* # Usage:
|
|
6
|
-
* optionVisibilityRuleGenerator.debug = true;
|
|
7
|
-
* optionVisibilityRuleGenerator.start();
|
|
8
|
-
*
|
|
9
|
-
* # HTML Example:
|
|
10
|
-
* <div editmode="true"> <!-- Parent element with matching attribute -->
|
|
11
|
-
* <div option:editmode="true"></div> <!-- This will be visible -->
|
|
12
|
-
* <div option:editmode="false"></div> <!-- This will be hidden -->
|
|
13
|
-
* </div>
|
|
14
|
-
*
|
|
15
|
-
* Elements with `option:` attributes will be:
|
|
16
|
-
* - Visible if any ancestor has matching attribute
|
|
17
|
-
* - Hidden if no ancestor has matching attribute
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
import Mutation from "../utilities/mutation.js";
|
|
21
|
-
|
|
22
|
-
const optionVisibilityRuleGenerator = {
|
|
23
|
-
debug: false,
|
|
24
|
-
styleElement: null,
|
|
25
|
-
|
|
26
|
-
HIDDEN_STYLES: `
|
|
27
|
-
visibility: hidden;
|
|
28
|
-
pointer-events: none;
|
|
29
|
-
width: 0;
|
|
30
|
-
height: 0;
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
`,
|
|
33
|
-
VISIBLE_STYLES: `
|
|
34
|
-
visibility: visible;
|
|
35
|
-
pointer-events: auto;
|
|
36
|
-
width: auto;
|
|
37
|
-
height: auto;
|
|
38
|
-
overflow: visible;
|
|
39
|
-
`,
|
|
40
|
-
|
|
41
|
-
STYLE_CLASS: 'option-visibility-styles',
|
|
42
|
-
|
|
43
|
-
log(message, ...args) {
|
|
44
|
-
if (this.debug) {
|
|
45
|
-
console.log(`[OptionVisibilityRuleGenerator] ${message}`, ...args);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
findOptionAttributes() {
|
|
50
|
-
const html = document.documentElement.outerHTML;
|
|
51
|
-
const optionAttributes = new Set(); // Using Set for unique combinations
|
|
52
|
-
const optionRegex = /option:([^\s"']+)=["']([^"']+)["']/g; // regex: "option:" + (anything but space and quote) + equal + quote + (anything but quote) + quote
|
|
53
|
-
|
|
54
|
-
let match;
|
|
55
|
-
while ((match = optionRegex.exec(html)) !== null) {
|
|
56
|
-
// Create a unique key for each name-value pair
|
|
57
|
-
const key = JSON.stringify({name: match[1], value: match[2]});
|
|
58
|
-
optionAttributes.add(key);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Convert back to objects
|
|
62
|
-
return Array.from(optionAttributes).map(key => JSON.parse(key));
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
minifyCSS(css) {
|
|
66
|
-
return css
|
|
67
|
-
.replace(/\s+/g, ' ')
|
|
68
|
-
.replace(/{\s+/g, '{')
|
|
69
|
-
.replace(/\s+}/g, '}')
|
|
70
|
-
.replace(/;\s+/g, ';')
|
|
71
|
-
.replace(/:\s+/g, ':')
|
|
72
|
-
.trim();
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
generateCSSRules(optionAttributes) {
|
|
76
|
-
const rules = [];
|
|
77
|
-
|
|
78
|
-
optionAttributes.forEach(({name, value}) => {
|
|
79
|
-
const escapedValue = value.replace(/["\\]/g, '\\$&');
|
|
80
|
-
|
|
81
|
-
rules.push(`
|
|
82
|
-
[option\\:${name}="${escapedValue}"] {
|
|
83
|
-
${this.HIDDEN_STYLES}
|
|
84
|
-
}
|
|
85
|
-
`);
|
|
86
|
-
|
|
87
|
-
rules.push(`
|
|
88
|
-
[${name}="${escapedValue}"] [option\\:${name}="${escapedValue}"] {
|
|
89
|
-
${this.VISIBLE_STYLES}
|
|
90
|
-
}
|
|
91
|
-
`);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return this.minifyCSS(rules.join('\n'));
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
generateRules() {
|
|
98
|
-
try {
|
|
99
|
-
this.log('Starting rule generation');
|
|
100
|
-
|
|
101
|
-
const optionAttributes = this.findOptionAttributes();
|
|
102
|
-
this.log('Found option attributes:', optionAttributes);
|
|
103
|
-
|
|
104
|
-
// Early return if no option attributes found
|
|
105
|
-
if (optionAttributes.length === 0) {
|
|
106
|
-
this.log('No option attributes found, skipping style creation');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const cssRules = this.generateCSSRules(optionAttributes);
|
|
111
|
-
this.log('Generated CSS rules:', cssRules);
|
|
112
|
-
|
|
113
|
-
// Check if we already have these exact rules
|
|
114
|
-
const existingStyleElement = document.head.querySelector(`.${this.STYLE_CLASS}`);
|
|
115
|
-
if (existingStyleElement && existingStyleElement.textContent.trim() === cssRules) {
|
|
116
|
-
this.log('Rules unchanged, skipping update');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Create new style element
|
|
121
|
-
const newStyleElement = document.createElement('style');
|
|
122
|
-
newStyleElement.className = this.STYLE_CLASS;
|
|
123
|
-
newStyleElement.textContent = cssRules;
|
|
124
|
-
document.head.appendChild(newStyleElement);
|
|
125
|
-
|
|
126
|
-
// Remove all previous style elements
|
|
127
|
-
document.head
|
|
128
|
-
.querySelectorAll(`.${this.STYLE_CLASS}`)
|
|
129
|
-
.forEach(el => {
|
|
130
|
-
if (el !== newStyleElement) {
|
|
131
|
-
el.remove();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
this.styleElement = newStyleElement;
|
|
136
|
-
|
|
137
|
-
this.log('Rule generation complete');
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.error('Error generating visibility rules:', error);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
start() {
|
|
144
|
-
Mutation.onAnyChange({
|
|
145
|
-
selectorFilter: el => [...el.attributes].some(attr => attr.name.startsWith('option:')),
|
|
146
|
-
debounce: 200
|
|
147
|
-
}, () => {
|
|
148
|
-
this.generateRules();
|
|
149
|
-
});
|
|
150
|
-
this.generateRules();
|
|
151
|
-
this.log('Started observing DOM mutations');
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// Auto-export to window unless suppressed by loader
|
|
156
|
-
if (!window.__hyperclayNoAutoExport) {
|
|
157
|
-
window.optionVisibilityRuleGenerator = optionVisibilityRuleGenerator;
|
|
158
|
-
window.hyperclay = window.hyperclay || {};
|
|
159
|
-
window.hyperclay.optionVisibilityRuleGenerator = optionVisibilityRuleGenerator;
|
|
160
|
-
window.h = window.hyperclay;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export default optionVisibilityRuleGenerator;
|
|
164
|
-
|
|
165
|
-
// Auto-initialize
|
|
166
|
-
export function init() {
|
|
167
|
-
optionVisibilityRuleGenerator.start();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Auto-init when module is imported
|
|
171
|
-
init();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Mutation from "../utilities/mutation.js";
|
|
2
|
-
|
|
3
|
-
function init() {
|
|
4
|
-
const executePageMutation = async element => {
|
|
5
|
-
try {
|
|
6
|
-
const code = element.getAttribute('onpagemutation');
|
|
7
|
-
const asyncFn = new Function(`return (async function() { ${code} })`)();
|
|
8
|
-
await asyncFn.call(element);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.error('Error in onpagemutation execution:', error);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
Mutation.onAnyChange({
|
|
15
|
-
debounce: 200,
|
|
16
|
-
omitChangeDetails: true
|
|
17
|
-
}, () => document.querySelectorAll('[onpagemutation]').forEach(executePageMutation));
|
|
18
|
-
}
|
|
19
|
-
export { init };
|
|
20
|
-
export default init;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|