Skip to content

Commit

Permalink
working on v21 syntax #296
Browse files Browse the repository at this point in the history
fix bind/intersect lazy reactiveExpression gen
  • Loading branch information
delaneyj committed Dec 3, 2024
1 parent cec2c37 commit 2ea15e4
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
16 changes: 8 additions & 8 deletions bundles/datastar.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bundles/datastar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions code/dotnet/sdk/src/Consts.fs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions code/go/site/routes_examples_disable_button.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ func setupExamplesDisableButton(examplesRouter chi.Router) error {
sse := datastar.NewSSE(w, r)

fragment := fmt.Sprintf(`<div>The time is %s</div>`, time.Now().UTC().Format(time.RFC3339))
sse.MergeFragments(fragment, datastar.WithMergeAppend())
sse.MergeFragments(fragment, datastar.WithSelectorID("container"), datastar.WithMergeAppend())

time.Sleep(1 * time.Second)
sse.MarshalAndMergeSignals(map[string]any{
"shouldDisable": false,
})
sse.MarshalAndMergeSignals(map[string]any{"shouldDisable": false})
})

return nil
Expand Down
2 changes: 1 addition & 1 deletion code/go/site/routes_home.templ
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ templ TodoRow(mode TodoViewMode, todo *Todo, i int, isEditing bool) {
data-on-click={ datastar.DeleteSSE("/api/todos/%d", i) }
data-testid={ fmt.Sprintf("delete_todo%d", i) }
data-indicator={ fetchingSignalName }
data-disabled={ "".value + fetchingSignalName }
data-disabled={ fetchingSignalName + ".value" }
>
@icon("material-symbols:close")
</button>
Expand Down
2 changes: 1 addition & 1 deletion code/go/site/static/md/examples/disable_button.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div id="container" data-signals="{shouldDisable:false}">
<button
id="target"
data-on-click="shouldDisable.value = true;sse('/examples/disable_button/data')"
data-on-click="shouldDisable.value=true ; sse('/examples/disable_button/data')"
data-bind-disabled="shouldDisable.value"
>Click Me</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions code/php/sdk/src/Consts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Consts
{
public const DATASTAR_KEY = 'datastar';
public const VERSION = '0.20.1';
public const VERSION_CLIENT_BYTE_SIZE = 32928;
public const VERSION_CLIENT_BYTE_SIZE_GZIP = 12036;
public const VERSION_CLIENT_BYTE_SIZE = 32940;
public const VERSION_CLIENT_BYTE_SIZE_GZIP = 12046;

// The default duration for settling during merges. Allows for CSS transitions to complete.
public const DEFAULT_SETTLE_DURATION = 300;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ export const Intersects: AttributePlugin = {
type: PluginType.Attribute,
name: "intersects",
mods: new Set([ONCE, HALF, FULL]),
onLoad: ({ el, key, rawKey, mods, genRX: rx }) => {
onLoad: ({ el, key, rawKey, mods, genRX }) => {
if (key.length) throw new Error("No key allowed");
const options = { threshold: 0 };
if (mods.has(FULL)) options.threshold = 1;
else if (mods.has(HALF)) options.threshold = 0.5;

const rx = genRX();
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
Expand Down
3 changes: 2 additions & 1 deletion library/src/plugins/official/dom/attributes/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Bind: AttributePlugin = {
type: PluginType.Attribute,
name: "bind",
onLoad: (ctx) => {
const { el, value, genRX: rx, key, signals, effect } = ctx;
const { el, value, genRX, key, signals, effect } = ctx;

let setFromSignal = () => {};
let fromElementToSignal = () => {};
Expand Down Expand Up @@ -191,6 +191,7 @@ export const Bind: AttributePlugin = {
} else {
// tied to an attribute
const kebabKey = kebabize(key);
const rx = genRX();
setFromSignal = () => {
const value = rx();
let v: string;
Expand Down
4 changes: 2 additions & 2 deletions sdk/go/consts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ea15e4

Please sign in to comment.