@pandacss/node 0.0.0-dev-20230119005608 → 0.0.0-dev-20230119080852
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/dist/index.d.ts +11 -12
- package/dist/index.js +117 -134
- package/dist/index.mjs +118 -135
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export { discardDuplicate } from '@pandacss/core';
|
|
|
4
4
|
import * as _pandacss_types_dist_config from '@pandacss/types/dist/config';
|
|
5
5
|
import * as ts_morph from 'ts-morph';
|
|
6
6
|
import * as _pandacss_types_dist_shared from '@pandacss/types/dist/shared';
|
|
7
|
-
import * as _pandacss_types_dist_recipe from '@pandacss/types/dist/recipe';
|
|
8
7
|
import * as _pandacss_types from '@pandacss/types';
|
|
9
8
|
import { Dict, RecipeConfig, PatternConfig, Config } from '@pandacss/types';
|
|
10
9
|
import * as _pandacss_config from '@pandacss/config';
|
|
@@ -37,7 +36,7 @@ declare function createContext(conf: LoadConfigResult, io?: IO): {
|
|
|
37
36
|
semanticTokens?: _pandacss_types.SemanticTokens<string> | undefined;
|
|
38
37
|
textStyles?: _pandacss_types.TextStyles | undefined;
|
|
39
38
|
layerStyles?: _pandacss_types.LayerStyles | undefined;
|
|
40
|
-
recipes?: Record<string, RecipeConfig<
|
|
39
|
+
recipes?: Record<string, RecipeConfig<_pandacss_types.RecipeVariantRecord>> | undefined;
|
|
41
40
|
};
|
|
42
41
|
config: _pandacss_types_dist_shared.UnwrapExtend<_pandacss_types.RequiredBy<_pandacss_types.Config<_pandacss_types.Conditions, Dict<any>, _pandacss_types.Tokens>, "include" | "outdir" | "cwd">>;
|
|
43
42
|
configPath: string;
|
|
@@ -97,7 +96,7 @@ declare function createContext(conf: LoadConfigResult, io?: IO): {
|
|
|
97
96
|
css: string;
|
|
98
97
|
file: string;
|
|
99
98
|
} | undefined;
|
|
100
|
-
getGlobalCss: () => string
|
|
99
|
+
getGlobalCss: () => string;
|
|
101
100
|
getStaticCss: () => string | undefined;
|
|
102
101
|
patterns: Record<string, PatternConfig>;
|
|
103
102
|
hasPatterns: boolean;
|
|
@@ -119,7 +118,7 @@ declare function createContext(conf: LoadConfigResult, io?: IO): {
|
|
|
119
118
|
jsxName: string;
|
|
120
119
|
blocklistType: string;
|
|
121
120
|
};
|
|
122
|
-
recipes: Record<string, RecipeConfig<
|
|
121
|
+
recipes: Record<string, RecipeConfig<_pandacss_types.RecipeVariantRecord>>;
|
|
123
122
|
getRecipe: (name: string) => RecipeConfig | undefined;
|
|
124
123
|
hasRecipes: boolean;
|
|
125
124
|
getRecipeDetails: () => {
|
|
@@ -189,7 +188,7 @@ declare class Builder {
|
|
|
189
188
|
semanticTokens?: _pandacss_types.SemanticTokens<string> | undefined;
|
|
190
189
|
textStyles?: _pandacss_types.TextStyles | undefined;
|
|
191
190
|
layerStyles?: _pandacss_types.LayerStyles | undefined;
|
|
192
|
-
recipes?: Record<string, _pandacss_types.RecipeConfig<
|
|
191
|
+
recipes?: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord>> | undefined;
|
|
193
192
|
};
|
|
194
193
|
config: _pandacss_types_dist_shared.UnwrapExtend<_pandacss_types.RequiredBy<_pandacss_types.Config<_pandacss_types.Conditions, _pandacss_types.Dict<any>, _pandacss_types.Tokens>, "include" | "outdir" | "cwd">>;
|
|
195
194
|
configPath: string;
|
|
@@ -249,7 +248,7 @@ declare class Builder {
|
|
|
249
248
|
css: string;
|
|
250
249
|
file: string;
|
|
251
250
|
} | undefined;
|
|
252
|
-
getGlobalCss: () => string
|
|
251
|
+
getGlobalCss: () => string;
|
|
253
252
|
getStaticCss: () => string | undefined;
|
|
254
253
|
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
255
254
|
hasPatterns: boolean;
|
|
@@ -271,8 +270,8 @@ declare class Builder {
|
|
|
271
270
|
jsxName: string;
|
|
272
271
|
blocklistType: string;
|
|
273
272
|
};
|
|
274
|
-
recipes: Record<string, _pandacss_types.RecipeConfig<
|
|
275
|
-
getRecipe: (name: string) => _pandacss_types.RecipeConfig<
|
|
273
|
+
recipes: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord>>;
|
|
274
|
+
getRecipe: (name: string) => _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord> | undefined;
|
|
276
275
|
hasRecipes: boolean;
|
|
277
276
|
getRecipeDetails: () => {
|
|
278
277
|
[x: string]: {
|
|
@@ -333,7 +332,7 @@ declare function loadConfigAndCreateContext(options?: {
|
|
|
333
332
|
semanticTokens?: _pandacss_types.SemanticTokens<string> | undefined;
|
|
334
333
|
textStyles?: _pandacss_types.TextStyles | undefined;
|
|
335
334
|
layerStyles?: _pandacss_types.LayerStyles | undefined;
|
|
336
|
-
recipes?: Record<string, _pandacss_types.RecipeConfig<
|
|
335
|
+
recipes?: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord>> | undefined;
|
|
337
336
|
};
|
|
338
337
|
config: _pandacss_types_dist_shared.UnwrapExtend<_pandacss_types.RequiredBy<Config<_pandacss_types.Conditions, _pandacss_types.Dict<any>, _pandacss_types.Tokens>, "include" | "outdir" | "cwd">>;
|
|
339
338
|
configPath: string;
|
|
@@ -393,7 +392,7 @@ declare function loadConfigAndCreateContext(options?: {
|
|
|
393
392
|
css: string;
|
|
394
393
|
file: string;
|
|
395
394
|
} | undefined;
|
|
396
|
-
getGlobalCss: () => string
|
|
395
|
+
getGlobalCss: () => string;
|
|
397
396
|
getStaticCss: () => string | undefined;
|
|
398
397
|
patterns: Record<string, _pandacss_types.PatternConfig>;
|
|
399
398
|
hasPatterns: boolean;
|
|
@@ -415,8 +414,8 @@ declare function loadConfigAndCreateContext(options?: {
|
|
|
415
414
|
jsxName: string;
|
|
416
415
|
blocklistType: string;
|
|
417
416
|
};
|
|
418
|
-
recipes: Record<string, _pandacss_types.RecipeConfig<
|
|
419
|
-
getRecipe: (name: string) => _pandacss_types.RecipeConfig<
|
|
417
|
+
recipes: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord>>;
|
|
418
|
+
getRecipe: (name: string) => _pandacss_types.RecipeConfig<_pandacss_types.RecipeVariantRecord> | undefined;
|
|
420
419
|
hasRecipes: boolean;
|
|
421
420
|
getRecipeDetails: () => {
|
|
422
421
|
[x: string]: {
|
package/dist/index.js
CHANGED
|
@@ -207,7 +207,7 @@ function generateCssFn(ctx) {
|
|
|
207
207
|
export declare function css(styles: SystemStyleObject): string
|
|
208
208
|
`,
|
|
209
209
|
js: import_outdent2.outdent`
|
|
210
|
-
import { createCss, withoutSpace } from '../helpers'
|
|
210
|
+
import { createCss, createMergeCss, withoutSpace } from '../helpers'
|
|
211
211
|
import { sortConditions, finalizeConditions } from './conditions'
|
|
212
212
|
|
|
213
213
|
const classNameMap = ${stringify(utility.entries())}
|
|
@@ -242,6 +242,8 @@ function generateCssFn(ctx) {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
export const css = createCss(context)
|
|
245
|
+
|
|
246
|
+
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
245
247
|
`
|
|
246
248
|
};
|
|
247
249
|
}
|
|
@@ -251,45 +253,39 @@ var import_outdent3 = require("outdent");
|
|
|
251
253
|
function generateCvaFn() {
|
|
252
254
|
return {
|
|
253
255
|
js: import_outdent3.outdent`
|
|
254
|
-
import { compact
|
|
255
|
-
import { css } from './css'
|
|
256
|
+
import { compact } from '../helpers'
|
|
257
|
+
import { css, mergeCss } from './css'
|
|
256
258
|
|
|
257
259
|
export function cva(config) {
|
|
258
260
|
const { base = {}, variants = {}, defaultVariants = {} } = config
|
|
259
|
-
|
|
261
|
+
|
|
262
|
+
function resolve(props) {
|
|
260
263
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
261
264
|
let result = { ...base }
|
|
262
265
|
for (const [key, value] of Object.entries(computedVariants)) {
|
|
263
266
|
if (variants[key]?.[value]) {
|
|
264
|
-
result =
|
|
267
|
+
result = mergeCss(result, variants[key][value])
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
|
-
return
|
|
270
|
+
return result
|
|
268
271
|
}
|
|
269
|
-
}
|
|
270
|
-
`,
|
|
271
|
-
dts: import_outdent3.outdent`
|
|
272
|
-
import { SystemStyleObject } from '../types'
|
|
273
|
-
|
|
274
|
-
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
|
|
275
272
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]>
|
|
280
|
-
}
|
|
273
|
+
function cvaFn(props) {
|
|
274
|
+
return css(resolve(props))
|
|
275
|
+
}
|
|
281
276
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
277
|
+
return Object.assign(cvaFn, {
|
|
278
|
+
__cva__: true,
|
|
279
|
+
variants: Object.keys(variants),
|
|
280
|
+
resolve,
|
|
281
|
+
config,
|
|
282
|
+
})
|
|
286
283
|
}
|
|
284
|
+
`,
|
|
285
|
+
dts: import_outdent3.outdent`
|
|
286
|
+
import { RecipeCreatorFn } from '../types/recipe'
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
export type VariantProps<T extends VariantFn<Variants>> = Parameters<T>[0]
|
|
291
|
-
|
|
292
|
-
export declare function cva<T extends Variants>(recipe?: AtomicRecipe<T>): VariantFn<T>
|
|
288
|
+
export declare const cva: RecipeCreatorFn
|
|
293
289
|
|
|
294
290
|
`
|
|
295
291
|
};
|
|
@@ -366,44 +362,33 @@ function generatePreactJsxFactory(ctx) {
|
|
|
366
362
|
import { h } from 'preact'
|
|
367
363
|
import { forwardRef } from 'preact/compat'
|
|
368
364
|
import { useMemo } from 'preact/hooks'
|
|
369
|
-
import { css, cx } from '../css'
|
|
370
|
-
import {
|
|
365
|
+
import { css, cx, assignCss } from '../css'
|
|
366
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
371
367
|
import { isCssProperty } from './is-valid-prop'
|
|
372
|
-
|
|
373
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
374
|
-
|
|
375
|
-
function normalizeHtmlProp(key) {
|
|
376
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
function splitProps(props) {
|
|
380
|
-
const styleProps = {}
|
|
381
|
-
const elementProps = {}
|
|
382
368
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
} else {
|
|
387
|
-
elementProps[normalizeHtmlProp(key)] = value
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
return [styleProps, elementProps]
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function styled(Dynamic) {
|
|
369
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
370
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
371
|
+
|
|
395
372
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
396
373
|
const { as: Element = Dynamic, ...restProps } = props
|
|
397
374
|
|
|
398
|
-
const [styleProps, elementProps] = useMemo(() =>
|
|
375
|
+
const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
376
|
+
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
377
|
+
}, [restProps])
|
|
399
378
|
|
|
400
379
|
function classes(){
|
|
401
|
-
const { css: cssStyles,
|
|
402
|
-
const
|
|
403
|
-
|
|
380
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
381
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
382
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
383
|
+
return cx(css(styles), elementProps.className)
|
|
404
384
|
}
|
|
405
385
|
|
|
406
|
-
return h(Element, {
|
|
386
|
+
return h(Element, {
|
|
387
|
+
...elementProps,
|
|
388
|
+
...normalizeHTMLProps(htmlProps),
|
|
389
|
+
ref,
|
|
390
|
+
className: classes()
|
|
391
|
+
})
|
|
407
392
|
})
|
|
408
393
|
|
|
409
394
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -538,8 +523,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
538
523
|
export declare const ${name}: ${upperName}
|
|
539
524
|
`,
|
|
540
525
|
jsxType: import_outdent8.outdent`
|
|
541
|
-
import
|
|
542
|
-
import
|
|
526
|
+
import { JSX, ComponentProps } from 'preact'
|
|
527
|
+
import { JsxStyleProps, Assign } from '.'
|
|
528
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
543
529
|
|
|
544
530
|
type Dict = Record<string, unknown>
|
|
545
531
|
type ElementType = keyof JSX.IntrinsicElements
|
|
@@ -561,7 +547,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
561
547
|
}
|
|
562
548
|
|
|
563
549
|
export type ${upperName} = {
|
|
564
|
-
<T extends ElementType, P extends
|
|
550
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
565
551
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
566
552
|
|
|
567
553
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -576,44 +562,35 @@ function generateReactJsxFactory(ctx) {
|
|
|
576
562
|
return {
|
|
577
563
|
js: import_outdent9.outdent`
|
|
578
564
|
import { forwardRef, useMemo } from 'react'
|
|
579
|
-
import { css, cx } from '../css'
|
|
580
|
-
import {
|
|
565
|
+
import { css, cx, cva, assignCss } from '../css'
|
|
566
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
581
567
|
import { isCssProperty } from './is-valid-prop'
|
|
582
|
-
|
|
583
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
584
|
-
|
|
585
|
-
function normalizeHtmlProp(key) {
|
|
586
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function splitProps(props) {
|
|
590
|
-
const styleProps = {}
|
|
591
|
-
const elementProps = {}
|
|
592
|
-
|
|
593
|
-
for (const [key, value] of Object.entries(props)) {
|
|
594
|
-
if (isCssProperty(key)) {
|
|
595
|
-
styleProps[key] = value
|
|
596
|
-
} else {
|
|
597
|
-
elementProps[normalizeHtmlProp(key)] = value
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
return [styleProps, elementProps]
|
|
602
|
-
}
|
|
603
568
|
|
|
604
|
-
function styled(Dynamic) {
|
|
569
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
570
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
571
|
+
|
|
605
572
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
606
573
|
const { as: Element = Dynamic, ...restProps } = props
|
|
607
574
|
|
|
608
|
-
const [styleProps, elementProps] = useMemo(() =>
|
|
575
|
+
const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
576
|
+
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
577
|
+
}, [restProps])
|
|
609
578
|
|
|
610
579
|
function classes(){
|
|
611
|
-
const { css: cssStyles,
|
|
612
|
-
const
|
|
613
|
-
|
|
580
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
581
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
582
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
583
|
+
return cx(css(styles), elementProps.className)
|
|
614
584
|
}
|
|
615
585
|
|
|
616
|
-
return
|
|
586
|
+
return(
|
|
587
|
+
<Element
|
|
588
|
+
ref={ref}
|
|
589
|
+
{...elementProps}
|
|
590
|
+
{...normalizeHTMLProps(htmlProps)}
|
|
591
|
+
className={classes()}
|
|
592
|
+
/>
|
|
593
|
+
)
|
|
617
594
|
})
|
|
618
595
|
|
|
619
596
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -750,8 +727,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
750
727
|
export declare const ${name}: ${upperName}
|
|
751
728
|
`,
|
|
752
729
|
jsxType: import_outdent12.outdent`
|
|
753
|
-
import
|
|
754
|
-
import
|
|
730
|
+
import { ElementType, ComponentProps } from 'react'
|
|
731
|
+
import { JsxStyleProps, Assign } from '.'
|
|
732
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
755
733
|
|
|
756
734
|
type Dict = Record<string, unknown>
|
|
757
735
|
|
|
@@ -772,7 +750,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
772
750
|
}
|
|
773
751
|
|
|
774
752
|
export type ${upperName} = {
|
|
775
|
-
<T extends ElementType, P extends
|
|
753
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
776
754
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
777
755
|
|
|
778
756
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -788,42 +766,38 @@ function generateSolidJsxFactory(ctx) {
|
|
|
788
766
|
js: import_outdent13.outdent`
|
|
789
767
|
import { Dynamic } from 'solid-js/web'
|
|
790
768
|
import { mergeProps, splitProps } from 'solid-js'
|
|
791
|
-
import { css, cx } from '../css'
|
|
792
|
-
import {
|
|
769
|
+
import { css, cx, assignCss } from '../css'
|
|
770
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
793
771
|
import { allCssProperties } from './is-valid-prop'
|
|
794
|
-
|
|
795
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
796
|
-
|
|
797
|
-
function normalizeHtmlProp(key) {
|
|
798
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
function normalizeHtmlProps(props) {
|
|
802
|
-
const result = {}
|
|
803
|
-
for (const [key, value] of Object.entries(props)) {
|
|
804
|
-
result[normalizeHtmlProp(key)] = value
|
|
805
|
-
}
|
|
806
|
-
return result
|
|
807
|
-
}
|
|
808
772
|
|
|
809
|
-
function styled(element) {
|
|
773
|
+
function styled(element, configOrCva = {}) {
|
|
774
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
775
|
+
|
|
810
776
|
return function ${componentName}(props) {
|
|
811
777
|
const mergedProps = mergeProps({ as: element }, props)
|
|
812
778
|
|
|
813
|
-
const [localProps,
|
|
779
|
+
const [localProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
814
780
|
mergedProps,
|
|
815
|
-
['as', 'class'
|
|
816
|
-
|
|
817
|
-
|
|
781
|
+
['as', 'class'],
|
|
782
|
+
allCssProperties,
|
|
783
|
+
normalizeHTMLProps.keys
|
|
818
784
|
)
|
|
819
785
|
|
|
820
786
|
const classes = () => {
|
|
821
|
-
const { css: cssStyles,
|
|
822
|
-
const
|
|
823
|
-
|
|
787
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
788
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
789
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
790
|
+
return cx(css(styles), localProps.class)
|
|
824
791
|
}
|
|
825
792
|
|
|
826
|
-
return
|
|
793
|
+
return (
|
|
794
|
+
<Dynamic
|
|
795
|
+
component={localProps.as}
|
|
796
|
+
{...elementProps}
|
|
797
|
+
{...normalizeHtmlProps(htmlProps)}
|
|
798
|
+
class={classes()}
|
|
799
|
+
/>
|
|
800
|
+
)
|
|
827
801
|
}
|
|
828
802
|
}
|
|
829
803
|
|
|
@@ -955,8 +929,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
955
929
|
export declare const ${name}: ${upperName}
|
|
956
930
|
`,
|
|
957
931
|
jsxType: import_outdent16.outdent`
|
|
958
|
-
import
|
|
959
|
-
import
|
|
932
|
+
import { JSX, ComponentProps, Component } from 'solid-js'
|
|
933
|
+
import { JsxStyleProps, Assign } from '.'
|
|
934
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
960
935
|
|
|
961
936
|
type Dict = Record<string, unknown>
|
|
962
937
|
|
|
@@ -979,7 +954,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
979
954
|
}
|
|
980
955
|
|
|
981
956
|
export type ${upperName} = {
|
|
982
|
-
<T extends ElementType, P extends
|
|
957
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
983
958
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
984
959
|
|
|
985
960
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -1175,6 +1150,7 @@ function generateRecipes(ctx) {
|
|
|
1175
1150
|
const { name, description, defaultVariants, variants } = recipe;
|
|
1176
1151
|
js.push(import_outdent19.outdent`
|
|
1177
1152
|
export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
|
|
1153
|
+
${name}.variants = ${JSON.stringify(Object.keys(variants ?? {}))}
|
|
1178
1154
|
`);
|
|
1179
1155
|
dts.push(import_outdent19.outdent`
|
|
1180
1156
|
export type ${(0, import_shared2.capitalize)(name)}Variants = {
|
|
@@ -1186,7 +1162,7 @@ function generateRecipes(ctx) {
|
|
|
1186
1162
|
}
|
|
1187
1163
|
|
|
1188
1164
|
${description ? `/** ${description} */` : ""}
|
|
1189
|
-
export declare function ${name}(variants?: ${(0, import_shared2.capitalize)(name)}Variants): string
|
|
1165
|
+
export declare function ${name}(variants?: ${(0, import_shared2.capitalize)(name)}Variants): string & { variants: string[] }
|
|
1190
1166
|
`);
|
|
1191
1167
|
});
|
|
1192
1168
|
return {
|
|
@@ -1434,10 +1410,11 @@ function getType(file) {
|
|
|
1434
1410
|
function generateCssType(ctx) {
|
|
1435
1411
|
const propList = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()));
|
|
1436
1412
|
return {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1413
|
+
css: getType("csstype.d.ts"),
|
|
1414
|
+
system: getType("system-types.d.ts"),
|
|
1415
|
+
selectors: getType("selectors.d.ts"),
|
|
1416
|
+
recipe: getType("recipe.d.ts"),
|
|
1417
|
+
exported: import_outdent22.default`
|
|
1441
1418
|
export { ConditionalValue } from './conditions'
|
|
1442
1419
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1443
1420
|
|
|
@@ -1490,20 +1467,21 @@ function setupDesignTokens(ctx) {
|
|
|
1490
1467
|
};
|
|
1491
1468
|
}
|
|
1492
1469
|
function setupTypes(ctx) {
|
|
1493
|
-
const
|
|
1470
|
+
const types = generateCssType(ctx);
|
|
1494
1471
|
const conditions = generateConditions(ctx);
|
|
1495
1472
|
const jsx = generateJsxTypes(ctx);
|
|
1496
1473
|
return {
|
|
1497
1474
|
dir: ctx.paths.types,
|
|
1498
1475
|
files: [
|
|
1499
1476
|
jsx ? { file: "jsx.d.ts", code: jsx.jsxType } : null,
|
|
1500
|
-
{ file: "csstype.d.ts", code:
|
|
1501
|
-
{ file: "system-types.d.ts", code:
|
|
1502
|
-
{ file: "selectors.d.ts", code:
|
|
1503
|
-
{ file: "
|
|
1477
|
+
{ file: "csstype.d.ts", code: types.css },
|
|
1478
|
+
{ file: "system-types.d.ts", code: types.system },
|
|
1479
|
+
{ file: "selectors.d.ts", code: types.selectors },
|
|
1480
|
+
{ file: "recipe.d.ts", code: types.recipe },
|
|
1481
|
+
{ file: "index.d.ts", code: types.exported },
|
|
1504
1482
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
1505
1483
|
{ file: "prop-type.d.ts", code: generatePropTypes(ctx.utility) },
|
|
1506
|
-
{ file: "style-props.d.ts", code:
|
|
1484
|
+
{ file: "style-props.d.ts", code: types.styleProps },
|
|
1507
1485
|
{ file: "conditions.d.ts", code: conditions.dts }
|
|
1508
1486
|
].filter(Boolean)
|
|
1509
1487
|
};
|
|
@@ -1892,7 +1870,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1892
1870
|
const recipe = recipeNodes.find((node) => node.name === name);
|
|
1893
1871
|
if (!recipe)
|
|
1894
1872
|
return [{}, props];
|
|
1895
|
-
return (0, import_shared4.
|
|
1873
|
+
return (0, import_shared4.splitProps)(props, recipe.props);
|
|
1896
1874
|
}
|
|
1897
1875
|
function getRecipeDetails() {
|
|
1898
1876
|
return Object.entries(recipes).map(([name, recipe]) => ({
|
|
@@ -1902,7 +1880,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1902
1880
|
}));
|
|
1903
1881
|
}
|
|
1904
1882
|
const hasRecipes = Object.keys(recipes).length > 0;
|
|
1905
|
-
const properties = Array.from(/* @__PURE__ */ new Set(["css",
|
|
1883
|
+
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
1906
1884
|
function isCustomCssProperty(prop) {
|
|
1907
1885
|
const regex = new RegExp("^(?:" + properties.join("|") + ")$");
|
|
1908
1886
|
return regex.test(prop);
|
|
@@ -2032,10 +2010,15 @@ function createContext(conf, io = fileSystem) {
|
|
|
2032
2010
|
}
|
|
2033
2011
|
});
|
|
2034
2012
|
function getGlobalCss() {
|
|
2035
|
-
if (!globalCss)
|
|
2036
|
-
return;
|
|
2037
2013
|
const sheet = new import_core3.Stylesheet(context());
|
|
2038
|
-
sheet.processGlobalCss(
|
|
2014
|
+
sheet.processGlobalCss({
|
|
2015
|
+
":root": {
|
|
2016
|
+
"--made-with-panda": `'\u{1F43C}'`
|
|
2017
|
+
}
|
|
2018
|
+
});
|
|
2019
|
+
if (globalCss) {
|
|
2020
|
+
sheet.processGlobalCss(globalCss);
|
|
2021
|
+
}
|
|
2039
2022
|
return sheet.toCss();
|
|
2040
2023
|
}
|
|
2041
2024
|
function getStaticCss() {
|
package/dist/index.mjs
CHANGED
|
@@ -161,7 +161,7 @@ function generateCssFn(ctx) {
|
|
|
161
161
|
export declare function css(styles: SystemStyleObject): string
|
|
162
162
|
`,
|
|
163
163
|
js: outdent2`
|
|
164
|
-
import { createCss, withoutSpace } from '../helpers'
|
|
164
|
+
import { createCss, createMergeCss, withoutSpace } from '../helpers'
|
|
165
165
|
import { sortConditions, finalizeConditions } from './conditions'
|
|
166
166
|
|
|
167
167
|
const classNameMap = ${stringify(utility.entries())}
|
|
@@ -196,6 +196,8 @@ function generateCssFn(ctx) {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
export const css = createCss(context)
|
|
199
|
+
|
|
200
|
+
export const { mergeCss, assignCss } = createMergeCss(context)
|
|
199
201
|
`
|
|
200
202
|
};
|
|
201
203
|
}
|
|
@@ -205,45 +207,39 @@ import { outdent as outdent3 } from "outdent";
|
|
|
205
207
|
function generateCvaFn() {
|
|
206
208
|
return {
|
|
207
209
|
js: outdent3`
|
|
208
|
-
import { compact
|
|
209
|
-
import { css } from './css'
|
|
210
|
+
import { compact } from '../helpers'
|
|
211
|
+
import { css, mergeCss } from './css'
|
|
210
212
|
|
|
211
213
|
export function cva(config) {
|
|
212
214
|
const { base = {}, variants = {}, defaultVariants = {} } = config
|
|
213
|
-
|
|
215
|
+
|
|
216
|
+
function resolve(props) {
|
|
214
217
|
const computedVariants = { ...defaultVariants, ...compact(props) }
|
|
215
218
|
let result = { ...base }
|
|
216
219
|
for (const [key, value] of Object.entries(computedVariants)) {
|
|
217
220
|
if (variants[key]?.[value]) {
|
|
218
|
-
result =
|
|
221
|
+
result = mergeCss(result, variants[key][value])
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
|
-
return
|
|
224
|
+
return result
|
|
222
225
|
}
|
|
223
|
-
}
|
|
224
|
-
`,
|
|
225
|
-
dts: outdent3`
|
|
226
|
-
import { SystemStyleObject } from '../types'
|
|
227
|
-
|
|
228
|
-
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
|
|
229
226
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]>
|
|
234
|
-
}
|
|
227
|
+
function cvaFn(props) {
|
|
228
|
+
return css(resolve(props))
|
|
229
|
+
}
|
|
235
230
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
231
|
+
return Object.assign(cvaFn, {
|
|
232
|
+
__cva__: true,
|
|
233
|
+
variants: Object.keys(variants),
|
|
234
|
+
resolve,
|
|
235
|
+
config,
|
|
236
|
+
})
|
|
240
237
|
}
|
|
238
|
+
`,
|
|
239
|
+
dts: outdent3`
|
|
240
|
+
import { RecipeCreatorFn } from '../types/recipe'
|
|
241
241
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
export type VariantProps<T extends VariantFn<Variants>> = Parameters<T>[0]
|
|
245
|
-
|
|
246
|
-
export declare function cva<T extends Variants>(recipe?: AtomicRecipe<T>): VariantFn<T>
|
|
242
|
+
export declare const cva: RecipeCreatorFn
|
|
247
243
|
|
|
248
244
|
`
|
|
249
245
|
};
|
|
@@ -320,44 +316,33 @@ function generatePreactJsxFactory(ctx) {
|
|
|
320
316
|
import { h } from 'preact'
|
|
321
317
|
import { forwardRef } from 'preact/compat'
|
|
322
318
|
import { useMemo } from 'preact/hooks'
|
|
323
|
-
import { css, cx } from '../css'
|
|
324
|
-
import {
|
|
319
|
+
import { css, cx, assignCss } from '../css'
|
|
320
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
325
321
|
import { isCssProperty } from './is-valid-prop'
|
|
326
|
-
|
|
327
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
328
|
-
|
|
329
|
-
function normalizeHtmlProp(key) {
|
|
330
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function splitProps(props) {
|
|
334
|
-
const styleProps = {}
|
|
335
|
-
const elementProps = {}
|
|
336
322
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
} else {
|
|
341
|
-
elementProps[normalizeHtmlProp(key)] = value
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return [styleProps, elementProps]
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function styled(Dynamic) {
|
|
323
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
324
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
325
|
+
|
|
349
326
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
350
327
|
const { as: Element = Dynamic, ...restProps } = props
|
|
351
328
|
|
|
352
|
-
const [styleProps, elementProps] = useMemo(() =>
|
|
329
|
+
const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
330
|
+
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
331
|
+
}, [restProps])
|
|
353
332
|
|
|
354
333
|
function classes(){
|
|
355
|
-
const { css: cssStyles,
|
|
356
|
-
const
|
|
357
|
-
|
|
334
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
335
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
336
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
337
|
+
return cx(css(styles), elementProps.className)
|
|
358
338
|
}
|
|
359
339
|
|
|
360
|
-
return h(Element, {
|
|
340
|
+
return h(Element, {
|
|
341
|
+
...elementProps,
|
|
342
|
+
...normalizeHTMLProps(htmlProps),
|
|
343
|
+
ref,
|
|
344
|
+
className: classes()
|
|
345
|
+
})
|
|
361
346
|
})
|
|
362
347
|
|
|
363
348
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -492,8 +477,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
492
477
|
export declare const ${name}: ${upperName}
|
|
493
478
|
`,
|
|
494
479
|
jsxType: outdent8`
|
|
495
|
-
import
|
|
496
|
-
import
|
|
480
|
+
import { JSX, ComponentProps } from 'preact'
|
|
481
|
+
import { JsxStyleProps, Assign } from '.'
|
|
482
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
497
483
|
|
|
498
484
|
type Dict = Record<string, unknown>
|
|
499
485
|
type ElementType = keyof JSX.IntrinsicElements
|
|
@@ -515,7 +501,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
515
501
|
}
|
|
516
502
|
|
|
517
503
|
export type ${upperName} = {
|
|
518
|
-
<T extends ElementType, P extends
|
|
504
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
519
505
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
520
506
|
|
|
521
507
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -530,44 +516,35 @@ function generateReactJsxFactory(ctx) {
|
|
|
530
516
|
return {
|
|
531
517
|
js: outdent9`
|
|
532
518
|
import { forwardRef, useMemo } from 'react'
|
|
533
|
-
import { css, cx } from '../css'
|
|
534
|
-
import {
|
|
519
|
+
import { css, cx, cva, assignCss } from '../css'
|
|
520
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
535
521
|
import { isCssProperty } from './is-valid-prop'
|
|
536
|
-
|
|
537
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
538
|
-
|
|
539
|
-
function normalizeHtmlProp(key) {
|
|
540
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
function splitProps(props) {
|
|
544
|
-
const styleProps = {}
|
|
545
|
-
const elementProps = {}
|
|
546
|
-
|
|
547
|
-
for (const [key, value] of Object.entries(props)) {
|
|
548
|
-
if (isCssProperty(key)) {
|
|
549
|
-
styleProps[key] = value
|
|
550
|
-
} else {
|
|
551
|
-
elementProps[normalizeHtmlProp(key)] = value
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
return [styleProps, elementProps]
|
|
556
|
-
}
|
|
557
522
|
|
|
558
|
-
function styled(Dynamic) {
|
|
523
|
+
function styled(Dynamic, configOrCva = {}) {
|
|
524
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
525
|
+
|
|
559
526
|
const ${componentName} = forwardRef(function ${componentName}(props, ref) {
|
|
560
527
|
const { as: Element = Dynamic, ...restProps } = props
|
|
561
528
|
|
|
562
|
-
const [styleProps, elementProps] = useMemo(() =>
|
|
529
|
+
const [styleProps, variantProps, htmlProps, elementProps] = useMemo(() => {
|
|
530
|
+
return splitProps(restProps, isCssProperty, cvaFn.variants, normalizeHTMLProps.keys)
|
|
531
|
+
}, [restProps])
|
|
563
532
|
|
|
564
533
|
function classes(){
|
|
565
|
-
const { css: cssStyles,
|
|
566
|
-
const
|
|
567
|
-
|
|
534
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
535
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
536
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
537
|
+
return cx(css(styles), elementProps.className)
|
|
568
538
|
}
|
|
569
539
|
|
|
570
|
-
return
|
|
540
|
+
return(
|
|
541
|
+
<Element
|
|
542
|
+
ref={ref}
|
|
543
|
+
{...elementProps}
|
|
544
|
+
{...normalizeHTMLProps(htmlProps)}
|
|
545
|
+
className={classes()}
|
|
546
|
+
/>
|
|
547
|
+
)
|
|
571
548
|
})
|
|
572
549
|
|
|
573
550
|
${componentName}.displayName = \`${name}.\${Dynamic}\`
|
|
@@ -704,8 +681,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
704
681
|
export declare const ${name}: ${upperName}
|
|
705
682
|
`,
|
|
706
683
|
jsxType: outdent12`
|
|
707
|
-
import
|
|
708
|
-
import
|
|
684
|
+
import { ElementType, ComponentProps } from 'react'
|
|
685
|
+
import { JsxStyleProps, Assign } from '.'
|
|
686
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord, RecipeRuntimeFn } from './recipe'
|
|
709
687
|
|
|
710
688
|
type Dict = Record<string, unknown>
|
|
711
689
|
|
|
@@ -726,7 +704,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
726
704
|
}
|
|
727
705
|
|
|
728
706
|
export type ${upperName} = {
|
|
729
|
-
<T extends ElementType, P extends
|
|
707
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
730
708
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
731
709
|
|
|
732
710
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -742,42 +720,38 @@ function generateSolidJsxFactory(ctx) {
|
|
|
742
720
|
js: outdent13`
|
|
743
721
|
import { Dynamic } from 'solid-js/web'
|
|
744
722
|
import { mergeProps, splitProps } from 'solid-js'
|
|
745
|
-
import { css, cx } from '../css'
|
|
746
|
-
import {
|
|
723
|
+
import { css, cx, assignCss } from '../css'
|
|
724
|
+
import { splitProps, normalizeHTMLProps } from '../helpers'
|
|
747
725
|
import { allCssProperties } from './is-valid-prop'
|
|
748
|
-
|
|
749
|
-
const htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
750
|
-
|
|
751
|
-
function normalizeHtmlProp(key) {
|
|
752
|
-
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
function normalizeHtmlProps(props) {
|
|
756
|
-
const result = {}
|
|
757
|
-
for (const [key, value] of Object.entries(props)) {
|
|
758
|
-
result[normalizeHtmlProp(key)] = value
|
|
759
|
-
}
|
|
760
|
-
return result
|
|
761
|
-
}
|
|
762
726
|
|
|
763
|
-
function styled(element) {
|
|
727
|
+
function styled(element, configOrCva = {}) {
|
|
728
|
+
const cvaFn = configOrCva.__cva__ ? configOrCva : cva(configOrCva)
|
|
729
|
+
|
|
764
730
|
return function ${componentName}(props) {
|
|
765
731
|
const mergedProps = mergeProps({ as: element }, props)
|
|
766
732
|
|
|
767
|
-
const [localProps,
|
|
733
|
+
const [localProps, styleProps, htmlProps, elementProps] = splitProps(
|
|
768
734
|
mergedProps,
|
|
769
|
-
['as', 'class'
|
|
770
|
-
|
|
771
|
-
|
|
735
|
+
['as', 'class'],
|
|
736
|
+
allCssProperties,
|
|
737
|
+
normalizeHTMLProps.keys
|
|
772
738
|
)
|
|
773
739
|
|
|
774
740
|
const classes = () => {
|
|
775
|
-
const { css: cssStyles,
|
|
776
|
-
const
|
|
777
|
-
|
|
741
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
742
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
743
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
744
|
+
return cx(css(styles), localProps.class)
|
|
778
745
|
}
|
|
779
746
|
|
|
780
|
-
return
|
|
747
|
+
return (
|
|
748
|
+
<Dynamic
|
|
749
|
+
component={localProps.as}
|
|
750
|
+
{...elementProps}
|
|
751
|
+
{...normalizeHtmlProps(htmlProps)}
|
|
752
|
+
class={classes()}
|
|
753
|
+
/>
|
|
754
|
+
)
|
|
781
755
|
}
|
|
782
756
|
}
|
|
783
757
|
|
|
@@ -909,8 +883,9 @@ import { ${upperName} } from '../types/jsx'
|
|
|
909
883
|
export declare const ${name}: ${upperName}
|
|
910
884
|
`,
|
|
911
885
|
jsxType: outdent16`
|
|
912
|
-
import
|
|
913
|
-
import
|
|
886
|
+
import { JSX, ComponentProps, Component } from 'solid-js'
|
|
887
|
+
import { JsxStyleProps, Assign } from '.'
|
|
888
|
+
import { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe'
|
|
914
889
|
|
|
915
890
|
type Dict = Record<string, unknown>
|
|
916
891
|
|
|
@@ -933,7 +908,7 @@ export type ${componentName}<T extends ElementType, P extends Dict = {}> = {
|
|
|
933
908
|
}
|
|
934
909
|
|
|
935
910
|
export type ${upperName} = {
|
|
936
|
-
<T extends ElementType, P extends
|
|
911
|
+
<T extends ElementType, P extends RecipeVariantRecord = {}>(component: T, recipe?: RecipeDefinition<P> | RecipeRuntimeFn<P>): ${componentName}<T, RecipeSelection<P>>
|
|
937
912
|
} & { [K in keyof JSX.IntrinsicElements]: ${componentName}<K, {}> }
|
|
938
913
|
|
|
939
914
|
export type ${typeName}<T extends ElementType> = Polyfill<ComponentProps<T>> & JsxStyleProps
|
|
@@ -1129,6 +1104,7 @@ function generateRecipes(ctx) {
|
|
|
1129
1104
|
const { name, description, defaultVariants, variants } = recipe;
|
|
1130
1105
|
js.push(outdent19`
|
|
1131
1106
|
export const ${name} = createRecipe('${name}', ${JSON.stringify(defaultVariants ?? {})})
|
|
1107
|
+
${name}.variants = ${JSON.stringify(Object.keys(variants ?? {}))}
|
|
1132
1108
|
`);
|
|
1133
1109
|
dts.push(outdent19`
|
|
1134
1110
|
export type ${capitalize2(name)}Variants = {
|
|
@@ -1140,7 +1116,7 @@ function generateRecipes(ctx) {
|
|
|
1140
1116
|
}
|
|
1141
1117
|
|
|
1142
1118
|
${description ? `/** ${description} */` : ""}
|
|
1143
|
-
export declare function ${name}(variants?: ${capitalize2(name)}Variants): string
|
|
1119
|
+
export declare function ${name}(variants?: ${capitalize2(name)}Variants): string & { variants: string[] }
|
|
1144
1120
|
`);
|
|
1145
1121
|
});
|
|
1146
1122
|
return {
|
|
@@ -1388,10 +1364,11 @@ function getType(file) {
|
|
|
1388
1364
|
function generateCssType(ctx) {
|
|
1389
1365
|
const propList = new Set(allCssProperties.concat(ctx.utility.keys()));
|
|
1390
1366
|
return {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1367
|
+
css: getType("csstype.d.ts"),
|
|
1368
|
+
system: getType("system-types.d.ts"),
|
|
1369
|
+
selectors: getType("selectors.d.ts"),
|
|
1370
|
+
recipe: getType("recipe.d.ts"),
|
|
1371
|
+
exported: outdent22`
|
|
1395
1372
|
export { ConditionalValue } from './conditions'
|
|
1396
1373
|
export { GlobalStyleObject, JsxStyleProps, SystemStyleObject } from './system-types'
|
|
1397
1374
|
|
|
@@ -1444,20 +1421,21 @@ function setupDesignTokens(ctx) {
|
|
|
1444
1421
|
};
|
|
1445
1422
|
}
|
|
1446
1423
|
function setupTypes(ctx) {
|
|
1447
|
-
const
|
|
1424
|
+
const types = generateCssType(ctx);
|
|
1448
1425
|
const conditions = generateConditions(ctx);
|
|
1449
1426
|
const jsx = generateJsxTypes(ctx);
|
|
1450
1427
|
return {
|
|
1451
1428
|
dir: ctx.paths.types,
|
|
1452
1429
|
files: [
|
|
1453
1430
|
jsx ? { file: "jsx.d.ts", code: jsx.jsxType } : null,
|
|
1454
|
-
{ file: "csstype.d.ts", code:
|
|
1455
|
-
{ file: "system-types.d.ts", code:
|
|
1456
|
-
{ file: "selectors.d.ts", code:
|
|
1457
|
-
{ file: "
|
|
1431
|
+
{ file: "csstype.d.ts", code: types.css },
|
|
1432
|
+
{ file: "system-types.d.ts", code: types.system },
|
|
1433
|
+
{ file: "selectors.d.ts", code: types.selectors },
|
|
1434
|
+
{ file: "recipe.d.ts", code: types.recipe },
|
|
1435
|
+
{ file: "index.d.ts", code: types.exported },
|
|
1458
1436
|
{ file: "token.d.ts", code: generateTokenDts(ctx.tokens) },
|
|
1459
1437
|
{ file: "prop-type.d.ts", code: generatePropTypes(ctx.utility) },
|
|
1460
|
-
{ file: "style-props.d.ts", code:
|
|
1438
|
+
{ file: "style-props.d.ts", code: types.styleProps },
|
|
1461
1439
|
{ file: "conditions.d.ts", code: conditions.dts }
|
|
1462
1440
|
].filter(Boolean)
|
|
1463
1441
|
};
|
|
@@ -1717,7 +1695,7 @@ import {
|
|
|
1717
1695
|
import { isCssProperty } from "@pandacss/is-valid-prop";
|
|
1718
1696
|
import { logger as logger4 } from "@pandacss/logger";
|
|
1719
1697
|
import { createParser, createProject } from "@pandacss/parser";
|
|
1720
|
-
import { capitalize as capitalize4, compact,
|
|
1698
|
+
import { capitalize as capitalize4, compact, dashCase as dashCase2, mapObject, splitProps, uncapitalize } from "@pandacss/shared";
|
|
1721
1699
|
import { TokenDictionary } from "@pandacss/token-dictionary";
|
|
1722
1700
|
import glob from "fast-glob";
|
|
1723
1701
|
import { readdirSync, readFileSync as readFileSync4 } from "fs";
|
|
@@ -1853,7 +1831,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1853
1831
|
const recipe = recipeNodes.find((node) => node.name === name);
|
|
1854
1832
|
if (!recipe)
|
|
1855
1833
|
return [{}, props];
|
|
1856
|
-
return
|
|
1834
|
+
return splitProps(props, recipe.props);
|
|
1857
1835
|
}
|
|
1858
1836
|
function getRecipeDetails() {
|
|
1859
1837
|
return Object.entries(recipes).map(([name, recipe]) => ({
|
|
@@ -1863,7 +1841,7 @@ function createContext(conf, io = fileSystem) {
|
|
|
1863
1841
|
}));
|
|
1864
1842
|
}
|
|
1865
1843
|
const hasRecipes = Object.keys(recipes).length > 0;
|
|
1866
|
-
const properties = Array.from(/* @__PURE__ */ new Set(["css",
|
|
1844
|
+
const properties = Array.from(/* @__PURE__ */ new Set(["css", ...utility.keys(), ...conditions.keys()]));
|
|
1867
1845
|
function isCustomCssProperty(prop) {
|
|
1868
1846
|
const regex = new RegExp("^(?:" + properties.join("|") + ")$");
|
|
1869
1847
|
return regex.test(prop);
|
|
@@ -1993,10 +1971,15 @@ function createContext(conf, io = fileSystem) {
|
|
|
1993
1971
|
}
|
|
1994
1972
|
});
|
|
1995
1973
|
function getGlobalCss() {
|
|
1996
|
-
if (!globalCss)
|
|
1997
|
-
return;
|
|
1998
1974
|
const sheet = new Stylesheet2(context());
|
|
1999
|
-
sheet.processGlobalCss(
|
|
1975
|
+
sheet.processGlobalCss({
|
|
1976
|
+
":root": {
|
|
1977
|
+
"--made-with-panda": `'\u{1F43C}'`
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
if (globalCss) {
|
|
1981
|
+
sheet.processGlobalCss(globalCss);
|
|
1982
|
+
}
|
|
2000
1983
|
return sheet.toCss();
|
|
2001
1984
|
}
|
|
2002
1985
|
function getStaticCss() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/node",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230119080852",
|
|
4
4
|
"description": "The core css panda library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"javascript-stringify": "2.1.0",
|
|
31
31
|
"ts-pattern": "4.1.3",
|
|
32
32
|
"ts-morph": "17.0.1",
|
|
33
|
-
"@pandacss/types": "0.0.0-dev-
|
|
34
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
35
|
-
"@pandacss/error": "0.0.0-dev-
|
|
36
|
-
"@pandacss/parser": "0.0.0-dev-
|
|
37
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
38
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
39
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
40
|
-
"@pandacss/core": "0.0.0-dev-
|
|
41
|
-
"@pandacss/config": "0.0.0-dev-
|
|
33
|
+
"@pandacss/types": "0.0.0-dev-20230119080852",
|
|
34
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230119080852",
|
|
35
|
+
"@pandacss/error": "0.0.0-dev-20230119080852",
|
|
36
|
+
"@pandacss/parser": "0.0.0-dev-20230119080852",
|
|
37
|
+
"@pandacss/shared": "0.0.0-dev-20230119080852",
|
|
38
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230119080852",
|
|
39
|
+
"@pandacss/logger": "0.0.0-dev-20230119080852",
|
|
40
|
+
"@pandacss/core": "0.0.0-dev-20230119080852",
|
|
41
|
+
"@pandacss/config": "0.0.0-dev-20230119080852"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/fs-extra": "11.0.1",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/glob-parent": "^5.1.1",
|
|
47
47
|
"@types/pluralize": "0.0.29",
|
|
48
48
|
"@types/lodash.merge": "4.6.7",
|
|
49
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
49
|
+
"@pandacss/fixture": "0.0.0-dev-20230119080852"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts --format=cjs,esm --shims --dts",
|