@horang-corp/react-system 0.1.1
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/css/conditions.mjs +36 -0
- package/css/css.d.ts +22 -0
- package/css/css.mjs +45 -0
- package/css/cva.d.ts +6 -0
- package/css/cva.mjs +87 -0
- package/css/cx.d.ts +5 -0
- package/css/cx.mjs +15 -0
- package/css/index.d.ts +5 -0
- package/css/index.mjs +4 -0
- package/css/sva.d.ts +4 -0
- package/css/sva.mjs +46 -0
- package/helpers.mjs +328 -0
- package/jsx/aspect-ratio.d.ts +10 -0
- package/jsx/aspect-ratio.mjs +14 -0
- package/jsx/bleed.d.ts +10 -0
- package/jsx/bleed.mjs +14 -0
- package/jsx/box.d.ts +10 -0
- package/jsx/box.mjs +14 -0
- package/jsx/center.d.ts +10 -0
- package/jsx/center.mjs +14 -0
- package/jsx/circle.d.ts +10 -0
- package/jsx/circle.mjs +14 -0
- package/jsx/container.d.ts +10 -0
- package/jsx/container.mjs +14 -0
- package/jsx/cq.d.ts +10 -0
- package/jsx/cq.mjs +14 -0
- package/jsx/create-style-context.d.ts +54 -0
- package/jsx/create-style-context.mjs +118 -0
- package/jsx/divider.d.ts +10 -0
- package/jsx/divider.mjs +14 -0
- package/jsx/factory-helper.mjs +22 -0
- package/jsx/factory.d.ts +3 -0
- package/jsx/factory.mjs +89 -0
- package/jsx/flex.d.ts +10 -0
- package/jsx/flex.mjs +14 -0
- package/jsx/float.d.ts +10 -0
- package/jsx/float.mjs +14 -0
- package/jsx/grid-item.d.ts +10 -0
- package/jsx/grid-item.mjs +14 -0
- package/jsx/grid.d.ts +10 -0
- package/jsx/grid.mjs +14 -0
- package/jsx/hstack.d.ts +10 -0
- package/jsx/hstack.mjs +14 -0
- package/jsx/index.d.ts +25 -0
- package/jsx/index.mjs +23 -0
- package/jsx/is-valid-prop.d.ts +11 -0
- package/jsx/is-valid-prop.mjs +17 -0
- package/jsx/link-overlay.d.ts +10 -0
- package/jsx/link-overlay.mjs +14 -0
- package/jsx/spacer.d.ts +10 -0
- package/jsx/spacer.mjs +14 -0
- package/jsx/square.d.ts +10 -0
- package/jsx/square.mjs +14 -0
- package/jsx/stack.d.ts +10 -0
- package/jsx/stack.mjs +14 -0
- package/jsx/visually-hidden.d.ts +10 -0
- package/jsx/visually-hidden.mjs +14 -0
- package/jsx/vstack.d.ts +10 -0
- package/jsx/vstack.mjs +14 -0
- package/jsx/wrap.d.ts +10 -0
- package/jsx/wrap.mjs +14 -0
- package/package.json +45 -0
- package/patterns/aspect-ratio.d.ts +20 -0
- package/patterns/aspect-ratio.mjs +38 -0
- package/patterns/bleed.d.ts +21 -0
- package/patterns/bleed.mjs +24 -0
- package/patterns/box.d.ts +20 -0
- package/patterns/box.mjs +15 -0
- package/patterns/center.d.ts +20 -0
- package/patterns/center.mjs +21 -0
- package/patterns/circle.d.ts +20 -0
- package/patterns/circle.mjs +25 -0
- package/patterns/container.d.ts +20 -0
- package/patterns/container.mjs +21 -0
- package/patterns/cq.d.ts +21 -0
- package/patterns/cq.mjs +21 -0
- package/patterns/divider.d.ts +22 -0
- package/patterns/divider.mjs +25 -0
- package/patterns/flex.d.ts +26 -0
- package/patterns/flex.mjs +26 -0
- package/patterns/float.d.ts +23 -0
- package/patterns/float.mjs +52 -0
- package/patterns/grid-item.d.ts +25 -0
- package/patterns/grid-item.mjs +25 -0
- package/patterns/grid.d.ts +24 -0
- package/patterns/grid.mjs +27 -0
- package/patterns/hstack.d.ts +21 -0
- package/patterns/hstack.mjs +24 -0
- package/patterns/index.d.ts +21 -0
- package/patterns/index.mjs +20 -0
- package/patterns/link-overlay.d.ts +20 -0
- package/patterns/link-overlay.mjs +24 -0
- package/patterns/spacer.d.ts +20 -0
- package/patterns/spacer.mjs +25 -0
- package/patterns/square.d.ts +20 -0
- package/patterns/square.mjs +24 -0
- package/patterns/stack.d.ts +23 -0
- package/patterns/stack.mjs +24 -0
- package/patterns/visually-hidden.d.ts +20 -0
- package/patterns/visually-hidden.mjs +18 -0
- package/patterns/vstack.d.ts +21 -0
- package/patterns/vstack.mjs +24 -0
- package/patterns/wrap.d.ts +24 -0
- package/patterns/wrap.mjs +25 -0
- package/runtime.d.ts +8 -0
- package/runtime.mjs +87 -0
- package/styles.css +18334 -0
- package/tokens/index.d.ts +9 -0
- package/tokens/index.mjs +2656 -0
- package/tokens/tokens.d.ts +60 -0
- package/types/composition.d.ts +227 -0
- package/types/conditions.d.ts +312 -0
- package/types/csstype.d.ts +22570 -0
- package/types/global.d.ts +20 -0
- package/types/index.d.ts +8 -0
- package/types/jsx.d.ts +69 -0
- package/types/parts.d.ts +8 -0
- package/types/pattern.d.ts +78 -0
- package/types/prop-type.d.ts +256 -0
- package/types/recipe.d.ts +181 -0
- package/types/selectors.d.ts +59 -0
- package/types/static-css.d.ts +56 -0
- package/types/style-props.d.ts +8094 -0
- package/types/system-types.d.ts +151 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getPatternStyles, patternFns } from '../helpers.mjs';
|
|
2
|
+
import { css } from '../css/index.mjs';
|
|
3
|
+
|
|
4
|
+
const wrapConfig = {
|
|
5
|
+
transform(props) {
|
|
6
|
+
const { columnGap, rowGap, gap = columnGap || rowGap ? void 0 : "8px", align, justify, ...rest } = props;
|
|
7
|
+
return {
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexWrap: "wrap",
|
|
10
|
+
alignItems: align,
|
|
11
|
+
justifyContent: justify,
|
|
12
|
+
gap,
|
|
13
|
+
columnGap,
|
|
14
|
+
rowGap,
|
|
15
|
+
...rest
|
|
16
|
+
};
|
|
17
|
+
}}
|
|
18
|
+
|
|
19
|
+
export const getWrapStyle = (styles = {}) => {
|
|
20
|
+
const _styles = getPatternStyles(wrapConfig, styles)
|
|
21
|
+
return wrapConfig.transform(_styles, patternFns)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const wrap = (styles) => css(getWrapStyle(styles))
|
|
25
|
+
wrap.raw = getWrapStyle
|
package/runtime.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
export declare function useSquircleClip<T extends HTMLElement>(
|
|
4
|
+
cornerRadius: number,
|
|
5
|
+
cornerSmoothing: number,
|
|
6
|
+
): [RefObject<T | null>, string | undefined]
|
|
7
|
+
|
|
8
|
+
export declare function mergeProps<T extends object>(defaults: T, props: Partial<T>): T
|
package/runtime.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { getSvgPath } from 'figma-squircle'
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
export function useSquircleClip(cornerRadius, cornerSmoothing) {
|
|
5
|
+
const ref = useRef(null)
|
|
6
|
+
const [clipPath, setClipPath] = useState(undefined)
|
|
7
|
+
useLayoutEffect(() => {
|
|
8
|
+
const el = ref.current
|
|
9
|
+
if (!el) return
|
|
10
|
+
let frame = 0
|
|
11
|
+
const timeouts = []
|
|
12
|
+
const update = () => {
|
|
13
|
+
const r = el.getBoundingClientRect()
|
|
14
|
+
if (!r.width || !r.height) return
|
|
15
|
+
const rootFontSize = Number.parseFloat(
|
|
16
|
+
window.getComputedStyle(document.documentElement).fontSize,
|
|
17
|
+
)
|
|
18
|
+
const scale = Number.isFinite(rootFontSize) && rootFontSize > 0 ? rootFontSize / 16 : 1
|
|
19
|
+
const path = getSvgPath({
|
|
20
|
+
width: r.width,
|
|
21
|
+
height: r.height,
|
|
22
|
+
cornerRadius: cornerRadius * scale * 1.02,
|
|
23
|
+
cornerSmoothing,
|
|
24
|
+
})
|
|
25
|
+
.replace(/\n/g, ' ')
|
|
26
|
+
.trim()
|
|
27
|
+
setClipPath(`path('${path}')`)
|
|
28
|
+
}
|
|
29
|
+
let framesLeft = 12
|
|
30
|
+
const scheduleFrames = () => {
|
|
31
|
+
if (framesLeft <= 0) return
|
|
32
|
+
frame = requestAnimationFrame(() => {
|
|
33
|
+
framesLeft -= 1
|
|
34
|
+
update()
|
|
35
|
+
scheduleFrames()
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
update()
|
|
39
|
+
scheduleFrames()
|
|
40
|
+
for (const ms of [50, 200, 800]) {
|
|
41
|
+
timeouts.push(setTimeout(update, ms))
|
|
42
|
+
}
|
|
43
|
+
const ro = new ResizeObserver(update)
|
|
44
|
+
ro.observe(el)
|
|
45
|
+
return () => {
|
|
46
|
+
cancelAnimationFrame(frame)
|
|
47
|
+
for (const timeout of timeouts) clearTimeout(timeout)
|
|
48
|
+
ro.disconnect()
|
|
49
|
+
}
|
|
50
|
+
}, [cornerRadius, cornerSmoothing])
|
|
51
|
+
return [ref, clipPath]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function mergeProps(defaults, props) {
|
|
55
|
+
const out = { ...defaults }
|
|
56
|
+
for (const k in props) {
|
|
57
|
+
const raw = props[k]
|
|
58
|
+
if (raw === undefined) continue
|
|
59
|
+
out[k] = normalizeLiteralProp(raw)
|
|
60
|
+
}
|
|
61
|
+
return out
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function normalizeLiteralProp(v) {
|
|
65
|
+
if (!v || typeof v !== 'object') return v
|
|
66
|
+
const obj = v
|
|
67
|
+
if (obj.kind !== 'literal') return v
|
|
68
|
+
const inner = obj.value
|
|
69
|
+
if (inner == null) return v
|
|
70
|
+
if (typeof inner === 'string') return inner
|
|
71
|
+
if (typeof inner === 'number' || typeof inner === 'boolean') return inner
|
|
72
|
+
if (typeof inner === 'object') {
|
|
73
|
+
const r = inner
|
|
74
|
+
if ('unit' in r && 'value' in r) {
|
|
75
|
+
const num = Number(r.value)
|
|
76
|
+
if (r.unit === 'px') return `${+(num / 16).toFixed(6)}rem`
|
|
77
|
+
return `${num}${r.unit}`
|
|
78
|
+
}
|
|
79
|
+
if ('r' in r && 'g' in r && 'b' in r) {
|
|
80
|
+
const a = 'a' in r ? Number(r.a) : 1
|
|
81
|
+
return a < 1
|
|
82
|
+
? `rgba(${r.r}, ${r.g}, ${r.b}, ${a})`
|
|
83
|
+
: `rgb(${r.r}, ${r.g}, ${r.b})`
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return v
|
|
87
|
+
}
|