@krizaka/ui 1.2.0 → 2.0.0-beta.0
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/README.md +114 -4
- package/dist/avatar.d.ts +98 -0
- package/dist/avatar.js +48 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +64 -0
- package/dist/badge.js +31 -0
- package/dist/badge.js.map +1 -0
- package/dist/button.d.ts +76 -0
- package/dist/button.js +46 -0
- package/dist/button.js.map +1 -0
- package/dist/chunk-CPMZS4XA.js +11 -0
- package/dist/chunk-CPMZS4XA.js.map +1 -0
- package/dist/cn.d.ts +10 -0
- package/dist/cn.js +7 -0
- package/dist/cn.js.map +1 -0
- package/dist/countdown.d.ts +46 -0
- package/dist/countdown.js +74 -0
- package/dist/countdown.js.map +1 -0
- package/dist/empty-state.d.ts +63 -0
- package/dist/empty-state.js +26 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/field.d.ts +80 -0
- package/dist/field.js +47 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/native.js +3 -3
- package/dist/native.js.map +1 -1
- package/dist/skeleton.d.ts +28 -0
- package/dist/skeleton.js +18 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/slot.d.ts +11 -0
- package/dist/slot.js +9 -0
- package/dist/slot.js.map +1 -0
- package/dist/spinner.d.ts +31 -0
- package/dist/spinner.js +31 -0
- package/dist/spinner.js.map +1 -0
- package/dist/theme.d.ts +95 -0
- package/dist/theme.js +140 -0
- package/dist/theme.js.map +1 -0
- package/package.json +185 -10
- package/tailwind.css +3 -0
package/dist/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/native/OrochiaMark.tsx","../src/marks/orochia-geometry.ts"],"sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { AccessibilityInfo, Animated, Easing, View } from \"react-native\";\nimport Svg, { Circle, Defs, Ellipse, G as Group, LinearGradient, Path, RadialGradient, Stop } from \"react-native-svg\";\nimport { OROCHIA as G } from \"../marks/orochia-geometry\";\n\nexport interface NativeMarkProps {\n /** Width and height in points. */\n size?: number;\n /** The orbit turns and the flame breathes; always still when the system asks to reduce motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n /** The neutral strokes (orbit, ring): the host's border colour. */\n neutral?: string;\n}\n\nconst CENTER = G.offset + 180;\n\n/**\n * The Orochia mark for React Native — the same geometry as the web mark (marks/orochia-geometry.ts), drawn with\n * react-native-svg. Three layers so that the motion runs on the native driver: the orbit turns, the eye and the flame\n * breathe, the serpent stays still.\n */\nexport function OrochiaMark({ size = 48, animated = true, title, neutral = \"rgba(255,255,255,0.35)\" }: NativeMarkProps) {\n const spin = useRef(new Animated.Value(0)).current;\n const pulse = useRef(new Animated.Value(0)).current;\n useEffect(() => {\n if (!animated) return;\n let loops: Animated.CompositeAnimation[] = [];\n let cancelled = false;\n void AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {\n if (reduce || cancelled) return;\n loops = [\n Animated.loop(Animated.timing(spin, { toValue: 1, duration: 30_000, easing: Easing.linear, useNativeDriver: true })),\n Animated.loop(\n Animated.sequence([\n Animated.timing(pulse, { toValue: 1, duration: 1600, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),\n Animated.timing(pulse, { toValue: 0, duration: 1600, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),\n ]),\n ),\n ];\n loops.forEach((l) => l.start());\n });\n return () => {\n cancelled = true;\n loops.forEach((l) => l.stop());\n };\n }, [animated, spin, pulse]);\n\n const viewBox = size < 48 ? G.croppedViewBox : G.viewBox;\n const layer = { position: \"absolute\" as const, width: size, height: size };\n const a11y = title ? { accessible: true, accessibilityRole: \"image\" as const, accessibilityLabel: title } : { accessibilityElementsHidden: true, importantForAccessibility: \"no-hide-descendants\" as const };\n const bodyGradient = (\n <LinearGradient id=\"body\" gradientUnits=\"userSpaceOnUse\" x1={G.body.x1 + G.offset} y1={G.body.y1 + G.offset} x2={G.body.x2 + G.offset} y2={G.body.y2 + G.offset}>\n {G.body.stops.map(([offset, color]) => (\n <Stop key={offset} offset={offset} stopColor={color} />\n ))}\n </LinearGradient>\n );\n\n return (\n <View style={{ width: size, height: size }} {...a11y}>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>\n <RadialGradient id=\"glow\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <Stop offset=\"0%\" stopColor={G.glow.color} stopOpacity={G.glow.opacity} />\n <Stop offset=\"100%\" stopColor={G.glow.color} stopOpacity={0} />\n </RadialGradient>\n </Defs>\n <Circle cx={CENTER} cy={CENTER} r={170} fill=\"url(#glow)\" />\n <Circle cx={CENTER} cy={CENTER} r={G.ring.r} stroke={neutral} strokeWidth={G.ring.width} opacity={0.35} fill=\"none\" />\n </Svg>\n <Animated.View style={[layer, { transform: [{ rotate: spin.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] }) }] }]}>\n <Svg viewBox={viewBox} style={layer}>\n <Circle cx={CENTER} cy={CENTER} r={G.orbit.r} stroke={neutral} strokeWidth={G.orbit.width} strokeDasharray={G.orbit.dash} opacity={0.6} fill=\"none\" />\n </Svg>\n </Animated.View>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>{bodyGradient}</Defs>\n <Group transform={`translate(${G.offset} ${G.offset})`}>\n <Path d={G.arc} stroke=\"url(#body)\" strokeWidth={22} strokeLinecap=\"round\" fill=\"none\" />\n <Path d={G.arc} stroke={G.scales.color} strokeOpacity={G.scales.opacity} strokeWidth={G.scales.width} strokeLinecap=\"round\" strokeDasharray={G.scales.dash} fill=\"none\" />\n <Path d={G.neck} stroke=\"url(#body)\" strokeWidth={14} strokeLinecap=\"round\" fill=\"none\" />\n <Path d={G.tail} stroke=\"url(#body)\" strokeWidth={6} strokeLinecap=\"round\" fill=\"none\" />\n <Ellipse cx={G.head.cx} cy={G.head.cy} rx={G.head.rx} ry={G.head.ry} rotation={G.head.rotate} origin={`${G.head.cx}, ${G.head.cy}`} fill=\"url(#body)\" />\n <Path d={G.tongue.d} stroke={G.tongue.color} strokeWidth={3} strokeLinecap=\"round\" fill=\"none\" />\n </Group>\n </Svg>\n <Animated.View style={[layer, { opacity: pulse.interpolate({ inputRange: [0, 1], outputRange: [0.85, 1] }) }]}>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>\n <LinearGradient id=\"flame\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\">\n {G.flameGradient.stops.map(([offset, color]) => (\n <Stop key={offset} offset={offset} stopColor={color} />\n ))}\n </LinearGradient>\n </Defs>\n <Group transform={`translate(${G.offset} ${G.offset})`}>\n <Circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.eye.color} />\n <Path d={G.flame.d} transform={`translate(${G.flame.translate[0]} ${G.flame.translate[1]}) scale(${G.flame.scale})`} fill=\"url(#flame)\" />\n </Group>\n </Svg>\n </Animated.View>\n </View>\n );\n}\n","/**\n * The Orochia mark's geometry — the one description of the serpent and its flame, drawn by the web mark (SVG in the\n * DOM, OrochiaLogo) and the native one (react-native-svg, @krizaka/ui/native). Coordinates are in the 360×360 artwork,\n * placed at (20, 20) in a 400×400 view box; below 48 px the view box crops to the serpent.\n */\nexport const OROCHIA = {\n viewBox: \"0 0 400 400\",\n croppedViewBox: \"86 82 228 228\",\n offset: 20,\n body: { x1: 70, y1: 290, x2: 290, y2: 70, stops: [[\"0%\", \"#7c3aed\"], [\"55%\", \"#d946ef\"], [\"100%\", \"#f472b6\"]] },\n flameGradient: { stops: [[\"0%\", \"#a855f7\"], [\"100%\", \"#f9a8d4\"]] },\n glow: { color: \"#d946ef\", opacity: 0.18 },\n orbit: { r: 160, dash: \"8 8\", width: 1.5 },\n ring: { r: 134, width: 1 },\n arc: \"M259.8,142.8 A88,88 0 1 1 142.8,100.2\",\n neck: \"M142.8,100.2 A88,88 0 0 1 187.7,92.3\",\n tail: \"M187.7,92.3 A88,88 0 0 1 221.3,102.3\",\n scales: { color: \"#fdf4ff\", opacity: 0.45, width: 3, dash: \"2 14\" },\n head: { cx: 253.9, cy: 130.1, rx: 13, ry: 20, rotate: -25 },\n tongue: { d: \"M245.4,112.0 L242.0,104.8 L235.0,101.5 M242.0,104.8 L244.0,97.3\", color: \"#f472b6\" },\n eye: { cx: 256.3, cy: 123.5, r: 4.5, color: \"#fdf4ff\" },\n flame: {\n translate: [127, 120] as const,\n scale: 4.4,\n d: \"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z\",\n },\n} as const;\n"],"mappings":";AAAA,SAAgB,WAAW,cAAc;AACzC,SAAS,mBAAmB,UAAU,QAAQ,YAAY;AAC1D,OAAO,OAAO,QAAQ,MAAM,SAAS,KAAK,OAAO,gBAAgB,MAAM,gBAAgB,YAAY;;;ACG5F,IAAM,UAAU;AAAA,EACrB,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,MAAM,EAAE,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,GAAG,CAAC,QAAQ,SAAS,CAAC,EAAE;AAAA,EAC9G,eAAe,EAAE,OAAO,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,SAAS,CAAC,EAAE;AAAA,EACjE,MAAM,EAAE,OAAO,WAAW,SAAS,KAAK;AAAA,EACxC,OAAO,EAAE,GAAG,KAAK,MAAM,OAAO,OAAO,IAAI;AAAA,EACzC,MAAM,EAAE,GAAG,KAAK,OAAO,EAAE;AAAA,EACzB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,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IAAI,UAAU,QAAE,KAAK,QAAQ,QAAQ,GAAG,QAAE,KAAK,EAAE,KAAK,QAAE,KAAK,EAAE,IAAI,MAAK,cAAa;AAAA,QACtJ,oBAAC,QAAK,GAAG,QAAE,OAAO,GAAG,QAAQ,QAAE,OAAO,OAAO,aAAa,GAAG,eAAc,SAAQ,MAAK,QAAO;AAAA,SACjG;AAAA,OACF;AAAA,IACA,oBAAC,SAAS,MAAT,EAAc,OAAO,CAAC,OAAO,EAAE,SAAS,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,GAC1G,+BAAC,OAAI,SAAkB,OAAO,OAC5B;AAAA,0BAAC,QACC,8BAAC,kBAAe,IAAG,SAAQ,IAAG,OAAM,IAAG,QAAO,IAAG,OAAM,IAAG,MACvD,kBAAE,cAAc,MAAM,IAAI,CAAC,CAAC,QAAQ,KAAK,MACxC,oBAAC,QAAkB,QAAgB,WAAW,SAAnC,MAA0C,CACtD,GACH,GACF;AAAA,MACA,qBAAC,SAAM,WAAW,aAAa,QAAE,MAAM,IAAI,QAAE,MAAM,KACjD;AAAA,4BAAC,UAAO,IAAI,QAAE,IAAI,IAAI,IAAI,QAAE,IAAI,IAAI,GAAG,QAAE,IAAI,GAAG,MAAM,QAAE,IAAI,OAAO;AAAA,QACnE,oBAAC,QAAK,GAAG,QAAE,MAAM,GAAG,WAAW,aAAa,QAAE,MAAM,UAAU,CAAC,CAAC,IAAI,QAAE,MAAM,UAAU,CAAC,CAAC,WAAW,QAAE,MAAM,KAAK,KAAK,MAAK,eAAc;AAAA,SAC1I;AAAA,OACF,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/native/OrochiaMark.tsx","../src/marks/orochia-geometry.ts"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { AccessibilityInfo, Animated, Easing, View } from \"react-native\";\nimport Svg, { Circle, Defs, Ellipse, G as Group, LinearGradient, Path, RadialGradient, Stop } from \"react-native-svg\";\n\nimport { OROCHIA as G } from \"../marks/orochia-geometry\";\n\nexport interface NativeMarkProps {\n /** Width and height in points. */\n size?: number;\n /** The orbit turns and the flame breathes; always still when the system asks to reduce motion. */\n animated?: boolean;\n /** An accessible name (the mark becomes an image); without it the mark is decorative. */\n title?: string;\n /** The neutral strokes (orbit, ring): the host's border colour. */\n neutral?: string;\n}\n\nconst CENTER = G.offset + 180;\n\n/**\n * The Orochia mark for React Native — the same geometry as the web mark (marks/orochia-geometry.ts), drawn with\n * react-native-svg. Three layers so that the motion runs on the native driver: the orbit turns, the eye and the flame\n * breathe, the serpent stays still.\n */\nexport function OrochiaMark({ size = 48, animated = true, title, neutral = \"rgba(255,255,255,0.35)\" }: NativeMarkProps) {\n const [spin] = useState(() => new Animated.Value(0));\n const [pulse] = useState(() => new Animated.Value(0));\n useEffect(() => {\n if (!animated) return;\n let loops: Animated.CompositeAnimation[] = [];\n let cancelled = false;\n void AccessibilityInfo.isReduceMotionEnabled().then((reduce) => {\n if (reduce || cancelled) return;\n loops = [\n Animated.loop(Animated.timing(spin, { toValue: 1, duration: 30_000, easing: Easing.linear, useNativeDriver: true })),\n Animated.loop(\n Animated.sequence([\n Animated.timing(pulse, { toValue: 1, duration: 1600, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),\n Animated.timing(pulse, { toValue: 0, duration: 1600, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),\n ]),\n ),\n ];\n loops.forEach((l) => l.start());\n });\n return () => {\n cancelled = true;\n loops.forEach((l) => l.stop());\n };\n }, [animated, spin, pulse]);\n\n const viewBox = size < 48 ? G.croppedViewBox : G.viewBox;\n const layer = { position: \"absolute\" as const, width: size, height: size };\n const a11y = title ? { accessible: true, accessibilityRole: \"image\" as const, accessibilityLabel: title } : { accessibilityElementsHidden: true, importantForAccessibility: \"no-hide-descendants\" as const };\n const bodyGradient = (\n <LinearGradient id=\"body\" gradientUnits=\"userSpaceOnUse\" x1={G.body.x1 + G.offset} y1={G.body.y1 + G.offset} x2={G.body.x2 + G.offset} y2={G.body.y2 + G.offset}>\n {G.body.stops.map(([offset, color]) => (\n <Stop key={offset} offset={offset} stopColor={color} />\n ))}\n </LinearGradient>\n );\n\n return (\n <View style={{ width: size, height: size }} {...a11y}>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>\n <RadialGradient id=\"glow\" cx=\"50%\" cy=\"50%\" r=\"50%\">\n <Stop offset=\"0%\" stopColor={G.glow.color} stopOpacity={G.glow.opacity} />\n <Stop offset=\"100%\" stopColor={G.glow.color} stopOpacity={0} />\n </RadialGradient>\n </Defs>\n <Circle cx={CENTER} cy={CENTER} r={170} fill=\"url(#glow)\" />\n <Circle cx={CENTER} cy={CENTER} r={G.ring.r} stroke={neutral} strokeWidth={G.ring.width} opacity={0.35} fill=\"none\" />\n </Svg>\n <Animated.View style={[layer, { transform: [{ rotate: spin.interpolate({ inputRange: [0, 1], outputRange: [\"0deg\", \"360deg\"] }) }] }]}>\n <Svg viewBox={viewBox} style={layer}>\n <Circle cx={CENTER} cy={CENTER} r={G.orbit.r} stroke={neutral} strokeWidth={G.orbit.width} strokeDasharray={G.orbit.dash} opacity={0.6} fill=\"none\" />\n </Svg>\n </Animated.View>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>{bodyGradient}</Defs>\n <Group transform={`translate(${G.offset} ${G.offset})`}>\n <Path d={G.arc} stroke=\"url(#body)\" strokeWidth={22} strokeLinecap=\"round\" fill=\"none\" />\n <Path d={G.arc} stroke={G.scales.color} strokeOpacity={G.scales.opacity} strokeWidth={G.scales.width} strokeLinecap=\"round\" strokeDasharray={G.scales.dash} fill=\"none\" />\n <Path d={G.neck} stroke=\"url(#body)\" strokeWidth={14} strokeLinecap=\"round\" fill=\"none\" />\n <Path d={G.tail} stroke=\"url(#body)\" strokeWidth={6} strokeLinecap=\"round\" fill=\"none\" />\n <Ellipse cx={G.head.cx} cy={G.head.cy} rx={G.head.rx} ry={G.head.ry} rotation={G.head.rotate} origin={`${G.head.cx}, ${G.head.cy}`} fill=\"url(#body)\" />\n <Path d={G.tongue.d} stroke={G.tongue.color} strokeWidth={3} strokeLinecap=\"round\" fill=\"none\" />\n </Group>\n </Svg>\n <Animated.View style={[layer, { opacity: pulse.interpolate({ inputRange: [0, 1], outputRange: [0.85, 1] }) }]}>\n <Svg viewBox={viewBox} style={layer}>\n <Defs>\n <LinearGradient id=\"flame\" x1=\"50%\" y1=\"100%\" x2=\"50%\" y2=\"0%\">\n {G.flameGradient.stops.map(([offset, color]) => (\n <Stop key={offset} offset={offset} stopColor={color} />\n ))}\n </LinearGradient>\n </Defs>\n <Group transform={`translate(${G.offset} ${G.offset})`}>\n <Circle cx={G.eye.cx} cy={G.eye.cy} r={G.eye.r} fill={G.eye.color} />\n <Path d={G.flame.d} transform={`translate(${G.flame.translate[0]} ${G.flame.translate[1]}) scale(${G.flame.scale})`} fill=\"url(#flame)\" />\n </Group>\n </Svg>\n </Animated.View>\n </View>\n );\n}\n","/**\n * The Orochia mark's geometry — the one description of the serpent and its flame, drawn by the web mark (SVG in the\n * DOM, OrochiaLogo) and the native one (react-native-svg, @krizaka/ui/native). Coordinates are in the 360×360 artwork,\n * placed at (20, 20) in a 400×400 view box; below 48 px the view box crops to the serpent.\n */\nexport const OROCHIA = {\n viewBox: \"0 0 400 400\",\n croppedViewBox: \"86 82 228 228\",\n offset: 20,\n body: { x1: 70, y1: 290, x2: 290, y2: 70, stops: [[\"0%\", \"#7c3aed\"], [\"55%\", \"#d946ef\"], [\"100%\", \"#f472b6\"]] },\n flameGradient: { stops: [[\"0%\", \"#a855f7\"], [\"100%\", \"#f9a8d4\"]] },\n glow: { color: \"#d946ef\", opacity: 0.18 },\n orbit: { r: 160, dash: \"8 8\", width: 1.5 },\n ring: { r: 134, width: 1 },\n arc: \"M259.8,142.8 A88,88 0 1 1 142.8,100.2\",\n neck: \"M142.8,100.2 A88,88 0 0 1 187.7,92.3\",\n tail: \"M187.7,92.3 A88,88 0 0 1 221.3,102.3\",\n scales: { color: \"#fdf4ff\", opacity: 0.45, width: 3, dash: \"2 14\" },\n head: { cx: 253.9, cy: 130.1, rx: 13, ry: 20, rotate: -25 },\n tongue: { d: \"M245.4,112.0 L242.0,104.8 L235.0,101.5 M242.0,104.8 L244.0,97.3\", color: \"#f472b6\" },\n eye: { cx: 256.3, cy: 123.5, r: 4.5, color: \"#fdf4ff\" },\n flame: {\n translate: [127, 120] as const,\n scale: 4.4,\n d: \"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z\",\n },\n} as const;\n"],"mappings":";AAAA,SAAgB,WAAW,gBAAgB;AAC3C,SAAS,mBAAmB,UAAU,QAAQ,YAAY;AAC1D,OAAO,OAAO,QAAQ,MAAM,SAAS,KAAK,OAAO,gBAAgB,MAAM,gBAAgB,YAAY;;;ACG5F,IAAM,UAAU;AAAA,EACrB,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,QAAQ;AAAA,EACR,MAAM,EAAE,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,GAAG,CAAC,QAAQ,SAAS,CAAC,EAAE;AAAA,EAC9G,eAAe,EAAE,OAAO,CAAC,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,SAAS,CAAC,EAAE;AAAA,EACjE,MAAM,EAAE,OAAO,WAAW,SAAS,KAAK;AAAA,EACxC,OAAO,EAAE,GAAG,KAAK,MAAM,OAAO,OAAO,IAAI;AAAA,EACzC,MAAM,EAAE,GAAG,KAAK,OAAO,EAAE;AAAA,EACzB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ,EAAE,OAA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AK,IAAI,UAAU,QAAE,KAAK,QAAQ,QAAQ,GAAG,QAAE,KAAK,EAAE,KAAK,QAAE,KAAK,EAAE,IAAI,MAAK,cAAa;AAAA,QACtJ,oBAAC,QAAK,GAAG,QAAE,OAAO,GAAG,QAAQ,QAAE,OAAO,OAAO,aAAa,GAAG,eAAc,SAAQ,MAAK,QAAO;AAAA,SACjG;AAAA,OACF;AAAA,IACA,oBAAC,SAAS,MAAT,EAAc,OAAO,CAAC,OAAO,EAAE,SAAS,MAAM,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,GAC1G,+BAAC,OAAI,SAAkB,OAAO,OAC5B;AAAA,0BAAC,QACC,8BAAC,kBAAe,IAAG,SAAQ,IAAG,OAAM,IAAG,QAAO,IAAG,OAAM,IAAG,MACvD,kBAAE,cAAc,MAAM,IAAI,CAAC,CAAC,QAAQ,KAAK,MACxC,oBAAC,QAAkB,QAAgB,WAAW,SAAnC,MAA0C,CACtD,GACH,GACF;AAAA,MACA,qBAAC,SAAM,WAAW,aAAa,QAAE,MAAM,IAAI,QAAE,MAAM,KACjD;AAAA,4BAAC,UAAO,IAAI,QAAE,IAAI,IAAI,IAAI,QAAE,IAAI,IAAI,GAAG,QAAE,IAAI,GAAG,MAAM,QAAE,IAAI,OAAO;AAAA,QACnE,oBAAC,QAAK,GAAG,QAAE,MAAM,GAAG,WAAW,aAAa,QAAE,MAAM,UAAU,CAAC,CAAC,IAAI,QAAE,MAAM,UAAU,CAAC,CAAC,WAAW,QAAE,MAAM,KAAK,KAAK,MAAK,eAAc;AAAA,SAC1I;AAAA,OACF,GACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
declare const skeletonVariants: tailwind_variants.TVReturnType<{
|
|
6
|
+
shape: {
|
|
7
|
+
text: "h-3 w-full rounded-sm";
|
|
8
|
+
circle: "aspect-square h-10 rounded-full";
|
|
9
|
+
rect: "h-24 w-full rounded-lg";
|
|
10
|
+
};
|
|
11
|
+
}, undefined, "block bg-surface-3 motion-safe:animate-pulse", {
|
|
12
|
+
shape: {
|
|
13
|
+
text: "h-3 w-full rounded-sm";
|
|
14
|
+
circle: "aspect-square h-10 rounded-full";
|
|
15
|
+
rect: "h-24 w-full rounded-lg";
|
|
16
|
+
};
|
|
17
|
+
}, undefined, tailwind_variants.TVReturnTypeLike<{
|
|
18
|
+
shape: {
|
|
19
|
+
text: "h-3 w-full rounded-sm";
|
|
20
|
+
circle: "aspect-square h-10 rounded-full";
|
|
21
|
+
rect: "h-24 w-full rounded-lg";
|
|
22
|
+
};
|
|
23
|
+
}, undefined>>;
|
|
24
|
+
type SkeletonProps = React.ComponentProps<"span"> & VariantProps<typeof skeletonVariants>;
|
|
25
|
+
/** A pulsing shape the size of what is loading. Announce the wait elsewhere (aria-busy on the region, a Spinner). */
|
|
26
|
+
declare function Skeleton({ shape, className, ...props }: SkeletonProps): React.JSX.Element;
|
|
27
|
+
|
|
28
|
+
export { Skeleton, type SkeletonProps, skeletonVariants };
|
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/skeleton/skeleton.tsx
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var skeletonVariants = tv({
|
|
5
|
+
base: "block bg-surface-3 motion-safe:animate-pulse",
|
|
6
|
+
variants: {
|
|
7
|
+
shape: { text: "h-3 w-full rounded-sm", circle: "aspect-square h-10 rounded-full", rect: "h-24 w-full rounded-lg" }
|
|
8
|
+
},
|
|
9
|
+
defaultVariants: { shape: "text" }
|
|
10
|
+
});
|
|
11
|
+
function Skeleton({ shape, className, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": true, "data-shape": shape ?? "text", className: skeletonVariants({ shape, className }), ...props });
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
Skeleton,
|
|
16
|
+
skeletonVariants
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/skeleton/skeleton.tsx"],"sourcesContent":["// Server-safe. A placeholder for content on its way: decorative, so hidden from assistive technology.\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const skeletonVariants = tv({\n base: \"block bg-surface-3 motion-safe:animate-pulse\",\n variants: {\n shape: { text: \"h-3 w-full rounded-sm\", circle: \"aspect-square h-10 rounded-full\", rect: \"h-24 w-full rounded-lg\" },\n },\n defaultVariants: { shape: \"text\" },\n});\n\nexport type SkeletonProps = React.ComponentProps<\"span\"> & VariantProps<typeof skeletonVariants>;\n\n/** A pulsing shape the size of what is loading. Announce the wait elsewhere (aria-busy on the region, a Spinner). */\nexport function Skeleton({ shape, className, ...props }: SkeletonProps) {\n return <span aria-hidden data-shape={shape ?? \"text\"} className={skeletonVariants({ shape, className })} {...props} />;\n}\n"],"mappings":";AAEA,SAAS,UAA6B;AAc7B;AAZF,IAAM,mBAAmB,GAAG;AAAA,EACjC,MAAM;AAAA,EACN,UAAU;AAAA,IACR,OAAO,EAAE,MAAM,yBAAyB,QAAQ,mCAAmC,MAAM,yBAAyB;AAAA,EACpH;AAAA,EACA,iBAAiB,EAAE,OAAO,OAAO;AACnC,CAAC;AAKM,SAAS,SAAS,EAAE,OAAO,WAAW,GAAG,MAAM,GAAkB;AACtE,SAAO,oBAAC,UAAK,eAAW,MAAC,cAAY,SAAS,QAAQ,WAAW,iBAAiB,EAAE,OAAO,UAAU,CAAC,GAAI,GAAG,OAAO;AACtH;","names":[]}
|
package/dist/slot.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { VisuallyHidden as VisuallyHidden$1 } from 'radix-ui';
|
|
3
|
+
|
|
4
|
+
/** Merges its props, `className` and `ref` into its only child: the engine of every `asChild`. */
|
|
5
|
+
declare const Slot: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLElement> & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
} & React$1.RefAttributes<HTMLElement>>;
|
|
8
|
+
/** Hidden on screen, read by assistive technology. */
|
|
9
|
+
declare const VisuallyHidden: React$1.ForwardRefExoticComponent<VisuallyHidden$1.VisuallyHiddenProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
10
|
+
|
|
11
|
+
export { Slot, VisuallyHidden };
|
package/dist/slot.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/slot/index.ts
|
|
2
|
+
import { Slot as SlotPrimitive, VisuallyHidden as VisuallyHiddenPrimitive } from "radix-ui";
|
|
3
|
+
var Slot = SlotPrimitive.Root;
|
|
4
|
+
var VisuallyHidden = VisuallyHiddenPrimitive.Root;
|
|
5
|
+
export {
|
|
6
|
+
Slot,
|
|
7
|
+
VisuallyHidden
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=slot.js.map
|
package/dist/slot.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/slot/index.ts"],"sourcesContent":["/** @krizaka/ui/slot — `Slot` (what `asChild` renders) and `VisuallyHidden` (a name for assistive technology only), from Radix. */\nimport { Slot as SlotPrimitive, VisuallyHidden as VisuallyHiddenPrimitive } from \"radix-ui\";\n\n/** Merges its props, `className` and `ref` into its only child: the engine of every `asChild`. */\nexport const Slot = SlotPrimitive.Root;\n/** Hidden on screen, read by assistive technology. */\nexport const VisuallyHidden = VisuallyHiddenPrimitive.Root;\n"],"mappings":";AACA,SAAS,QAAQ,eAAe,kBAAkB,+BAA+B;AAG1E,IAAM,OAAO,cAAc;AAE3B,IAAM,iBAAiB,wBAAwB;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
declare const spinnerVariants: tailwind_variants.TVReturnType<{
|
|
6
|
+
size: {
|
|
7
|
+
sm: "h-4 w-4";
|
|
8
|
+
md: "h-6 w-6";
|
|
9
|
+
lg: "h-10 w-10";
|
|
10
|
+
};
|
|
11
|
+
}, undefined, "shrink-0 text-accent motion-safe:animate-spin", {
|
|
12
|
+
size: {
|
|
13
|
+
sm: "h-4 w-4";
|
|
14
|
+
md: "h-6 w-6";
|
|
15
|
+
lg: "h-10 w-10";
|
|
16
|
+
};
|
|
17
|
+
}, undefined, tailwind_variants.TVReturnTypeLike<{
|
|
18
|
+
size: {
|
|
19
|
+
sm: "h-4 w-4";
|
|
20
|
+
md: "h-6 w-6";
|
|
21
|
+
lg: "h-10 w-10";
|
|
22
|
+
};
|
|
23
|
+
}, undefined>>;
|
|
24
|
+
type SpinnerProps = Omit<React.ComponentProps<"svg">, "children"> & VariantProps<typeof spinnerVariants> & {
|
|
25
|
+
/** The accessible name of the wait, e.g. "Loading" — passed translated. */
|
|
26
|
+
label: string;
|
|
27
|
+
};
|
|
28
|
+
/** A turning ring with `role="status"` (it stops turning under prefers-reduced-motion). */
|
|
29
|
+
declare function Spinner({ label, size, className, ...props }: SpinnerProps): React.JSX.Element;
|
|
30
|
+
|
|
31
|
+
export { Spinner, type SpinnerProps, spinnerVariants };
|
package/dist/spinner.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/spinner/spinner.tsx
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var spinnerVariants = tv({
|
|
5
|
+
base: "shrink-0 text-accent motion-safe:animate-spin",
|
|
6
|
+
variants: { size: { sm: "h-4 w-4", md: "h-6 w-6", lg: "h-10 w-10" } },
|
|
7
|
+
defaultVariants: { size: "md" }
|
|
8
|
+
});
|
|
9
|
+
function Spinner({ label, size, className, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
"svg",
|
|
12
|
+
{
|
|
13
|
+
role: "status",
|
|
14
|
+
"aria-label": label,
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
fill: "none",
|
|
17
|
+
"data-size": size ?? "md",
|
|
18
|
+
className: spinnerVariants({ size, className }),
|
|
19
|
+
...props,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeOpacity: "0.2", strokeWidth: "3" }),
|
|
22
|
+
/* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 0 0-9-9", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round" })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
Spinner,
|
|
29
|
+
spinnerVariants
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/spinner/spinner.tsx"],"sourcesContent":["// Server-safe. An indeterminate wait: an SVG ring, announced as a status with its `label`.\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const spinnerVariants = tv({\n base: \"shrink-0 text-accent motion-safe:animate-spin\",\n variants: { size: { sm: \"h-4 w-4\", md: \"h-6 w-6\", lg: \"h-10 w-10\" } },\n defaultVariants: { size: \"md\" },\n});\n\nexport type SpinnerProps = Omit<React.ComponentProps<\"svg\">, \"children\"> &\n VariantProps<typeof spinnerVariants> & {\n /** The accessible name of the wait, e.g. \"Loading\" — passed translated. */\n label: string;\n };\n\n/** A turning ring with `role=\"status\"` (it stops turning under prefers-reduced-motion). */\nexport function Spinner({ label, size, className, ...props }: SpinnerProps) {\n return (\n <svg\n role=\"status\"\n aria-label={label}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n data-size={size ?? \"md\"}\n className={spinnerVariants({ size, className })}\n {...props}\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" stroke=\"currentColor\" strokeOpacity=\"0.2\" strokeWidth=\"3\" />\n <path d=\"M21 12a9 9 0 0 0-9-9\" stroke=\"currentColor\" strokeWidth=\"3\" strokeLinecap=\"round\" />\n </svg>\n );\n}\n"],"mappings":";AAEA,SAAS,UAA6B;AAiBlC,SASE,KATF;AAfG,IAAM,kBAAkB,GAAG;AAAA,EAChC,MAAM;AAAA,EACN,UAAU,EAAE,MAAM,EAAE,IAAI,WAAW,IAAI,WAAW,IAAI,YAAY,EAAE;AAAA,EACpE,iBAAiB,EAAE,MAAM,KAAK;AAChC,CAAC;AASM,SAAS,QAAQ,EAAE,OAAO,MAAM,WAAW,GAAG,MAAM,GAAiB;AAC1E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,aAAW,QAAQ;AAAA,MACnB,WAAW,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAAA,MAC7C,GAAG;AAAA,MAEJ;AAAA,4BAAC,YAAO,IAAG,MAAK,IAAG,MAAK,GAAE,KAAI,QAAO,gBAAe,eAAc,OAAM,aAAY,KAAI;AAAA,QACxF,oBAAC,UAAK,GAAE,wBAAuB,QAAO,gBAAe,aAAY,KAAI,eAAc,SAAQ;AAAA;AAAA;AAAA,EAC7F;AAEJ;","names":[]}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
3
|
+
import { VariantProps } from 'tailwind-variants';
|
|
4
|
+
|
|
5
|
+
declare const buttonVariants: tailwind_variants.TVReturnType<{
|
|
6
|
+
variant: {
|
|
7
|
+
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
8
|
+
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
9
|
+
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
10
|
+
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
11
|
+
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
12
|
+
};
|
|
13
|
+
size: {
|
|
14
|
+
sm: "h-8 px-3 text-xs";
|
|
15
|
+
md: "h-10 px-4 text-sm";
|
|
16
|
+
lg: "h-12 px-6 text-sm";
|
|
17
|
+
icon: "h-10 w-10";
|
|
18
|
+
};
|
|
19
|
+
shape: {
|
|
20
|
+
rounded: "rounded-lg";
|
|
21
|
+
pill: "rounded-full";
|
|
22
|
+
};
|
|
23
|
+
}, undefined, string, {
|
|
24
|
+
variant: {
|
|
25
|
+
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
26
|
+
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
27
|
+
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
28
|
+
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
29
|
+
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
30
|
+
};
|
|
31
|
+
size: {
|
|
32
|
+
sm: "h-8 px-3 text-xs";
|
|
33
|
+
md: "h-10 px-4 text-sm";
|
|
34
|
+
lg: "h-12 px-6 text-sm";
|
|
35
|
+
icon: "h-10 w-10";
|
|
36
|
+
};
|
|
37
|
+
shape: {
|
|
38
|
+
rounded: "rounded-lg";
|
|
39
|
+
pill: "rounded-full";
|
|
40
|
+
};
|
|
41
|
+
}, undefined, tailwind_variants.TVReturnTypeLike<{
|
|
42
|
+
variant: {
|
|
43
|
+
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover";
|
|
44
|
+
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3";
|
|
45
|
+
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent";
|
|
46
|
+
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg";
|
|
47
|
+
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20";
|
|
48
|
+
};
|
|
49
|
+
size: {
|
|
50
|
+
sm: "h-8 px-3 text-xs";
|
|
51
|
+
md: "h-10 px-4 text-sm";
|
|
52
|
+
lg: "h-12 px-6 text-sm";
|
|
53
|
+
icon: "h-10 w-10";
|
|
54
|
+
};
|
|
55
|
+
shape: {
|
|
56
|
+
rounded: "rounded-lg";
|
|
57
|
+
pill: "rounded-full";
|
|
58
|
+
};
|
|
59
|
+
}, undefined>>;
|
|
60
|
+
type ButtonVariants = VariantProps<typeof buttonVariants>;
|
|
61
|
+
|
|
62
|
+
type Mode = "dark" | "light" | "system";
|
|
63
|
+
/**
|
|
64
|
+
* In <head>, before anything renders: applies the persisted mode and named theme, so the page never flashes.
|
|
65
|
+
* `nonce` for a strict Content-Security-Policy.
|
|
66
|
+
*/
|
|
67
|
+
declare function ThemeScript({ nonce }: {
|
|
68
|
+
nonce?: string;
|
|
69
|
+
}): React.JSX.Element;
|
|
70
|
+
type ThemeContextValue = {
|
|
71
|
+
/** The chosen mode: dark, light or follow the system. */
|
|
72
|
+
mode: Mode;
|
|
73
|
+
setMode: (mode: Mode) => void;
|
|
74
|
+
/** The named theme (`html.theme-<name>`), or null. */
|
|
75
|
+
theme: string | null;
|
|
76
|
+
setTheme: (theme: string | null) => void;
|
|
77
|
+
};
|
|
78
|
+
type ThemeProviderProps = {
|
|
79
|
+
children: React.ReactNode;
|
|
80
|
+
/** The mode before anything is persisted. */
|
|
81
|
+
defaultMode?: Mode;
|
|
82
|
+
};
|
|
83
|
+
declare function ThemeProvider({ children, defaultMode }: ThemeProviderProps): React.JSX.Element;
|
|
84
|
+
declare function useTheme(): ThemeContextValue;
|
|
85
|
+
type ThemeToggleProps = Omit<React.ComponentProps<"button">, "onClick" | "children"> & Pick<ButtonVariants, "variant" | "shape"> & {
|
|
86
|
+
/** The accessible name — a string, or one per current mode (e.g. `(mode) => t("theme." + mode)`). */
|
|
87
|
+
label: string | ((mode: Mode) => string);
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* An icon button (styled as `IconButton`, without its Slot) that cycles dark → light → system. Needs a
|
|
91
|
+
* <ThemeProvider> above it. State: `data-mode`.
|
|
92
|
+
*/
|
|
93
|
+
declare function ThemeToggle({ label, variant, shape, className, ...props }: ThemeToggleProps): React.JSX.Element;
|
|
94
|
+
|
|
95
|
+
export { type Mode, type ThemeContextValue, ThemeProvider, type ThemeProviderProps, ThemeScript, ThemeToggle, type ThemeToggleProps, useTheme };
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/theme/theme.tsx
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
// src/button/button.tsx
|
|
7
|
+
import { Slot } from "radix-ui";
|
|
8
|
+
import { tv } from "tailwind-variants";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var buttonVariants = tv({
|
|
11
|
+
base: "inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap font-semibold transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 disabled:pointer-events-none disabled:opacity-40 data-loading:cursor-progress active:scale-[0.98]",
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
primary: "bg-accent text-on-accent shadow-sm hover:bg-accent-hover",
|
|
15
|
+
secondary: "border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3",
|
|
16
|
+
outline: "border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent",
|
|
17
|
+
ghost: "text-fg-secondary hover:bg-surface-2 hover:text-fg",
|
|
18
|
+
// The danger token is invariant and too light for small text on a light surface (3.6:1): the label stays a
|
|
19
|
+
// text role, the border and the tint carry the danger.
|
|
20
|
+
danger: "border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20"
|
|
21
|
+
},
|
|
22
|
+
size: { sm: "h-8 px-3 text-xs", md: "h-10 px-4 text-sm", lg: "h-12 px-6 text-sm", icon: "h-10 w-10" },
|
|
23
|
+
shape: { rounded: "rounded-lg", pill: "rounded-full" }
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: { variant: "secondary", size: "md", shape: "rounded" }
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// src/theme/theme.tsx
|
|
29
|
+
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
30
|
+
var MODE_KEY = "kz-theme";
|
|
31
|
+
var NAME_KEY = "kz-theme-name";
|
|
32
|
+
var MODES = ["dark", "light", "system"];
|
|
33
|
+
var DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
34
|
+
var isMode = (value) => MODES.includes(value);
|
|
35
|
+
var memory = /* @__PURE__ */ new Map();
|
|
36
|
+
function read(key) {
|
|
37
|
+
try {
|
|
38
|
+
return localStorage.getItem(key);
|
|
39
|
+
} catch {
|
|
40
|
+
return memory.get(key) ?? null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function write(key, value) {
|
|
44
|
+
if (value === null) memory.delete(key);
|
|
45
|
+
else memory.set(key, value);
|
|
46
|
+
try {
|
|
47
|
+
if (value === null) localStorage.removeItem(key);
|
|
48
|
+
else localStorage.setItem(key, value);
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
53
|
+
var notify = () => listeners.forEach((listener) => listener());
|
|
54
|
+
function subscribe(listener) {
|
|
55
|
+
listeners.add(listener);
|
|
56
|
+
window.addEventListener("storage", listener);
|
|
57
|
+
return () => {
|
|
58
|
+
listeners.delete(listener);
|
|
59
|
+
window.removeEventListener("storage", listener);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function applyMode(mode) {
|
|
63
|
+
const dark = window.matchMedia(DARK_QUERY).matches;
|
|
64
|
+
document.documentElement.classList.toggle("light", mode === "light" || mode === "system" && !dark);
|
|
65
|
+
}
|
|
66
|
+
function applyName(previous, next) {
|
|
67
|
+
const classes = document.documentElement.classList;
|
|
68
|
+
if (previous) classes.remove(`theme-${previous}`);
|
|
69
|
+
if (next) classes.add(`theme-${next}`);
|
|
70
|
+
}
|
|
71
|
+
function ThemeScript({ nonce }) {
|
|
72
|
+
const js = `(function(){try{var m=localStorage.getItem("${MODE_KEY}")||"system";var n=localStorage.getItem("${NAME_KEY}");var d=matchMedia("${DARK_QUERY}").matches;var c=document.documentElement.classList;c.toggle("light",m==="light"||(m==="system"&&!d));if(n)c.add("theme-"+n)}catch(e){}})()`;
|
|
73
|
+
return /* @__PURE__ */ jsx2("script", { nonce, dangerouslySetInnerHTML: { __html: js } });
|
|
74
|
+
}
|
|
75
|
+
var ThemeContext = React.createContext(null);
|
|
76
|
+
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
77
|
+
const stored = React.useSyncExternalStore(subscribe, () => read(MODE_KEY), () => null);
|
|
78
|
+
const mode = isMode(stored) ? stored : defaultMode;
|
|
79
|
+
const theme = React.useSyncExternalStore(subscribe, () => read(NAME_KEY), () => null);
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
if (mode !== "system") return;
|
|
82
|
+
const query = window.matchMedia(DARK_QUERY);
|
|
83
|
+
const onChange = () => applyMode("system");
|
|
84
|
+
query.addEventListener?.("change", onChange);
|
|
85
|
+
return () => query.removeEventListener?.("change", onChange);
|
|
86
|
+
}, [mode]);
|
|
87
|
+
const setMode = React.useCallback((next) => {
|
|
88
|
+
write(MODE_KEY, next);
|
|
89
|
+
applyMode(next);
|
|
90
|
+
notify();
|
|
91
|
+
}, []);
|
|
92
|
+
const setTheme = React.useCallback((next) => {
|
|
93
|
+
applyName(read(NAME_KEY), next);
|
|
94
|
+
write(NAME_KEY, next);
|
|
95
|
+
notify();
|
|
96
|
+
}, []);
|
|
97
|
+
const value = React.useMemo(() => ({ mode, setMode, theme, setTheme }), [mode, setMode, theme, setTheme]);
|
|
98
|
+
return /* @__PURE__ */ jsx2(ThemeContext.Provider, { value, children });
|
|
99
|
+
}
|
|
100
|
+
function useTheme() {
|
|
101
|
+
const context = React.useContext(ThemeContext);
|
|
102
|
+
if (!context) throw new Error("useTheme: wrap the app in <ThemeProvider>");
|
|
103
|
+
return context;
|
|
104
|
+
}
|
|
105
|
+
var ICONS = {
|
|
106
|
+
dark: /* @__PURE__ */ jsx2("path", { d: "M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z" }),
|
|
107
|
+
light: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
+
/* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "4" }),
|
|
109
|
+
/* @__PURE__ */ jsx2("path", { d: "M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" })
|
|
110
|
+
] }),
|
|
111
|
+
system: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
112
|
+
/* @__PURE__ */ jsx2("rect", { x: "3", y: "4", width: "18", height: "12", rx: "2" }),
|
|
113
|
+
/* @__PURE__ */ jsx2("path", { d: "M8 20h8M12 16v4" })
|
|
114
|
+
] })
|
|
115
|
+
};
|
|
116
|
+
function ThemeToggle({ label, variant = "ghost", shape, className, ...props }) {
|
|
117
|
+
const { mode, setMode } = useTheme();
|
|
118
|
+
const next = MODES[(MODES.indexOf(mode) + 1) % MODES.length];
|
|
119
|
+
const name = typeof label === "function" ? label(mode) : label;
|
|
120
|
+
return /* @__PURE__ */ jsx2(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
"aria-label": name,
|
|
125
|
+
title: name,
|
|
126
|
+
"data-mode": mode,
|
|
127
|
+
onClick: () => setMode(next),
|
|
128
|
+
className: buttonVariants({ variant, shape, size: "icon", className }),
|
|
129
|
+
...props,
|
|
130
|
+
children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 24 24", className: "h-5 w-5", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: ICONS[mode] })
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
ThemeProvider,
|
|
136
|
+
ThemeScript,
|
|
137
|
+
ThemeToggle,
|
|
138
|
+
useTheme
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/theme/theme.tsx","../src/button/button.tsx"],"sourcesContent":["// Client. ONE mechanism for the whole organisation: dark by default, `html.light` for light, `html.theme-<name>` for a\n// named theme, persisted in localStorage (`kz-theme` for the mode, `kz-theme-name` for the named theme).\nimport * as React from \"react\";\n\nimport { type ButtonVariants, buttonVariants } from \"../button/button\";\n\nexport type Mode = \"dark\" | \"light\" | \"system\";\n\nconst MODE_KEY = \"kz-theme\";\nconst NAME_KEY = \"kz-theme-name\";\nconst MODES: readonly Mode[] = [\"dark\", \"light\", \"system\"];\nconst DARK_QUERY = \"(prefers-color-scheme: dark)\";\n\nconst isMode = (value: unknown): value is Mode => MODES.includes(value as Mode);\n\n// Storage blocked (private mode, sandbox): the choice lives in memory for the page.\nconst memory = new Map<string, string>();\n\nfunction read(key: string): string | null {\n try {\n return localStorage.getItem(key);\n } catch {\n return memory.get(key) ?? null;\n }\n}\n\nfunction write(key: string, value: string | null) {\n if (value === null) memory.delete(key);\n else memory.set(key, value);\n try {\n if (value === null) localStorage.removeItem(key);\n else localStorage.setItem(key, value);\n } catch {\n // storage blocked: memory holds it\n }\n}\n\n// The persisted choice is an external store: every provider and tab reads the same value, the server reads none.\nconst listeners = new Set<() => void>();\nconst notify = () => listeners.forEach((listener) => listener());\nfunction subscribe(listener: () => void) {\n listeners.add(listener);\n window.addEventListener(\"storage\", listener);\n return () => {\n listeners.delete(listener);\n window.removeEventListener(\"storage\", listener);\n };\n}\n\nfunction applyMode(mode: Mode) {\n const dark = window.matchMedia(DARK_QUERY).matches;\n document.documentElement.classList.toggle(\"light\", mode === \"light\" || (mode === \"system\" && !dark));\n}\n\nfunction applyName(previous: string | null, next: string | null) {\n const classes = document.documentElement.classList;\n if (previous) classes.remove(`theme-${previous}`);\n if (next) classes.add(`theme-${next}`);\n}\n\n/**\n * In <head>, before anything renders: applies the persisted mode and named theme, so the page never flashes.\n * `nonce` for a strict Content-Security-Policy.\n */\nexport function ThemeScript({ nonce }: { nonce?: string }) {\n const js =\n `(function(){try{var m=localStorage.getItem(\"${MODE_KEY}\")||\"system\";var n=localStorage.getItem(\"${NAME_KEY}\");` +\n `var d=matchMedia(\"${DARK_QUERY}\").matches;var c=document.documentElement.classList;` +\n `c.toggle(\"light\",m===\"light\"||(m===\"system\"&&!d));if(n)c.add(\"theme-\"+n)}catch(e){}})()`;\n return <script nonce={nonce} dangerouslySetInnerHTML={{ __html: js }} />;\n}\n\nexport type ThemeContextValue = {\n /** The chosen mode: dark, light or follow the system. */\n mode: Mode;\n setMode: (mode: Mode) => void;\n /** The named theme (`html.theme-<name>`), or null. */\n theme: string | null;\n setTheme: (theme: string | null) => void;\n};\n\nconst ThemeContext = React.createContext<ThemeContextValue | null>(null);\n\nexport type ThemeProviderProps = {\n children: React.ReactNode;\n /** The mode before anything is persisted. */\n defaultMode?: Mode;\n};\n\nexport function ThemeProvider({ children, defaultMode = \"system\" }: ThemeProviderProps) {\n // Before hydration the server knows nothing persisted (ThemeScript has already applied it to <html>).\n const stored = React.useSyncExternalStore(subscribe, () => read(MODE_KEY), () => null);\n const mode: Mode = isMode(stored) ? stored : defaultMode;\n const theme = React.useSyncExternalStore(subscribe, () => read(NAME_KEY), () => null);\n\n // \"system\" follows the operating system while the page is open.\n React.useEffect(() => {\n if (mode !== \"system\") return;\n const query = window.matchMedia(DARK_QUERY);\n const onChange = () => applyMode(\"system\");\n query.addEventListener?.(\"change\", onChange);\n return () => query.removeEventListener?.(\"change\", onChange);\n }, [mode]);\n\n const setMode = React.useCallback((next: Mode) => {\n write(MODE_KEY, next);\n applyMode(next);\n notify();\n }, []);\n\n const setTheme = React.useCallback((next: string | null) => {\n applyName(read(NAME_KEY), next);\n write(NAME_KEY, next);\n notify();\n }, []);\n\n const value = React.useMemo(() => ({ mode, setMode, theme, setTheme }), [mode, setMode, theme, setTheme]);\n return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;\n}\n\nexport function useTheme(): ThemeContextValue {\n const context = React.useContext(ThemeContext);\n if (!context) throw new Error(\"useTheme: wrap the app in <ThemeProvider>\");\n return context;\n}\n\nconst ICONS: Record<Mode, React.ReactNode> = {\n dark: <path d=\"M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z\" />,\n light: (\n <>\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <path d=\"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4\" />\n </>\n ),\n system: (\n <>\n <rect x=\"3\" y=\"4\" width=\"18\" height=\"12\" rx=\"2\" />\n <path d=\"M8 20h8M12 16v4\" />\n </>\n ),\n};\n\nexport type ThemeToggleProps = Omit<React.ComponentProps<\"button\">, \"onClick\" | \"children\"> &\n Pick<ButtonVariants, \"variant\" | \"shape\"> & {\n /** The accessible name — a string, or one per current mode (e.g. `(mode) => t(\"theme.\" + mode)`). */\n label: string | ((mode: Mode) => string);\n };\n\n/**\n * An icon button (styled as `IconButton`, without its Slot) that cycles dark → light → system. Needs a\n * <ThemeProvider> above it. State: `data-mode`.\n */\nexport function ThemeToggle({ label, variant = \"ghost\", shape, className, ...props }: ThemeToggleProps) {\n const { mode, setMode } = useTheme();\n const next = MODES[(MODES.indexOf(mode) + 1) % MODES.length] as Mode;\n const name = typeof label === \"function\" ? label(mode) : label;\n return (\n <button\n type=\"button\"\n aria-label={name}\n title={name}\n data-mode={mode}\n onClick={() => setMode(next)}\n className={buttonVariants({ variant, shape, size: \"icon\", className })}\n {...props}\n >\n <svg viewBox=\"0 0 24 24\" className=\"h-5 w-5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n {ICONS[mode]}\n </svg>\n </button>\n );\n}\n","// Server-safe: no hook, no context. `buttonVariants` styles a <Link> or a Server Component without the component.\nimport { Slot } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const buttonVariants = tv({\n base:\n \"inline-flex shrink-0 select-none items-center justify-center gap-2 whitespace-nowrap font-semibold transition-all \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 \" +\n \"disabled:pointer-events-none disabled:opacity-40 data-loading:cursor-progress active:scale-[0.98]\",\n variants: {\n variant: {\n primary: \"bg-accent text-on-accent shadow-sm hover:bg-accent-hover\",\n secondary: \"border border-border-default bg-surface-2 text-fg hover:border-border-strong hover:bg-surface-3\",\n outline: \"border border-border-default bg-transparent text-fg hover:border-accent hover:text-accent\",\n ghost: \"text-fg-secondary hover:bg-surface-2 hover:text-fg\",\n // The danger token is invariant and too light for small text on a light surface (3.6:1): the label stays a\n // text role, the border and the tint carry the danger.\n danger: \"border border-danger/50 bg-danger/10 text-fg hover:border-danger hover:bg-danger/20\",\n },\n size: { sm: \"h-8 px-3 text-xs\", md: \"h-10 px-4 text-sm\", lg: \"h-12 px-6 text-sm\", icon: \"h-10 w-10\" },\n shape: { rounded: \"rounded-lg\", pill: \"rounded-full\" },\n },\n defaultVariants: { variant: \"secondary\", size: \"md\", shape: \"rounded\" },\n});\n\nexport type ButtonVariants = VariantProps<typeof buttonVariants>;\n\nexport type ButtonProps = React.ComponentProps<\"button\"> &\n ButtonVariants & {\n /** Renders the child (e.g. a <Link>) instead of the <button>, with props, classes and ref merged. */\n asChild?: boolean;\n /** Disables and signals the wait (aria-busy, data-loading) — the product adds a spinner if it wants one. */\n loading?: boolean;\n };\n\nexport function Button({ asChild, loading, variant, size, shape, className, disabled, ...props }: ButtonProps) {\n const Comp = asChild ? Slot.Root : \"button\";\n return (\n <Comp\n type={asChild ? undefined : \"button\"}\n aria-busy={loading || undefined}\n data-loading={loading ? \"\" : undefined}\n data-variant={variant ?? \"secondary\"}\n disabled={asChild ? undefined : disabled || loading}\n aria-disabled={asChild && (disabled || loading) ? true : undefined}\n className={buttonVariants({ variant, size, shape, className })}\n {...props}\n />\n );\n}\n\nexport type IconButtonProps = Omit<ButtonProps, \"size\"> & {\n /** The accessible name (and tooltip) of the button — required, passed translated. */\n label: string;\n size?: ButtonProps[\"size\"];\n};\n\n/** An icon-only button: `label` is required, it is its accessible name. */\nexport function IconButton({ label, size = \"icon\", ...props }: IconButtonProps) {\n return <Button aria-label={label} title={label} size={size} {...props} />;\n}\n"],"mappings":";;;AAEA,YAAY,WAAW;;;ACDvB,SAAS,YAAY;AAErB,SAAS,UAA6B;AAoClC;AAlCG,IAAM,iBAAiB,GAAG;AAAA,EAC/B,MACE;AAAA,EAGF,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,MACT,WAAW;AAAA,MACX,SAAS;AAAA,MACT,OAAO;AAAA;AAAA;AAAA,MAGP,QAAQ;AAAA,IACV;AAAA,IACA,MAAM,EAAE,IAAI,oBAAoB,IAAI,qBAAqB,IAAI,qBAAqB,MAAM,YAAY;AAAA,IACpG,OAAO,EAAE,SAAS,cAAc,MAAM,eAAe;AAAA,EACvD;AAAA,EACA,iBAA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