@pandacss/shared 0.0.0-dev-20230122145009 → 0.0.0-dev-20230125073613
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 +2 -2
- package/dist/index.js +24 -6
- package/dist/index.mjs +23 -6
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +39 -6
- package/dist/shared.mjs +38 -6
- package/dist/{split-props-29274d16.d.ts → split-props-6eb4eecb.d.ts} +4 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-
|
|
2
|
-
export { C as CreateCssContext, M as MappedObject,
|
|
1
|
+
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-6eb4eecb.js';
|
|
2
|
+
export { C as CreateCssContext, M as MappedObject, l as WalkObjectOptions, W as WalkObjectStopFn, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, o as mapObject, m as mergeProps, s as splitProps, t as toHash, n as walkObject, w as withoutImportant, j as withoutSpace } from './split-props-6eb4eecb.js';
|
|
3
3
|
|
|
4
4
|
type Operand = string | number | {
|
|
5
5
|
ref: string;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
getDotPath: () => getDotPath,
|
|
34
34
|
getNegativePath: () => getNegativePath,
|
|
35
35
|
getUnit: () => getUnit,
|
|
36
|
+
hypenateProperty: () => hypenateProperty,
|
|
36
37
|
isBaseCondition: () => isBaseCondition,
|
|
37
38
|
isFunction: () => isFunction,
|
|
38
39
|
isImportant: () => isImportant,
|
|
@@ -206,6 +207,18 @@ var fallbackCondition = {
|
|
|
206
207
|
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
207
208
|
function createCss(context) {
|
|
208
209
|
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
210
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
211
|
+
const hashFn = (conditions, className) => {
|
|
212
|
+
let result;
|
|
213
|
+
if (hash) {
|
|
214
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
215
|
+
result = formatClassName(toHash(baseArray.join(":")));
|
|
216
|
+
} else {
|
|
217
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
218
|
+
result = baseArray.join(":");
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
};
|
|
209
222
|
return (styleObject = {}) => {
|
|
210
223
|
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
211
224
|
const classNames = /* @__PURE__ */ new Set();
|
|
@@ -216,12 +229,9 @@ function createCss(context) {
|
|
|
216
229
|
const [prop, ...allConditions] = conds.shift(paths);
|
|
217
230
|
const conditions = filterBaseConditions(allConditions);
|
|
218
231
|
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
219
|
-
let
|
|
220
|
-
if (important)
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
const baseArray = [...conds.finalize(conditions), transformedClassName];
|
|
224
|
-
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":");
|
|
232
|
+
let className = hashFn(conditions, transformed.className);
|
|
233
|
+
if (important)
|
|
234
|
+
className = `${className}!`;
|
|
225
235
|
classNames.add(className);
|
|
226
236
|
});
|
|
227
237
|
return Array.from(classNames).join(" ");
|
|
@@ -354,6 +364,13 @@ var memo = (fn) => {
|
|
|
354
364
|
return get;
|
|
355
365
|
};
|
|
356
366
|
|
|
367
|
+
// src/hypenate.ts
|
|
368
|
+
var hypenateProperty = memo((property) => {
|
|
369
|
+
if (property.startsWith("--"))
|
|
370
|
+
return property;
|
|
371
|
+
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
372
|
+
});
|
|
373
|
+
|
|
357
374
|
// src/split.ts
|
|
358
375
|
function splitBy(value, separator = ",") {
|
|
359
376
|
const result = [];
|
|
@@ -454,6 +471,7 @@ function unionType(values) {
|
|
|
454
471
|
getDotPath,
|
|
455
472
|
getNegativePath,
|
|
456
473
|
getUnit,
|
|
474
|
+
hypenateProperty,
|
|
457
475
|
isBaseCondition,
|
|
458
476
|
isFunction,
|
|
459
477
|
isImportant,
|
package/dist/index.mjs
CHANGED
|
@@ -145,6 +145,18 @@ var fallbackCondition = {
|
|
|
145
145
|
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
146
146
|
function createCss(context) {
|
|
147
147
|
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
148
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
149
|
+
const hashFn = (conditions, className) => {
|
|
150
|
+
let result;
|
|
151
|
+
if (hash) {
|
|
152
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
153
|
+
result = formatClassName(toHash(baseArray.join(":")));
|
|
154
|
+
} else {
|
|
155
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
156
|
+
result = baseArray.join(":");
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
};
|
|
148
160
|
return (styleObject = {}) => {
|
|
149
161
|
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
150
162
|
const classNames = /* @__PURE__ */ new Set();
|
|
@@ -155,12 +167,9 @@ function createCss(context) {
|
|
|
155
167
|
const [prop, ...allConditions] = conds.shift(paths);
|
|
156
168
|
const conditions = filterBaseConditions(allConditions);
|
|
157
169
|
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
158
|
-
let
|
|
159
|
-
if (important)
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
const baseArray = [...conds.finalize(conditions), transformedClassName];
|
|
163
|
-
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":");
|
|
170
|
+
let className = hashFn(conditions, transformed.className);
|
|
171
|
+
if (important)
|
|
172
|
+
className = `${className}!`;
|
|
164
173
|
classNames.add(className);
|
|
165
174
|
});
|
|
166
175
|
return Array.from(classNames).join(" ");
|
|
@@ -293,6 +302,13 @@ var memo = (fn) => {
|
|
|
293
302
|
return get;
|
|
294
303
|
};
|
|
295
304
|
|
|
305
|
+
// src/hypenate.ts
|
|
306
|
+
var hypenateProperty = memo((property) => {
|
|
307
|
+
if (property.startsWith("--"))
|
|
308
|
+
return property;
|
|
309
|
+
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
310
|
+
});
|
|
311
|
+
|
|
296
312
|
// src/split.ts
|
|
297
313
|
function splitBy(value, separator = ",") {
|
|
298
314
|
const result = [];
|
|
@@ -392,6 +408,7 @@ export {
|
|
|
392
408
|
getDotPath,
|
|
393
409
|
getNegativePath,
|
|
394
410
|
getUnit,
|
|
411
|
+
hypenateProperty,
|
|
395
412
|
isBaseCondition,
|
|
396
413
|
isFunction,
|
|
397
414
|
isImportant,
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, f as isBaseCondition, b as isObject,
|
|
1
|
+
export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, k as hypenateProperty, f as isBaseCondition, b as isObject, o as mapObject, m as mergeProps, s as splitProps, t as toHash, n as walkObject, j as withoutSpace } from './split-props-6eb4eecb.js';
|
|
2
2
|
|
|
3
3
|
declare function normalizeHTMLProps(props: Record<string, any>): {
|
|
4
4
|
[k: string]: any;
|
package/dist/shared.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(shared_exports, {
|
|
|
24
24
|
createCss: () => createCss,
|
|
25
25
|
createMergeCss: () => createMergeCss,
|
|
26
26
|
filterBaseConditions: () => filterBaseConditions,
|
|
27
|
+
hypenateProperty: () => hypenateProperty,
|
|
27
28
|
isBaseCondition: () => isBaseCondition,
|
|
28
29
|
isObject: () => isObject,
|
|
29
30
|
mapObject: () => mapObject,
|
|
@@ -157,6 +158,18 @@ var fallbackCondition = {
|
|
|
157
158
|
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
158
159
|
function createCss(context) {
|
|
159
160
|
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
161
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
162
|
+
const hashFn = (conditions, className) => {
|
|
163
|
+
let result;
|
|
164
|
+
if (hash) {
|
|
165
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
166
|
+
result = formatClassName(toHash(baseArray.join(":")));
|
|
167
|
+
} else {
|
|
168
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
169
|
+
result = baseArray.join(":");
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
160
173
|
return (styleObject = {}) => {
|
|
161
174
|
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
162
175
|
const classNames = /* @__PURE__ */ new Set();
|
|
@@ -167,12 +180,9 @@ function createCss(context) {
|
|
|
167
180
|
const [prop, ...allConditions] = conds.shift(paths);
|
|
168
181
|
const conditions = filterBaseConditions(allConditions);
|
|
169
182
|
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
170
|
-
let
|
|
171
|
-
if (important)
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
const baseArray = [...conds.finalize(conditions), transformedClassName];
|
|
175
|
-
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":");
|
|
183
|
+
let className = hashFn(conditions, transformed.className);
|
|
184
|
+
if (important)
|
|
185
|
+
className = `${className}!`;
|
|
176
186
|
classNames.add(className);
|
|
177
187
|
});
|
|
178
188
|
return Array.from(classNames).join(" ");
|
|
@@ -225,12 +235,35 @@ function splitProps(props, ...keys) {
|
|
|
225
235
|
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
|
|
226
236
|
return keys.map(fn).concat(split(dKeys));
|
|
227
237
|
}
|
|
238
|
+
|
|
239
|
+
// src/memo.ts
|
|
240
|
+
var memo = (fn) => {
|
|
241
|
+
const cache = /* @__PURE__ */ new Map();
|
|
242
|
+
const get = (...args) => {
|
|
243
|
+
const key = JSON.stringify(args);
|
|
244
|
+
if (cache.has(key)) {
|
|
245
|
+
return cache.get(key);
|
|
246
|
+
}
|
|
247
|
+
const result = fn(...args);
|
|
248
|
+
cache.set(key, result);
|
|
249
|
+
return result;
|
|
250
|
+
};
|
|
251
|
+
return get;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// src/hypenate.ts
|
|
255
|
+
var hypenateProperty = memo((property) => {
|
|
256
|
+
if (property.startsWith("--"))
|
|
257
|
+
return property;
|
|
258
|
+
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
259
|
+
});
|
|
228
260
|
// Annotate the CommonJS export names for ESM import in node:
|
|
229
261
|
0 && (module.exports = {
|
|
230
262
|
compact,
|
|
231
263
|
createCss,
|
|
232
264
|
createMergeCss,
|
|
233
265
|
filterBaseConditions,
|
|
266
|
+
hypenateProperty,
|
|
234
267
|
isBaseCondition,
|
|
235
268
|
isObject,
|
|
236
269
|
mapObject,
|
package/dist/shared.mjs
CHANGED
|
@@ -119,6 +119,18 @@ var fallbackCondition = {
|
|
|
119
119
|
var sanitize = (value) => typeof value === "string" ? value.replaceAll(/[\n\s]+/g, " ") : value;
|
|
120
120
|
function createCss(context) {
|
|
121
121
|
const { utility, hash, conditions: conds = fallbackCondition } = context;
|
|
122
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-");
|
|
123
|
+
const hashFn = (conditions, className) => {
|
|
124
|
+
let result;
|
|
125
|
+
if (hash) {
|
|
126
|
+
const baseArray = [...conds.finalize(conditions), className];
|
|
127
|
+
result = formatClassName(toHash(baseArray.join(":")));
|
|
128
|
+
} else {
|
|
129
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)];
|
|
130
|
+
result = baseArray.join(":");
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
122
134
|
return (styleObject = {}) => {
|
|
123
135
|
const normalizedObject = normalizeStyleObject(styleObject, context);
|
|
124
136
|
const classNames = /* @__PURE__ */ new Set();
|
|
@@ -129,12 +141,9 @@ function createCss(context) {
|
|
|
129
141
|
const [prop, ...allConditions] = conds.shift(paths);
|
|
130
142
|
const conditions = filterBaseConditions(allConditions);
|
|
131
143
|
const transformed = utility.transform(prop, withoutImportant(sanitize(value)));
|
|
132
|
-
let
|
|
133
|
-
if (important)
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
const baseArray = [...conds.finalize(conditions), transformedClassName];
|
|
137
|
-
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":");
|
|
144
|
+
let className = hashFn(conditions, transformed.className);
|
|
145
|
+
if (important)
|
|
146
|
+
className = `${className}!`;
|
|
138
147
|
classNames.add(className);
|
|
139
148
|
});
|
|
140
149
|
return Array.from(classNames).join(" ");
|
|
@@ -187,11 +196,34 @@ function splitProps(props, ...keys) {
|
|
|
187
196
|
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
|
|
188
197
|
return keys.map(fn).concat(split(dKeys));
|
|
189
198
|
}
|
|
199
|
+
|
|
200
|
+
// src/memo.ts
|
|
201
|
+
var memo = (fn) => {
|
|
202
|
+
const cache = /* @__PURE__ */ new Map();
|
|
203
|
+
const get = (...args) => {
|
|
204
|
+
const key = JSON.stringify(args);
|
|
205
|
+
if (cache.has(key)) {
|
|
206
|
+
return cache.get(key);
|
|
207
|
+
}
|
|
208
|
+
const result = fn(...args);
|
|
209
|
+
cache.set(key, result);
|
|
210
|
+
return result;
|
|
211
|
+
};
|
|
212
|
+
return get;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// src/hypenate.ts
|
|
216
|
+
var hypenateProperty = memo((property) => {
|
|
217
|
+
if (property.startsWith("--"))
|
|
218
|
+
return property;
|
|
219
|
+
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
220
|
+
});
|
|
190
221
|
export {
|
|
191
222
|
compact,
|
|
192
223
|
createCss,
|
|
193
224
|
createMergeCss,
|
|
194
225
|
filterBaseConditions,
|
|
226
|
+
hypenateProperty,
|
|
195
227
|
isBaseCondition,
|
|
196
228
|
isObject,
|
|
197
229
|
mapObject,
|
|
@@ -9,6 +9,7 @@ type CreateCssContext = {
|
|
|
9
9
|
* Partial properties from the Utility class
|
|
10
10
|
*/
|
|
11
11
|
utility: {
|
|
12
|
+
prefix: string;
|
|
12
13
|
hasShorthand: boolean;
|
|
13
14
|
resolveShorthand: (prop: string) => string;
|
|
14
15
|
transform: (prop: string, value: any) => {
|
|
@@ -56,6 +57,8 @@ declare function mapObject(obj: any, fn: (value: any) => any): any;
|
|
|
56
57
|
|
|
57
58
|
declare function toHash(str: string): string;
|
|
58
59
|
|
|
60
|
+
declare const hypenateProperty: (property: string) => string;
|
|
61
|
+
|
|
59
62
|
declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
|
|
60
63
|
|
|
61
64
|
type Dict = Record<string, unknown>;
|
|
@@ -63,4 +66,4 @@ type PredicateFn = (key: string) => boolean;
|
|
|
63
66
|
type Key = PredicateFn | string[];
|
|
64
67
|
declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
|
|
65
68
|
|
|
66
|
-
export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, createCss as c, createMergeCss as d, compact as e, isBaseCondition as f, filterBaseConditions as g, isImportant as h, isString as i, withoutSpace as j,
|
|
69
|
+
export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, createCss as c, createMergeCss as d, compact as e, isBaseCondition as f, filterBaseConditions as g, isImportant as h, isString as i, withoutSpace as j, hypenateProperty as k, WalkObjectOptions as l, mergeProps as m, walkObject as n, mapObject as o, splitProps as s, toHash as t, withoutImportant as w };
|