@pandacss/studio 0.0.0-dev-20230613163214
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 +21 -0
- package/astro.config.ts +14 -0
- package/dist/studio.d.ts +13 -0
- package/dist/studio.js +2089 -0
- package/dist/studio.mjs +2087 -0
- package/index.ts +1 -0
- package/package.json +59 -0
- package/panda.config.ts +110 -0
- package/public/favicon.svg +13 -0
- package/src/components/analyzer/category-utilities.tsx +146 -0
- package/src/components/analyzer/data-combobox.tsx +125 -0
- package/src/components/analyzer/data-table.tsx +43 -0
- package/src/components/analyzer/external-icon.tsx +8 -0
- package/src/components/analyzer/file-details.tsx +101 -0
- package/src/components/analyzer/get-report-infos-from.ts +80 -0
- package/src/components/analyzer/quick-tooltip.tsx +15 -0
- package/src/components/analyzer/report-item-columns.tsx +52 -0
- package/src/components/analyzer/report-item-link.tsx +98 -0
- package/src/components/analyzer/section.tsx +24 -0
- package/src/components/analyzer/sort-icon.tsx +7 -0
- package/src/components/analyzer/text-with-count.tsx +28 -0
- package/src/components/analyzer/token-search-combobox.tsx +39 -0
- package/src/components/analyzer/truncated-text.tsx +26 -0
- package/src/components/analyzer/utility-details.tsx +312 -0
- package/src/components/color-constrast.tsx +131 -0
- package/src/components/color-item.tsx +37 -0
- package/src/components/color-wrapper.tsx +25 -0
- package/src/components/colors.tsx +96 -0
- package/src/components/empty-state.tsx +19 -0
- package/src/components/font-family.tsx +55 -0
- package/src/components/font-tokens.tsx +69 -0
- package/src/components/head.astro +35 -0
- package/src/components/icons.tsx +207 -0
- package/src/components/input.tsx +27 -0
- package/src/components/layer-styles.tsx +38 -0
- package/src/components/logo.tsx +34 -0
- package/src/components/nav-item.tsx +39 -0
- package/src/components/overview.tsx +65 -0
- package/src/components/radii.tsx +34 -0
- package/src/components/semantic-color.tsx +27 -0
- package/src/components/side-nav-item.astro +25 -0
- package/src/components/side-nav.astro +30 -0
- package/src/components/sizes.tsx +53 -0
- package/src/components/text-styles.tsx +33 -0
- package/src/components/theme-toggle.astro +56 -0
- package/src/components/token-analyzer.tsx +390 -0
- package/src/components/token-content.tsx +5 -0
- package/src/components/token-group.tsx +6 -0
- package/src/components/typography-playground.tsx +83 -0
- package/src/env.d.ts +1 -0
- package/src/icons/moon.tsx +15 -0
- package/src/icons/sun.tsx +19 -0
- package/src/layouts/Layout.astro +19 -0
- package/src/layouts/Sidebar.astro +35 -0
- package/src/lib/analysis-data.ts +17 -0
- package/src/lib/color-contrast-checker.ts +218 -0
- package/src/lib/color.ts +40 -0
- package/src/lib/constants.ts +140 -0
- package/src/lib/create-context.ts +27 -0
- package/src/lib/get-report-item.tsx +41 -0
- package/src/lib/group-in.ts +35 -0
- package/src/lib/panda.context.ts +23 -0
- package/src/lib/pick.ts +24 -0
- package/src/lib/sizes-sort.ts +10 -0
- package/src/lib/truncate.tsx +7 -0
- package/src/lib/use-color-docs.ts +101 -0
- package/src/pages/colors.astro +11 -0
- package/src/pages/font-sizes.astro +15 -0
- package/src/pages/font-weights.astro +15 -0
- package/src/pages/fonts.astro +11 -0
- package/src/pages/index.astro +8 -0
- package/src/pages/layer-styles.astro +11 -0
- package/src/pages/letter-spacings.astro +20 -0
- package/src/pages/line-heights.astro +21 -0
- package/src/pages/playground/contrast-checker.astro +11 -0
- package/src/pages/playground/typography.astro +11 -0
- package/src/pages/radii.astro +11 -0
- package/src/pages/sizes.astro +14 -0
- package/src/pages/spacing.astro +14 -0
- package/src/pages/text-styles.astro +11 -0
- package/src/pages/token-analyzer/file.astro +11 -0
- package/src/pages/token-analyzer/index.astro +11 -0
- package/src/pages/token-analyzer/utility.astro +11 -0
- package/styled-system/chunks/..__core____tests____composition.test.css +2 -0
- package/styled-system/chunks/src__components__analyzer__category-utilities.css +97 -0
- package/styled-system/chunks/src__components__analyzer__data-combobox.css +77 -0
- package/styled-system/chunks/src__components__analyzer__data-table.css +37 -0
- package/styled-system/chunks/src__components__analyzer__file-details.css +103 -0
- package/styled-system/chunks/src__components__analyzer__quick-tooltip.css +2 -0
- package/styled-system/chunks/src__components__analyzer__report-item-columns.css +29 -0
- package/styled-system/chunks/src__components__analyzer__report-item-link.css +109 -0
- package/styled-system/chunks/src__components__analyzer__section.css +29 -0
- package/styled-system/chunks/src__components__analyzer__text-with-count.css +33 -0
- package/styled-system/chunks/src__components__analyzer__truncated-text.css +13 -0
- package/styled-system/chunks/src__components__analyzer__utility-details.css +125 -0
- package/styled-system/chunks/src__components__color-constrast.css +114 -0
- package/styled-system/chunks/src__components__color-item.css +21 -0
- package/styled-system/chunks/src__components__color-wrapper.css +73 -0
- package/styled-system/chunks/src__components__colors.css +97 -0
- package/styled-system/chunks/src__components__empty-state.css +45 -0
- package/styled-system/chunks/src__components__font-family.css +85 -0
- package/styled-system/chunks/src__components__font-tokens.css +61 -0
- package/styled-system/chunks/src__components__input.css +68 -0
- package/styled-system/chunks/src__components__layer-styles.css +66 -0
- package/styled-system/chunks/src__components__nav-item.css +73 -0
- package/styled-system/chunks/src__components__overview.css +125 -0
- package/styled-system/chunks/src__components__radii.css +49 -0
- package/styled-system/chunks/src__components__semantic-color.css +45 -0
- package/styled-system/chunks/src__components__side-nav-item.css +33 -0
- package/styled-system/chunks/src__components__side-nav.css +49 -0
- package/styled-system/chunks/src__components__sizes.css +41 -0
- package/styled-system/chunks/src__components__text-styles.css +31 -0
- package/styled-system/chunks/src__components__theme-toggle.css +63 -0
- package/styled-system/chunks/src__components__token-analyzer.css +227 -0
- package/styled-system/chunks/src__components__token-content.css +13 -0
- package/styled-system/chunks/src__components__token-group.css +21 -0
- package/styled-system/chunks/src__components__token-search-combobox.css +2 -0
- package/styled-system/chunks/src__components__typography-playground.css +61 -0
- package/styled-system/chunks/src__layouts__Layout.css +2 -0
- package/styled-system/chunks/src__layouts__Sidebar.css +113 -0
- package/styled-system/chunks/src__pages__colors.css +2 -0
- package/styled-system/chunks/src__pages__font-sizes.css +2 -0
- package/styled-system/chunks/src__pages__font-weights.css +2 -0
- package/styled-system/chunks/src__pages__fonts.css +2 -0
- package/styled-system/chunks/src__pages__index.css +2 -0
- package/styled-system/chunks/src__pages__layer-styles.css +2 -0
- package/styled-system/chunks/src__pages__letter-spacings.css +2 -0
- package/styled-system/chunks/src__pages__line-heights.css +2 -0
- package/styled-system/chunks/src__pages__playground__contrast-checker.css +2 -0
- package/styled-system/chunks/src__pages__playground__typography.css +2 -0
- package/styled-system/chunks/src__pages__radii.css +2 -0
- package/styled-system/chunks/src__pages__sizes.css +2 -0
- package/styled-system/chunks/src__pages__spacing.css +2 -0
- package/styled-system/chunks/src__pages__text-styles.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__file.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__index.css +2 -0
- package/styled-system/chunks/src__pages__token-analyzer__utility.css +2 -0
- package/styled-system/css/conditions.mjs +147 -0
- package/styled-system/css/css.d.ts +2 -0
- package/styled-system/css/css.mjs +391 -0
- package/styled-system/css/cva.d.ts +5 -0
- package/styled-system/css/cva.mjs +63 -0
- package/styled-system/css/cx.d.ts +4 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +3 -0
- package/styled-system/css/index.mjs +3 -0
- package/styled-system/global.css +61 -0
- package/styled-system/helpers.mjs +251 -0
- package/styled-system/jsx/absolute-center.d.ts +8 -0
- package/styled-system/jsx/absolute-center.mjs +9 -0
- package/styled-system/jsx/aspect-ratio.d.ts +8 -0
- package/styled-system/jsx/aspect-ratio.mjs +9 -0
- package/styled-system/jsx/box.d.ts +8 -0
- package/styled-system/jsx/box.mjs +8 -0
- package/styled-system/jsx/center.d.ts +8 -0
- package/styled-system/jsx/center.mjs +9 -0
- package/styled-system/jsx/circle.d.ts +8 -0
- package/styled-system/jsx/circle.mjs +9 -0
- package/styled-system/jsx/container.d.ts +8 -0
- package/styled-system/jsx/container.mjs +8 -0
- package/styled-system/jsx/divider.d.ts +8 -0
- package/styled-system/jsx/divider.mjs +9 -0
- package/styled-system/jsx/factory.d.ts +2 -0
- package/styled-system/jsx/factory.mjs +59 -0
- package/styled-system/jsx/flex.d.ts +8 -0
- package/styled-system/jsx/flex.mjs +9 -0
- package/styled-system/jsx/float.d.ts +8 -0
- package/styled-system/jsx/float.mjs +9 -0
- package/styled-system/jsx/grid-item.d.ts +8 -0
- package/styled-system/jsx/grid-item.mjs +9 -0
- package/styled-system/jsx/grid.d.ts +8 -0
- package/styled-system/jsx/grid.mjs +9 -0
- package/styled-system/jsx/hstack.d.ts +8 -0
- package/styled-system/jsx/hstack.mjs +9 -0
- package/styled-system/jsx/index.d.ts +20 -0
- package/styled-system/jsx/index.mjs +19 -0
- package/styled-system/jsx/is-valid-prop.mjs +1010 -0
- package/styled-system/jsx/spacer.d.ts +8 -0
- package/styled-system/jsx/spacer.mjs +9 -0
- package/styled-system/jsx/square.d.ts +8 -0
- package/styled-system/jsx/square.mjs +9 -0
- package/styled-system/jsx/stack.d.ts +8 -0
- package/styled-system/jsx/stack.mjs +9 -0
- package/styled-system/jsx/styled-link.d.ts +8 -0
- package/styled-system/jsx/styled-link.mjs +8 -0
- package/styled-system/jsx/vstack.d.ts +8 -0
- package/styled-system/jsx/vstack.mjs +9 -0
- package/styled-system/jsx/wrap.d.ts +8 -0
- package/styled-system/jsx/wrap.mjs +9 -0
- package/styled-system/patterns/absolute-center.d.ts +14 -0
- package/styled-system/patterns/absolute-center.mjs +23 -0
- package/styled-system/patterns/aspect-ratio.d.ts +14 -0
- package/styled-system/patterns/aspect-ratio.mjs +25 -0
- package/styled-system/patterns/box.d.ts +14 -0
- package/styled-system/patterns/box.mjs +12 -0
- package/styled-system/patterns/center.d.ts +14 -0
- package/styled-system/patterns/center.mjs +18 -0
- package/styled-system/patterns/circle.d.ts +14 -0
- package/styled-system/patterns/circle.mjs +22 -0
- package/styled-system/patterns/container.d.ts +14 -0
- package/styled-system/patterns/container.mjs +18 -0
- package/styled-system/patterns/divider.d.ts +16 -0
- package/styled-system/patterns/divider.mjs +21 -0
- package/styled-system/patterns/flex.d.ts +20 -0
- package/styled-system/patterns/flex.mjs +23 -0
- package/styled-system/patterns/float.d.ts +17 -0
- package/styled-system/patterns/float.mjs +45 -0
- package/styled-system/patterns/grid-item.d.ts +19 -0
- package/styled-system/patterns/grid-item.mjs +20 -0
- package/styled-system/patterns/grid.d.ts +18 -0
- package/styled-system/patterns/grid.mjs +25 -0
- package/styled-system/patterns/hstack.d.ts +15 -0
- package/styled-system/patterns/hstack.mjs +20 -0
- package/styled-system/patterns/index.d.ts +18 -0
- package/styled-system/patterns/index.mjs +18 -0
- package/styled-system/patterns/spacer.d.ts +14 -0
- package/styled-system/patterns/spacer.mjs +18 -0
- package/styled-system/patterns/square.d.ts +14 -0
- package/styled-system/patterns/square.mjs +21 -0
- package/styled-system/patterns/stack.d.ts +17 -0
- package/styled-system/patterns/stack.mjs +20 -0
- package/styled-system/patterns/styled-link.d.ts +14 -0
- package/styled-system/patterns/styled-link.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +15 -0
- package/styled-system/patterns/vstack.mjs +20 -0
- package/styled-system/patterns/wrap.d.ts +18 -0
- package/styled-system/patterns/wrap.mjs +22 -0
- package/styled-system/reset.css +190 -0
- package/styled-system/static.css +5 -0
- package/styled-system/styles.css +938 -0
- package/styled-system/tokens/index.css +374 -0
- package/styled-system/tokens/index.d.ts +8 -0
- package/styled-system/tokens/index.mjs +1590 -0
- package/styled-system/tokens/keyframes.css +30 -0
- package/styled-system/tokens/tokens.d.ts +56 -0
- package/styled-system/types/composition.d.ts +110 -0
- package/styled-system/types/conditions.d.ts +135 -0
- package/styled-system/types/csstype.d.ts +20748 -0
- package/styled-system/types/global.d.ts +15 -0
- package/styled-system/types/helpers.d.ts +1 -0
- package/styled-system/types/index.d.ts +3 -0
- package/styled-system/types/jsx.d.ts +27 -0
- package/styled-system/types/parts.d.ts +5 -0
- package/styled-system/types/pattern.d.ts +52 -0
- package/styled-system/types/prop-type.d.ts +300 -0
- package/styled-system/types/recipe.d.ts +79 -0
- package/styled-system/types/selectors.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +688 -0
- package/styled-system/types/system-types.d.ts +76 -0
- package/virtual-panda.ts +72 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// src/assert.ts
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return typeof value === 'object' && value != null && !Array.isArray(value)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// src/compact.ts
|
|
7
|
+
function compact(value) {
|
|
8
|
+
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0))
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/condition.ts
|
|
12
|
+
var isBaseCondition = (v) => v === 'base'
|
|
13
|
+
function filterBaseConditions(c) {
|
|
14
|
+
return c.slice().filter((v) => !isBaseCondition(v))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/css-important.ts
|
|
18
|
+
var importantRegex = /!(important)?$/
|
|
19
|
+
function isImportant(value) {
|
|
20
|
+
return typeof value === 'string' ? importantRegex.test(value) : false
|
|
21
|
+
}
|
|
22
|
+
function withoutImportant(value) {
|
|
23
|
+
return typeof value === 'string' ? value.replace(importantRegex, '').trim() : value
|
|
24
|
+
}
|
|
25
|
+
function withoutSpace(str) {
|
|
26
|
+
return typeof str === 'string' ? str.replaceAll(' ', '_') : str
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/hash.ts
|
|
30
|
+
function toChar(code) {
|
|
31
|
+
return String.fromCharCode(code + (code > 25 ? 39 : 97))
|
|
32
|
+
}
|
|
33
|
+
function toName(code) {
|
|
34
|
+
let name = ''
|
|
35
|
+
let x
|
|
36
|
+
for (x = Math.abs(code); x > 52; x = (x / 52) | 0) name = toChar(x % 52) + name
|
|
37
|
+
return toChar(x % 52) + name
|
|
38
|
+
}
|
|
39
|
+
function toPhash(h, x) {
|
|
40
|
+
let i = x.length
|
|
41
|
+
while (i) h = (h * 33) ^ x.charCodeAt(--i)
|
|
42
|
+
return h
|
|
43
|
+
}
|
|
44
|
+
function toHash(value) {
|
|
45
|
+
return toName(toPhash(5381, value) >>> 0)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/merge-props.ts
|
|
49
|
+
function mergeProps(...sources) {
|
|
50
|
+
const result = {}
|
|
51
|
+
for (const source of sources) {
|
|
52
|
+
for (const [key, value] of Object.entries(source)) {
|
|
53
|
+
if (isObject(value)) {
|
|
54
|
+
result[key] = mergeProps(result[key] || {}, value)
|
|
55
|
+
} else {
|
|
56
|
+
result[key] = value
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/walk-object.ts
|
|
64
|
+
function walkObject(target, predicate, options = {}) {
|
|
65
|
+
const { stop, getKey } = options
|
|
66
|
+
function inner(value, path = []) {
|
|
67
|
+
if (isObject(value) || Array.isArray(value)) {
|
|
68
|
+
const result = {}
|
|
69
|
+
for (const [prop, child] of Object.entries(value)) {
|
|
70
|
+
const key = getKey?.(prop) ?? prop
|
|
71
|
+
const childPath = [...path, key]
|
|
72
|
+
if (stop?.(value, childPath)) {
|
|
73
|
+
return predicate(value, path)
|
|
74
|
+
}
|
|
75
|
+
result[key] = inner(child, childPath)
|
|
76
|
+
}
|
|
77
|
+
return result
|
|
78
|
+
}
|
|
79
|
+
return predicate(value, path)
|
|
80
|
+
}
|
|
81
|
+
return inner(target)
|
|
82
|
+
}
|
|
83
|
+
function mapObject(obj, fn) {
|
|
84
|
+
if (!isObject(obj)) return fn(obj)
|
|
85
|
+
return walkObject(obj, (value) => fn(value))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/normalize-style-object.ts
|
|
89
|
+
function toResponsiveObject(values, breakpoints) {
|
|
90
|
+
return values.reduce((acc, current, index) => {
|
|
91
|
+
const key = breakpoints[index]
|
|
92
|
+
if (current != null) {
|
|
93
|
+
acc[key] = current
|
|
94
|
+
}
|
|
95
|
+
return acc
|
|
96
|
+
}, {})
|
|
97
|
+
}
|
|
98
|
+
function normalizeShorthand(styles, context) {
|
|
99
|
+
const { hasShorthand, resolveShorthand } = context.utility
|
|
100
|
+
return walkObject(styles, (v) => v, {
|
|
101
|
+
getKey: (prop) => {
|
|
102
|
+
return hasShorthand ? resolveShorthand(prop) : prop
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
function normalizeStyleObject(styles, context) {
|
|
107
|
+
const { utility, conditions } = context
|
|
108
|
+
const { hasShorthand, resolveShorthand } = utility
|
|
109
|
+
return walkObject(
|
|
110
|
+
styles,
|
|
111
|
+
(value) => {
|
|
112
|
+
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
stop: (value) => Array.isArray(value),
|
|
116
|
+
getKey: (prop) => {
|
|
117
|
+
return hasShorthand ? resolveShorthand(prop) : prop
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/classname.ts
|
|
124
|
+
var fallbackCondition = {
|
|
125
|
+
shift: (v) => v,
|
|
126
|
+
finalize: (v) => v,
|
|
127
|
+
breakpoints: { keys: [] },
|
|
128
|
+
}
|
|
129
|
+
var sanitize = (value) => (typeof value === 'string' ? value.replaceAll(/[\n\s]+/g, ' ') : value)
|
|
130
|
+
function createCss(context) {
|
|
131
|
+
const { utility, hash, conditions: conds = fallbackCondition } = context
|
|
132
|
+
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join('-')
|
|
133
|
+
const hashFn = (conditions, className) => {
|
|
134
|
+
let result
|
|
135
|
+
if (hash) {
|
|
136
|
+
const baseArray = [...conds.finalize(conditions), className]
|
|
137
|
+
result = formatClassName(toHash(baseArray.join(':')))
|
|
138
|
+
} else {
|
|
139
|
+
const baseArray = [...conds.finalize(conditions), formatClassName(className)]
|
|
140
|
+
result = baseArray.join(':')
|
|
141
|
+
}
|
|
142
|
+
return result
|
|
143
|
+
}
|
|
144
|
+
return (styleObject = {}) => {
|
|
145
|
+
const normalizedObject = normalizeStyleObject(styleObject, context)
|
|
146
|
+
const classNames = /* @__PURE__ */ new Set()
|
|
147
|
+
walkObject(normalizedObject, (value, paths) => {
|
|
148
|
+
const important = isImportant(value)
|
|
149
|
+
if (value == null) return
|
|
150
|
+
const [prop, ...allConditions] = conds.shift(paths)
|
|
151
|
+
const conditions = filterBaseConditions(allConditions)
|
|
152
|
+
const transformed = utility.transform(prop, withoutImportant(sanitize(value)))
|
|
153
|
+
let className = hashFn(conditions, transformed.className)
|
|
154
|
+
if (important) className = `${className}!`
|
|
155
|
+
classNames.add(className)
|
|
156
|
+
})
|
|
157
|
+
return Array.from(classNames).join(' ')
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function compactStyles(...styles) {
|
|
161
|
+
return styles.filter((style) => isObject(style) && Object.keys(compact(style)).length > 0)
|
|
162
|
+
}
|
|
163
|
+
function createMergeCss(context) {
|
|
164
|
+
function resolve(styles) {
|
|
165
|
+
const allStyles = compactStyles(...styles)
|
|
166
|
+
if (allStyles.length === 1) return allStyles
|
|
167
|
+
return allStyles.map((style) => normalizeShorthand(style, context))
|
|
168
|
+
}
|
|
169
|
+
function mergeCss(...styles) {
|
|
170
|
+
return mergeProps(...resolve(styles))
|
|
171
|
+
}
|
|
172
|
+
function assignCss(...styles) {
|
|
173
|
+
return Object.assign({}, ...resolve(styles))
|
|
174
|
+
}
|
|
175
|
+
return { mergeCss, assignCss }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/normalize-html.ts
|
|
179
|
+
var htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
|
|
180
|
+
function convert(key) {
|
|
181
|
+
return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
|
|
182
|
+
}
|
|
183
|
+
function normalizeHTMLProps(props) {
|
|
184
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]))
|
|
185
|
+
}
|
|
186
|
+
normalizeHTMLProps.keys = htmlProps
|
|
187
|
+
|
|
188
|
+
// src/split-props.ts
|
|
189
|
+
function splitProps(props, ...keys) {
|
|
190
|
+
const descriptors = Object.getOwnPropertyDescriptors(props)
|
|
191
|
+
const dKeys = Object.keys(descriptors)
|
|
192
|
+
const split = (k) => {
|
|
193
|
+
const clone = {}
|
|
194
|
+
for (let i = 0; i < k.length; i++) {
|
|
195
|
+
const key = k[i]
|
|
196
|
+
if (descriptors[key]) {
|
|
197
|
+
Object.defineProperty(clone, key, descriptors[key])
|
|
198
|
+
delete descriptors[key]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return clone
|
|
202
|
+
}
|
|
203
|
+
const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key))
|
|
204
|
+
return keys.map(fn).concat(split(dKeys))
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/memo.ts
|
|
208
|
+
var memo = (fn) => {
|
|
209
|
+
const cache = /* @__PURE__ */ new Map()
|
|
210
|
+
const get = (...args) => {
|
|
211
|
+
const key = JSON.stringify(args)
|
|
212
|
+
if (cache.has(key)) {
|
|
213
|
+
return cache.get(key)
|
|
214
|
+
}
|
|
215
|
+
const result = fn(...args)
|
|
216
|
+
cache.set(key, result)
|
|
217
|
+
return result
|
|
218
|
+
}
|
|
219
|
+
return get
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/hypenate.ts
|
|
223
|
+
var dashCaseRegex = /[A-Z]/g
|
|
224
|
+
var hypenateProperty = memo((property) => {
|
|
225
|
+
if (property.startsWith('--')) return property
|
|
226
|
+
return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`)
|
|
227
|
+
})
|
|
228
|
+
export {
|
|
229
|
+
compact,
|
|
230
|
+
createCss,
|
|
231
|
+
createMergeCss,
|
|
232
|
+
filterBaseConditions,
|
|
233
|
+
hypenateProperty,
|
|
234
|
+
isBaseCondition,
|
|
235
|
+
isObject,
|
|
236
|
+
mapObject,
|
|
237
|
+
mergeProps,
|
|
238
|
+
normalizeHTMLProps,
|
|
239
|
+
splitProps,
|
|
240
|
+
toHash,
|
|
241
|
+
walkObject,
|
|
242
|
+
withoutSpace,
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function __spreadValues(a, b) {
|
|
246
|
+
return { ...a, ...b }
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function __objRest(source, exclude) {
|
|
250
|
+
return Object.fromEntries(Object.entries(source).filter(([key]) => !exclude.includes(key)))
|
|
251
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { AbsoluteCenterProperties } from '../patterns/absolute-center'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type AbsoluteCenterProps = AbsoluteCenterProperties & Omit<HTMLPandaProps<'div'>, keyof AbsoluteCenterProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const AbsoluteCenter: FunctionComponent<AbsoluteCenterProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getAbsoluteCenterStyle } from '../patterns/absolute-center.mjs'
|
|
4
|
+
|
|
5
|
+
export const AbsoluteCenter = forwardRef(function AbsoluteCenter(props, ref) {
|
|
6
|
+
const { axis, ...restProps } = props
|
|
7
|
+
const styleProps = getAbsoluteCenterStyle({ axis })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { AspectRatioProperties } from '../patterns/aspect-ratio'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type AspectRatioProps = AspectRatioProperties & Omit<HTMLPandaProps<'div'>, keyof AspectRatioProperties | 'aspectRatio'>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const AspectRatio: FunctionComponent<AspectRatioProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getAspectRatioStyle } from '../patterns/aspect-ratio.mjs'
|
|
4
|
+
|
|
5
|
+
export const AspectRatio = forwardRef(function AspectRatio(props, ref) {
|
|
6
|
+
const { ratio, ...restProps } = props
|
|
7
|
+
const styleProps = getAspectRatioStyle({ ratio })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { BoxProperties } from '../patterns/box'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type BoxProps = BoxProperties & Omit<HTMLPandaProps<'div'>, keyof BoxProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Box: FunctionComponent<BoxProps>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getBoxStyle } from '../patterns/box.mjs'
|
|
4
|
+
|
|
5
|
+
export const Box = forwardRef(function Box(props, ref) {
|
|
6
|
+
const styleProps = getBoxStyle()
|
|
7
|
+
return createElement(panda.div, { ref, ...styleProps, ...props })
|
|
8
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { CenterProperties } from '../patterns/center'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type CenterProps = CenterProperties & Omit<HTMLPandaProps<'div'>, keyof CenterProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Center: FunctionComponent<CenterProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getCenterStyle } from '../patterns/center.mjs'
|
|
4
|
+
|
|
5
|
+
export const Center = forwardRef(function Center(props, ref) {
|
|
6
|
+
const { inline, ...restProps } = props
|
|
7
|
+
const styleProps = getCenterStyle({ inline })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { CircleProperties } from '../patterns/circle'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type CircleProps = CircleProperties & Omit<HTMLPandaProps<'div'>, keyof CircleProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Circle: FunctionComponent<CircleProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getCircleStyle } from '../patterns/circle.mjs'
|
|
4
|
+
|
|
5
|
+
export const Circle = forwardRef(function Circle(props, ref) {
|
|
6
|
+
const { size, ...restProps } = props
|
|
7
|
+
const styleProps = getCircleStyle({ size })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { ContainerProperties } from '../patterns/container'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type ContainerProps = ContainerProperties & Omit<HTMLPandaProps<'div'>, keyof ContainerProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Container: FunctionComponent<ContainerProps>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getContainerStyle } from '../patterns/container.mjs'
|
|
4
|
+
|
|
5
|
+
export const Container = forwardRef(function Container(props, ref) {
|
|
6
|
+
const styleProps = getContainerStyle()
|
|
7
|
+
return createElement(panda.div, { ref, ...styleProps, ...props })
|
|
8
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { DividerProperties } from '../patterns/divider'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type DividerProps = DividerProperties & Omit<HTMLPandaProps<'div'>, keyof DividerProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Divider: FunctionComponent<DividerProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getDividerStyle } from '../patterns/divider.mjs'
|
|
4
|
+
|
|
5
|
+
export const Divider = forwardRef(function Divider(props, ref) {
|
|
6
|
+
const { orientation, thickness, color, ...restProps } = props
|
|
7
|
+
const styleProps = getDividerStyle({ orientation, thickness, color })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createElement, forwardRef, useMemo } from 'react'
|
|
2
|
+
import { css, cx, cva, assignCss } from '../css/index.mjs'
|
|
3
|
+
import { splitProps, normalizeHTMLProps } from '../helpers.mjs'
|
|
4
|
+
import { isCssProperty } from './is-valid-prop.mjs'
|
|
5
|
+
|
|
6
|
+
function styledFn(Dynamic, configOrCva = {}) {
|
|
7
|
+
const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
|
|
8
|
+
|
|
9
|
+
const PandaComponent = forwardRef(function PandaComponent(props, ref) {
|
|
10
|
+
const { as: Element = Dynamic, ...restProps } = props
|
|
11
|
+
|
|
12
|
+
const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
|
|
13
|
+
return splitProps(restProps, cvaFn.variantKeys, isCssProperty, normalizeHTMLProps.keys)
|
|
14
|
+
}, [restProps])
|
|
15
|
+
|
|
16
|
+
function recipeClass() {
|
|
17
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
18
|
+
const styles = assignCss(propStyles, cssStyles)
|
|
19
|
+
return cx(cvaFn(variantProps), css(styles), elementProps.className)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function cvaClass() {
|
|
23
|
+
const { css: cssStyles, ...propStyles } = styleProps
|
|
24
|
+
const cvaStyles = cvaFn.resolve(variantProps)
|
|
25
|
+
const styles = assignCss(cvaStyles, propStyles, cssStyles)
|
|
26
|
+
return cx(css(styles), elementProps.className)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const classes = configOrCva.__recipe__ ? recipeClass : cvaClass
|
|
30
|
+
|
|
31
|
+
return createElement(Element, {
|
|
32
|
+
ref,
|
|
33
|
+
...elementProps,
|
|
34
|
+
...normalizeHTMLProps(htmlProps),
|
|
35
|
+
className: classes(),
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
PandaComponent.displayName = `panda.${Dynamic}`
|
|
40
|
+
return PandaComponent
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function createJsxFactory() {
|
|
44
|
+
const cache = new Map()
|
|
45
|
+
|
|
46
|
+
return new Proxy(styledFn, {
|
|
47
|
+
apply(_, __, args) {
|
|
48
|
+
return styledFn(...args)
|
|
49
|
+
},
|
|
50
|
+
get(_, el) {
|
|
51
|
+
if (!cache.has(el)) {
|
|
52
|
+
cache.set(el, styledFn(el))
|
|
53
|
+
}
|
|
54
|
+
return cache.get(el)
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const panda = createJsxFactory()
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { FlexProperties } from '../patterns/flex'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type FlexProps = FlexProperties & Omit<HTMLPandaProps<'div'>, keyof FlexProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Flex: FunctionComponent<FlexProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getFlexStyle } from '../patterns/flex.mjs'
|
|
4
|
+
|
|
5
|
+
export const Flex = forwardRef(function Flex(props, ref) {
|
|
6
|
+
const { align, justify, direction, wrap, basis, grow, shrink, ...restProps } = props
|
|
7
|
+
const styleProps = getFlexStyle({ align, justify, direction, wrap, basis, grow, shrink })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { FloatProperties } from '../patterns/float'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type FloatProps = FloatProperties & Omit<HTMLPandaProps<'div'>, keyof FloatProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Float: FunctionComponent<FloatProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getFloatStyle } from '../patterns/float.mjs'
|
|
4
|
+
|
|
5
|
+
export const Float = forwardRef(function Float(props, ref) {
|
|
6
|
+
const { offsetX, offsetY, offset, placement, ...restProps } = props
|
|
7
|
+
const styleProps = getFloatStyle({ offsetX, offsetY, offset, placement })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { GridItemProperties } from '../patterns/grid-item'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type GridItemProps = GridItemProperties & Omit<HTMLPandaProps<'div'>, keyof GridItemProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const GridItem: FunctionComponent<GridItemProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getGridItemStyle } from '../patterns/grid-item.mjs'
|
|
4
|
+
|
|
5
|
+
export const GridItem = forwardRef(function GridItem(props, ref) {
|
|
6
|
+
const { colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd, ...restProps } = props
|
|
7
|
+
const styleProps = getGridItemStyle({ colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { GridProperties } from '../patterns/grid'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type GridProps = GridProperties & Omit<HTMLPandaProps<'div'>, keyof GridProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const Grid: FunctionComponent<GridProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getGridStyle } from '../patterns/grid.mjs'
|
|
4
|
+
|
|
5
|
+
export const Grid = forwardRef(function Grid(props, ref) {
|
|
6
|
+
const { gap, columnGap, rowGap, columns, minChildWidth, ...restProps } = props
|
|
7
|
+
const styleProps = getGridStyle({ gap, columnGap, rowGap, columns, minChildWidth })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FunctionComponent } from 'react'
|
|
2
|
+
import type { HstackProperties } from '../patterns/hstack'
|
|
3
|
+
import type { HTMLPandaProps } from '../types/jsx'
|
|
4
|
+
|
|
5
|
+
export type HstackProps = HstackProperties & Omit<HTMLPandaProps<'div'>, keyof HstackProperties >
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export declare const HStack: FunctionComponent<HstackProps>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createElement, forwardRef } from 'react'
|
|
2
|
+
import { panda } from './factory.mjs'
|
|
3
|
+
import { getHstackStyle } from '../patterns/hstack.mjs'
|
|
4
|
+
|
|
5
|
+
export const HStack = forwardRef(function HStack(props, ref) {
|
|
6
|
+
const { justify, gap, ...restProps } = props
|
|
7
|
+
const styleProps = getHstackStyle({ justify, gap })
|
|
8
|
+
return createElement(panda.div, { ref, ...styleProps, ...restProps })
|
|
9
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './factory'
|
|
2
|
+
export * from './box'
|
|
3
|
+
export * from './flex'
|
|
4
|
+
export * from './stack'
|
|
5
|
+
export * from './vstack'
|
|
6
|
+
export * from './hstack'
|
|
7
|
+
export * from './spacer'
|
|
8
|
+
export * from './square'
|
|
9
|
+
export * from './circle'
|
|
10
|
+
export * from './center'
|
|
11
|
+
export * from './absolute-center'
|
|
12
|
+
export * from './aspect-ratio'
|
|
13
|
+
export * from './grid'
|
|
14
|
+
export * from './grid-item'
|
|
15
|
+
export * from './wrap'
|
|
16
|
+
export * from './container'
|
|
17
|
+
export * from './divider'
|
|
18
|
+
export * from './float'
|
|
19
|
+
export * from './styled-link'
|
|
20
|
+
export type { HTMLPandaProps } from '../types/jsx'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from './factory.mjs'
|
|
2
|
+
export * from './box.mjs'
|
|
3
|
+
export * from './flex.mjs'
|
|
4
|
+
export * from './stack.mjs'
|
|
5
|
+
export * from './vstack.mjs'
|
|
6
|
+
export * from './hstack.mjs'
|
|
7
|
+
export * from './spacer.mjs'
|
|
8
|
+
export * from './square.mjs'
|
|
9
|
+
export * from './circle.mjs'
|
|
10
|
+
export * from './center.mjs'
|
|
11
|
+
export * from './absolute-center.mjs'
|
|
12
|
+
export * from './aspect-ratio.mjs'
|
|
13
|
+
export * from './grid.mjs'
|
|
14
|
+
export * from './grid-item.mjs'
|
|
15
|
+
export * from './wrap.mjs'
|
|
16
|
+
export * from './container.mjs'
|
|
17
|
+
export * from './divider.mjs'
|
|
18
|
+
export * from './float.mjs'
|
|
19
|
+
export * from './styled-link.mjs'
|