Skip to content

Commit

Permalink
chore: fixed linting & build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-solanki committed Feb 10, 2023
1 parent 21329e8 commit ba02a10
Show file tree
Hide file tree
Showing 32 changed files with 78 additions and 87 deletions.
7 changes: 0 additions & 7 deletions packages/anu-nuxt/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,9 @@ export default defineNuxtModule<ModuleOptions>({

// Add default presets for Anu into the unocss options.
nuxt.options.unocss.presets = [
// @ts-expect-error - We know that is a valid preset
presetUno(),

// @ts-expect-error - We know that is a valid preset
presetAnu(),

// @ts-expect-error - We know that is a valid preset
presetIcons(iconPreset),

// @ts-expect-error - We know that is a valid preset
presetThemeDefault(),
...(nuxt.options.unocss.presets || []),
]
Expand Down
4 changes: 2 additions & 2 deletions packages/anu-vue/src/components/badge/ABadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ const formatMaxContent = (content: unknown) => {
}
const anchorOffset = computed(() => {
const newOffsetY = props.overlap && defaultOffset === props.offsetY ? defaultOverlapOffset : props.offsetY
const newOffsetX = props.overlap && defaultOffset === props.offsetX ? defaultOverlapOffset : props.offsetX
const newOffsetY = (props.overlap && defaultOffset === props.offsetY) ? defaultOverlapOffset : props.offsetY
const newOffsetX = (props.overlap && defaultOffset === props.offsetX) ? defaultOverlapOffset : props.offsetX
return { y: newOffsetY, x: newOffsetX }
})
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/badge/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ABadge } from './ABadge.vue'

6 changes: 4 additions & 2 deletions packages/anu-vue/src/components/base-input/ABaseInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TransitionExpand from '@/transitions/TransitionExpand.vue'
// TODO: Provide a way to attach classes to root element
const props = defineProps(baseInputProps)
const emit = defineEmits<{
defineEmits<{
(e: 'click:inputWrapper'): void
}>()
Expand All @@ -23,7 +23,9 @@ const spacing = useSpacing(toRef(props, 'spacing'))
const configurableLabel = useConfigurable(toRef(props, 'label'))
const iconTransition = 'transition duration-150 ease -in'
const elementId = attrs.id || props.label ? `a-input-${attrs.id || props.label}-${Math.random().toString(36).slice(2, 7)}` : undefined
const _elementIdToken = attrs.id || props.label
const elementId = _elementIdToken ? `a-input-${_elementIdToken}-${Math.random().toString(36).slice(2, 7)}` : undefined
const refRoot = ref()
const refInputContainer = ref()
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/base-input/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { default as ABaseInput } from './ABaseInput.vue'
export * from './props'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/btn/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ABtn } from './ABtn.vue'

2 changes: 1 addition & 1 deletion packages/anu-vue/src/components/checkbox/ACheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ watch([data, () => props.indeterminate], ([checked, indeterminate], [_, prevInde
if (refCheckbox.value)
refCheckbox.value.indeterminate = indeterminate
_icon.value = !indeterminate && (!prevIndeterminate || checked) ? props.icon : 'i-bx-minus'
_icon.value = (!indeterminate && (!prevIndeterminate || checked)) ? props.icon : 'i-bx-minus'
}, { immediate: true })
const state = computed(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ACheckbox } from './ACheckbox.vue'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/chip/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as AChip } from './AChip.vue'

3 changes: 1 addition & 2 deletions packages/anu-vue/src/components/data-table/ADataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ const fetchRows = () => {
const {
currentPage,
currentPageSize,
pageCount,
isFirstPage,
isLastPage,
prev: goToPreviousPage,
Expand Down Expand Up @@ -219,7 +218,7 @@ const handleHeaderClick = (clickedCol: any) => {
*/
if (!props.multiSort) {
// Loop over all table columns
cols.value.forEach((_col, index) => {
cols.value.forEach(_col => {
// If iterating column is other than clicked column
if (_col.name !== clickedCol.name) {
// Remove sorting
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/data-table/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as ADataTable } from './ADataTable.vue'
export * from './events'
export * from './props'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/dialog/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ADialog } from './ADialog.vue'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/drawer/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ADrawer } from './ADrawer.vue'

4 changes: 3 additions & 1 deletion packages/anu-vue/src/components/floating/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export const sameWidth = (floatingEl: Ref<HTMLElement>) => ({
name: 'sameWidth',
fn: ({ rects, x, y }: { rects: ElementRects; x: number; y: number }) => {
// Set width of reference to floating
unrefElement(floatingEl).style.minWidth = `${rects.reference.width}px`
const _floatingEL = unrefElement(floatingEl)
if (_floatingEL)
_floatingEL.style.minWidth = `${rects.reference.width}px`

return { x, y }
},
Expand Down
2 changes: 1 addition & 1 deletion packages/anu-vue/src/components/input/AInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const props = defineProps(defu({
modelValue: [String, Number],
}, baseInputProps))
const emit = defineEmits<{
defineEmits<{
(e: 'update:modelValue', value: (ExtractPropTypes<typeof props>)['modelValue']): void
}>()
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/input/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as AInput } from './AInput.vue'

// export { AInput } from './AInput'

6 changes: 3 additions & 3 deletions packages/anu-vue/src/components/list-item/AListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useLayer } from '@/composables/useLayer'
const props = defineProps(listItemProps)
const emit = defineEmits<{
defineEmits<{
(e: 'click:icon'): void
(e: 'click:avatar'): void
(e: 'click:iconAppend'): void
Expand All @@ -30,8 +30,8 @@ else
// useLayer
const { styles, classes } = getLayerClasses(
computed(() => props.isActive ? props.color || 'primary' : undefined),
computed(() => props.isActive ? props.variant || 'light' : 'text'),
computed(() => props.isActive ? (props.color || 'primary') : undefined),
computed(() => props.isActive ? (props.variant || 'light') : 'text'),
toRef(props, 'states'),
{ statesClass: 'states:10' },
)
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/list-item/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export { default as AListItem } from './AListItem.vue'
export * from './props'

50 changes: 8 additions & 42 deletions packages/anu-vue/src/components/list/AList.vue
Original file line number Diff line number Diff line change
@@ -1,53 +1,19 @@
<script lang="ts" setup>
import type { ExtractPropTypes, PropType } from 'vue'
import type { ListItemProps } from '@/components/list-item'
import type { ExtractPropTypes } from 'vue'
import type { ListPropItems } from './props'
import { listProps } from './props'
import { AListItem } from '@/components/list-item'
import { useGroupModel } from '@/composables'
import { spacing as spacingProp } from '@/composables/useProps'
import { useSpacing } from '@/composables/useSpacing'
import { isObject } from '@/utils/helpers'
type ListItem = ListItemProps | string
const props = defineProps({
/**
* Items to render in list
*/
'items': {
type: Array as PropType<ListItem[]>,
default: () => [],
},
/**
* Enable selecting multiple list items
*/
'multi': Boolean,
/**
* Bind v-model value to selected list item
*/
'modelValue': null,
/**
* By default when icon props are used icon rendered at start. Use `iconAppend` to render icon at end.
*/
'iconAppend': Boolean,
/**
* By default when avatar props are used avatar is added at start. Use `avatarAppend` to render avatar at end.
*/
'avatarAppend': Boolean,
// 鈩癸笍 Workaround for checking if event is present on component instance: https://github.com/vuejs/core/issues/5220#issuecomment-1007488240
'onClick:item': Function,
'spacing': spacingProp,
})
const props = defineProps(listProps)
const emit = defineEmits<{
(e: 'update:modelValue', value: (ExtractPropTypes<typeof props>)['modelValue']): void
// 鈩癸笍 Fix type => (e: 'click:item', value: (ExtractPropTypes<typeof props>)['items'][number]): void
(e: 'click:item', value: { index: number; item: ListItem; value: any }): void
(e: 'click:item', value: { index: number; item: ListPropItems[number]; value: any }): void
}>()
defineOptions({
Expand All @@ -56,15 +22,15 @@ defineOptions({
const spacing = useSpacing(toRef(props, 'spacing'))
const extractItemValueFromItemOption = (item: ListItem) => typeof item === 'string' ? item : (item.value || item)
const extractItemValueFromItemOption = (item: ListPropItems[number]) => isObject(item) ? (item.value || item) : item
const { options, select: selectListItem, value } = useGroupModel({
options: props.items.map(i => extractItemValueFromItemOption(i)),
multi: props.multi,
})
// const isActive = computed(() => options.value[itemIndex].isSelected)
const handleListItemClick = (item: ListItem, index: number) => {
const handleListItemClick = (item: ListPropItems[number], index: number) => {
selectListItem(extractItemValueFromItemOption(item) || index)
emit('update:modelValue', value.value)
emit('click:item', {
Expand Down
2 changes: 1 addition & 1 deletion packages/anu-vue/src/components/list/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as AList } from './AList.vue'

export * from './props'
43 changes: 43 additions & 0 deletions packages/anu-vue/src/components/list/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { ExtractPropTypes, PropType } from 'vue'
import type { ListItemProps } from '@/components/list-item'
import { spacing } from '@/composables/useProps'

export type ListPropItems = (ListItemProps | string | number)[]

export const listProps = {
/**
* Items to render in list
*/
'items': {
type: Array as PropType<ListPropItems>,
default: () => [],
},

/**
* Enable selecting multiple list items
*/
'multi': Boolean,

/**
* Bind v-model value to selected list item
*/
'modelValue': null,

/**
* By default when icon props are used icon rendered at start. Use `iconAppend` to render icon at end.
*/
'iconAppend': Boolean,

/**
* By default when avatar props are used avatar is added at start. Use `avatarAppend` to render avatar at end.
*/
'avatarAppend': Boolean,

// 鈩癸笍 Workaround for checking if event is present on component instance: https://github.com/vuejs/core/issues/5220#issuecomment-1007488240

'onClick:item': Function,

'spacing': spacing,
}

export type ListProps = ExtractPropTypes<typeof listProps>
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/radio/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ARadio } from './ARadio.vue'

4 changes: 2 additions & 2 deletions packages/anu-vue/src/components/rating/ARating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ const rating = ref(0)
const isHovered = ref(false)
const visibleRating = computed(() =>
!props.noHoverHint
(!props.noHoverHint
&& !props.readonly
&& !props.disabled
&& isHovered.value
&& isHovered.value)
? rating.value
: props.modelValue ?? 0,
)
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/rating/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ARating } from './ARating.vue'

6 changes: 3 additions & 3 deletions packages/anu-vue/src/components/select/ASelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ExtractPropTypes, PropType } from 'vue'
import { ACard, AList } from '@/components'
import { ABaseInput, baseInputProps } from '@/components/base-input'
import { AFloating, sameWidthFloatingUIMiddleware } from '@/components/floating'
import type { ListItemProps } from '@/components/list-item'
import type { ListPropItems } from '@/components/list'
import { isObject } from '@/utils/helpers'
export interface ObjectOption { label: string; value: string | number }
Expand All @@ -14,7 +14,7 @@ const props = defineProps(defu({
// 鈩癸笍 If we want any type need to set `propName: { type: null }`. Using `propName: null` will omit (disable) the prop.
modelValue: { type: null },
options: {
type: Array as PropType<ListItemProps[]>,
type: Array as PropType<ListPropItems>,
default: () => [],
},
emitObject: Boolean,
Expand Down Expand Up @@ -67,7 +67,7 @@ const handleInputClick = () => {
}
// 馃憠 Options
const handleOptionClick = (item: ListItemProps, value: any) => {
const handleOptionClick = (item: ListPropItems[number], value: any) => {
const valueToEmit = props.emitObject ? item : value
emit('change', valueToEmit)
emit('input', valueToEmit)
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/select/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ASelect } from './ASelect.vue'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/switch/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ASwitch } from './ASwitch.vue'

2 changes: 1 addition & 1 deletion packages/anu-vue/src/components/table/ATable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ACard, cardProps } from '@/components/card'
const props = defineProps(defu(tableProps, cardProps))
// TODO: We aren't getting type error for click:header
const emit = defineEmits<{
defineEmits<{
(e: 'click:header', col: Exclude<(ExtractPropTypes<typeof props>)['cols'], undefined>): void
}>()
Expand Down
1 change: 0 additions & 1 deletion packages/anu-vue/src/components/table/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as ATable } from './ATable.vue'
export * from './events'
export * from './props'

1 change: 0 additions & 1 deletion packages/anu-vue/src/components/textarea/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as ATextarea } from './ATextarea.vue'

6 changes: 3 additions & 3 deletions packages/anu-vue/src/composables/useConfigurable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export const useConfigurable = (value: MaybeRef<ConfigurableValue>) => computed(

const [content, classes, attrs] = _value === undefined
? []
: typeof _value === 'string' || typeof _value === 'number'
? [_value]
: _value
: (typeof _value === 'string' || typeof _value === 'number')
? [_value]
: _value

return { content, classes, attrs }
},
Expand Down
2 changes: 2 additions & 0 deletions packages/anu-vue/volar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ declare module 'vue' {
ADataTable: typeof import('anu-vue')['ADataTable']
ADialog: typeof import('anu-vue')['ADialog']
ADrawer: typeof import('anu-vue')['ADrawer']
AFloating: typeof import('anu-vue')['AFloating']
AInput: typeof import('anu-vue')['AInput']
AList: typeof import('anu-vue')['AList']
AListItem: typeof import('anu-vue')['AListItem']
ALoader: typeof import('anu-vue')['ALoader']
ALoadingIcon: typeof import('anu-vue')['ALoadingIcon']
AMenu: typeof import('anu-vue')['AMenu']
ARadio: typeof import('anu-vue')['ARadio']
ARating: typeof import('anu-vue')['ARating']
Expand Down

0 comments on commit ba02a10

Please sign in to comment.