@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.
Files changed (124) hide show
  1. package/css/conditions.mjs +36 -0
  2. package/css/css.d.ts +22 -0
  3. package/css/css.mjs +45 -0
  4. package/css/cva.d.ts +6 -0
  5. package/css/cva.mjs +87 -0
  6. package/css/cx.d.ts +5 -0
  7. package/css/cx.mjs +15 -0
  8. package/css/index.d.ts +5 -0
  9. package/css/index.mjs +4 -0
  10. package/css/sva.d.ts +4 -0
  11. package/css/sva.mjs +46 -0
  12. package/helpers.mjs +328 -0
  13. package/jsx/aspect-ratio.d.ts +10 -0
  14. package/jsx/aspect-ratio.mjs +14 -0
  15. package/jsx/bleed.d.ts +10 -0
  16. package/jsx/bleed.mjs +14 -0
  17. package/jsx/box.d.ts +10 -0
  18. package/jsx/box.mjs +14 -0
  19. package/jsx/center.d.ts +10 -0
  20. package/jsx/center.mjs +14 -0
  21. package/jsx/circle.d.ts +10 -0
  22. package/jsx/circle.mjs +14 -0
  23. package/jsx/container.d.ts +10 -0
  24. package/jsx/container.mjs +14 -0
  25. package/jsx/cq.d.ts +10 -0
  26. package/jsx/cq.mjs +14 -0
  27. package/jsx/create-style-context.d.ts +54 -0
  28. package/jsx/create-style-context.mjs +118 -0
  29. package/jsx/divider.d.ts +10 -0
  30. package/jsx/divider.mjs +14 -0
  31. package/jsx/factory-helper.mjs +22 -0
  32. package/jsx/factory.d.ts +3 -0
  33. package/jsx/factory.mjs +89 -0
  34. package/jsx/flex.d.ts +10 -0
  35. package/jsx/flex.mjs +14 -0
  36. package/jsx/float.d.ts +10 -0
  37. package/jsx/float.mjs +14 -0
  38. package/jsx/grid-item.d.ts +10 -0
  39. package/jsx/grid-item.mjs +14 -0
  40. package/jsx/grid.d.ts +10 -0
  41. package/jsx/grid.mjs +14 -0
  42. package/jsx/hstack.d.ts +10 -0
  43. package/jsx/hstack.mjs +14 -0
  44. package/jsx/index.d.ts +25 -0
  45. package/jsx/index.mjs +23 -0
  46. package/jsx/is-valid-prop.d.ts +11 -0
  47. package/jsx/is-valid-prop.mjs +17 -0
  48. package/jsx/link-overlay.d.ts +10 -0
  49. package/jsx/link-overlay.mjs +14 -0
  50. package/jsx/spacer.d.ts +10 -0
  51. package/jsx/spacer.mjs +14 -0
  52. package/jsx/square.d.ts +10 -0
  53. package/jsx/square.mjs +14 -0
  54. package/jsx/stack.d.ts +10 -0
  55. package/jsx/stack.mjs +14 -0
  56. package/jsx/visually-hidden.d.ts +10 -0
  57. package/jsx/visually-hidden.mjs +14 -0
  58. package/jsx/vstack.d.ts +10 -0
  59. package/jsx/vstack.mjs +14 -0
  60. package/jsx/wrap.d.ts +10 -0
  61. package/jsx/wrap.mjs +14 -0
  62. package/package.json +45 -0
  63. package/patterns/aspect-ratio.d.ts +20 -0
  64. package/patterns/aspect-ratio.mjs +38 -0
  65. package/patterns/bleed.d.ts +21 -0
  66. package/patterns/bleed.mjs +24 -0
  67. package/patterns/box.d.ts +20 -0
  68. package/patterns/box.mjs +15 -0
  69. package/patterns/center.d.ts +20 -0
  70. package/patterns/center.mjs +21 -0
  71. package/patterns/circle.d.ts +20 -0
  72. package/patterns/circle.mjs +25 -0
  73. package/patterns/container.d.ts +20 -0
  74. package/patterns/container.mjs +21 -0
  75. package/patterns/cq.d.ts +21 -0
  76. package/patterns/cq.mjs +21 -0
  77. package/patterns/divider.d.ts +22 -0
  78. package/patterns/divider.mjs +25 -0
  79. package/patterns/flex.d.ts +26 -0
  80. package/patterns/flex.mjs +26 -0
  81. package/patterns/float.d.ts +23 -0
  82. package/patterns/float.mjs +52 -0
  83. package/patterns/grid-item.d.ts +25 -0
  84. package/patterns/grid-item.mjs +25 -0
  85. package/patterns/grid.d.ts +24 -0
  86. package/patterns/grid.mjs +27 -0
  87. package/patterns/hstack.d.ts +21 -0
  88. package/patterns/hstack.mjs +24 -0
  89. package/patterns/index.d.ts +21 -0
  90. package/patterns/index.mjs +20 -0
  91. package/patterns/link-overlay.d.ts +20 -0
  92. package/patterns/link-overlay.mjs +24 -0
  93. package/patterns/spacer.d.ts +20 -0
  94. package/patterns/spacer.mjs +25 -0
  95. package/patterns/square.d.ts +20 -0
  96. package/patterns/square.mjs +24 -0
  97. package/patterns/stack.d.ts +23 -0
  98. package/patterns/stack.mjs +24 -0
  99. package/patterns/visually-hidden.d.ts +20 -0
  100. package/patterns/visually-hidden.mjs +18 -0
  101. package/patterns/vstack.d.ts +21 -0
  102. package/patterns/vstack.mjs +24 -0
  103. package/patterns/wrap.d.ts +24 -0
  104. package/patterns/wrap.mjs +25 -0
  105. package/runtime.d.ts +8 -0
  106. package/runtime.mjs +87 -0
  107. package/styles.css +18334 -0
  108. package/tokens/index.d.ts +9 -0
  109. package/tokens/index.mjs +2656 -0
  110. package/tokens/tokens.d.ts +60 -0
  111. package/types/composition.d.ts +227 -0
  112. package/types/conditions.d.ts +312 -0
  113. package/types/csstype.d.ts +22570 -0
  114. package/types/global.d.ts +20 -0
  115. package/types/index.d.ts +8 -0
  116. package/types/jsx.d.ts +69 -0
  117. package/types/parts.d.ts +8 -0
  118. package/types/pattern.d.ts +78 -0
  119. package/types/prop-type.d.ts +256 -0
  120. package/types/recipe.d.ts +181 -0
  121. package/types/selectors.d.ts +59 -0
  122. package/types/static-css.d.ts +56 -0
  123. package/types/style-props.d.ts +8094 -0
  124. 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
+ }