scala-js / scala-js-dom

Statically typed DOM API for Scala.js
Other
315 stars 160 forks source link

Refresh `DataTransfer` API #738

Closed armanbilge closed 1 year ago

armanbilge commented 1 year ago

I think there are some changes. Also it can use the new FrozenArray type.

https://github.com/scala-js/scala-js-dom/blob/714813e31cf5838d9844141f7bc1b90275f79fa3/dom/src/main/scala/org/scalajs/dom/DataTransfer.scala

https://html.spec.whatwg.org/multipage/dnd.html#datatransfer

zetashift commented 1 year ago

I have a question concerning effectAllowed and dropEffect. They return enums form the spec

The dropEffect attribute controls the drag-and-drop feedback that the user is given during a drag-and-drop operation. When the DataTransfer object is created, the dropEffect attribute is set to a string value. On getting, it must return its current value. On setting, if the new value is one of "none", "copy", "link", or "move", then the attribute's current value must be set to the new value. Other values must be ignored.

The effectAllowed attribute is used in the drag-and-drop processing model to initialize the dropEffect attribute during the dragenter and dragover events. When the DataTransfer object is created, the effectAllowed attribute is set to a string value. On getting, it must return its current value. On setting, if drag data store's mode is the read/write mode and the new value is one of "none", "copy", "copyLink", "copyMove", "link", "linkMove", "move", "all", or "uninitialized", then the attribute's current value must be set to the new value. Otherwise it must be left unchanged.

But how do I name these things lol, EffectAllowedTypes and DropEffectTypes? or Kinds instead of types?

armanbilge commented 1 year ago

Hmmm 😂 I see TypeScript is no help here.

https://github.com/microsoft/TypeScript/blob/7d1cc88a8cbdf8aa847a7f2a7d4bfeb89c8dde15/lib/lib.dom.d.ts#L4302-L4318

erm ... IDK. DropEffectOperation ? but EffectAllowedOperation seems weird.

I wonder if just DropEffect and EffectAllowed could be okay.

zetashift commented 1 year ago

DropEffectValue and EffectAllowedValue?

I'm also okay with DropEffect and EffectAllowed!

armanbilge commented 1 year ago

/shrug if you don't mind open the PR with anything and then let me bikeshed it for 6 months 😛