Skip to content

Commit

Permalink
Merge pull request #10 from lucky-media/v1.5
Browse files Browse the repository at this point in the history
🚀 v1.5 Release
  • Loading branch information
Afan417 authored Aug 7, 2024
2 parents 4b4de42 + 0956a15 commit 39a5d42
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 32 deletions.
26 changes: 26 additions & 0 deletions public/build/assets/site-35f9b7b6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/build/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"src": "resources/css/site.css"
},
"resources/js/site.js": {
"file": "assets/site-77a4b0d4.js",
"file": "assets/site-35f9b7b6.js",
"isEntry": true,
"src": "resources/js/site.js"
}
Expand Down
20 changes: 8 additions & 12 deletions resources/js/form/Formatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,21 @@ export const Formatic = () => ({
this.form = this.$form(
"post",
this.$refs.form.getAttribute("action"),
JSON.parse(this.$refs.form.getAttribute("x-data")).form,
{
headers: {
"X-CSRF-Token": {
toString: () =>
this.$refs.form.querySelector('[name="_token"]')
.value,
},
},
}
JSON.parse(this.$refs.form.getAttribute("x-data")).form
);
},

submit: async function () {
try {
const response = await this.form.submit({
headers: { "Content-Type": "multipart/form-data" },
// Remove false values from form data
Object.keys(this.form).forEach((key) => {
if (this.form[key] === false) {
delete this.form[key];
}
});

const response = await this.form.submit();

if (
response.status === 200 &&
this.isMultiStep() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:tabindex="form.{{ handle }} === '{{ option }}' ? 0 : -1">

<input class="sr-only" id="radio-{{ option }}" name="{{ handle }}" value="{{ option }}" type="radio"
{{ js_attributes }} {{ (validate | contains:required) ?= 'required' }}>
{{ (validate | contains:required) ?= 'required' }}>

<x-button as="label" for="radio-{{ option }}"
x-bind:class="form.{handle} === '{option}' && 'border border-primary'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@change="form.validate('{{ handle }}')"
:aria-invalid="form.invalid('{{ handle }}')"
class="h-4 w-4 bg-transparent text-primary shrink-0 rounded-sm border border-primary focus:border-input focus:ring-background focus:ring-offset-background ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
{{ js_attributes }}
{{ (old | in_array(value)) ?= 'checked' }}
>
<x-label for="{{ handle }}-{{ index }}" class="ml-2">{{ label }}</x-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{{ instructions_position == 'below' ?= 'aria-describedBy="{handle}-instructions"' }}
{{ placeholder ?= 'placeholder="{placeholder}"' }}
{{ character_limit ?= 'maxlength="{character_limit}"' }}
{{ js_attributes }}
{{ (validate|contains:required) ?= 'required' }}
{{ old ? 'value="{old}"' : 'value="{value}"' }}
>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
:class="{ 'border-red-600 focus-visible:border-red-600': form.invalid('{{ handle }}') }"
{{ instructions_position == 'below' ?= 'aria-describedBy="{handle}-instructions"' }}
{{ old ? 'value="{old}"' : 'value="{value}"' }}
{{ js_attributes }}
{{ (validate | contains:required) ?= 'required' }}
class="absolute w-full left-0 bg-background font-semibold px-4 py-0 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none outline-none border-background focus:border-none"
x-init="$watch('form.{{ handle }}', (value) => form.{{ handle }} = value < 0 ? 0 : value)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
value="{{ option }}"
@change="form.validate('{{ handle }}')"
class="h-4 w-4 rounded-full bg-transparent border border-primary text-primary focus:border-input focus:ring-background focus:ring-offset-background ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
{{ js_attributes }}
{{ (value == option) ?= 'checked' }}
{{ (validate|contains:required) ?= 'required' }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@change="form.validate('{{ handle }}')"
:aria-invalid="form.invalid('{{ handle }}')"
:class="{ 'border-red-600 focus-visible:border-red-600': form.invalid('{{ handle }}') }"
{{ js_attributes }}
{{ (validate | contains:required) ?= 'required' }}
class="w-full h-2 bg-secondary rounded-full appearance-none cursor-pointer accent-primary">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
:class="{ 'border-red-600 focus-visible:border-red-600': form.invalid('{{ handle }}')}"
class="flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:border-input focus:ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
{{ instructions_position == 'below' ?= 'aria-describedBy="{handle}-instructions"' }}
{{ js_attributes }}
{{ (validate|contains:required) ?= 'required' }}
>
<option value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
{{ autocomplete ?= 'autocomplete="{autocomplete}"' }}
{{ placeholder ?= 'placeholder="{placeholder}"' }}
{{ character_limit ?= 'maxlength="{character_limit}"' }}
{{ js_attributes }}
{{ (validate|contains:required) ?= 'required' }}
>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{{ instructions_position == 'below' ?= 'aria-describedBy="{handle}-instructions"' }}
{{ placeholder ?= 'placeholder="{placeholder}"' }}
{{ character_limit ?= 'maxlength="{character_limit}"' }}
{{ js_attributes }}
{{ (validate|contains:required) ?= 'required' }}
{{ old ? 'value="{old}"' : 'value="{value}"' }}
>
Expand Down
19 changes: 9 additions & 10 deletions resources/views/vendor/statamic/forms/fields/toggle.antlers.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<label
class="relative inline-flex items-center cursor-pointer"
<label
class="relative inline-flex items-center cursor-pointer"
:id="$id('{{ handle }}')"
x-model="form.{{ handle }}"
@change="form.validate('{{ handle }}')"
:aria-invalid="form.invalid('{{ handle }}')"
{{ instructions_position == 'below' ?= 'aria-describedBy="{handle}-instructions"' }}>
<input type="hidden" name="{{ handle }}" value="0">

<input type="hidden" name="{{ handle }}" x-model="form.{{ handle }}" value="0">
<input
x-model="form.{{ handle }}"
@change="form.validate('{{ handle }}')"
class="sr-only peer"
type="checkbox"
name="{{ handle }}"
id="{{ handle }}"
value="1"
class="sr-only peer"
{{ js_attributes }}
{{ (value && value !== '0') ?= 'checked' }}
value="1"
{{ (!old && default) ?= 'checked' }}
{{ (validate|contains:required) ?= 'required' }}
>
<div
Expand Down

0 comments on commit 39a5d42

Please sign in to comment.