init
Tests / metadata (push) Canceled after 0s
Tests / nova-credentials (push) Canceled after 0s
Tests / PHP 8.2 (push) Canceled after 0s
Tests / PHP 8.3 (push) Canceled after 0s
Tests / PHP 8.4 (push) Canceled after 0s
Tests / PHP 8.5 (push) Canceled after 0s
Tests / metadata (push) Canceled after 0s
Tests / nova-credentials (push) Canceled after 0s
Tests / PHP 8.2 (push) Canceled after 0s
Tests / PHP 8.3 (push) Canceled after 0s
Tests / PHP 8.4 (push) Canceled after 0s
Tests / PHP 8.5 (push) Canceled after 0s
This commit is contained in:
19 files changed
+1102
No files matched your search
Vendored
+179
@@ -0,0 +1,179 @@
|
||||
[data-nfd-form][data-nfd-active][data-nfd-position="bottom"] {
|
||||
padding-bottom: calc(
|
||||
var(--nfd-original-padding-bottom, 0px) +
|
||||
var(--nfd-actions-height, 0px) + 1.5rem
|
||||
) !important;
|
||||
}
|
||||
|
||||
[data-nfd-form][data-nfd-active][data-nfd-position="top"] {
|
||||
padding-top: calc(
|
||||
var(--nfd-original-padding-top, 0px) +
|
||||
var(--nfd-actions-height, 0px) + 1.5rem
|
||||
) !important;
|
||||
}
|
||||
|
||||
[data-nfd-form][data-nfd-active][data-nfd-position="left"] {
|
||||
padding-left: calc(
|
||||
var(--nfd-original-padding-left, 0px) +
|
||||
var(--nfd-actions-width, 0px) + 1.5rem
|
||||
) !important;
|
||||
}
|
||||
|
||||
[data-nfd-form][data-nfd-active][data-nfd-position="right"] {
|
||||
padding-right: calc(
|
||||
var(--nfd-original-padding-right, 0px) +
|
||||
var(--nfd-actions-width, 0px) + 1.5rem
|
||||
) !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions] {
|
||||
position: fixed !important;
|
||||
z-index: 40;
|
||||
padding: 0.75rem 1rem !important;
|
||||
border: 1px solid rgba(var(--colors-gray-200), 0.9);
|
||||
border-radius: 0.75rem;
|
||||
background: rgba(var(--colors-gray-50), 0.92);
|
||||
box-shadow:
|
||||
0 -2px 8px rgb(0 0 0 / 0.06),
|
||||
0 8px 24px rgb(0 0 0 / 0.12);
|
||||
backdrop-filter: blur(12px);
|
||||
transition:
|
||||
opacity 120ms ease-out,
|
||||
transform 120ms ease-out;
|
||||
animation: nfd-enter 120ms ease-out;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="top"],
|
||||
[data-nfd-actions][data-nfd-position="bottom"] {
|
||||
right: var(--nfd-inline-end, 1rem);
|
||||
left: var(--nfd-inline-start, 1rem);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="top"] {
|
||||
top: var(--nfd-block-start, 1rem);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="bottom"] {
|
||||
bottom: calc(
|
||||
var(--nfd-floating-gap, 12px) + env(safe-area-inset-bottom, 0px)
|
||||
);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"],
|
||||
[data-nfd-actions][data-nfd-position="right"] {
|
||||
display: flex !important;
|
||||
width: min(14rem, calc(100vw - 2rem));
|
||||
flex-direction: column !important;
|
||||
align-items: stretch !important;
|
||||
gap: 0.5rem !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"] {
|
||||
left: var(--nfd-inline-start, 1rem);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="right"] {
|
||||
right: var(--nfd-inline-end, 1rem);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"] > *,
|
||||
[data-nfd-actions][data-nfd-position="right"] > * {
|
||||
width: 100%;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"][data-nfd-alignment="start"],
|
||||
[data-nfd-actions][data-nfd-position="right"][data-nfd-alignment="start"] {
|
||||
top: var(--nfd-block-start, 1rem);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"][data-nfd-alignment="center"],
|
||||
[data-nfd-actions][data-nfd-position="right"][data-nfd-alignment="center"] {
|
||||
top: 50%;
|
||||
translate: 0 -50%;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="left"][data-nfd-alignment="end"],
|
||||
[data-nfd-actions][data-nfd-position="right"][data-nfd-alignment="end"] {
|
||||
bottom: calc(
|
||||
var(--nfd-floating-gap, 12px) + env(safe-area-inset-bottom, 0px)
|
||||
);
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="top"][data-nfd-alignment="start"],
|
||||
[data-nfd-actions][data-nfd-position="bottom"][data-nfd-alignment="start"] {
|
||||
justify-content: flex-start !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="top"][data-nfd-alignment="center"],
|
||||
[data-nfd-actions][data-nfd-position="bottom"][data-nfd-alignment="center"] {
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-position="top"][data-nfd-alignment="end"],
|
||||
[data-nfd-actions][data-nfd-position="bottom"][data-nfd-alignment="end"] {
|
||||
justify-content: flex-end !important;
|
||||
}
|
||||
|
||||
@keyframes nfd-enter {
|
||||
from {
|
||||
opacity: 0.7;
|
||||
transform: translateY(4px);
|
||||
}
|
||||
}
|
||||
|
||||
.dark [data-nfd-actions] {
|
||||
border-color: rgba(var(--colors-gray-700), 0.9);
|
||||
background: rgba(var(--colors-gray-900), 0.92);
|
||||
box-shadow:
|
||||
0 -2px 8px rgb(0 0 0 / 0.18),
|
||||
0 8px 24px rgb(0 0 0 / 0.3);
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
[data-nfd-actions][data-nfd-compact-mobile][data-nfd-position="top"],
|
||||
[data-nfd-actions][data-nfd-compact-mobile][data-nfd-position="bottom"] {
|
||||
display: flex !important;
|
||||
flex-flow: row wrap !important;
|
||||
align-items: stretch !important;
|
||||
gap: 0.5rem !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-compact-mobile][data-nfd-position="top"] > *,
|
||||
[data-nfd-actions][data-nfd-compact-mobile][data-nfd-position="bottom"] > * {
|
||||
flex: 1 1 auto;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions][data-nfd-type="create"] > [dusk="create-button"],
|
||||
[data-nfd-actions][data-nfd-type="update"] > [dusk="update-button"] {
|
||||
order: -1;
|
||||
flex-basis: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[data-nfd-actions] {
|
||||
animation: none;
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
[data-nfd-form][data-nfd-active] {
|
||||
padding: var(--nfd-original-padding-top, 0px)
|
||||
var(--nfd-original-padding-right, 0px)
|
||||
var(--nfd-original-padding-bottom, 0px)
|
||||
var(--nfd-original-padding-left, 0px) !important;
|
||||
}
|
||||
|
||||
[data-nfd-actions] {
|
||||
position: static !important;
|
||||
width: auto;
|
||||
padding: 0 !important;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
translate: none;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
}
|
||||
Vendored
+332
@@ -0,0 +1,332 @@
|
||||
(function () {
|
||||
'use strict'
|
||||
|
||||
const FORM_SELECTOR = '#nova [dusk="content"] form[data-form-unique-id]'
|
||||
const controllers = new Map()
|
||||
let scanFrame = null
|
||||
let started = false
|
||||
|
||||
function configuredValue(value, allowedValues, fallback) {
|
||||
return allowedValues.includes(value) ? value : fallback
|
||||
}
|
||||
|
||||
function packageConfig() {
|
||||
const configured = Nova.config('novaFormDock') || {}
|
||||
const positions = ['top', 'bottom', 'left', 'right']
|
||||
|
||||
return {
|
||||
mode: configured.mode === 'always' ? 'always' : 'automatic',
|
||||
minimumFormHeight: Number(configured.minimum_form_height) || null,
|
||||
forms: {
|
||||
create: configured.forms?.create !== false,
|
||||
update: configured.forms?.update !== false,
|
||||
},
|
||||
resources: {
|
||||
only: Array.isArray(configured.resources?.only)
|
||||
? configured.resources.only
|
||||
: [],
|
||||
except: Array.isArray(configured.resources?.except)
|
||||
? configured.resources.except
|
||||
: [],
|
||||
},
|
||||
appearance: {
|
||||
position: configuredValue(
|
||||
configured.appearance?.position,
|
||||
positions,
|
||||
'bottom',
|
||||
),
|
||||
mobilePosition: configuredValue(
|
||||
configured.appearance?.mobile_position,
|
||||
positions,
|
||||
'bottom',
|
||||
),
|
||||
alignment: configuredValue(
|
||||
configured.appearance?.alignment,
|
||||
['start', 'center', 'end'],
|
||||
'end',
|
||||
),
|
||||
compactMobile: configured.appearance?.compact_mobile !== false,
|
||||
floatingGap: Math.max(
|
||||
0,
|
||||
Number(configured.appearance?.floating_gap) || 0,
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
function effectivePosition(config) {
|
||||
return window.matchMedia('(max-width: 767px)').matches
|
||||
? config.appearance.mobilePosition
|
||||
: config.appearance.position
|
||||
}
|
||||
|
||||
function formDetails(form) {
|
||||
if (form.closest('.modal')) {
|
||||
return null
|
||||
}
|
||||
|
||||
const actions = form.lastElementChild
|
||||
|
||||
if (!actions) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (
|
||||
actions.querySelector(':scope > [dusk="create-button"]') &&
|
||||
actions.querySelector(':scope > [dusk="cancel-create-button"]')
|
||||
) {
|
||||
return { actions, type: 'create' }
|
||||
}
|
||||
|
||||
if (
|
||||
actions.querySelector(':scope > [dusk="update-button"]') &&
|
||||
actions.querySelector(':scope > [dusk="cancel-update-button"]')
|
||||
) {
|
||||
return { actions, type: 'update' }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function currentResource() {
|
||||
const match = window.location.pathname.match(/\/resources\/([^/]+)/)
|
||||
|
||||
if (!match) {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
return decodeURIComponent(match[1])
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function resourceIsEnabled(config) {
|
||||
const resource = currentResource()
|
||||
|
||||
if (!resource || config.resources.except.includes(resource)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return (
|
||||
config.resources.only.length === 0 ||
|
||||
config.resources.only.includes(resource)
|
||||
)
|
||||
}
|
||||
|
||||
function scheduleScan() {
|
||||
if (scanFrame !== null) {
|
||||
return
|
||||
}
|
||||
|
||||
scanFrame = window.requestAnimationFrame(() => {
|
||||
scanFrame = null
|
||||
scan()
|
||||
})
|
||||
}
|
||||
|
||||
function createController(form, details) {
|
||||
const computedStyle = window.getComputedStyle(form)
|
||||
const resizeObserver = window.ResizeObserver
|
||||
? new ResizeObserver(scheduleScan)
|
||||
: { disconnect() {}, observe() {} }
|
||||
|
||||
resizeObserver.observe(form)
|
||||
resizeObserver.observe(details.actions)
|
||||
|
||||
if (details.actions.previousElementSibling) {
|
||||
resizeObserver.observe(details.actions.previousElementSibling)
|
||||
}
|
||||
|
||||
return {
|
||||
actions: details.actions,
|
||||
form,
|
||||
naturalActionHeight: details.actions.getBoundingClientRect().height,
|
||||
originalPadding: {
|
||||
top: computedStyle.paddingTop,
|
||||
right: computedStyle.paddingRight,
|
||||
bottom: computedStyle.paddingBottom,
|
||||
left: computedStyle.paddingLeft,
|
||||
},
|
||||
resizeObserver,
|
||||
type: details.type,
|
||||
}
|
||||
}
|
||||
|
||||
function naturalFormHeight(controller) {
|
||||
const { actions, form } = controller
|
||||
const content = actions.previousElementSibling
|
||||
|
||||
if (!content) {
|
||||
return form.scrollHeight
|
||||
}
|
||||
|
||||
const contentRect = content.getBoundingClientRect()
|
||||
const verticalPadding =
|
||||
Number.parseFloat(controller.originalPadding.top) +
|
||||
Number.parseFloat(controller.originalPadding.bottom)
|
||||
|
||||
return contentRect.height + controller.naturalActionHeight + verticalPadding + 32
|
||||
}
|
||||
|
||||
function shouldActivate(controller, config) {
|
||||
if (!config.forms[controller.type] || !resourceIsEnabled(config)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (config.mode === 'always') {
|
||||
return true
|
||||
}
|
||||
|
||||
const availableViewportHeight = Math.max(
|
||||
320,
|
||||
window.innerHeight - Math.max(0, controller.form.getBoundingClientRect().top),
|
||||
)
|
||||
const threshold = config.minimumFormHeight || availableViewportHeight
|
||||
|
||||
return naturalFormHeight(controller) > threshold
|
||||
}
|
||||
|
||||
function setDockDimensions(controller, config) {
|
||||
const formRect = controller.form.getBoundingClientRect()
|
||||
const actionRect = controller.actions.getBoundingClientRect()
|
||||
const headerBottom = document.querySelector('#nova header')
|
||||
?.getBoundingClientRect().bottom
|
||||
const floatingGap = config.appearance.floatingGap
|
||||
|
||||
Object.entries(controller.originalPadding).forEach(([side, value]) => {
|
||||
controller.form.style.setProperty(`--nfd-original-padding-${side}`, value)
|
||||
})
|
||||
|
||||
controller.form.style.setProperty('--nfd-actions-height', `${actionRect.height}px`)
|
||||
controller.form.style.setProperty('--nfd-actions-width', `${actionRect.width}px`)
|
||||
controller.actions.style.setProperty(
|
||||
'--nfd-inline-start',
|
||||
`${Math.max(0, formRect.left)}px`,
|
||||
)
|
||||
controller.actions.style.setProperty(
|
||||
'--nfd-inline-end',
|
||||
`${Math.max(0, window.innerWidth - formRect.right)}px`,
|
||||
)
|
||||
controller.actions.style.setProperty(
|
||||
'--nfd-floating-gap',
|
||||
`${floatingGap}px`,
|
||||
)
|
||||
controller.actions.style.setProperty(
|
||||
'--nfd-block-start',
|
||||
`${Math.max(floatingGap, (headerBottom || 0) + floatingGap)}px`,
|
||||
)
|
||||
}
|
||||
|
||||
function activate(controller, config) {
|
||||
const position = effectivePosition(config)
|
||||
|
||||
controller.form.dataset.nfdForm = ''
|
||||
controller.form.dataset.nfdActive = ''
|
||||
controller.form.dataset.nfdPosition = position
|
||||
controller.actions.dataset.nfdActions = ''
|
||||
controller.actions.dataset.nfdType = controller.type
|
||||
controller.actions.dataset.nfdPosition = position
|
||||
controller.actions.dataset.nfdAlignment = config.appearance.alignment
|
||||
|
||||
if (config.appearance.compactMobile) {
|
||||
controller.actions.dataset.nfdCompactMobile = ''
|
||||
} else {
|
||||
delete controller.actions.dataset.nfdCompactMobile
|
||||
}
|
||||
|
||||
setDockDimensions(controller, config)
|
||||
}
|
||||
|
||||
function deactivate(controller) {
|
||||
delete controller.form.dataset.nfdForm
|
||||
delete controller.form.dataset.nfdActive
|
||||
delete controller.form.dataset.nfdPosition
|
||||
delete controller.actions.dataset.nfdActions
|
||||
delete controller.actions.dataset.nfdType
|
||||
delete controller.actions.dataset.nfdPosition
|
||||
delete controller.actions.dataset.nfdAlignment
|
||||
delete controller.actions.dataset.nfdCompactMobile
|
||||
|
||||
Object.keys(controller.originalPadding).forEach(side => {
|
||||
controller.form.style.removeProperty(`--nfd-original-padding-${side}`)
|
||||
})
|
||||
|
||||
controller.form.style.removeProperty('--nfd-actions-height')
|
||||
controller.form.style.removeProperty('--nfd-actions-width')
|
||||
controller.actions.style.removeProperty('--nfd-inline-start')
|
||||
controller.actions.style.removeProperty('--nfd-inline-end')
|
||||
controller.actions.style.removeProperty('--nfd-floating-gap')
|
||||
controller.actions.style.removeProperty('--nfd-block-start')
|
||||
}
|
||||
|
||||
function destroy(controller) {
|
||||
deactivate(controller)
|
||||
controller.resizeObserver.disconnect()
|
||||
controllers.delete(controller.form)
|
||||
}
|
||||
|
||||
function scan() {
|
||||
const config = packageConfig()
|
||||
const candidates = new Set()
|
||||
|
||||
document.querySelectorAll(FORM_SELECTOR).forEach(form => {
|
||||
const details = formDetails(form)
|
||||
|
||||
if (!details) {
|
||||
return
|
||||
}
|
||||
|
||||
candidates.add(form)
|
||||
|
||||
let controller = controllers.get(form)
|
||||
|
||||
if (!controller || controller.actions !== details.actions) {
|
||||
if (controller) {
|
||||
destroy(controller)
|
||||
}
|
||||
|
||||
controller = createController(form, details)
|
||||
controllers.set(form, controller)
|
||||
}
|
||||
|
||||
if (!controller.form.hasAttribute('data-nfd-active')) {
|
||||
controller.naturalActionHeight = details.actions.getBoundingClientRect().height
|
||||
}
|
||||
|
||||
if (shouldActivate(controller, config)) {
|
||||
activate(controller, config)
|
||||
} else {
|
||||
deactivate(controller)
|
||||
}
|
||||
})
|
||||
|
||||
controllers.forEach(controller => {
|
||||
if (!controller.form.isConnected || !candidates.has(controller.form)) {
|
||||
destroy(controller)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function start() {
|
||||
if (started) {
|
||||
return
|
||||
}
|
||||
|
||||
started = true
|
||||
|
||||
const observer = new MutationObserver(scheduleScan)
|
||||
observer.observe(document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
})
|
||||
|
||||
window.addEventListener('resize', scheduleScan, { passive: true })
|
||||
window.addEventListener('scroll', scheduleScan, { passive: true })
|
||||
Nova.$router?.on('navigate', scheduleScan)
|
||||
scheduleScan()
|
||||
}
|
||||
|
||||
Nova.booting(start)
|
||||
})()
|
||||
Reference in new issue
Block a user