daisy-ui-kit 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/utils/-utils.ts +41 -0
- package/utils/Button.config.ts +26 -0
- package/utils/drawer-utils.ts +32 -0
- package/utils/fixtures.ts +62 -0
- package/utils/types.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "daisy-ui-kit",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "nuxi build",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"components/*.vue",
|
|
19
19
|
"components/Mask.config.ts",
|
|
20
|
+
"utils/*",
|
|
20
21
|
"nuxt.js"
|
|
21
22
|
],
|
|
22
23
|
"peerDependencies": {
|
package/utils/-utils.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed } from 'vue'
|
|
2
|
+
|
|
3
|
+
interface MakeExclusiveClassOptions {
|
|
4
|
+
props: Record<string, any>
|
|
5
|
+
prefix: string
|
|
6
|
+
prop: string
|
|
7
|
+
propList: string[]
|
|
8
|
+
defaultVal?: string
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a className for the provided `prop` name and checks that multiple are not enabled.
|
|
12
|
+
* @param prefix will be added to all classes that do not begin with `-`. For those that do, the `-` will be stripped.
|
|
13
|
+
* @param prop
|
|
14
|
+
* @param propList
|
|
15
|
+
* @param defaultVal
|
|
16
|
+
*/
|
|
17
|
+
export function makeExclusiveClass({
|
|
18
|
+
props,
|
|
19
|
+
prefix,
|
|
20
|
+
prop,
|
|
21
|
+
propList,
|
|
22
|
+
defaultVal = '',
|
|
23
|
+
}: MakeExclusiveClassOptions) {
|
|
24
|
+
return computed(() => {
|
|
25
|
+
const active = propList.filter((v: string) => props[v.replace('-', '')])
|
|
26
|
+
if (active.length > 1) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`only one ${prop} can be enabled at a time. Current are ${active}`
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
const current = active[0] || ''
|
|
32
|
+
const _prefix = current.startsWith('-') ? '' : prefix
|
|
33
|
+
return current ? `${_prefix}${current.replace('-', '') || defaultVal}` : ''
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function makeIndividualClass({ props, prefix, prop }) {
|
|
38
|
+
return computed(() => {
|
|
39
|
+
return props[prop] ? `${prefix}${prop}` : ''
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './-utils'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a list of prop names to an object of Booleans. Can be spread into props.
|
|
5
|
+
* @param propList list of prop names to become booleans
|
|
6
|
+
*/
|
|
7
|
+
export function toProps(propList: string[]): Record<string, boolean> {
|
|
8
|
+
return propList.reduce((all: Record<string, any>, current: string) => {
|
|
9
|
+
all[current.replace('-', '')] = Boolean
|
|
10
|
+
return all
|
|
11
|
+
}, {})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const directionVariants = ['top', 'bottom', 'left', 'right']
|
|
15
|
+
export const colorVariants = ['neutral', 'primary', 'secondary', 'accent']
|
|
16
|
+
export const stateVariants = ['info', 'success', 'warning', 'error']
|
|
17
|
+
export const allColorVariants = [...colorVariants, ...stateVariants]
|
|
18
|
+
export const variants = [
|
|
19
|
+
...colorVariants,
|
|
20
|
+
...stateVariants,
|
|
21
|
+
'ghost',
|
|
22
|
+
'link',
|
|
23
|
+
'glass',
|
|
24
|
+
]
|
|
25
|
+
export const sizes = ['xs', 'sm', 'md', 'lg']
|
|
26
|
+
export const shapes = ['circle', 'square']
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { reactive } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface DrawerState {
|
|
4
|
+
name: string
|
|
5
|
+
isDrawerOpen: boolean
|
|
6
|
+
openDrawer: () => void
|
|
7
|
+
closeDrawer: () => void
|
|
8
|
+
toggleDrawer: () => void
|
|
9
|
+
}
|
|
10
|
+
export interface Drawers {
|
|
11
|
+
[key: string]: DrawerState
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const drawers = reactive<Drawers>({})
|
|
15
|
+
|
|
16
|
+
export function createDrawerState(name: string) {
|
|
17
|
+
const drawerState = drawers[name] || reactive<DrawerState>({
|
|
18
|
+
name,
|
|
19
|
+
isDrawerOpen: false,
|
|
20
|
+
openDrawer() {
|
|
21
|
+
drawerState.isDrawerOpen = true
|
|
22
|
+
},
|
|
23
|
+
closeDrawer() {
|
|
24
|
+
drawerState.isDrawerOpen = false
|
|
25
|
+
},
|
|
26
|
+
toggleDrawer() {
|
|
27
|
+
drawerState.isDrawerOpen = !drawerState.isDrawerOpen
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
drawers[name] = drawerState
|
|
31
|
+
return drawerState
|
|
32
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const people = [
|
|
2
|
+
{
|
|
3
|
+
id: 1,
|
|
4
|
+
name: 'Wade Cooper',
|
|
5
|
+
avatar:
|
|
6
|
+
'https://images.unsplash.com/photo-1491528323818-fdd1faba62cc?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: 2,
|
|
10
|
+
name: 'Arlene Mccoy',
|
|
11
|
+
avatar:
|
|
12
|
+
'https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-1.2.1&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 3,
|
|
16
|
+
name: 'Devon Webb',
|
|
17
|
+
avatar:
|
|
18
|
+
'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2.25&w=256&h=256&q=80',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 4,
|
|
22
|
+
name: 'Tom Cook',
|
|
23
|
+
avatar:
|
|
24
|
+
'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 5,
|
|
28
|
+
name: 'Tanya Fox',
|
|
29
|
+
avatar:
|
|
30
|
+
'https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 6,
|
|
34
|
+
name: 'Hellen Schmidt',
|
|
35
|
+
avatar:
|
|
36
|
+
'https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 7,
|
|
40
|
+
name: 'Caroline Schultz',
|
|
41
|
+
avatar:
|
|
42
|
+
'https://images.unsplash.com/photo-1568409938619-12e139227838?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 8,
|
|
46
|
+
name: 'Mason Heaney',
|
|
47
|
+
avatar:
|
|
48
|
+
'https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 9,
|
|
52
|
+
name: 'Claudie Smitham',
|
|
53
|
+
avatar:
|
|
54
|
+
'https://images.unsplash.com/photo-1584486520270-19eca1efcce5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 10,
|
|
58
|
+
name: 'Emil Schaefer',
|
|
59
|
+
avatar:
|
|
60
|
+
'https://images.unsplash.com/photo-1561505457-3bcad021f8ee?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
|
|
61
|
+
},
|
|
62
|
+
]
|