Svelecte Alternatives
I'm looking to implement a searchable list of sorts, and I found Svelecte:
https://mskocik.github.io/svelecte/
However, as with most plugins, obviously it has little chance to fit into Foundry applications - is there any similar things I could use in its place with TJS? TJSContextMenu seems the closest approximation!
38 Replies
The reason why I don't want to use datalists is because of their absolutely garbage styling options and lack of separated text & value pairs
What causes it to be unable to fit?
(more a selfish question for my svelte education)
It is bound to the application, unfortunately
npm
svelte-select
A component for Svelte apps. Latest version: 5.7.0, last published: 2 months ago. Start using svelte-select in your project by running
npm i svelte-select
. There are 41 other projects in the npm registry using svelte-select.@Wasp this is the one we're using in the a5e system
can pretty much style it to how you like
Oh nice! Does it support a floating absolute dropdown element?
floatingConfig
there's an option that you can pass the floating config to have it be absolute I believe 🤔
https://github.com/Pjb518/FoundryVTT-Level-Up-Official/blob/main/src/apps/components/effectChanges/ChangeConfiguration.svelte#L29-L48
Here's our usecase of itVery nice! I can't seem to find where to pass a different parent to the config tho
Just as an interesting aside since I'm doing so much work on supporting PopOut in the next TRL release (hopefully out today). Most 3rd party components will not work w/ PopOut. In
svelte-select
this dooms it:
https://github.com/rob-balfre/svelte-select/blob/master/src/lib/Select.svelte#L667😄
https://github.com/fedorovvvv/svelte-floating-ui
This is the repo for the flaoting ui wrapper.
you wanna pass it an object like this.
Doesn't have to include everything
<:thonk_cry:918876481965400114>
hmm
you should prolly be able to override it via css 🤔
Ah, it is because the app itself is a TJSDialog, which has overflow hidden
Yep, it was!
Woop!
Thanks once again @Nekro Darkmoon ! 😄
np
Did you have problems with clicking elements in the dropdown list? Mine doesn't trigger a change when I click elements
ah yes thats the focus manager 😄
https://github.com/Pjb518/FoundryVTT-Level-Up-Official/blob/main/src/apps/ActiveEffectConfig.js#L29
setting focusAuto to false fixes it 😄
So it does
Also a note... A lot of 3rd party components may not be oriented around pointer events. If this one line was changed to
pointerdown
instead of mousedown
then it likely would work without adjusting the TRL focus manager: https://github.com/rob-balfre/svelte-select/blob/master/src/lib/Select.svelte#L679C1-L679C32
But this is why there are options for the focus manager to change behavior as necessary.^ yup
Eventually I will be flushing out the standard library with lots of components that play nice 100%. A fancy select is on the table for the future. However, other priorities like converting existing resources to Svelte 5 and generalizing the architecture to run on top of vanilla Svelte / SvelteKit + continued Foundry support are up first before adding more components to the standard library. In the meantime for whatever is not provided you have to take into consideration that 3rd party libraries won't have the design considerations that one encounters in Foundry. I'm designing all components in the standard library to the latest good practices and mileage may vary w/ 3rd party components.
TJSMenu / TJSContextMenu / TJSColordPicker are getting an upgrade to work w/ PopOut. There is a new
activeWindow
reactive parameter in in app.reactive.activeWindow
and associated store for when the browser window changes. For any component that pops up additional elements and requires event listening external to the component there is now a solution that is easy to implement in custom components. I also got the focus management to work super smooth in popped out state.
Re: PopOut... No 3rd party components that you find will have any expectation of switching browser windows.Final result
❤️ modal TJSDialogs
Did this component work out well for you? Considering it. Also which module is this?
svelte-select
, and the app has --tjs-app-overflow: visible;
You should create a new forum post as this is a different topic.
How do I use
--tjs-app-overflow: visible;
? I'm not sure where to put that. I tried putting it in a css file, nothing happened.You should scope it to the particular app ID that you want to apply it to. So add an app ID in the
defaultOptions
of the specific app then in your separate CSS file use:
E.g. my tab content, which is a child component of the ApplicationShell. I also tried it in the ApplicationShell itself
The CSS variable corresponds to the
ApplicationShell
so you either need to add it via inline styles through props to ApplicationShell
or as a separate CSS file you include scoped by the app ID.Like this?
Probably not.
I don't understand the bit where you say "add in an app ID in the defaultOptions". I know what the defaultOptions are but I don't know anything about the app-id or it's key value format / signature.
No...
main
is in your template. The CSS variable needs to apply ApplicationShell
.
You can apply inline styles via a prop like.
or through a separate CSS file that is scoped to the app ID set in defaultOptions
.hmm.. I've done both but I'm still getting overflow hidden.
and in index.js
and in
init.scss
and in the defaultOptions
Yeah... Well.. It's not
bind: stylesApp
. To pass a prop it's like the code that provided above if you are going the inline styles route. Could be handy to review the Svelte interactive tutorial on how props work.
And of course I can't help you with any of the Pug aspects. You are on your own there.The binding is working and the style is being registered to the application but it doesn't seem to affect the outcome. Hopefully this video explains what I mean.
Maybe Wasp can offer some insight as perhaps you have to configure
svelte-select
. Have you even read the documentation for svelte-select
? It looks like there is a floatingConfig prop. You have to do a little bit of the work here. I can't help you with 3rd party Svelte components much.
Re: props.. You should still learn how props work and just use standard prop passing instead of a binding regardless if that works in this particular instance.