hyperclayjs 1.12.0 → 1.14.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 +7 -7
- package/package.json +1 -1
- package/src/core/tailwindInject.js +2 -1
- package/src/hyperclay.js +10 -4
- package/src/ui/theModal.js +16 -50
- package/src/ui/toast.js +4 -2
- package/src/utilities/cacheBust.js +4 -3
package/README.md
CHANGED
|
@@ -85,8 +85,8 @@ import 'hyperclayjs/presets/standard.js';
|
|
|
85
85
|
| Module | Size | Description |
|
|
86
86
|
|--------|------|-------------|
|
|
87
87
|
| dialogs | 7.7KB | ask(), consent(), tell(), snippet() dialog functions |
|
|
88
|
-
| the-modal |
|
|
89
|
-
| toast | 7.
|
|
88
|
+
| the-modal | 21KB | Full modal window creation system - window.theModal |
|
|
89
|
+
| toast | 7.9KB | Success/error message notifications, toast(msg, msgType) |
|
|
90
90
|
|
|
91
91
|
### Utilities (Core utilities (often auto-included))
|
|
92
92
|
|
|
@@ -132,17 +132,17 @@ import 'hyperclayjs/presets/standard.js';
|
|
|
132
132
|
|
|
133
133
|
## Presets
|
|
134
134
|
|
|
135
|
-
### Minimal (~
|
|
135
|
+
### Minimal (~38.1KB)
|
|
136
136
|
Essential features for basic editing
|
|
137
137
|
|
|
138
|
-
**Modules:** `save-core`, `save-system`, `edit-mode-helpers`, `toast`, `save-toast`, `export-to-window`
|
|
138
|
+
**Modules:** `save-core`, `snapshot`, `save-system`, `edit-mode-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
|
|
139
139
|
|
|
140
|
-
### Standard (~
|
|
140
|
+
### Standard (~57.4KB)
|
|
141
141
|
Standard feature set for most use cases
|
|
142
142
|
|
|
143
|
-
**Modules:** `save-core`, `save-system`, `edit-mode-helpers`, `persist`, `option-visibility`, `event-attrs`, `dom-helpers`, `toast`, `save-toast`, `export-to-window`
|
|
143
|
+
**Modules:** `save-core`, `snapshot`, `save-system`, `unsaved-warning`, `edit-mode-helpers`, `persist`, `option-visibility`, `event-attrs`, `dom-helpers`, `toast`, `save-toast`, `export-to-window`, `view-mode-excludes-edit-modules`
|
|
144
144
|
|
|
145
|
-
### Everything (~
|
|
145
|
+
### Everything (~178KB)
|
|
146
146
|
All available features
|
|
147
147
|
|
|
148
148
|
Includes all available modules across all categories.
|
package/package.json
CHANGED
|
@@ -5,9 +5,10 @@ function init() {
|
|
|
5
5
|
const currentResource = cookie.get('currentResource');
|
|
6
6
|
if (!currentResource) return;
|
|
7
7
|
|
|
8
|
-
const href = `/tailwindcss/${currentResource}`;
|
|
8
|
+
const href = `/tailwindcss/${currentResource}.css`;
|
|
9
9
|
insertStyles(href, (link) => {
|
|
10
10
|
link.setAttribute('onaftersave', 'cacheBust(this)');
|
|
11
|
+
link.setAttribute('mutations-ignore', '');
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
|
package/src/hyperclay.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HyperclayJS v1.
|
|
2
|
+
* HyperclayJS v1.14.0 - Minimal Browser-Native Loader
|
|
3
3
|
*
|
|
4
4
|
* Modules auto-init when imported (no separate init call needed).
|
|
5
5
|
* Include `export-to-window` feature to export to window.hyperclay.
|
|
@@ -73,11 +73,13 @@ const PRESETS = {
|
|
|
73
73
|
"description": "Essential features for basic editing",
|
|
74
74
|
"modules": [
|
|
75
75
|
"save-core",
|
|
76
|
+
"snapshot",
|
|
76
77
|
"save-system",
|
|
77
78
|
"edit-mode-helpers",
|
|
78
79
|
"toast",
|
|
79
80
|
"save-toast",
|
|
80
|
-
"export-to-window"
|
|
81
|
+
"export-to-window",
|
|
82
|
+
"view-mode-excludes-edit-modules"
|
|
81
83
|
]
|
|
82
84
|
},
|
|
83
85
|
"standard": {
|
|
@@ -85,7 +87,9 @@ const PRESETS = {
|
|
|
85
87
|
"description": "Standard feature set for most use cases",
|
|
86
88
|
"modules": [
|
|
87
89
|
"save-core",
|
|
90
|
+
"snapshot",
|
|
88
91
|
"save-system",
|
|
92
|
+
"unsaved-warning",
|
|
89
93
|
"edit-mode-helpers",
|
|
90
94
|
"persist",
|
|
91
95
|
"option-visibility",
|
|
@@ -93,7 +97,8 @@ const PRESETS = {
|
|
|
93
97
|
"dom-helpers",
|
|
94
98
|
"toast",
|
|
95
99
|
"save-toast",
|
|
96
|
-
"export-to-window"
|
|
100
|
+
"export-to-window",
|
|
101
|
+
"view-mode-excludes-edit-modules"
|
|
97
102
|
]
|
|
98
103
|
},
|
|
99
104
|
"everything": {
|
|
@@ -140,7 +145,8 @@ const PRESETS = {
|
|
|
140
145
|
"file-upload",
|
|
141
146
|
"live-sync",
|
|
142
147
|
"tailwind-inject",
|
|
143
|
-
"export-to-window"
|
|
148
|
+
"export-to-window",
|
|
149
|
+
"view-mode-excludes-edit-modules"
|
|
144
150
|
]
|
|
145
151
|
}
|
|
146
152
|
};
|
package/src/ui/theModal.js
CHANGED
|
@@ -166,8 +166,10 @@ const MicroModal = (() => {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
removeEventListeners () {
|
|
169
|
-
this.modal
|
|
170
|
-
|
|
169
|
+
if (this.modal) {
|
|
170
|
+
this.modal.removeEventListener('touchstart', this.onClick)
|
|
171
|
+
this.modal.removeEventListener('click', this.onClick)
|
|
172
|
+
}
|
|
171
173
|
document.removeEventListener('keydown', this.onKeydown)
|
|
172
174
|
}
|
|
173
175
|
|
|
@@ -303,7 +305,9 @@ const MicroModal = (() => {
|
|
|
303
305
|
}
|
|
304
306
|
|
|
305
307
|
const close = targetModal => {
|
|
308
|
+
if (!activeModal) return
|
|
306
309
|
targetModal ? activeModal.closeModalById(targetModal) : activeModal.closeModal()
|
|
310
|
+
activeModal = null
|
|
307
311
|
}
|
|
308
312
|
|
|
309
313
|
return { init, show, close }
|
|
@@ -318,8 +322,8 @@ const modalCss = `<style class="micromodal-css">
|
|
|
318
322
|
.micromodal {
|
|
319
323
|
display: none;
|
|
320
324
|
color: #fff;
|
|
321
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
322
|
-
font-size: 18px;
|
|
325
|
+
font-family: var(--hyperclay-modal-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace);
|
|
326
|
+
font-size: var(--hyperclay-modal-font-size, 18px);
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
.micromodal button:not(.custom-button) {
|
|
@@ -364,6 +368,7 @@ const modalCss = `<style class="micromodal-css">
|
|
|
364
368
|
|
|
365
369
|
.micromodal__container {
|
|
366
370
|
position: relative;
|
|
371
|
+
max-width: 600px;
|
|
367
372
|
box-sizing: border-box;
|
|
368
373
|
overflow-y: auto;
|
|
369
374
|
padding: 26px 40px 40px 40px;
|
|
@@ -415,7 +420,7 @@ const modalCss = `<style class="micromodal-css">
|
|
|
415
420
|
.micromodal .micromodal__input {
|
|
416
421
|
width: clamp(300px, calc(100vw - 100px), 420px);
|
|
417
422
|
padding: 6px 6px 7px;
|
|
418
|
-
font-size: 16px;
|
|
423
|
+
font-size: var(--hyperclay-modal-input-font-size, 16px);
|
|
419
424
|
color: #000;
|
|
420
425
|
}
|
|
421
426
|
|
|
@@ -465,7 +470,7 @@ const modalCss = `<style class="micromodal-css">
|
|
|
465
470
|
background-color: #1D1F2F;
|
|
466
471
|
color: #E5E7EB;
|
|
467
472
|
font-family: inherit;
|
|
468
|
-
font-size:
|
|
473
|
+
font-size: inherit;
|
|
469
474
|
font-weight: bold;
|
|
470
475
|
}
|
|
471
476
|
|
|
@@ -495,7 +500,7 @@ const modalCss = `<style class="micromodal-css">
|
|
|
495
500
|
|
|
496
501
|
.micromodal .snippet-code-block pre {
|
|
497
502
|
color: white;
|
|
498
|
-
font-family:
|
|
503
|
+
font-family: var(--hyperclay-modal-code-font-family, var(--hyperclay-modal-font-family, monospace));
|
|
499
504
|
font-size: 0.875rem;
|
|
500
505
|
white-space: nowrap;
|
|
501
506
|
margin: 0;
|
|
@@ -540,21 +545,21 @@ const modalCss = `<style class="micromodal-css">
|
|
|
540
545
|
}
|
|
541
546
|
|
|
542
547
|
.micromodal .micromodal__tell-title {
|
|
543
|
-
font-size: 20px;
|
|
548
|
+
font-size: var(--hyperclay-modal-title-font-size, 20px);
|
|
544
549
|
font-weight: bold;
|
|
545
550
|
}
|
|
546
551
|
|
|
547
552
|
.micromodal .micromodal__tell-content {
|
|
548
|
-
font-size: 16px;
|
|
553
|
+
font-size: var(--hyperclay-modal-font-size, 16px);
|
|
549
554
|
font-weight: normal;
|
|
550
555
|
}
|
|
551
556
|
|
|
552
557
|
@media (min-width: 640px) {
|
|
553
558
|
.micromodal .micromodal__tell-title {
|
|
554
|
-
font-size: 22px;
|
|
559
|
+
font-size: var(--hyperclay-modal-title-font-size, 22px);
|
|
555
560
|
}
|
|
556
561
|
.micromodal .micromodal__tell-content {
|
|
557
|
-
font-size: 18px;
|
|
562
|
+
font-size: var(--hyperclay-modal-font-size, 18px);
|
|
558
563
|
}
|
|
559
564
|
}
|
|
560
565
|
</style>`;
|
|
@@ -572,19 +577,12 @@ const modalHtml = `<div class="micromodal" id="micromodal" aria-hidden="true">
|
|
|
572
577
|
</div>
|
|
573
578
|
</div>`;
|
|
574
579
|
|
|
575
|
-
const DEFAULT_FONT_FAMILY = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace";
|
|
576
|
-
const DEFAULT_FONT_SIZE = "18px";
|
|
577
|
-
const DEFAULT_INPUT_FONT_SIZE = "16px";
|
|
578
|
-
|
|
579
580
|
const themodal = (() => {
|
|
580
581
|
let html = "";
|
|
581
582
|
let yes = "";
|
|
582
583
|
let no = "";
|
|
583
584
|
let zIndex = "100";
|
|
584
585
|
let closeHtml = "";
|
|
585
|
-
let fontFamily = DEFAULT_FONT_FAMILY;
|
|
586
|
-
let fontSize = DEFAULT_FONT_SIZE;
|
|
587
|
-
let inputFontSize = DEFAULT_INPUT_FONT_SIZE;
|
|
588
586
|
|
|
589
587
|
let enableClickOutsideCloses = true;
|
|
590
588
|
let disableScroll = true;
|
|
@@ -612,17 +610,6 @@ const themodal = (() => {
|
|
|
612
610
|
modalOverlayElem.style.zIndex = zIndex;
|
|
613
611
|
modalCloseElem.innerHTML = closeHtml;
|
|
614
612
|
|
|
615
|
-
// Apply font styles to the modal
|
|
616
|
-
const modalElem = document.querySelector("#micromodal");
|
|
617
|
-
modalElem.style.fontFamily = fontFamily;
|
|
618
|
-
modalElem.style.fontSize = fontSize;
|
|
619
|
-
|
|
620
|
-
// Apply input font size
|
|
621
|
-
const modalInputElem = document.querySelector(".micromodal__input");
|
|
622
|
-
if (modalInputElem) {
|
|
623
|
-
modalInputElem.style.fontSize = inputFontSize;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
613
|
// MODIFIED so modal doesn't close if mousedown happened inside the modal
|
|
627
614
|
let mousedownOnBackdrop = false;
|
|
628
615
|
|
|
@@ -702,9 +689,6 @@ const themodal = (() => {
|
|
|
702
689
|
no = "";
|
|
703
690
|
zIndex = "100";
|
|
704
691
|
closeHtml = "";
|
|
705
|
-
fontFamily = DEFAULT_FONT_FAMILY;
|
|
706
|
-
fontSize = DEFAULT_FONT_SIZE;
|
|
707
|
-
inputFontSize = DEFAULT_INPUT_FONT_SIZE;
|
|
708
692
|
|
|
709
693
|
// reset to defaults
|
|
710
694
|
enableClickOutsideCloses = true;
|
|
@@ -768,24 +752,6 @@ const themodal = (() => {
|
|
|
768
752
|
set zIndex(newVal) {
|
|
769
753
|
zIndex = newVal;
|
|
770
754
|
},
|
|
771
|
-
get fontFamily() {
|
|
772
|
-
return fontFamily;
|
|
773
|
-
},
|
|
774
|
-
set fontFamily(newVal) {
|
|
775
|
-
fontFamily = newVal;
|
|
776
|
-
},
|
|
777
|
-
get fontSize() {
|
|
778
|
-
return fontSize;
|
|
779
|
-
},
|
|
780
|
-
set fontSize(newVal) {
|
|
781
|
-
fontSize = newVal;
|
|
782
|
-
},
|
|
783
|
-
get inputFontSize() {
|
|
784
|
-
return inputFontSize;
|
|
785
|
-
},
|
|
786
|
-
set inputFontSize(newVal) {
|
|
787
|
-
inputFontSize = newVal;
|
|
788
|
-
},
|
|
789
755
|
get disableFocus() {
|
|
790
756
|
return disableFocus;
|
|
791
757
|
},
|
package/src/ui/toast.js
CHANGED
|
@@ -71,8 +71,8 @@ const modernStyles = `
|
|
|
71
71
|
align-items: center;
|
|
72
72
|
gap: 12px;
|
|
73
73
|
padding: 16px 24px 16px 16px;
|
|
74
|
-
font-size: 16px;
|
|
75
|
-
font-family: monospace;
|
|
74
|
+
font-size: var(--hyperclay-toast-font-size, 16px);
|
|
75
|
+
font-family: var(--hyperclay-toast-font-family, monospace);
|
|
76
76
|
font-weight: bold;
|
|
77
77
|
color: white;
|
|
78
78
|
border-width: 1px;
|
|
@@ -155,6 +155,8 @@ export const hyperclayStyles = `
|
|
|
155
155
|
background-color: #0B0C12;
|
|
156
156
|
border: 2px dashed rgba(255,255,255,.6);
|
|
157
157
|
transition: right 0.5s ease-in-out;
|
|
158
|
+
font-size: var(--hyperclay-toast-font-size, inherit);
|
|
159
|
+
font-family: var(--hyperclay-toast-font-family, inherit);
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
[data-toast-theme="hyperclay"] .toast svg {
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Cache-bust an element's href or src attribute by adding/updating a version query param
|
|
3
3
|
|
|
4
4
|
function cacheBust(el) {
|
|
5
|
-
const attr = el.href
|
|
6
|
-
const
|
|
5
|
+
const attr = el.hasAttribute('href') ? 'href' : 'src';
|
|
6
|
+
const currentValue = el.getAttribute(attr);
|
|
7
|
+
const url = new URL(currentValue, location.href);
|
|
7
8
|
url.searchParams.set('v', Date.now());
|
|
8
|
-
el
|
|
9
|
+
el.setAttribute(attr, url.href);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
// Auto-export to window unless suppressed by loader
|