chore: fix code style

This commit is contained in:
danharrin
2022-10-14 10:35:16 +00:00
committed by github-actions[bot]
parent 25ae6a6efb
commit 516ac75b85
10 changed files with 60 additions and 104 deletions
+4 -6
View File
@@ -1,11 +1,7 @@
const esbuild = require('esbuild')
const shouldWatch = process.argv.includes('--watch')
const packages = [
'forms',
'notifications',
'support',
]
const packages = ['forms', 'notifications', 'support']
packages.forEach((package) => {
esbuild
@@ -47,7 +43,9 @@ formComponents.forEach((component) => {
? `'production'`
: `'development'`,
},
entryPoints: [`packages/forms/resources/js/components/${component}.js`],
entryPoints: [
`packages/forms/resources/js/components/${component}.js`,
],
outfile: `packages/forms/dist/components/${component}.js`,
bundle: true,
platform: 'neutral',
@@ -3,7 +3,11 @@ import 'vanilla-colorful/hsl-string-color-picker'
import 'vanilla-colorful/rgb-string-color-picker'
import 'vanilla-colorful/rgba-string-color-picker'
export default function colorPickerFormComponent({ isAutofocused, isDisabled, state }) {
export default function colorPickerFormComponent({
isAutofocused,
isDisabled,
state,
}) {
return {
state,
@@ -20,12 +24,9 @@ export default function colorPickerFormComponent({ isAutofocused, isDisabled, st
this.setState(event.target.value)
})
this.$refs.panel.addEventListener(
'color-changed',
(event) => {
this.setState(event.detail.value)
},
)
this.$refs.panel.addEventListener('color-changed', (event) => {
this.setState(event.detail.value)
})
},
togglePanelVisibility: function () {
@@ -57,10 +57,7 @@ export default function dateTimePickerFormComponent({
this.getSelectedDate() ??
dayjs().tz(timezone).hour(0).minute(0).second(0)
if (
this.getMaxDate() !== null &&
date.isAfter(this.getMaxDate())
) {
if (this.getMaxDate() !== null && date.isAfter(this.getMaxDate())) {
date = null
} else if (
this.getMinDate() !== null &&
@@ -90,9 +87,7 @@ export default function dateTimePickerFormComponent({
return
}
this.focusedDate = this.focusedDate.month(
this.focusedMonth,
)
this.focusedDate = this.focusedDate.month(this.focusedMonth)
})
this.$watch('focusedYear', () => {
@@ -100,10 +95,7 @@ export default function dateTimePickerFormComponent({
this.focusedYear = this.focusedYear.substring(0, 4)
}
if (
!this.focusedYear ||
this.focusedYear?.length !== 4
) {
if (!this.focusedYear || this.focusedYear?.length !== 4) {
return
}
@@ -433,9 +425,7 @@ export default function dateTimePickerFormComponent({
this.emptyDaysInFocusedMonth = Array.from(
{
length: this.focusedDate
.date(8 - firstDayOfWeek)
.day(),
length: this.focusedDate.date(8 - firstDayOfWeek).day(),
},
(_, i) => i + 1,
)
@@ -449,9 +439,9 @@ export default function dateTimePickerFormComponent({
},
setFocusedDay: function (day) {
this.focusedDate = (
this.focusedDate ?? dayjs().tz(timezone)
).date(day)
this.focusedDate = (this.focusedDate ?? dayjs().tz(timezone)).date(
day,
)
},
setState: function (date) {
@@ -81,20 +81,16 @@ export default function fileUploadFormComponent({
imageResizeTargetHeight,
imageResizeTargetWidth,
imageResizeMode,
itemInsertLocation: shouldAppendFiles
? 'after'
: 'before',
itemInsertLocation: shouldAppendFiles ? 'after' : 'before',
...(placeholder && { labelIdle: placeholder }),
maxFileSize: maxSize,
minFileSize: minSize,
styleButtonProcessItemPosition: uploadButtonPosition,
styleButtonRemoveItemPosition:
removeUploadedFileButtonPosition,
styleButtonRemoveItemPosition: removeUploadedFileButtonPosition,
styleLoadIndicatorPosition: loadingIndicatorPosition,
stylePanelAspectRatio: panelAspectRatio,
stylePanelLayout: panelLayout,
styleProgressIndicatorPosition:
uploadProgressIndicatorPosition,
styleProgressIndicatorPosition: uploadProgressIndicatorPosition,
server: {
load: async (source, load) => {
let response = await fetch(source)
@@ -121,9 +117,7 @@ export default function fileUploadFormComponent({
).replace(/[018]/g, (c) =>
(
c ^
(crypto.getRandomValues(
new Uint8Array(1),
)[0] &
(crypto.getRandomValues(new Uint8Array(1))[0] &
(15 >> (c / 4)))
).toString(16),
)
@@ -141,8 +135,7 @@ export default function fileUploadFormComponent({
)
},
remove: async (source, load) => {
let fileKey =
this.uploadedFileUrlIndex[source] ?? null
let fileKey = this.uploadedFileUrlIndex[source] ?? null
if (!fileKey) {
return
@@ -189,8 +182,7 @@ export default function fileUploadFormComponent({
.map((file) =>
file.source instanceof File
? file.serverId
: this.uploadedFileUrlIndex[file.source] ??
null,
: this.uploadedFileUrlIndex[file.source] ?? null,
) // file.serverId is null for a file that is not yet uploaded
.filter((fileKey) => fileKey)
@@ -264,9 +256,7 @@ export default function fileUploadFormComponent({
this.fileKeyIndex = uploadedFileUrls ?? {}
this.uploadedFileUrlIndex = Object.entries(
this.fileKeyIndex,
)
this.uploadedFileUrlIndex = Object.entries(this.fileKeyIndex)
.filter((value) => value)
.reduce((obj, [key, value]) => {
obj[value] = key
@@ -280,9 +270,7 @@ export default function fileUploadFormComponent({
let files = []
for (const uploadedFileUrl of Object.values(
this.fileKeyIndex,
)) {
for (const uploadedFileUrl of Object.values(this.fileKeyIndex)) {
if (!uploadedFileUrl) {
continue
}
@@ -1,4 +1,4 @@
export default function keyValueFormComponent ({ state }) {
export default function keyValueFormComponent({ state }) {
return {
state,
@@ -4,7 +4,7 @@ import DOMPurify from 'dompurify'
import { marked } from 'marked'
import { highlight } from 'mdhl'
export default function markdownEditorFormComponent ({ state, tab }) {
export default function markdownEditorFormComponent({ state, tab }) {
return {
attachment: null,
@@ -57,9 +57,7 @@ export default function selectFormComponent({
await this.refreshChoices({ withInitialOptions: true })
if (![null, undefined, ''].includes(this.state)) {
this.select.setChoiceByValue(
this.formatState(this.state),
)
this.select.setChoiceByValue(this.formatState(this.state))
}
this.refreshPlaceholder()
@@ -81,45 +79,39 @@ export default function selectFormComponent({
})
if (hasDynamicOptions) {
this.$refs.input.addEventListener(
'showDropdown',
async () => {
this.select.clearChoices()
await this.select.setChoices([
{
label: loadingMessage,
value: '',
disabled: true,
},
])
this.$refs.input.addEventListener('showDropdown', async () => {
this.select.clearChoices()
await this.select.setChoices([
{
label: loadingMessage,
value: '',
disabled: true,
},
])
await this.refreshChoices()
},
)
await this.refreshChoices()
})
}
if (hasDynamicSearchResults) {
this.$refs.input.addEventListener(
'search',
async (event) => {
let search = event.detail.value?.trim()
this.$refs.input.addEventListener('search', async (event) => {
let search = event.detail.value?.trim()
if ([null, undefined, ''].includes(search)) {
return
}
if ([null, undefined, ''].includes(search)) {
return
}
this.isSearching = true
this.isSearching = true
this.select.clearChoices()
await this.select.setChoices([
{
label: searchingMessage,
value: '',
disabled: true,
},
])
},
)
this.select.clearChoices()
await this.select.setChoices([
{
label: searchingMessage,
value: '',
disabled: true,
},
])
})
this.$refs.input.addEventListener(
'search',
@@ -149,9 +141,7 @@ export default function selectFormComponent({
this.setChoices(choices)
if (![null, undefined, ''].includes(this.state)) {
this.select.setChoiceByValue(
this.formatState(this.state),
)
this.select.setChoiceByValue(this.formatState(this.state))
}
})
},
@@ -177,11 +167,7 @@ export default function selectFormComponent({
return options
}
if (
search !== '' &&
search !== null &&
search !== undefined
) {
if (search !== '' && search !== null && search !== undefined) {
return await getSearchResultsUsing(search)
}
@@ -226,11 +212,7 @@ export default function selectFormComponent({
)
if (isMultiple) {
if (
state.every((value) =>
existingOptionValues.has(value),
)
) {
if (state.every((value) => existingOptionValues.has(value))) {
return {}
}
@@ -1,4 +1,4 @@
export default function tagsInputFormComponent ({ state }) {
export default function tagsInputFormComponent({ state }) {
return {
newTag: '',
@@ -4,7 +4,6 @@ namespace Filament\Forms;
use Filament\Forms\Testing\TestsForms;
use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Assets\Js;
use Filament\Support\Facades\Asset;
use Illuminate\Filesystem\Filesystem;
use Livewire\Testing\TestableLivewire;
@@ -2,8 +2,6 @@
namespace Filament\Support\Assets;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Arr;
class AssetManager