@stokelp/styled-system 1.15.0 → 1.16.0
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 +1 -1
- package/recipes/chip.d.ts +39 -0
- package/recipes/chip.mjs +66 -0
- package/recipes/index.d.ts +1 -0
- package/recipes/index.mjs +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import type { ConditionalValue } from '../types/index';
|
|
3
|
+
import type { DistributiveOmit, Pretty } from '../types/system-types';
|
|
4
|
+
|
|
5
|
+
interface ChipVariant {
|
|
6
|
+
/**
|
|
7
|
+
* @default "md"
|
|
8
|
+
*/
|
|
9
|
+
size: "lg" | "md" | "sm"
|
|
10
|
+
/**
|
|
11
|
+
* @default "secondary"
|
|
12
|
+
*/
|
|
13
|
+
colorScheme: "secondary" | "grey" | "red" | "yellow" | "green" | "blue" | "purple" | "brown"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ChipVariantMap = {
|
|
17
|
+
[key in keyof ChipVariant]: Array<ChipVariant[key]>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ChipVariantProps = {
|
|
21
|
+
[key in keyof ChipVariant]?: ConditionalValue<ChipVariant[key]> | undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ChipRecipe {
|
|
25
|
+
__type: ChipVariantProps
|
|
26
|
+
(props?: ChipVariantProps): Pretty<Record<"root" | "avatar" | "body" | "clearTrigger", string>>
|
|
27
|
+
raw: (props?: ChipVariantProps) => ChipVariantProps
|
|
28
|
+
variantMap: ChipVariantMap
|
|
29
|
+
variantKeys: Array<keyof ChipVariant>
|
|
30
|
+
splitVariantProps<Props extends ChipVariantProps>(props: Props): [ChipVariantProps, Pretty<DistributiveOmit<Props, keyof ChipVariantProps>>]
|
|
31
|
+
getVariantProps: (props?: ChipVariantProps) => ChipVariantProps
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The styles for the Chip component
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
*/
|
|
39
|
+
export declare const chip: ChipRecipe
|
package/recipes/chip.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { compact, getSlotCompoundVariant, memo, splitProps } from '../helpers.mjs';
|
|
2
|
+
import { createRecipe } from './create-recipe.mjs';
|
|
3
|
+
|
|
4
|
+
const chipDefaultVariants = {
|
|
5
|
+
"size": "md",
|
|
6
|
+
"colorScheme": "secondary"
|
|
7
|
+
}
|
|
8
|
+
const chipCompoundVariants = []
|
|
9
|
+
|
|
10
|
+
const chipSlotNames = [
|
|
11
|
+
[
|
|
12
|
+
"root",
|
|
13
|
+
"chip__root"
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
"avatar",
|
|
17
|
+
"chip__avatar"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"body",
|
|
21
|
+
"chip__body"
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"clearTrigger",
|
|
25
|
+
"chip__clearTrigger"
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
const chipSlotFns = /* @__PURE__ */ chipSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, chipDefaultVariants, getSlotCompoundVariant(chipCompoundVariants, slotName))])
|
|
29
|
+
|
|
30
|
+
const chipFn = memo((props = {}) => {
|
|
31
|
+
return Object.fromEntries(chipSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const chipVariantKeys = [
|
|
35
|
+
"size",
|
|
36
|
+
"colorScheme"
|
|
37
|
+
]
|
|
38
|
+
const getVariantProps = (variants) => ({ ...chipDefaultVariants, ...compact(variants) })
|
|
39
|
+
|
|
40
|
+
export const chip = /* @__PURE__ */ Object.assign(chipFn, {
|
|
41
|
+
__recipe__: false,
|
|
42
|
+
__name__: 'chip',
|
|
43
|
+
raw: (props) => props,
|
|
44
|
+
variantKeys: chipVariantKeys,
|
|
45
|
+
variantMap: {
|
|
46
|
+
"size": [
|
|
47
|
+
"lg",
|
|
48
|
+
"md",
|
|
49
|
+
"sm"
|
|
50
|
+
],
|
|
51
|
+
"colorScheme": [
|
|
52
|
+
"secondary",
|
|
53
|
+
"grey",
|
|
54
|
+
"red",
|
|
55
|
+
"yellow",
|
|
56
|
+
"green",
|
|
57
|
+
"blue",
|
|
58
|
+
"purple",
|
|
59
|
+
"brown"
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
splitVariantProps(props) {
|
|
63
|
+
return splitProps(props, chipVariantKeys)
|
|
64
|
+
},
|
|
65
|
+
getVariantProps
|
|
66
|
+
})
|
package/recipes/index.d.ts
CHANGED