addStaticFloatingLabel.ts 1.2 KB

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import type { Classes } from '#shared/form/plugins/utils.ts'
  3. import { clean, extendClasses } from '#shared/form/plugins/utils.ts'
  4. /**
  5. * We cannot use absolute positioning for the floating label, because we might need to display
  6. * several rows of information on the screen - so content can depend on the actual label size and not
  7. * overlap.
  8. */
  9. export const addStaticFloatingLabel = (classes: Classes = {}): Classes => {
  10. return extendClasses(classes, {
  11. outer: clean(`focus-within:bg-blue-highlight relative flex flex-col px-2`),
  12. wrapper: 'relative flex flex-1 flex-col justify-center self-start py-1',
  13. inner: 'relative flex pb-1 ltr:pr-2 rtl:pl-2',
  14. block: 'formkit-disabled:cursor-default flex min-h-[3.5rem] cursor-pointer',
  15. // text-base ensures there is no zoom when you click on the input on iOS
  16. input: clean(
  17. `formkit-label-hidden:pt-4 w-full border-none bg-transparent pt-6 text-base placeholder:text-transparent focus:outline-none ltr:pl-2 rtl:pr-2`,
  18. ),
  19. label: clean(
  20. `pointer-events-none absolute top-0 h-14 origin-left px-2 py-4 transition-all duration-100 ease-in-out ltr:left-0 rtl:right-0`,
  21. ),
  22. })
  23. }