@pandacss/node 0.0.0-dev-20221121152823

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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Segun Adebayo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ ## Folder structure
2
+
3
+ - `.panda`
4
+ - `tokens` (index.js, index.d.ts, index.css)
5
+ - `styled-system` (index.js, index.d.ts)
6
+ - `package.json`
7
+
8
+ ```js
9
+ const tokens = {
10
+ 'colors.red.400': { value: '...', variable: '...' },
11
+ }
12
+
13
+ const tokenMap = {
14
+ colors: [{ group: 'red', key: 'red.400', value: '...' }],
15
+ fonts: [],
16
+ }
17
+
18
+ function getToken(path) {
19
+ const { value } = tokens[path] || {}
20
+ return value
21
+ }
22
+
23
+ function getTokenVar(path) {
24
+ const { variable } = tokens[path] || {}
25
+ return variable
26
+ }
27
+ ```
28
+
29
+ ```js
30
+ import { generateCssVar, generateDts, generateJs } from '@pandacss/generator'
31
+ import { createTokenMap } from '@pandacss/token-dictionary'
32
+
33
+ const conf = new Conf()
34
+
35
+ const dict = createTokenMap(config)
36
+
37
+ const cssVars = generateCssVar(dict, { root: ':root' })
38
+ const dts = generateDts(dict)
39
+ const files = generateJs(dict, { formats: ['esm', 'cjs'] })
40
+ ```
41
+
42
+ ```json
43
+ {
44
+ "name": "dot-panda",
45
+ "description": "...",
46
+ "exports": {
47
+ "./tokens": {
48
+ "import": "./generated/tokens/index.mjs"
49
+ },
50
+ "./css": {
51
+ "import": "./generated/css/index.mjs"
52
+ }
53
+ },
54
+ "typeVersions": {
55
+ "*": {
56
+ "tokens": ["./generated/tokens"],
57
+ "css": ["./generated/css"]
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ ```js
64
+ import { definePackage, writePackage } from '@pandacss/generators'
65
+
66
+ const pkg = setupPackage({
67
+ name: 'dot-panda',
68
+ description: '...',
69
+ dir: 'generated',
70
+ exports: ['tokens', 'css'],
71
+ })
72
+
73
+ writePackage(pkg)
74
+
75
+ updateTsConfig({
76
+ compilerOptions: {
77
+ paths: {
78
+ 'design-system': ['./.panda'],
79
+ },
80
+ },
81
+ })
82
+
83
+ updateGitIgnore({ comment: '# Panda', path: '.css-panda' })
84
+ ```
85
+
86
+ ```ts
87
+ type ConditionType =
88
+ | 'color-scheme'
89
+ | 'resolution'
90
+ | 'writing-mode'
91
+ | 'pseudo'
92
+ | 'selector'
93
+ | 'viewport'
94
+ | 'interaction-media'
95
+ | 'reduced-motion'
96
+ | 'reduced-data'
97
+ | 'reduced-transparent'
98
+ | 'contrast'
99
+
100
+ const conditions = {
101
+ dark: {
102
+ type: 'color-scheme',
103
+ value: '[data-theme=dark]',
104
+ colorScheme: 'dark',
105
+ },
106
+ darkDimmed: {
107
+ type: 'color-scheme',
108
+ value: '[data-theme=dark_dimmed]',
109
+ colorScheme: 'dark',
110
+ },
111
+ ltr: {
112
+ type: 'dir',
113
+ value: '[dir=rtl]',
114
+ },
115
+ rtl: {
116
+ type: 'dir',
117
+ value: '[dir=rtl]',
118
+ },
119
+ hover: {
120
+ type: 'pseudo',
121
+ value: '&:hover',
122
+ },
123
+ focus: {
124
+ type: 'pseudo',
125
+ value: '&:focus',
126
+ },
127
+ sm: {
128
+ type: 'viewport',
129
+ value: '@media (min-width: 480px)',
130
+ },
131
+ }
132
+ ```
133
+
134
+ ```ts
135
+ const defaults = {
136
+ className: ({ prop, value }) => `${prop}-${esc(value)}`,
137
+ }
138
+
139
+ const tt = defineConfig({
140
+ utilities: [
141
+ {
142
+ properties: {
143
+ display: {
144
+ className: ({ value }) => `d-${value}`,
145
+ transform(value) {
146
+ return { display: value }
147
+ },
148
+ values: {
149
+ fl: 'flex',
150
+ ib: 'inline-block',
151
+ },
152
+ },
153
+ background: {
154
+ className: ({ prop, value }) => `bg-${value}`,
155
+ values: ({ tokens }) => ({
156
+ ...tokens.colors,
157
+ inherit: 'inherit',
158
+ }),
159
+ },
160
+ color: {
161
+ className: ({ prop, value }) => `text-${value}`,
162
+ values: (tokens) => ({ ...tokens.colors }),
163
+ },
164
+ fill: { values: 'colors' },
165
+ lineClamp: {
166
+ className: ({ prop, value }) => `clamp-${value}`,
167
+ values: {
168
+ '1': {
169
+ '--line-clamp': '1',
170
+ },
171
+ },
172
+ },
173
+ },
174
+ shorthands: {
175
+ bg: 'background',
176
+ },
177
+ },
178
+
179
+ {
180
+ properties: {
181
+ strokeWidth: {
182
+ values: { '1': '1px', 2: '2px' },
183
+ },
184
+ },
185
+ },
186
+
187
+ {
188
+ properties: {
189
+ paddingLeft: { values: 'space', className: 'pl' },
190
+ paddingRight: { values: 'space', className: 'pr' },
191
+ paddingX: {
192
+ className: 'px',
193
+ values({ theme, map }) {
194
+ return map(theme.space, (value) => ({
195
+ paddingLeft: value,
196
+ paddingRight: value,
197
+ }))
198
+ },
199
+ },
200
+ },
201
+ shorthands: {
202
+ pl: 'paddingLeft',
203
+ px: 'paddingX',
204
+ },
205
+ },
206
+ ],
207
+ })
208
+ ```
@@ -0,0 +1,395 @@
1
+ import * as _pandacss_core from '@pandacss/core';
2
+ import { StylesheetContext, Conditions, Utility } from '@pandacss/core';
3
+ export { discardDuplicate } from '@pandacss/core';
4
+ import * as _pandacss_types_src_generator from '@pandacss/types/src/generator';
5
+ import * as ts_morph from 'ts-morph';
6
+ import * as _pandacss_types from '@pandacss/types';
7
+ import { RecipeConfig, Config } from '@pandacss/types';
8
+ import * as _pandacss_ast from '@pandacss/ast';
9
+ import { Collector } from '@pandacss/ast';
10
+ import * as _pandacss_config from '@pandacss/config';
11
+ import { LoadConfigResult } from '@pandacss/config';
12
+ import * as _pandacss_shared from '@pandacss/shared';
13
+ import { mapObject } from '@pandacss/shared';
14
+ import * as _pandacss_token_dictionary from '@pandacss/token-dictionary';
15
+ import { TokenDictionary } from '@pandacss/token-dictionary';
16
+ import { Root, Message } from 'postcss';
17
+
18
+ declare type IO = {
19
+ read(id: string): Promise<string>;
20
+ write(id: string, content: string): Promise<void>;
21
+ rm(id: string): Promise<void>;
22
+ };
23
+ declare type Output = {
24
+ dir?: string;
25
+ files: Array<{
26
+ file: string;
27
+ code: string | undefined;
28
+ }>;
29
+ };
30
+ declare function createContext(conf: LoadConfigResult, io?: IO): {
31
+ config: _pandacss_types.UserConfig;
32
+ configPath: string;
33
+ cwd: string;
34
+ conf: LoadConfigResult;
35
+ chunks: {
36
+ dir: string;
37
+ readFile(file: string): Promise<string>;
38
+ getFiles(): string[];
39
+ format(file: string): string;
40
+ write(file: string, css: string): Promise<void[]>;
41
+ rm(file: string): Promise<void>;
42
+ glob: string[];
43
+ };
44
+ files: string[];
45
+ helpers: {
46
+ map: typeof mapObject;
47
+ };
48
+ context: () => StylesheetContext;
49
+ exclude: string[];
50
+ conditions: Conditions;
51
+ importMap: {
52
+ css: string;
53
+ recipe: string;
54
+ pattern: string;
55
+ jsx: string;
56
+ };
57
+ reloadSourceFiles(): void;
58
+ getSourceFile(file: string): ts_morph.SourceFile | undefined;
59
+ addSourceFile(file: string): ts_morph.SourceFile;
60
+ removeSourceFile(file: string): boolean | undefined;
61
+ parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => Collector | undefined;
62
+ getPath: (str: string) => string;
63
+ paths: {
64
+ config: string;
65
+ css: string;
66
+ token: string;
67
+ types: string;
68
+ recipe: string;
69
+ pattern: string;
70
+ chunk: string;
71
+ outCss: string;
72
+ jsx: string;
73
+ };
74
+ write: (dir: string, options: Array<{
75
+ file: string;
76
+ code: string | undefined;
77
+ }>) => Promise<void[]>;
78
+ writeOutput: (output: Output) => Promise<void[]>;
79
+ cleanOutdir: () => Promise<void>;
80
+ tokens: TokenDictionary;
81
+ hasTokens: boolean;
82
+ utility: Utility;
83
+ collectStyles: (collector: Collector, file: string) => {
84
+ css: string;
85
+ file: string;
86
+ } | undefined;
87
+ patterns: Record<string, _pandacss_types.PatternConfig>;
88
+ hasPattern: boolean;
89
+ getPattern: (name: string) => _pandacss_types.PatternConfig;
90
+ execPattern: (name: string, data: Record<string, any>) => _pandacss_types.ConditionCssProperties<{
91
+ [x: string]: string;
92
+ }, {
93
+ __type?: "never" | undefined;
94
+ }, false>;
95
+ patternNodes: {
96
+ name: string;
97
+ props: string[];
98
+ baseName: string;
99
+ }[];
100
+ getPatternFnName: (jsx: string) => string;
101
+ recipes: Record<string, RecipeConfig<_pandacss_types.TRecipe>>;
102
+ getRecipe: (name: string) => RecipeConfig;
103
+ hasRecipes: boolean;
104
+ jsxFramework: "react" | "solid" | "preact" | undefined;
105
+ jsxFactory: string;
106
+ cssVarRoot: string;
107
+ properties: string[];
108
+ isProperty: (prop: string) => boolean;
109
+ extract: (fn: (file: string) => Promise<{
110
+ css: string;
111
+ file: string;
112
+ } | undefined>) => Promise<({
113
+ css: string;
114
+ file: string;
115
+ } | undefined)[]>;
116
+ hash?: boolean | undefined;
117
+ semanticTokens?: _pandacss_types.SemanticTokens<string | number> | undefined;
118
+ separator?: "-" | "_" | "=" | undefined;
119
+ breakpoints?: _pandacss_types.Dict<any> | undefined;
120
+ keyframes?: _pandacss_types.Keyframes | undefined;
121
+ minify?: boolean | undefined;
122
+ utilities?: _pandacss_types.UtilityConfig | undefined;
123
+ globalCss?: any;
124
+ logLevel?: "debug" | "info" | "warn" | "error" | "silent" | undefined;
125
+ presets?: string[] | undefined;
126
+ preflight?: boolean | undefined;
127
+ clean?: boolean | undefined;
128
+ cssVar?: {
129
+ prefix?: string | undefined;
130
+ root?: string | undefined;
131
+ } | undefined;
132
+ watch?: boolean | undefined;
133
+ poll?: boolean | undefined;
134
+ textStyles?: _pandacss_types.TextStyles<_pandacss_types.TCondition> | undefined;
135
+ layerStyles?: _pandacss_types.LayerStyles<_pandacss_types.TCondition> | undefined;
136
+ strictTokens?: boolean | undefined;
137
+ generator?: _pandacss_types_src_generator.ClassGeneratorOptions | undefined;
138
+ include: string[];
139
+ outdir: string;
140
+ };
141
+ declare type PandaContext = ReturnType<typeof createContext>;
142
+
143
+ declare function emitArtifacts(ctx: PandaContext): Promise<string>;
144
+ declare function emitAndExtract(ctx: PandaContext): Promise<void>;
145
+
146
+ declare class Builder {
147
+ fileModifiedMap: Map<string, number>;
148
+ fileMap: Map<string, string>;
149
+ context: PandaContext | undefined;
150
+ configChanged: boolean;
151
+ updateFile(file: string, css: string): void;
152
+ setup(): Promise<void>;
153
+ ensure(): {
154
+ config: _pandacss_types.UserConfig;
155
+ configPath: string;
156
+ cwd: string;
157
+ conf: _pandacss_config.LoadConfigResult;
158
+ chunks: {
159
+ dir: string;
160
+ readFile(file: string): Promise<string>;
161
+ getFiles(): string[];
162
+ format(file: string): string;
163
+ write(file: string, css: string): Promise<void[]>;
164
+ rm(file: string): Promise<void>;
165
+ glob: string[];
166
+ };
167
+ files: string[];
168
+ helpers: {
169
+ map: typeof _pandacss_shared.mapObject;
170
+ };
171
+ context: () => _pandacss_core.StylesheetContext;
172
+ exclude: string[];
173
+ conditions: _pandacss_core.Conditions;
174
+ importMap: {
175
+ css: string;
176
+ recipe: string;
177
+ pattern: string;
178
+ jsx: string;
179
+ };
180
+ reloadSourceFiles(): void;
181
+ getSourceFile(file: string): ts_morph.SourceFile | undefined;
182
+ addSourceFile(file: string): ts_morph.SourceFile;
183
+ removeSourceFile(file: string): boolean | undefined;
184
+ parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => _pandacss_ast.Collector | undefined;
185
+ getPath: (str: string) => string;
186
+ paths: {
187
+ config: string;
188
+ css: string;
189
+ token: string;
190
+ types: string;
191
+ recipe: string;
192
+ pattern: string;
193
+ chunk: string;
194
+ outCss: string;
195
+ jsx: string;
196
+ };
197
+ write: (dir: string, options: {
198
+ file: string;
199
+ code: string | undefined;
200
+ }[]) => Promise<void[]>;
201
+ writeOutput: (output: Output) => Promise<void[]>;
202
+ cleanOutdir: () => Promise<void>;
203
+ tokens: _pandacss_token_dictionary.TokenDictionary;
204
+ hasTokens: boolean;
205
+ utility: _pandacss_core.Utility;
206
+ collectStyles: (collector: _pandacss_ast.Collector, file: string) => {
207
+ css: string;
208
+ file: string;
209
+ } | undefined;
210
+ patterns: Record<string, _pandacss_types.PatternConfig>;
211
+ hasPattern: boolean;
212
+ getPattern: (name: string) => _pandacss_types.PatternConfig;
213
+ execPattern: (name: string, data: Record<string, any>) => _pandacss_types.ConditionCssProperties<{
214
+ [x: string]: string;
215
+ }, {
216
+ __type?: "never" | undefined;
217
+ }, false>;
218
+ patternNodes: {
219
+ name: string;
220
+ props: string[];
221
+ baseName: string;
222
+ }[];
223
+ getPatternFnName: (jsx: string) => string;
224
+ recipes: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.TRecipe>>;
225
+ getRecipe: (name: string) => _pandacss_types.RecipeConfig<_pandacss_types.TRecipe>;
226
+ hasRecipes: boolean;
227
+ jsxFramework: "react" | "solid" | "preact" | undefined;
228
+ jsxFactory: string;
229
+ cssVarRoot: string;
230
+ properties: string[];
231
+ isProperty: (prop: string) => boolean;
232
+ extract: (fn: (file: string) => Promise<{
233
+ css: string;
234
+ file: string;
235
+ } | undefined>) => Promise<({
236
+ css: string;
237
+ file: string;
238
+ } | undefined)[]>;
239
+ hash?: boolean | undefined;
240
+ semanticTokens?: _pandacss_types.SemanticTokens<string | number> | undefined;
241
+ separator?: "-" | "_" | "=" | undefined;
242
+ breakpoints?: _pandacss_types.Dict<any> | undefined;
243
+ keyframes?: _pandacss_types.Keyframes | undefined;
244
+ minify?: boolean | undefined;
245
+ utilities?: _pandacss_types.UtilityConfig | undefined;
246
+ globalCss?: any;
247
+ logLevel?: "debug" | "info" | "warn" | "error" | "silent" | undefined;
248
+ presets?: string[] | undefined;
249
+ preflight?: boolean | undefined;
250
+ clean?: boolean | undefined;
251
+ cssVar?: {
252
+ prefix?: string | undefined;
253
+ root?: string | undefined;
254
+ } | undefined;
255
+ watch?: boolean | undefined;
256
+ poll?: boolean | undefined;
257
+ textStyles?: _pandacss_types.TextStyles<_pandacss_types.TCondition> | undefined;
258
+ layerStyles?: _pandacss_types.LayerStyles<_pandacss_types.TCondition> | undefined;
259
+ strictTokens?: boolean | undefined;
260
+ generator?: _pandacss_types_src_generator.ClassGeneratorOptions | undefined;
261
+ include: string[];
262
+ outdir: string;
263
+ };
264
+ extract(): Promise<void>;
265
+ toString(): string;
266
+ write(root: Root): void;
267
+ registerDependency(fn: (dep: Message) => void): void;
268
+ }
269
+
270
+ declare function loadConfigAndCreateContext(options?: {
271
+ cwd?: string;
272
+ config?: Config;
273
+ configPath?: string;
274
+ }): Promise<{
275
+ config: _pandacss_types.UserConfig;
276
+ configPath: string;
277
+ cwd: string;
278
+ conf: _pandacss_config.LoadConfigResult;
279
+ chunks: {
280
+ dir: string;
281
+ readFile(file: string): Promise<string>;
282
+ getFiles(): string[];
283
+ format(file: string): string;
284
+ write(file: string, css: string): Promise<void[]>;
285
+ rm(file: string): Promise<void>;
286
+ glob: string[];
287
+ };
288
+ files: string[];
289
+ helpers: {
290
+ map: typeof _pandacss_shared.mapObject;
291
+ };
292
+ context: () => _pandacss_core.StylesheetContext;
293
+ exclude: string[];
294
+ conditions: _pandacss_core.Conditions;
295
+ importMap: {
296
+ css: string;
297
+ recipe: string;
298
+ pattern: string;
299
+ jsx: string;
300
+ };
301
+ reloadSourceFiles(): void;
302
+ getSourceFile(file: string): ts_morph.SourceFile | undefined;
303
+ addSourceFile(file: string): ts_morph.SourceFile;
304
+ removeSourceFile(file: string): boolean | undefined;
305
+ parseSourceFile: (sourceFile: ts_morph.SourceFile | undefined) => _pandacss_ast.Collector | undefined;
306
+ getPath: (str: string) => string;
307
+ paths: {
308
+ config: string;
309
+ css: string;
310
+ token: string;
311
+ types: string;
312
+ recipe: string;
313
+ pattern: string;
314
+ chunk: string;
315
+ outCss: string;
316
+ jsx: string;
317
+ };
318
+ write: (dir: string, options: {
319
+ file: string;
320
+ code: string | undefined;
321
+ }[]) => Promise<void[]>;
322
+ writeOutput: (output: Output) => Promise<void[]>;
323
+ cleanOutdir: () => Promise<void>;
324
+ tokens: _pandacss_token_dictionary.TokenDictionary;
325
+ hasTokens: boolean;
326
+ utility: _pandacss_core.Utility;
327
+ collectStyles: (collector: _pandacss_ast.Collector, file: string) => {
328
+ css: string;
329
+ file: string;
330
+ } | undefined;
331
+ patterns: Record<string, _pandacss_types.PatternConfig>;
332
+ hasPattern: boolean;
333
+ getPattern: (name: string) => _pandacss_types.PatternConfig;
334
+ execPattern: (name: string, data: Record<string, any>) => _pandacss_types.ConditionCssProperties<{
335
+ [x: string]: string;
336
+ }, {
337
+ __type?: "never" | undefined;
338
+ }, false>;
339
+ patternNodes: {
340
+ name: string;
341
+ props: string[];
342
+ baseName: string;
343
+ }[];
344
+ getPatternFnName: (jsx: string) => string;
345
+ recipes: Record<string, _pandacss_types.RecipeConfig<_pandacss_types.TRecipe>>;
346
+ getRecipe: (name: string) => _pandacss_types.RecipeConfig<_pandacss_types.TRecipe>;
347
+ hasRecipes: boolean;
348
+ jsxFramework: "react" | "solid" | "preact" | undefined;
349
+ jsxFactory: string;
350
+ cssVarRoot: string;
351
+ properties: string[];
352
+ isProperty: (prop: string) => boolean;
353
+ extract: (fn: (file: string) => Promise<{
354
+ css: string;
355
+ file: string;
356
+ } | undefined>) => Promise<({
357
+ css: string;
358
+ file: string;
359
+ } | undefined)[]>;
360
+ hash?: boolean | undefined;
361
+ semanticTokens?: _pandacss_types.SemanticTokens<string | number> | undefined;
362
+ separator?: "-" | "_" | "=" | undefined;
363
+ breakpoints?: _pandacss_types.Dict<any> | undefined;
364
+ keyframes?: _pandacss_types.Keyframes | undefined;
365
+ minify?: boolean | undefined;
366
+ utilities?: _pandacss_types.UtilityConfig | undefined;
367
+ globalCss?: any;
368
+ logLevel?: "debug" | "info" | "warn" | "error" | "silent" | undefined;
369
+ presets?: string[] | undefined;
370
+ preflight?: boolean | undefined;
371
+ clean?: boolean | undefined;
372
+ cssVar?: {
373
+ prefix?: string | undefined;
374
+ root?: string | undefined;
375
+ } | undefined;
376
+ watch?: boolean | undefined;
377
+ poll?: boolean | undefined;
378
+ textStyles?: _pandacss_types.TextStyles<_pandacss_types.TCondition> | undefined;
379
+ layerStyles?: _pandacss_types.LayerStyles<_pandacss_types.TCondition> | undefined;
380
+ strictTokens?: boolean | undefined;
381
+ generator?: _pandacss_types_src_generator.ClassGeneratorOptions | undefined;
382
+ include: string[];
383
+ outdir: string;
384
+ }>;
385
+
386
+ declare function execCommand(cmd: string, cwd: string): Promise<void>;
387
+
388
+ declare function generate(config: Config, configPath?: string): Promise<void>;
389
+
390
+ declare function setupConfig(cwd: string, { force }: {
391
+ force?: boolean;
392
+ }): Promise<void>;
393
+ declare function setupPostcss(cwd: string): Promise<void>;
394
+
395
+ export { Builder, createContext, emitAndExtract, emitArtifacts, execCommand, generate, loadConfigAndCreateContext, setupConfig, setupPostcss };