Skip to content

Commit 2c4b8da

Browse files
committed
1.0.0-RC.1
1 parent 97c3694 commit 2c4b8da

10 files changed

+82
-79
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# Release Notes for Datastar
22

3-
## 1.0.0-RC.1 - Unreleased
3+
## 1.0.0-RC.1 - 2025-07-15
44

5-
- The plugin now requires Datastar [v1.0.0-RC.1](https://github.com/starfederation/datastar/releases/tag/v1.0.0-RC.1).
5+
- The plugin now requires Datastar [1.0.0-RC.1](https://github.com/starfederation/datastar/releases/tag/v1.0.0-RC.1) or later, and Craft CMS 5.4.0 or later.
6+
- Added the `patchsignals` Twig tag.
7+
- Added the `removeelements` Twig tag.
68
- Renamed the `fragments` Twig tag to `patchelements`.
7-
- Renamed the `removefragments` Twig tag to `removeelements`.
89
- Renamed the `defaultFragmentOptions` config setting to `defaultElementOptions`.
10+
- Removed the `datastar.signals()` and `datastar.signalsFromClass()` methods. Use the `|json_encode` filter instead.
11+
- Removed the `SignalsModel` class. The `signals` variable passed into Datastar templates is now a regular array. Use the `patchsignals` Twig tag to update and remove signals.
912

1013
## 1.0.0-beta.9 - 2025-03-29
1114

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ This plugin is licensed for free under the MIT License.
2727

2828
## Requirements
2929

30-
This plugin requires [Craft CMS](https://craftcms.com/) 5.0.0 or later.
30+
This plugin requires [Craft CMS](https://craftcms.com/) 5.4.0 or later.
3131

3232
## Installation
3333

3434
To install the plugin, search for “Datastar” in the Craft Plugin Store, or install manually using composer.
3535

3636
```shell
37-
composer require putyourlightson/craft-datastar:^1.0.0-beta.1
37+
composer require putyourlightson/craft-datastar:^1.0.0-RC.1
3838
```
3939

4040
---

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "mit",
77
"require": {
88
"php": "^8.2",
9-
"craftcms/cms": "^5.0",
9+
"craftcms/cms": "^5.4",
1010
"putyourlightson/craft-datastar-module": "^1.0.0-RC.1"
1111
},
1212
"require-dev": {

examples/_datastar/save-entry.twig

Lines changed: 0 additions & 58 deletions
This file was deleted.

examples/_datastar/hello-world.twig renamed to examples/_partials/hello-world.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set delay = signals.delay * 1000 %}
1+
{% set delay = (signals.delay ?? 1) * 1000 %}
22
{% set message = 'Hello, world!' %}
33

44
{% for i in range(0, message|length - 1) %}

examples/_partials/save-entry.twig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{% set response = datastar.runAction('entries/save-entry', {
2+
entryId: signals.entryId,
3+
title: signals.title,
4+
}) %}
5+
6+
{% if response.isSuccessful %}
7+
{% patchelements %}
8+
{# https://daisyui.com/components/alert/#success-color #}
9+
<div id="alert" data-show="alert.value" role="alert" class="alert alert-success">
10+
<svg
11+
xmlns="http://www.w3.org/2000/svg"
12+
class="h-6 w-6 shrink-0 stroke-current"
13+
fill="none"
14+
viewBox="0 0 24 24">
15+
<path
16+
stroke-linecap="round"
17+
stroke-linejoin="round"
18+
stroke-width="2"
19+
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
20+
</svg>
21+
<span>
22+
Entry successfully saved!
23+
</span>
24+
</div>
25+
<div id="title-{{ signals.entryId }}">
26+
{{ signals.title }}
27+
</div>
28+
<button id="edit-{{ signals.entryId }}" data-on-click="entryId.value = {{ signals.entryId }}; title..value = '{{ signals.title }}'" data-show="entryId.value != {{ signals.entryId }}" class="btn">
29+
Edit
30+
</button>
31+
{% endpatchelements %}
32+
{% patchsignals {entryId: 0} %}
33+
{% else %}
34+
{% patchelements %}
35+
{# https://daisyui.com/components/alert/#error-color #}
36+
<div id="alert" data-show="alert.value" role="alert" class="alert alert-error">
37+
<svg
38+
xmlns="http://www.w3.org/2000/svg"
39+
class="h-6 w-6 shrink-0 stroke-current"
40+
fill="none"
41+
viewBox="0 0 24 24">
42+
<path
43+
stroke-linecap="round"
44+
stroke-linejoin="round"
45+
stroke-width="2"
46+
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
47+
</svg>
48+
<span>
49+
Error!
50+
{% for error in response.data.errors %}
51+
{{ error|first }}
52+
{% endfor %}
53+
</span>
54+
</div>
55+
{% endpatchelements %}
56+
{% endif %}
57+
58+
{% patchsignals {alert: true} %}

examples/hello-world.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<h1 class="text-gray-900 dark:text-white text-3xl font-semibold">
1111
Datastar SDK Demo
1212
</h1>
13-
<img src="https://data-star.dev/static/images/rocket.png" alt="Rocket" width="64" height="64"/>
13+
<img src="https://putyourlightson.com/assets/logos/datastar.svg" alt="Datastar Logo" width="64" height="64"/>
1414
</div>
1515
<p class="mt-2">
1616
SSE events will be streamed from the backend to the frontend.
@@ -21,7 +21,7 @@
2121
</label>
2222
<input data-bind-delay id="delay" type="number" step="100" min="0" class="w-36 rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-sky-500 focus:outline focus:outline-sky-500 dark:disabled:border-gray-700 dark:disabled:bg-gray-800/20"/>
2323
</div>
24-
<button data-on-click="{{ datastar.get('_datastar/hello-world') }}" class="rounded-md bg-sky-500 px-5 py-2.5 leading-5 font-semibold text-white hover:bg-sky-700 hover:text-gray-100 cursor-pointer">
24+
<button data-on-click="{{ datastar.get('_partials/hello-world') }}" class="rounded-md bg-sky-500 px-5 py-2.5 leading-5 font-semibold text-white hover:bg-sky-700 hover:text-gray-100 cursor-pointer">
2525
Start
2626
</button>
2727
</div>

examples/inline-entry-editing.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,24 @@
2626
<tr>
2727
<td>{{ entry.id }}</td>
2828
<td>
29-
<div data-show="entryId.value != {{ entry.id }}">
29+
<div data-show="$entryId != {{ entry.id }}">
3030
<div id="title-{{ entry.id }}">
3131
{{ entry.title }}
3232
</div>
3333
</div>
34-
<div data-show="entryId.value == {{ entry.id }}" style="display: none">
35-
<input data-bind-title data-on-keydown="evt.key == 'Enter' && save.value.click()" type="text" class="input input-bordered w-full">
34+
<div data-show="$entryId == {{ entry.id }}" style="display: none">
35+
<input data-bind-title data-on-keydown="evt.key == 'Enter' && confirm('Are you sure?') && {{ datastar.post('_partials/save-entry.twig') }}" type="text" class="input input-bordered w-full">
3636
</div>
3737
</td>
3838
<td>{{ entry.author.username }}</td>
3939
<td>
40-
<button id="edit-{{ entry.id }}" data-on-click="alert.value = false; entryId.value = {{ entry.id }}; title.value = '{{ entry.title }}'" data-show="entryId.value != {{ entry.id }}" class="btn">
40+
<button id="edit-{{ entry.id }}" data-on-click="$alert = false; $entryId = {{ entry.id }}; $title = '{{ entry.title }}'" data-show="$entryId != {{ entry.id }}" class="btn">
4141
Edit
4242
</button>
43-
<button data-on-click="alert.value = false; entryId.value = 0" data-show="entryId.value == {{ entry.id }}" class="btn" style="display: none">
43+
<button data-on-click="$alert = false; $entryId = 0" data-show="$entryId == {{ entry.id }}" class="btn" style="display: none">
4444
Cancel
4545
</button>
46-
<button data-ref-save data-on-click="confirm('Are you sure?') && {{ datastar.post('_datastar/save-entry.twig') }}" data-show="entryId.value == {{ entry.id }}" class="btn btn-primary" style="display: none">
46+
<button data-on-click="confirm('Are you sure?') && {{ datastar.post('_partials/save-entry.twig') }}" data-show="$entryId == {{ entry.id }}" class="btn btn-primary" style="display: none">
4747
Save
4848
</button>
4949
</td>

examples/two-way-binding-function.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
<body>
1010
{# https://tailwindcss.com/docs/container #}
1111
<div class="container mx-auto max-w-xl py-16">
12-
<div data-signals="{reversed: ''}" data-on-reverse__window="reversed.value = evt.detail.value" class="flex flex-col space-y-8">
12+
<div data-signals="{reversed: ''}" data-on-reverse__window="$reversed = evt.detail.value" class="flex flex-col space-y-8">
1313
<div class="space-y-2">
1414
<label>Name</label>
15-
<input data-bind-name data-on-input="reverse(name.value)" class="input input-bordered w-full">
15+
<input data-bind-name data-on-input="reverse($name)" class="input input-bordered w-full">
1616
</div>
1717
<div class="space-y-2">
1818
<label>Reversed</label>
1919
<div class="alert h-14">
20-
<span data-text="reversed.value"></span>
20+
<span data-text="$reversed"></span>
2121
</div>
2222
</div>
2323
</div>

examples/two-way-binding-web-component.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
<div class="space-y-2">
1818
<label>Reversed</label>
1919
<div class="alert h-14">
20-
<span data-text="reversed.value"></span>
20+
<span data-text="$reversed"></span>
2121
</div>
2222
</div>
2323
<reverse-component
24-
data-attributes-name="name.value"
25-
data-on-reverse="reversed.value = evt.detail.value"
24+
data-attributes-name="$name"
25+
data-on-reverse="$reversed = evt.detail.value"
2626
></reverse-component>
2727
</div>
2828
</div>

0 commit comments

Comments
 (0)