lowcoder icon indicating copy to clipboard operation
lowcoder copied to clipboard

[Feat]:Day.js all plugins out of the box

Open biboluke opened this issue 2 years ago • 9 comments
trafficstars

Hello, I noticed that day.js doesn't support the iso week of the year out of the box It's impossible for me to migrare to newer version until i can add the isoWeek in the format component.


Since day.js has replaced moment, I think it would be great if all of moment's features were included in day.js

If it's not possible to include all the plugins: I would like to be able to add the plugins for all my app in Lowcoder


image

biboluke avatar Oct 26 '23 07:10 biboluke

Screenshot 2023-11-11 at 09 01 06

We found, that you can do this already. Please use the possibility per App or per Workspace to add JavaScript Libraries.

The plugins are available via https://cdn.jsdelivr.net - and so we can import them dynamically. If this for any reason not work, please re-open the issue.

FalkWolsky avatar Nov 11 '23 08:11 FalkWolsky

image

I'm sorry but I was not able to make it work :( Can you help me?

biboluke avatar Nov 27 '23 22:11 biboluke

The standard functions of DayJS are available. However, what you seek are eventually the advanced-format functions. We need to look at how this could work. https://day.js.org/docs/en/plugin/advanced-format

Screenshot 2023-11-28 at 00 02 59

FalkWolsky avatar Nov 27 '23 23:11 FalkWolsky

https://cdnjs.com/libraries/dayjs

Screenshot 2023-11-28 at 00 09 43

FalkWolsky avatar Nov 27 '23 23:11 FalkWolsky

Can't find it anywhere on how to add the plugin to dayjs. Can you show me?

hoahai avatar Jan 26 '24 17:01 hoahai

We need kindly to excuse that this took us sooo long. Solution is: You import the JS for any DayJS Plugin you need via CDN: https://cdnjs.com/libraries/dayjs

Screenshot 2024-01-26 at 19 21 28 Screenshot 2024-01-26 at 19 21 36 Screenshot 2024-01-26 at 19 21 44

Then in the "Scripts and Styles" for Workspace or App, you need to initialize it. For Advanced Formats for example:

var advancedFormat = require('dayjs/plugin/advancedFormat'); window.dayjs.extend(advancedFormat);

And after that, you can simply use it.

Screenshot 2024-01-26 at 19 27 14

FalkWolsky avatar Jan 26 '24 18:01 FalkWolsky

Thank you for that. I'm trying to add a timezone plugin but failed. What did I do wrong? image

hoahai avatar Jan 26 '24 18:01 hoahai

We need to research further. DayJs Timezone depends on UTC, which needs to be in place before. However, even with that - we did not make it running till now. DayJs Format however, works fine.

Screenshot 2024-01-26 at 22 23 42

We reopen the ticket and research further

FalkWolsky avatar Jan 26 '24 21:01 FalkWolsky

Still doesn't works for me, After copying and pasting your code and restarting the docker i get an error in the debug console: "Can't find variable require" Any clues?

biboluke avatar Jan 26 '24 22:01 biboluke

We solved this in v2.3.1. Now all Day.js plugins are automatically available.

FalkWolsky avatar May 19 '24 12:05 FalkWolsky