|
|
@ -1,5 +1,5 @@
|
|
|
|
import { toChildArray } from 'preact'
|
|
|
|
import { toChildArray } from 'preact'
|
|
|
|
import { useCallback, useEffect, useState } from 'preact/hooks'
|
|
|
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'
|
|
|
|
|
|
|
|
|
|
|
|
export function hashCode(s) {
|
|
|
|
export function hashCode(s) {
|
|
|
|
s = s.toString() + "seed iniziale dell'hash"
|
|
|
|
s = s.toString() + "seed iniziale dell'hash"
|
|
|
@ -82,6 +82,45 @@ export function useRemoteState(url, initialValue = null) {
|
|
|
|
return [value, error, refresh]
|
|
|
|
return [value, error, refresh]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Toggle CSS Class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// export function useClasses(classes) {
|
|
|
|
|
|
|
|
// const elementRef = useRef(null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (Array.isArray(classes)) {
|
|
|
|
|
|
|
|
// classes = Object.fromEntries(classes.filter(Boolean).map(className => [className, true]))
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const updateClasses = () => {
|
|
|
|
|
|
|
|
// if (elementRef.current) {
|
|
|
|
|
|
|
|
// const $el = elementRef.current
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log($el.classList)
|
|
|
|
|
|
|
|
// console.log('Applying classes:', classes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for (const [className, present] of Object.entries(classes)) {
|
|
|
|
|
|
|
|
// if (present) {
|
|
|
|
|
|
|
|
// if (!$el.classList.contains(className)) {
|
|
|
|
|
|
|
|
// console.log('Adding class:', className, present)
|
|
|
|
|
|
|
|
// $el.classList.add(className)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// if ($el.classList.contains(className)) {
|
|
|
|
|
|
|
|
// console.log('Removing class:', className, present)
|
|
|
|
|
|
|
|
// $el.classList.remove(className)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// useEffect(() => {
|
|
|
|
|
|
|
|
// updateClasses()
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return [elementRef]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Change Case Utility
|
|
|
|
// Change Case Utility
|
|
|
|
//
|
|
|
|
//
|
|
|
|