-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"separateMethodMetaAndSource" : false, | ||
"noMethodMetaData" : true, | ||
"useCypressPropertiesFile" : true | ||
} |
Empty file.
3 changes: 3 additions & 0 deletions
3
repository/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/class/canBeRoot.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
testing | ||
canBeRoot | ||
^ true |
8 changes: 8 additions & 0 deletions
8
repository/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/class/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
initialization | ||
initialize | ||
| application | | ||
application := WAAdmin register: WAApplication at: 'examples/headless-counter' in: WAAdmin defaultDispatcher. | ||
application configuration addParent: WARenderLoopConfiguration instance. | ||
application rootClass: self; | ||
preferenceAt: #renderPhaseContinuationClass put: WAFragmentRenderPhaseContinuation; | ||
yourself |
3 changes: 3 additions & 0 deletions
3
repository/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/instance/children.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hooks | ||
children | ||
^ Array with: counter |
4 changes: 4 additions & 0 deletions
4
repository/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/instance/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
initialization | ||
initialize | ||
super initialize. | ||
counter := WACounter new |
3 changes: 3 additions & 0 deletions
3
...y/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/instance/renderContentOn..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rendering | ||
renderContentOn: html | ||
html render: counter |
13 changes: 13 additions & 0 deletions
13
repository/Seaside-WebComponents-Core.package/WAHeadlessCounter.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"commentStamp" : "", | ||
"super" : "WAHeadlessComponent", | ||
"category" : "Seaside-WebComponents-Core", | ||
"classinstvars" : [ ], | ||
"pools" : [ ], | ||
"classvars" : [ ], | ||
"instvars" : [ | ||
"counter" | ||
], | ||
"name" : "WAHeadlessCounter", | ||
"type" : "normal" | ||
} |
Empty file.
3 changes: 3 additions & 0 deletions
3
...easide-WebComponents-Core.package/WAWebComponentsDemoApplication.class/class/canBeRoot.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
testing | ||
canBeRoot | ||
^ true |
4 changes: 4 additions & 0 deletions
4
...aside-WebComponents-Core.package/WAWebComponentsDemoApplication.class/class/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
initialization | ||
initialize | ||
(WAAdmin register: self asApplicationAt: 'examples/web-components') | ||
scriptGeneratorClass: WANullScriptGenerator |
7 changes: 7 additions & 0 deletions
7
...Components-Core.package/WAWebComponentsDemoApplication.class/instance/renderContentOn..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
rendering | ||
renderContentOn: html | ||
html heading: 'Seaside WebComponents Demo'. | ||
(html tag: 'seaside-component') | ||
attributeAt: 'url' put: '/examples/headless-counter'; | ||
attributeAt: 'ajaxify' put: 'true'; | ||
with: 'Loading...' |
5 changes: 5 additions & 0 deletions
5
...e-WebComponents-Core.package/WAWebComponentsDemoApplication.class/instance/updateRoot..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
updating | ||
updateRoot: aRoot | ||
super updateRoot: aRoot. | ||
aRoot title: 'Seaside WebComponents Demo'. | ||
aRoot script url: WAWebComponentsLibrary / #seasideWebComponentsJs |
11 changes: 11 additions & 0 deletions
11
...y/Seaside-WebComponents-Core.package/WAWebComponentsDemoApplication.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"commentStamp" : "", | ||
"super" : "WAComponent", | ||
"category" : "Seaside-WebComponents-Core", | ||
"classinstvars" : [ ], | ||
"pools" : [ ], | ||
"classvars" : [ ], | ||
"instvars" : [ ], | ||
"name" : "WAWebComponentsDemoApplication", | ||
"type" : "normal" | ||
} |
28 changes: 28 additions & 0 deletions
28
...itory/Seaside-WebComponents-Core.package/WAWebComponentsLibrary.class/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
I am a WebComponent library that allows users to embed Seaside components into existing web pages. | ||
|
||
|
||
# Usage | ||
|
||
To use this library | ||
|
||
```language=HTML | ||
<html> | ||
<head> | ||
<!-- --> | ||
<script src="seaside-components.js" defer></script> | ||
</head> | ||
<body> | ||
<!-- --> | ||
<seaside-component url="/examples/headless-counter">Loading...</seaside-component> | ||
<!-- --> | ||
</body> | ||
</html> | ||
``` | ||
|
||
Per default no ajaxification will happen so you have to make sure your component does not perform full page requests. | ||
|
||
You can opt in to ajaxification using | ||
|
||
```language=HTML | ||
<seaside-component url="/examples/headless-counter" ajaxify="true">Loading...</seaside-component> | ||
``` |
67 changes: 67 additions & 0 deletions
67
...ebComponents-Core.package/WAWebComponentsLibrary.class/instance/seasideWebComponentsJs.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
scripts | ||
seasideWebComponentsJs | ||
^ '"use strict"; | ||
(function() { | ||
class SeasideComponent extends HTMLElement { | ||
#shadowRoot; | ||
constructor() { | ||
super(); | ||
this.#shadowRoot = this.attachShadow({mode: "closed"}); | ||
} | ||
#ajaxify() { | ||
this.#shadowRoot.addEventListener("click", (event) => { | ||
// links | ||
const anchor = event.target.closest("a"); | ||
if (anchor !== null) { | ||
this.#load("GET", anchor.getAttribute("href"), null); | ||
event.preventDefault(); | ||
return; | ||
} | ||
// submit | ||
const submit = event.target.closest("input[type=submit], button[type=submit]"); | ||
if (submit !== null) { | ||
const form = submit.closest("form"); | ||
if (form !== null) { | ||
const formData = new FormData(form); | ||
formData.append(submit.getAttribute("name"), ""); | ||
this.#load("POST", form.getAttribute("action"), formData); | ||
event.preventDefault(); | ||
} | ||
} | ||
}); | ||
} | ||
#load(method, url, data) { | ||
const xhr = new XMLHttpRequest(); | ||
xhr.responseType = "text"; // we do not stirp anyhing, just use innerHtml | ||
xhr.addEventListener("load", (event) => { | ||
if (xhr.status === 200) { | ||
this.#shadowRoot.innerHTML = xhr.response; | ||
} | ||
}); | ||
xhr.open(method, url); | ||
// WAActionCallback per default are disabled for AJAX requests | ||
// Detection happens with X-Requested-With so we override it | ||
xhr.setRequestHeader("X-Requested-With", "Seaside-WebComponents"); | ||
xhr.send(data); | ||
} | ||
connectedCallback() { | ||
const componentUrl = this.getAttribute("url"); | ||
const ajaxify = this.getAttribute("ajaxify"); | ||
if (ajaxify === "true") { | ||
this.#ajaxify(); | ||
} | ||
this.#load("GET", componentUrl, null); | ||
} | ||
} | ||
customElements.define("seaside-component", SeasideComponent); | ||
})(); | ||
' |
11 changes: 11 additions & 0 deletions
11
repository/Seaside-WebComponents-Core.package/WAWebComponentsLibrary.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"commentStamp" : "xxx 7/7/2024 16:54", | ||
"super" : "WAFileLibrary", | ||
"category" : "Seaside-WebComponents-Core", | ||
"classinstvars" : [ ], | ||
"pools" : [ ], | ||
"classvars" : [ ], | ||
"instvars" : [ ], | ||
"name" : "WAWebComponentsLibrary", | ||
"type" : "normal" | ||
} |
1 change: 1 addition & 0 deletions
1
repository/Seaside-WebComponents-Core.package/monticello.meta/categories.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
self packageOrganizer ensurePackage: #'Seaside-WebComponents-Core' withTags: #()! |
Empty file.
1 change: 1 addition & 0 deletions
1
repository/Seaside-WebComponents-Core.package/monticello.meta/package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(name 'Seaside-WebComponents-Core') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ } |