unocss-preset-primitives icon indicating copy to clipboard operation
unocss-preset-primitives copied to clipboard

feat(autocomplete): add autocomplete

Open FlorianDevPhynix opened this issue 1 year ago • 8 comments

I was interested what this preset does and so I looked at the source code. I saw that there was no autocomplete so I added it. Currently only tested in the playground. Might test it later on a project with Kobalte

FlorianDevPhynix avatar Apr 01 '24 12:04 FlorianDevPhynix

thank you @FlorianDevPhynix, it's possible to

  • [ ] lint
  • [ ] add some tests

zirbest avatar Apr 01 '24 12:04 zirbest

thank you @FlorianDevPhynix, it's possible to

  • [ ] lint
  • [ ] add some tests

Not sure what to test here. All of this is just for the editor.

The default preset also has no tests and lints for the autocomplete https://github.com/unocss/unocss/tree/main/packages/preset-mini/src/_variants

FlorianDevPhynix avatar Apr 01 '24 12:04 FlorianDevPhynix

autocomplete test example

https://github.com/unocss/unocss/blob/main/test/autocomplete-fuzzy.test.ts

lint

npm run lint --fix

zirbest avatar Apr 01 '24 12:04 zirbest

Ok, I did lint fix and it added a single semicolon. I definitely can write some tests based on this

https://github.com/unocss/unocss/blob/main/test/autocomplete-fuzzy.test.ts

FlorianDevPhynix avatar Apr 01 '24 13:04 FlorianDevPhynix

I will have to added @unocss/autocomplete as a dev dependency.

Should I wrap all the different preset describe's in autocomplete-fuzzy?

describe('autocomplete-fuzzy', () => {
describe('unocss-preset-headlessui', () => { ... })
...
})

FlorianDevPhynix avatar Apr 01 '24 13:04 FlorianDevPhynix

yep add the test file to the test folder test/autocomplte.test.ts

zirbest avatar Apr 01 '24 16:04 zirbest

OK, the test are done. Let me know what I should improve.

FlorianDevPhynix avatar Apr 01 '24 17:04 FlorianDevPhynix

How about we try a more straightforward method?

describe('unocss-preset-kobalte', async () => {
  const uno = createGenerator({
    rules: [['foo', { name: 'foo' }], ['bar', { name: 'bar' }]],
    presets: [presetKobalte()],
  })

  const ac = createAutocomplete(uno, {
    matchType: 'fuzzy',
  })

  it('check against impl', async () => {
    expect(await ac.suggest('uicl'))
      .include('ui-closed:')

    expect(await ac.suggest('uincl'))
      .include('ui-not-closed:')
  })
})

zirbest avatar Apr 02 '24 00:04 zirbest

thank you @FlorianDevPhynix take a look at the new release

zirbest avatar Jul 04 '24 10:07 zirbest