@spark-ui/internal-utils
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -6,2 +6,9 @@ # Change Log | ||
# [1.4.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.3.0...@spark-ui/internal-utils@1.4.0) (2023-04-06) | ||
### Features | ||
- **internal-utils:** add comment ([fde9ab5](https://github.com/adevinta/spark/commit/fde9ab550895a0d362aaf7edb3975bf89560f965)) | ||
- **internal-utils:** clean up code (variants folder) ([9f62a0f](https://github.com/adevinta/spark/commit/9f62a0f876d37c4962704c107eb0567bef2eeb1c)) | ||
# [1.3.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@1.2.0...@spark-ui/internal-utils@1.3.0) (2023-04-05) | ||
@@ -8,0 +15,0 @@ |
export { tw } from './tw'; | ||
export { makeDesigns, makeIntents, makeShapes, makeSizes } from './variants'; | ||
export { makeVariants } from './variants'; | ||
export * as VariantTypes from './variants/types'; | ||
export * as variantConstants from './variants/constants'; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),n=Object.freeze(Object.defineProperty({__proto__:null,designs:["filled","outlined","tinted","ghost","contrast"],intents:["primary","secondary","success","error","info","alert","danger","neutral","surface"],shapes:["rounded","square","pill"],sizes:["sm","md","lg"]},Symbol.toStringTag,{value:"Module"}));exports.VariantTypes=t,exports.makeDesigns=function(e){return{design:e}},exports.makeIntents=function(e){return{intent:e}},exports.makeShapes=function(e){return{shape:e}},exports.makeSizes=function(e){return{size:e}},exports.tw=function(e){return e},exports.variantConstants=n; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),r=Object.freeze(Object.defineProperty({__proto__:null,designs:["filled","outlined","tinted","ghost","contrast"],intents:["primary","secondary","success","error","info","alert","danger","neutral","surface"],shapes:["rounded","square","pill"],sizes:["sm","md","lg"]},Symbol.toStringTag,{value:"Module"}));exports.VariantTypes=t,exports.makeVariants=function(e){return e},exports.tw=function(e){return e},exports.variantConstants=r; |
@@ -5,2 +5,4 @@ /** | ||
* | ||
* For more context, see: https://github.com/joe-bell/cva/discussions/85#discussioncomment-4568738 | ||
* | ||
* @example | ||
@@ -7,0 +9,0 @@ * |
@@ -1,14 +0,3 @@ | ||
import { Design, DesignLookup, Intent, IntentLookup, Picks, Shape, ShapeLookup, Size, SizeLookup } from './types'; | ||
declare function makeSizes<P extends Size[] = []>(sizes: P extends [] ? SizeLookup : Picks<SizeLookup, P>): { | ||
size: P extends [] ? SizeLookup : Picks<SizeLookup, P>; | ||
}; | ||
declare function makeIntents<P extends Intent[] = []>(intents: P extends [] ? IntentLookup : Picks<IntentLookup, P>): { | ||
intent: P extends [] ? IntentLookup : Picks<IntentLookup, P>; | ||
}; | ||
declare function makeDesigns<P extends Design[] = []>(designs: P extends [] ? DesignLookup : Picks<DesignLookup, P>): { | ||
design: P extends [] ? DesignLookup : Picks<DesignLookup, P>; | ||
}; | ||
declare function makeShapes<P extends Shape[] = []>(shapes: P extends [] ? ShapeLookup : Picks<ShapeLookup, P>): { | ||
shape: P extends [] ? ShapeLookup : Picks<ShapeLookup, P>; | ||
}; | ||
export { makeSizes, makeIntents, makeDesigns, makeShapes }; | ||
import { Picks, VariantLookup } from './types'; | ||
declare function makeVariants<Variant extends 'design' | 'intent' | 'shape' | 'size', P extends (keyof VariantLookup[Variant])[] = []>(variants: P extends [] ? VariantLookup[Variant] : Picks<VariantLookup[Variant], P>): P extends [] ? VariantLookup[Variant] : Picks<VariantLookup[Variant], P>; | ||
export { makeVariants }; |
import { designs, intents, shapes, sizes } from './constants'; | ||
type Picks<T extends object, Entries extends (keyof T)[], Acc = {}> = Entries extends [ | ||
infer Entry, | ||
type Picks<T extends object, PickedItems extends (keyof T)[], Acc = {}> = PickedItems extends [ | ||
infer Head, | ||
...infer Rest | ||
] ? Rest extends (keyof T)[] ? Entry extends keyof T ? Picks<T, Rest, Acc & Pick<T, Entry>> : Acc : Acc : Acc; | ||
] ? Rest extends (keyof T)[] ? Head extends keyof T ? Picks<T, Rest, Acc & Pick<T, Head>> : Acc : Acc : Acc; | ||
type Size = (typeof sizes)[number]; | ||
@@ -14,2 +14,8 @@ type SizeLookup = Record<Size, string[]>; | ||
type ShapeLookup = Record<Shape, string[]>; | ||
export type { Size, SizeLookup, Intent, IntentLookup, Design, DesignLookup, Shape, ShapeLookup, Picks, }; | ||
interface VariantLookup { | ||
design: DesignLookup; | ||
intent: IntentLookup; | ||
shape: ShapeLookup; | ||
size: SizeLookup; | ||
} | ||
export type { Size, SizeLookup, Intent, IntentLookup, Design, DesignLookup, Shape, ShapeLookup, Picks, VariantLookup, }; |
{ | ||
"name": "@spark-ui/internal-utils", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "package for sharing reusable code and resources across the codebase", | ||
@@ -14,3 +14,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "2b57fad10e74d51ea57d0bfff9bb636dbdd8914b" | ||
"gitHead": "a5a87741408264a57672bf562f14b97a3a63582a" | ||
} |
Sorry, the diff of this file is not supported yet
7159
105