maliknajjar / guifier

An interactive front-end toolkit simplifying JSON, YAML, TOML, and XML data. Visualize, edit, convert formats, and perform real-time data manipulations. Empower your data-driven apps with user-friendly data processing and interactive visualization.
https://guifier.com
MIT License
37 stars 5 forks source link

TOML local date not supported #5

Closed MoritzRitter closed 1 month ago

MoritzRitter commented 1 month ago

Acc. to https://toml.io/en/v1.0.0#local-date a local date looks like this: ld1 = 1979-05-27

However, the TOML Viewer & Editor at https://guifier.com/toml reports an error Error: SyntaxError: Expected "T" but "\n" found.

Expected behavior: the local date is shown and can be edited.

maliknajjar commented 1 month ago

Hi @MoritzRitter Thank you for helping finding these issues and bugs. really appreciate it

this should be an issue in the toml parser library we are using. I have to debug it and see exactly whats the cause of this issue. I will inform asap

maliknajjar commented 1 month ago

The issue arises because the toml package on npm is no longer maintained and only supports TOML specification version 0.4.0, which is outdated. I will try to find an alternative library and replace it.

maliknajjar commented 1 month ago

Hi @MoritzRitter,
I've replaced the TOML library with smol-toml, which supports TOML v1.0.0. Additionally, I've implemented a Date field type, allowing the TOML string to be rendered as a date input.

image

You can check it out here:
https://guifier.com/toml/

It now successfully parses the toml date values.

MoritzRitter commented 1 month ago

Thanks for the update! There seems to be still be a little flaw:

When I open the page, everything is fine: image

But then, when I edit the date using the widget, the date is written back as string (instead of a local date): image Expected: the local date date = 1979-05-28 (without the string quotes "").

maliknajjar commented 1 month ago

I will check that asap

maliknajjar commented 1 month ago

Currently, when editing the date, it gets parsed into this format:

image

The smol-toml library includes the time by default when handling dates. Based on their documentation, I couldn’t find a way to adjust the parsing behavior to output this specific date format:

image

Does this work for you?

MoritzRitter commented 1 month ago

Thanks for checking! Let's put it like this: I would need a local date without timezone info etc. And this is not what we have at the moment. But I can work around it. Much better than a parsing error!

maliknajjar commented 1 month ago

Got it! Since this is related to the smol-toml library, I’ve opened an issue in their repository. Hopefully, they already have this feature or are willing to implement it.

maliknajjar commented 1 month ago

Hi @MoritzRitter I fixed the issue now it works as expected even if the date is edited from the UI image

MoritzRitter commented 1 month ago

Hi @maliknajjar Thanks for the update. There seems to be a new problem with the preservation of multi-line basic strings (acc. to https://toml.io/en/v1.0.0#string): When I add such a string like in this example: image then it is already now displayed in the widget omitting the new lines. And when I then edit the date (or any other object) using the widgets on the right, then the string is converted to a basic string: image While the content is probably still the same, this seems not to be the behavior that the user wants. Would you agree?

maliknajjar commented 1 month ago

Hi @MoritzRitter, I created a seperate issue for this https://github.com/maliknajjar/guifier/issues/7 you can follow it there