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.
Files changed (61) hide show
  1. package/README.md +14 -14
  2. package/package.json +17 -25
  3. package/src/core/adminContenteditable.js +51 -0
  4. package/{core → src/core}/adminInputs.js +29 -8
  5. package/src/core/adminOnClick.js +54 -0
  6. package/{core → src/core}/adminResources.js +25 -5
  7. package/src/core/optionVisibility.js +216 -0
  8. package/{core → src/core}/savePage.js +1 -1
  9. package/{core → src/core}/savePageCore.js +13 -3
  10. package/{custom-attributes → src/custom-attributes}/domHelpers.js +17 -4
  11. package/{custom-attributes → src/custom-attributes}/events.js +2 -0
  12. package/src/custom-attributes/onmutation.js +90 -0
  13. package/src/custom-attributes/onpagemutation.js +32 -0
  14. package/{custom-attributes → src/custom-attributes}/sortable.js +16 -1
  15. package/{dom-utilities → src/dom-utilities}/All.js +22 -0
  16. package/{hyperclay.js → src/hyperclay.js} +4 -4
  17. package/{module-dependency-graph.json → src/module-dependency-graph.json} +16 -26
  18. package/{ui → src/ui}/prompts.js +13 -18
  19. package/{ui → src/ui}/theModal.js +101 -0
  20. package/{ui → src/ui}/toast.js +4 -3
  21. package/core/adminContenteditable.js +0 -36
  22. package/core/adminOnClick.js +0 -31
  23. package/core/optionVisibilityRuleGenerator.js +0 -171
  24. package/custom-attributes/onpagemutation.js +0 -20
  25. /package/{communication → src/communication}/behaviorCollector.js +0 -0
  26. /package/{communication → src/communication}/sendMessage.js +0 -0
  27. /package/{communication → src/communication}/uploadFile.js +0 -0
  28. /package/{core → src/core}/adminSystem.js +0 -0
  29. /package/{core → src/core}/autosave.js +0 -0
  30. /package/{core → src/core}/editmode.js +0 -0
  31. /package/{core → src/core}/editmodeSystem.js +0 -0
  32. /package/{core → src/core}/enablePersistentFormInputValues.js +0 -0
  33. /package/{core → src/core}/exportToWindow.js +0 -0
  34. /package/{core → src/core}/isAdminOfCurrentResource.js +0 -0
  35. /package/{core → src/core}/saveToast.js +0 -0
  36. /package/{core → src/core}/setPageTypeOnDocumentElement.js +0 -0
  37. /package/{custom-attributes → src/custom-attributes}/ajaxElements.js +0 -0
  38. /package/{custom-attributes → src/custom-attributes}/autosize.js +0 -0
  39. /package/{custom-attributes → src/custom-attributes}/inputHelpers.js +0 -0
  40. /package/{custom-attributes → src/custom-attributes}/onaftersave.js +0 -0
  41. /package/{custom-attributes → src/custom-attributes}/onclickaway.js +0 -0
  42. /package/{custom-attributes → src/custom-attributes}/onclone.js +0 -0
  43. /package/{custom-attributes → src/custom-attributes}/onrender.js +0 -0
  44. /package/{custom-attributes → src/custom-attributes}/preventEnter.js +0 -0
  45. /package/{dom-utilities → src/dom-utilities}/getDataFromForm.js +0 -0
  46. /package/{dom-utilities → src/dom-utilities}/insertStyleTag.js +0 -0
  47. /package/{dom-utilities → src/dom-utilities}/onDomReady.js +0 -0
  48. /package/{dom-utilities → src/dom-utilities}/onLoad.js +0 -0
  49. /package/{string-utilities → src/string-utilities}/copy-to-clipboard.js +0 -0
  50. /package/{string-utilities → src/string-utilities}/query.js +0 -0
  51. /package/{string-utilities → src/string-utilities}/slugify.js +0 -0
  52. /package/{ui → src/ui}/toast-hyperclay.js +0 -0
  53. /package/{utilities → src/utilities}/cookie.js +0 -0
  54. /package/{utilities → src/utilities}/debounce.js +0 -0
  55. /package/{utilities → src/utilities}/loadVendorScript.js +0 -0
  56. /package/{utilities → src/utilities}/mutation.js +0 -0
  57. /package/{utilities → src/utilities}/nearest.js +0 -0
  58. /package/{utilities → src/utilities}/pipe.js +0 -0
  59. /package/{utilities → src/utilities}/throttle.js +0 -0
  60. /package/{vendor → src/vendor}/Sortable.vendor.js +0 -0
  61. /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