0.0.50 • Published 3 months ago

quasar-app-components v0.0.50

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

AppForm

Generate Form for quasar

Install npm or yarn

npm i quasar-app-components
yarn add quasar-app-components

Documentation

In your vue3 applications import component

<script setup lang="ts">
import { QInput } from 'quasar'
import { z } from 'zod'
import { AppForm, AppFormSchemaField } from 'quasar-app-components'

const modelSchema = z.object({
  name: z.string().noempty(),
})

const schema: AppFormSchemaField[] = [
  {
    scope: 'name',
    component: QInput,
    defaultValue: '',
    componentProps: {
      label: 'Namn',
      // component props i.e from quasar
      square: true,
    },
  },
]
</script>

<template>
  <app-form :schema="schema" :model-schema="modelSchema" />
</template>

AppForm

PropDefaultRequired
schemaSee AppFormSchemaField interfaceYes
modelSchemaA ZodType ObjectYes
colGutterGutter of columns'sm'
modelValueBind formData
readonlyMake all fields readonlyfalse
disableMake all fields disabledfalse
loadingBind loading prop buttonsfalse
fieldWrapperWrapper around all fields'div'
Event
submitReturns validated formData if valid
resetReset formData to defaultValues
errorReturns field errors
Slot
topTop slot for extra content
bottomBottom slot for extra content
[scope]Overwrite schema component

AppFormSchemaField interface

PropDefaultRequired
scopeObject path i.e 'obj.value'Yes
colsSpan number of cols (max 12)'cols-auto'
componentField componentYes
columnColumn position in row1
transformTransform value function before setting to modelValue
defaultValueDefault value of field if not specified in AppForm modelValue propYes
componentPropsProps to add to componentYes

AppSelect

Easy to use quasar q-select with filtering, add new value, checkbox list.

Props
exactFilterMatchFilter exact
transformNewValueTransform new-value label & value
<script setup lang="ts">
import { ref } from 'vue'
import { AppSelect } from 'quasar-app-components'

const model = ref([])
const options = [
   {
      value: 1,
      label: 'Test',
      // optional
      caption: 'Caption'
      disable: true
   },
   {
      value: 2,
      label: 'Test 2',
   }
]
</script>

<template>
  <app-select v-model="model" multiple :options="options" new-value />
</template>

AppModal

Uses quasar dialog plugin.

Open Modal

import { Dialog } from 'quasar'
import { useAppModal } from 'quasar-app-components'

useAppModal(Dialog, {
  // Qdialog props
  persistent: true,
  // Modal title
  title: 'Edit example',
  // Fetch data when open modal, and are provided when injecting modal in slot component
  dependencies: fetchDataArray,
  // Modal slot component content
  slot: {
    component: ExampleContentComponent,
    componentProps: {
      // Slot component props
      exampleProp: true,
    },
  },
})
// slot component
import { appModalInjectionKey } from 'quasar-app-components'

const props = defineProps<{ exampleProp: boolean }>()

const modal = inject(appModalInjectionKey) as AppModalProvider

// injected props
modal.pending // is submit pending
// data fetched in array from dependencies
modal.dependencyData
// onSubmit promise fn callback (sets pending prop and closes modal by itself)
modal.onSubmit(() => {
  return new Promise()
})
// close dialog (optional payload)
modal.onDialogOK()
// close dialog
modal.onDialogCancel()

AppList & AppListItem

Recursive list. Open nested items in new list menu

<script setup lang="ts">
import { ref } from 'vue'
import { QMenu } from 'quasar'
import { AppList, AppListItemProps } from 'quasar-app-components'

const listProps: QListProps = {
  dense: false,
}

const items = ref<AppListItemProps[]>([
  {
    // AppListitem props
    label: 'Settings',
    icon: 'mdi-an-icon',
    color: 'primary',
    visible: true,
    componentProps: {
      // QItem props
      disable: false,
    },
    items: [
      {
        label: 'More settings',
        clickFn: () => {
          // example open useAppModal()
        },
      },
    ],
  },
])
</script>

<template>
  <q-btn icon="mdi-dots-vertical">
    <q-menu square>
      <AppList :component="QMenu" :items="items" :props="listProps" />
    </q-menu>
  </q-btn>
  <!-- or -->
  <q-btn-dropdown label="Åtgärder">
    <AppList :items="items" />
  </q-btn-dropdown>
</template>
0.0.47

4 months ago

0.0.50

3 months ago

0.0.48

3 months ago

0.0.49

3 months ago

0.0.45

4 months ago

0.0.46

4 months ago

0.0.40

6 months ago

0.0.41

6 months ago

0.0.42

6 months ago

0.0.43

6 months ago

0.0.44

6 months ago

0.0.33

6 months ago

0.0.34

6 months ago

0.0.35

6 months ago

0.0.36

6 months ago

0.0.37

6 months ago

0.0.38

6 months ago

0.0.39

6 months ago

0.0.32

8 months ago

0.0.31

8 months ago

0.0.30

8 months ago

0.0.28

8 months ago

0.0.27

8 months ago

0.0.26

8 months ago