@newtonedev/components 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composites/actions/Button/Button.d.ts.map +1 -1
- package/dist/composites/form-controls/Select/Select.styles.d.ts.map +1 -1
- package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts.map +1 -1
- package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts.map +1 -1
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts.map +1 -1
- package/dist/fonts/GoogleFontLoader.d.ts +5 -4
- package/dist/fonts/GoogleFontLoader.d.ts.map +1 -1
- package/dist/fonts/SelfHostedFontLoader.d.ts +14 -0
- package/dist/fonts/SelfHostedFontLoader.d.ts.map +1 -0
- package/dist/fonts/buildGoogleFontsUrl.d.ts +1 -16
- package/dist/fonts/buildGoogleFontsUrl.d.ts.map +1 -1
- package/dist/fonts/measureFont.d.ts +18 -0
- package/dist/fonts/measureFont.d.ts.map +1 -0
- package/dist/fonts/reportQueue.d.ts +7 -0
- package/dist/fonts/reportQueue.d.ts.map +1 -0
- package/dist/fonts/useLocalCalibration.d.ts +19 -0
- package/dist/fonts/useLocalCalibration.d.ts.map +1 -0
- package/dist/fonts/useTypographyCalibrations.d.ts +11 -0
- package/dist/fonts/useTypographyCalibrations.d.ts.map +1 -0
- package/dist/index.cjs +629 -422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +568 -376
- package/dist/index.js.map +1 -1
- package/dist/primitives/Icon/Icon.types.d.ts +1 -1
- package/dist/primitives/Icon/Icon.types.d.ts.map +1 -1
- package/dist/primitives/Text/Text.d.ts +33 -8
- package/dist/primitives/Text/Text.d.ts.map +1 -1
- package/dist/primitives/Text/Text.spans.d.ts +22 -0
- package/dist/primitives/Text/Text.spans.d.ts.map +1 -0
- package/dist/primitives/Text/Text.types.d.ts +77 -27
- package/dist/primitives/Text/Text.types.d.ts.map +1 -1
- package/dist/primitives/Text/index.d.ts +23 -2
- package/dist/primitives/Text/index.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/registry/codegen.d.ts.map +1 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/types.d.ts +2 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/theme/NewtoneProvider.d.ts +9 -1
- package/dist/theme/NewtoneProvider.d.ts.map +1 -1
- package/dist/theme/defaults.d.ts +1 -0
- package/dist/theme/defaults.d.ts.map +1 -1
- package/dist/theme/types.d.ts +48 -32
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/useBreakpoint.d.ts +9 -0
- package/dist/theme/useBreakpoint.d.ts.map +1 -0
- package/dist/tokens/computeTokens.d.ts +9 -22
- package/dist/tokens/computeTokens.d.ts.map +1 -1
- package/dist/tokens/types.d.ts +40 -22
- package/dist/tokens/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/composites/actions/Button/Button.styles.ts +3 -3
- package/src/composites/actions/Button/Button.tsx +3 -2
- package/src/composites/form-controls/Select/Select.styles.ts +8 -8
- package/src/composites/form-controls/Select/Select.tsx +1 -1
- package/src/composites/form-controls/Select/SelectOption.tsx +3 -3
- package/src/composites/form-controls/TextInput/TextInput.styles.ts +5 -5
- package/src/composites/form-controls/Toggle/Toggle.styles.ts +3 -3
- package/src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.ts +6 -6
- package/src/composites/range-inputs/HueSlider/HueSlider.styles.ts +9 -9
- package/src/composites/range-inputs/Slider/Slider.styles.ts +9 -9
- package/src/fonts/GoogleFontLoader.tsx +25 -10
- package/src/fonts/SelfHostedFontLoader.tsx +44 -0
- package/src/fonts/buildGoogleFontsUrl.ts +2 -31
- package/src/fonts/measureFont.ts +42 -0
- package/src/fonts/reportQueue.ts +54 -0
- package/src/fonts/useLocalCalibration.ts +97 -0
- package/src/fonts/useTypographyCalibrations.ts +15 -0
- package/src/index.ts +16 -7
- package/src/primitives/Frame/Frame.tsx +3 -3
- package/src/primitives/Icon/Icon.tsx +1 -1
- package/src/primitives/Icon/Icon.types.ts +1 -1
- package/src/primitives/Text/Text.spans.ts +57 -0
- package/src/primitives/Text/Text.tsx +208 -53
- package/src/primitives/Text/Text.types.ts +83 -27
- package/src/primitives/Text/index.ts +27 -3
- package/src/primitives/index.ts +3 -2
- package/src/registry/codegen.ts +1 -0
- package/src/registry/registry.ts +55 -53
- package/src/registry/types.ts +2 -0
- package/src/theme/NewtoneProvider.tsx +18 -2
- package/src/theme/defaults.ts +8 -28
- package/src/theme/types.ts +63 -33
- package/src/theme/useBreakpoint.ts +14 -0
- package/src/tokens/computeTokens.ts +23 -19
- package/src/tokens/types.ts +10 -24
- package/dist/fonts/googleFonts.d.ts +0 -20
- package/dist/fonts/googleFonts.d.ts.map +0 -1
- package/src/fonts/googleFonts.ts +0 -87
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DEFAULT_NEUTRAL_SATURATION, DEFAULT_NEUTRAL_HUE, DEFAULT_ACCENT_SATURATION, DEFAULT_ACCENT_HUE, DEFAULT_SUCCESS_SATURATION, DEFAULT_SUCCESS_HUE, DEFAULT_WARNING_SATURATION, DEFAULT_WARNING_HUE, DEFAULT_ERROR_SATURATION, DEFAULT_ERROR_HUE
|
|
3
|
-
import {
|
|
1
|
+
import React14, { createContext, useState, useMemo, useEffect, useContext, useCallback, useRef } from 'react';
|
|
2
|
+
import { srgbToHex, getColor, DEFAULT_NEUTRAL_SATURATION, DEFAULT_NEUTRAL_HUE, DEFAULT_ACCENT_SATURATION, DEFAULT_ACCENT_HUE, DEFAULT_SUCCESS_SATURATION, DEFAULT_SUCCESS_HUE, DEFAULT_WARNING_SATURATION, DEFAULT_WARNING_HUE, DEFAULT_ERROR_SATURATION, DEFAULT_ERROR_HUE } from 'newtone';
|
|
3
|
+
import { SEMANTIC_WEIGHT_MAP, ROLE_DEFAULT_WEIGHTS, BREAKPOINT_ROLE_SCALE, scaleRoleStep, resolveResponsiveSize, estimateLineWidths, REFERENCE_LINE_HEIGHT_RATIO, buildFontFeatureSettings, getBreakpointForWidth, fontConfigToFamily, DEFAULT_ROLE_SCALES, DEFAULT_LINE_HEIGHTS, DEFAULT_FONT_SIZES, DEFAULT_FONT_SLOTS, buildGoogleFontsUrl } from '@newtonedev/fonts';
|
|
4
|
+
export { DEFAULT_FONT_SIZES, DEFAULT_LINE_HEIGHTS, DEFAULT_ROLE_SCALES, buildGoogleFontsUrl } from '@newtonedev/fonts';
|
|
5
|
+
import { Text, View, useWindowDimensions, Pressable, TextInput as TextInput$1, ScrollView, PanResponder, Animated, StyleSheet } from 'react-native';
|
|
4
6
|
|
|
5
7
|
// src/theme/NewtoneProvider.tsx
|
|
6
8
|
var DEFAULT_THEME_CONFIG = {
|
|
@@ -54,40 +56,10 @@ var DEFAULT_THEME_CONFIG = {
|
|
|
54
56
|
pill: 999
|
|
55
57
|
},
|
|
56
58
|
typography: {
|
|
57
|
-
fonts:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fallback: "SFMono-Regular, Menlo, Monaco, Consolas, monospace"
|
|
62
|
-
},
|
|
63
|
-
display: {
|
|
64
|
-
type: "system",
|
|
65
|
-
family: "system-ui",
|
|
66
|
-
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
67
|
-
},
|
|
68
|
-
default: {
|
|
69
|
-
type: "system",
|
|
70
|
-
family: "system-ui",
|
|
71
|
-
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
scale: {
|
|
75
|
-
xs: 10,
|
|
76
|
-
// 16 / 1.25^2
|
|
77
|
-
sm: 13,
|
|
78
|
-
// 16 / 1.25
|
|
79
|
-
base: 16,
|
|
80
|
-
md: 20,
|
|
81
|
-
// 16 * 1.25
|
|
82
|
-
lg: 25,
|
|
83
|
-
// 16 * 1.25^2
|
|
84
|
-
xl: 31,
|
|
85
|
-
// 16 * 1.25^3
|
|
86
|
-
xxl: 39
|
|
87
|
-
// 16 * 1.25^4
|
|
88
|
-
},
|
|
89
|
-
lineHeight: { tight: 1.25, normal: 1.5, relaxed: 1.75 },
|
|
90
|
-
fontWeight: { regular: 400, medium: 500, semibold: 600, bold: 700 }
|
|
59
|
+
fonts: DEFAULT_FONT_SLOTS,
|
|
60
|
+
fontSizes: DEFAULT_FONT_SIZES,
|
|
61
|
+
lineHeights: DEFAULT_LINE_HEIGHTS,
|
|
62
|
+
roles: DEFAULT_ROLE_SCALES
|
|
91
63
|
},
|
|
92
64
|
icons: {
|
|
93
65
|
variant: "rounded",
|
|
@@ -99,20 +71,6 @@ var DEFAULT_THEME_CONFIG = {
|
|
|
99
71
|
}
|
|
100
72
|
};
|
|
101
73
|
|
|
102
|
-
// src/fonts/buildGoogleFontsUrl.ts
|
|
103
|
-
function buildGoogleFontsUrl(fonts) {
|
|
104
|
-
const googleFonts = [fonts.mono, fonts.display, fonts.default].filter(
|
|
105
|
-
(f) => f.type === "google"
|
|
106
|
-
);
|
|
107
|
-
if (googleFonts.length === 0) return null;
|
|
108
|
-
const unique = [...new Map(googleFonts.map((f) => [f.family, f])).values()];
|
|
109
|
-
const families = unique.map((f) => {
|
|
110
|
-
const encoded = f.family.replace(/ /g, "+");
|
|
111
|
-
return `family=${encoded}:wght@400;500;600;700`;
|
|
112
|
-
});
|
|
113
|
-
return `https://fonts.googleapis.com/css2?${families.join("&")}&display=swap`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
74
|
// src/fonts/GoogleFontLoader.tsx
|
|
117
75
|
function GoogleFontLoader({ fonts }) {
|
|
118
76
|
const linkRef = useRef(null);
|
|
@@ -138,15 +96,52 @@ function GoogleFontLoader({ fonts }) {
|
|
|
138
96
|
}
|
|
139
97
|
};
|
|
140
98
|
}, [
|
|
141
|
-
fonts.
|
|
142
|
-
fonts.
|
|
143
|
-
fonts.
|
|
144
|
-
fonts.
|
|
145
|
-
fonts.
|
|
146
|
-
fonts.
|
|
99
|
+
fonts.main.config.family,
|
|
100
|
+
fonts.main.config.type,
|
|
101
|
+
fonts.main.weights.regular,
|
|
102
|
+
fonts.main.weights.medium,
|
|
103
|
+
fonts.main.weights.bold,
|
|
104
|
+
fonts.display.config.family,
|
|
105
|
+
fonts.display.config.type,
|
|
106
|
+
fonts.display.weights.regular,
|
|
107
|
+
fonts.display.weights.medium,
|
|
108
|
+
fonts.display.weights.bold,
|
|
109
|
+
fonts.mono.config.family,
|
|
110
|
+
fonts.mono.config.type,
|
|
111
|
+
fonts.mono.weights.regular,
|
|
112
|
+
fonts.mono.weights.medium,
|
|
113
|
+
fonts.mono.weights.bold,
|
|
114
|
+
fonts.currency.config.family,
|
|
115
|
+
fonts.currency.config.type,
|
|
116
|
+
fonts.currency.weights.regular,
|
|
117
|
+
fonts.currency.weights.medium,
|
|
118
|
+
fonts.currency.weights.bold
|
|
147
119
|
]);
|
|
148
120
|
return null;
|
|
149
121
|
}
|
|
122
|
+
function SelfHostedFontLoader({ fontFaceCss }) {
|
|
123
|
+
const styleRef = useRef(null);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (typeof document === "undefined") return;
|
|
126
|
+
if (styleRef.current) {
|
|
127
|
+
styleRef.current.remove();
|
|
128
|
+
styleRef.current = null;
|
|
129
|
+
}
|
|
130
|
+
if (!fontFaceCss) return;
|
|
131
|
+
const style = document.createElement("style");
|
|
132
|
+
style.setAttribute("data-newtone-fonts", "self-hosted");
|
|
133
|
+
style.textContent = fontFaceCss;
|
|
134
|
+
document.head.appendChild(style);
|
|
135
|
+
styleRef.current = style;
|
|
136
|
+
return () => {
|
|
137
|
+
if (styleRef.current) {
|
|
138
|
+
styleRef.current.remove();
|
|
139
|
+
styleRef.current = null;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}, [fontFaceCss]);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
150
145
|
function IconFontLoader({ icons }) {
|
|
151
146
|
const linkRef = useRef(null);
|
|
152
147
|
useEffect(() => {
|
|
@@ -180,18 +175,21 @@ var ThemeContext = createContext(null);
|
|
|
180
175
|
function NewtoneProvider({
|
|
181
176
|
config = DEFAULT_THEME_CONFIG,
|
|
182
177
|
initialMode = "light",
|
|
183
|
-
children
|
|
178
|
+
children,
|
|
179
|
+
reportingEndpoint,
|
|
180
|
+
fontFaceCss
|
|
184
181
|
}) {
|
|
185
182
|
const [mode, setMode] = useState(initialMode);
|
|
186
183
|
const value = useMemo(
|
|
187
184
|
() => ({
|
|
188
185
|
config,
|
|
189
186
|
mode,
|
|
190
|
-
setMode
|
|
187
|
+
setMode,
|
|
188
|
+
reportingEndpoint
|
|
191
189
|
}),
|
|
192
|
-
[config, mode]
|
|
190
|
+
[config, mode, reportingEndpoint]
|
|
193
191
|
);
|
|
194
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ React14.createElement(ThemeContext.Provider, { value }, fontFaceCss ? /* @__PURE__ */ React14.createElement(SelfHostedFontLoader, { fontFaceCss }) : /* @__PURE__ */ React14.createElement(GoogleFontLoader, { fonts: config.typography.fonts }), /* @__PURE__ */ React14.createElement(IconFontLoader, { icons: config.icons }), children);
|
|
195
193
|
}
|
|
196
194
|
function useNewtoneTheme() {
|
|
197
195
|
const context = useContext(ThemeContext);
|
|
@@ -274,10 +272,6 @@ var ERROR_DEFAULTS = {
|
|
|
274
272
|
border: { enabled: 0.08, focused: 0.16, filled: 0.24 }
|
|
275
273
|
}
|
|
276
274
|
};
|
|
277
|
-
function fontConfigToFamily(font) {
|
|
278
|
-
const family = font.family.includes(" ") ? `"${font.family}"` : font.family;
|
|
279
|
-
return `${family}, ${font.fallback}`;
|
|
280
|
-
}
|
|
281
275
|
var clamp = (n) => Math.max(0, Math.min(1, n));
|
|
282
276
|
function computePaletteTokens(palette, defaults, mode, elevation, dynamicRange, elevationDelta, effectiveTextMode, autoAccentNv, neutralTextPrimary, neutralBgElevated) {
|
|
283
277
|
const modeDefaults = defaults[mode];
|
|
@@ -532,13 +526,25 @@ function computeTokens(config, mode, elevation, spacing, radius, typography, ico
|
|
|
532
526
|
radius,
|
|
533
527
|
typography: {
|
|
534
528
|
fonts: {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
529
|
+
main: {
|
|
530
|
+
family: fontConfigToFamily(typography.fonts.main.config),
|
|
531
|
+
weights: typography.fonts.main.weights
|
|
532
|
+
},
|
|
533
|
+
display: {
|
|
534
|
+
family: fontConfigToFamily(typography.fonts.display.config),
|
|
535
|
+
weights: typography.fonts.display.weights
|
|
536
|
+
},
|
|
537
|
+
mono: {
|
|
538
|
+
family: fontConfigToFamily(typography.fonts.mono.config),
|
|
539
|
+
weights: typography.fonts.mono.weights
|
|
540
|
+
},
|
|
541
|
+
currency: {
|
|
542
|
+
family: fontConfigToFamily(typography.fonts.currency.config),
|
|
543
|
+
weights: typography.fonts.currency.weights
|
|
544
|
+
}
|
|
538
545
|
},
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
weight: typography.fontWeight
|
|
546
|
+
fontSizes: typography.fontSizes,
|
|
547
|
+
lineHeights: typography.lineHeights
|
|
542
548
|
},
|
|
543
549
|
icons: {
|
|
544
550
|
variant: icons.variant,
|
|
@@ -653,7 +659,7 @@ function getSizeConfig(size, tokens) {
|
|
|
653
659
|
padding: 8,
|
|
654
660
|
gap: tokens.spacing["08"],
|
|
655
661
|
borderRadius: 8,
|
|
656
|
-
textSize: "
|
|
662
|
+
textSize: "md",
|
|
657
663
|
// 16px
|
|
658
664
|
iconSize: 24
|
|
659
665
|
},
|
|
@@ -661,7 +667,7 @@ function getSizeConfig(size, tokens) {
|
|
|
661
667
|
padding: 12,
|
|
662
668
|
gap: tokens.spacing["08"],
|
|
663
669
|
borderRadius: 12,
|
|
664
|
-
textSize: "
|
|
670
|
+
textSize: "md",
|
|
665
671
|
// 16px
|
|
666
672
|
iconSize: 24
|
|
667
673
|
},
|
|
@@ -669,7 +675,7 @@ function getSizeConfig(size, tokens) {
|
|
|
669
675
|
padding: 16,
|
|
670
676
|
gap: tokens.spacing["08"],
|
|
671
677
|
borderRadius: 16,
|
|
672
|
-
textSize: "
|
|
678
|
+
textSize: "md",
|
|
673
679
|
// 16px
|
|
674
680
|
iconSize: 24
|
|
675
681
|
}
|
|
@@ -784,7 +790,7 @@ function Icon({
|
|
|
784
790
|
}) {
|
|
785
791
|
const tokens = useTokens();
|
|
786
792
|
const iconStyle = useMemo(() => {
|
|
787
|
-
const fontSize = size ?? tokens.typography.
|
|
793
|
+
const fontSize = size ?? tokens.typography.fontSizes["05"];
|
|
788
794
|
const getOpticalSize = (size2) => {
|
|
789
795
|
if (size2 <= 22) return 20;
|
|
790
796
|
if (size2 <= 32) return 24;
|
|
@@ -813,7 +819,7 @@ function Icon({
|
|
|
813
819
|
...style
|
|
814
820
|
};
|
|
815
821
|
}, [tokens, size, opticalSize, fill, color, style]);
|
|
816
|
-
return /* @__PURE__ */
|
|
822
|
+
return /* @__PURE__ */ React14.createElement(
|
|
817
823
|
Text,
|
|
818
824
|
{
|
|
819
825
|
ref,
|
|
@@ -826,6 +832,118 @@ function Icon({
|
|
|
826
832
|
name
|
|
827
833
|
);
|
|
828
834
|
}
|
|
835
|
+
|
|
836
|
+
// src/fonts/measureFont.ts
|
|
837
|
+
var REF_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
|
|
838
|
+
async function measureAvgCharWidth(fontFamily, fontWeight, fallback, fontSize = 16) {
|
|
839
|
+
if (typeof document === "undefined") return 0.55;
|
|
840
|
+
try {
|
|
841
|
+
await document.fonts.load(`${fontWeight} ${fontSize}px "${fontFamily}"`);
|
|
842
|
+
const canvas = document.createElement("canvas");
|
|
843
|
+
const ctx = canvas.getContext("2d");
|
|
844
|
+
if (!ctx) return 0.55;
|
|
845
|
+
ctx.font = `${fontWeight} ${fontSize}px "${fontFamily}", ${fallback}`;
|
|
846
|
+
const ratio = ctx.measureText(REF_STRING).width / REF_STRING.length / fontSize;
|
|
847
|
+
return Math.round(ratio * 1e3) / 1e3;
|
|
848
|
+
} catch {
|
|
849
|
+
return 0.55;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// src/fonts/useLocalCalibration.ts
|
|
854
|
+
var STORAGE_KEY = "newtone:font-metrics:v1";
|
|
855
|
+
var TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
856
|
+
function readCache() {
|
|
857
|
+
if (typeof localStorage === "undefined") return {};
|
|
858
|
+
try {
|
|
859
|
+
const raw = localStorage.getItem(STORAGE_KEY);
|
|
860
|
+
return raw ? JSON.parse(raw) : {};
|
|
861
|
+
} catch {
|
|
862
|
+
return {};
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
function writeCache(cache) {
|
|
866
|
+
if (typeof localStorage === "undefined") return;
|
|
867
|
+
try {
|
|
868
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(cache));
|
|
869
|
+
} catch {
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
function cacheKey(fontFamily, fontWeight) {
|
|
873
|
+
return `${fontFamily}:${fontWeight}`;
|
|
874
|
+
}
|
|
875
|
+
function useLocalCalibration(fontFamily, fontWeight, fallback, baseCalibration) {
|
|
876
|
+
const key = cacheKey(fontFamily, fontWeight);
|
|
877
|
+
const [ratio, setRatio] = useState(() => {
|
|
878
|
+
const cache = readCache();
|
|
879
|
+
const entry = cache[key];
|
|
880
|
+
if (entry && Date.now() - entry.measuredAt < TTL_MS) {
|
|
881
|
+
return entry.ratio;
|
|
882
|
+
}
|
|
883
|
+
return baseCalibration ?? 0.55;
|
|
884
|
+
});
|
|
885
|
+
useEffect(() => {
|
|
886
|
+
const cache = readCache();
|
|
887
|
+
const entry = cache[key];
|
|
888
|
+
if (entry && Date.now() - entry.measuredAt < TTL_MS) {
|
|
889
|
+
if (entry.ratio !== ratio) setRatio(entry.ratio);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
let cancelled = false;
|
|
893
|
+
measureAvgCharWidth(fontFamily, fontWeight, fallback).then((measured) => {
|
|
894
|
+
if (cancelled) return;
|
|
895
|
+
const updated = { ...readCache(), [key]: { ratio: measured, measuredAt: Date.now() } };
|
|
896
|
+
writeCache(updated);
|
|
897
|
+
setRatio(measured);
|
|
898
|
+
});
|
|
899
|
+
return () => {
|
|
900
|
+
cancelled = true;
|
|
901
|
+
};
|
|
902
|
+
}, [key, fontFamily, fontWeight, fallback]);
|
|
903
|
+
return ratio;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/fonts/useTypographyCalibrations.ts
|
|
907
|
+
function useTypographyCalibrations() {
|
|
908
|
+
const { config } = useNewtoneTheme();
|
|
909
|
+
return config.typography.calibrations ?? {};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
// src/fonts/reportQueue.ts
|
|
913
|
+
var queue = [];
|
|
914
|
+
var flushTimer;
|
|
915
|
+
function flush() {
|
|
916
|
+
if (queue.length === 0) return;
|
|
917
|
+
const byEndpoint = /* @__PURE__ */ new Map();
|
|
918
|
+
for (const item of queue) {
|
|
919
|
+
const group = byEndpoint.get(item.endpoint) ?? [];
|
|
920
|
+
group.push(item.payload);
|
|
921
|
+
byEndpoint.set(item.endpoint, group);
|
|
922
|
+
}
|
|
923
|
+
queue.length = 0;
|
|
924
|
+
for (const [endpoint, observations] of byEndpoint) {
|
|
925
|
+
fetch(endpoint, {
|
|
926
|
+
method: "POST",
|
|
927
|
+
headers: { "Content-Type": "application/json" },
|
|
928
|
+
body: JSON.stringify({ observations }),
|
|
929
|
+
// keepalive: true allows the request to outlive the page
|
|
930
|
+
keepalive: true
|
|
931
|
+
}).catch(() => {
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
function enqueueObservation(endpoint, payload) {
|
|
936
|
+
queue.push({ endpoint, payload });
|
|
937
|
+
if (flushTimer !== void 0) clearTimeout(flushTimer);
|
|
938
|
+
flushTimer = setTimeout(flush, 2e3);
|
|
939
|
+
}
|
|
940
|
+
function useBreakpoint() {
|
|
941
|
+
const { width } = useWindowDimensions();
|
|
942
|
+
return getBreakpointForWidth(width);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// src/primitives/Text/Text.tsx
|
|
946
|
+
var TextScopeContext = createContext(null);
|
|
829
947
|
function resolveTextColor(color, tokens) {
|
|
830
948
|
switch (color) {
|
|
831
949
|
case "primary":
|
|
@@ -846,53 +964,189 @@ function resolveTextColor(color, tokens) {
|
|
|
846
964
|
return srgbToHex(tokens.error.fill.srgb);
|
|
847
965
|
}
|
|
848
966
|
}
|
|
849
|
-
|
|
967
|
+
var ADAPTIVE_ROLES = /* @__PURE__ */ new Set(["headline", "title", "heading", "subheading"]);
|
|
968
|
+
var ROLE_HEADING_LEVEL = {
|
|
969
|
+
headline: 1,
|
|
970
|
+
title: 2,
|
|
971
|
+
heading: 3
|
|
972
|
+
};
|
|
973
|
+
function extractCharacterCount(node) {
|
|
974
|
+
if (typeof node === "string") return node.length;
|
|
975
|
+
if (typeof node === "number") return String(node).length;
|
|
976
|
+
if (!node) return 0;
|
|
977
|
+
if (Array.isArray(node)) {
|
|
978
|
+
return node.reduce((sum, child) => sum + extractCharacterCount(child), 0);
|
|
979
|
+
}
|
|
980
|
+
if (typeof node === "object" && "props" in node) {
|
|
981
|
+
return extractCharacterCount(node.props?.children);
|
|
982
|
+
}
|
|
983
|
+
return 0;
|
|
984
|
+
}
|
|
985
|
+
function TextBase({
|
|
850
986
|
children,
|
|
851
|
-
|
|
852
|
-
|
|
987
|
+
scope = "main",
|
|
988
|
+
role = "body",
|
|
853
989
|
color = "primary",
|
|
854
|
-
|
|
855
|
-
|
|
990
|
+
size: sizeOverride,
|
|
991
|
+
weight: weightOverride,
|
|
856
992
|
align,
|
|
857
993
|
numberOfLines,
|
|
858
994
|
elevation = 1,
|
|
859
995
|
style,
|
|
860
|
-
|
|
861
|
-
accessibilityRole,
|
|
862
|
-
// Testing & platform
|
|
996
|
+
accessibilityRole: accessibilityRoleOverride,
|
|
863
997
|
testID,
|
|
864
998
|
nativeID,
|
|
865
|
-
ref
|
|
999
|
+
ref,
|
|
1000
|
+
responsive = false,
|
|
1001
|
+
centerVertically = false,
|
|
1002
|
+
features
|
|
866
1003
|
}) {
|
|
867
1004
|
const tokens = useTokens(elevation);
|
|
1005
|
+
const { config, reportingEndpoint } = useNewtoneTheme();
|
|
1006
|
+
const size = sizeOverride ?? "md";
|
|
1007
|
+
const fontSlot = tokens.typography.fonts[scope];
|
|
1008
|
+
const resolvedFontWeight = weightOverride ? SEMANTIC_WEIGHT_MAP[weightOverride] : config.typography.roleWeights?.[role] ?? ROLE_DEFAULT_WEIGHTS[role];
|
|
1009
|
+
const breakpoint = useBreakpoint();
|
|
1010
|
+
const baseStep = config.typography.roles[role][size];
|
|
1011
|
+
const bpScale = BREAKPOINT_ROLE_SCALE[breakpoint][role];
|
|
1012
|
+
const step = bpScale === 1 ? baseStep : scaleRoleStep(baseStep, bpScale);
|
|
1013
|
+
const calibrations = useTypographyCalibrations();
|
|
1014
|
+
const fontSlotFull = config.typography.fonts[scope];
|
|
1015
|
+
const localRatio = useLocalCalibration(
|
|
1016
|
+
fontSlot.family,
|
|
1017
|
+
SEMANTIC_WEIGHT_MAP.regular,
|
|
1018
|
+
fontSlotFull.config.fallback,
|
|
1019
|
+
calibrations[fontSlot.family]
|
|
1020
|
+
);
|
|
1021
|
+
const isAdaptive = ADAPTIVE_ROLES.has(role);
|
|
1022
|
+
const [containerWidth, setContainerWidth] = useState(null);
|
|
1023
|
+
const characterCount = useMemo(() => extractCharacterCount(children), [children]);
|
|
1024
|
+
const resolvedStep = useMemo(
|
|
1025
|
+
() => resolveResponsiveSize(
|
|
1026
|
+
{
|
|
1027
|
+
role,
|
|
1028
|
+
size,
|
|
1029
|
+
responsive: responsive && isAdaptive,
|
|
1030
|
+
fontFamily: fontSlot.family,
|
|
1031
|
+
maxFontSize: step.fontSize,
|
|
1032
|
+
minFontSize: Math.max(8, Math.round(step.fontSize * 0.7))
|
|
1033
|
+
},
|
|
1034
|
+
config.typography.roles,
|
|
1035
|
+
containerWidth != null ? { containerWidth, characterCount } : void 0,
|
|
1036
|
+
{ [fontSlot.family]: localRatio }
|
|
1037
|
+
),
|
|
1038
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1039
|
+
[role, size, responsive, isAdaptive, fontSlot.family, step.fontSize, config.typography.roles, containerWidth, characterCount, localRatio]
|
|
1040
|
+
);
|
|
1041
|
+
useEffect(() => {
|
|
1042
|
+
if (!reportingEndpoint || !responsive || !isAdaptive || containerWidth == null) return;
|
|
1043
|
+
const lineWidths = estimateLineWidths(characterCount, containerWidth, resolvedStep.fontSize, localRatio);
|
|
1044
|
+
const lastLine = lineWidths[lineWidths.length - 1];
|
|
1045
|
+
enqueueObservation(reportingEndpoint, {
|
|
1046
|
+
fontFamily: fontSlot.family,
|
|
1047
|
+
fontWeight: resolvedFontWeight,
|
|
1048
|
+
role,
|
|
1049
|
+
size,
|
|
1050
|
+
fontSize: resolvedStep.fontSize,
|
|
1051
|
+
containerWidth,
|
|
1052
|
+
characterCount,
|
|
1053
|
+
lineCount: lineWidths.length,
|
|
1054
|
+
lastLineRatio: containerWidth > 0 ? lastLine / containerWidth : 1
|
|
1055
|
+
});
|
|
1056
|
+
}, [reportingEndpoint, resolvedStep.fontSize, containerWidth]);
|
|
868
1057
|
const resolvedStyle = useMemo(() => {
|
|
869
|
-
const
|
|
1058
|
+
const activeStep = responsive && isAdaptive ? resolvedStep : step;
|
|
1059
|
+
const currentMetrics = config.typography.fontMetrics?.[fontSlot.family];
|
|
1060
|
+
const correctedLineHeight = currentMetrics ? Math.round(activeStep.lineHeight * currentMetrics.naturalLineHeightRatio / REFERENCE_LINE_HEIGHT_RATIO / 4) * 4 : activeStep.lineHeight;
|
|
1061
|
+
const vcOffset = centerVertically && currentMetrics ? Math.round(currentMetrics.verticalCenterOffset * activeStep.fontSize * 2) / 2 : 0;
|
|
1062
|
+
const activeFeatures = features ? currentMetrics?.features ? features.filter((tag) => currentMetrics.features.includes(tag)) : [...features] : [];
|
|
1063
|
+
const featureSettings = activeFeatures.length > 0 ? buildFontFeatureSettings(activeFeatures) : void 0;
|
|
870
1064
|
return {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
// Font weight is stored as a number (e.g. 400, 600) but React Native expects a string.
|
|
875
|
-
fontWeight: String(tokens.typography.weight[weight]),
|
|
876
|
-
// Convert the theme color from internal sRGB format to a hex string (e.g. '#1a1a1a').
|
|
1065
|
+
fontFamily: fontSlot.family,
|
|
1066
|
+
fontSize: activeStep.fontSize,
|
|
1067
|
+
fontWeight: String(resolvedFontWeight),
|
|
877
1068
|
color: resolveTextColor(color, tokens),
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1069
|
+
lineHeight: correctedLineHeight,
|
|
1070
|
+
textAlign: align,
|
|
1071
|
+
...vcOffset !== 0 ? { transform: [{ translateY: vcOffset }] } : {},
|
|
1072
|
+
...featureSettings ? { fontFeatureSettings: featureSettings } : {}
|
|
881
1073
|
};
|
|
882
|
-
}, [tokens,
|
|
883
|
-
|
|
1074
|
+
}, [tokens, fontSlot, step, resolvedStep, responsive, isAdaptive, resolvedFontWeight, color, align, config.typography.fontMetrics, centerVertically, features]);
|
|
1075
|
+
const inferredA11yRole = role === "headline" || role === "title" || role === "heading" ? "header" : void 0;
|
|
1076
|
+
const effectiveA11yRole = accessibilityRoleOverride ?? inferredA11yRole;
|
|
1077
|
+
const ariaLevel = effectiveA11yRole === "header" ? ROLE_HEADING_LEVEL[role] : void 0;
|
|
1078
|
+
const scopeCtx = useMemo(() => ({ weights: SEMANTIC_WEIGHT_MAP }), []);
|
|
1079
|
+
const textNode = /* @__PURE__ */ React14.createElement(TextScopeContext.Provider, { value: scopeCtx }, /* @__PURE__ */ React14.createElement(
|
|
884
1080
|
Text,
|
|
885
1081
|
{
|
|
886
1082
|
ref,
|
|
887
1083
|
testID,
|
|
888
1084
|
nativeID,
|
|
889
|
-
accessibilityRole,
|
|
1085
|
+
accessibilityRole: effectiveA11yRole,
|
|
1086
|
+
"aria-level": ariaLevel,
|
|
890
1087
|
style: style ? [resolvedStyle, ...Array.isArray(style) ? style : [style]] : resolvedStyle,
|
|
891
1088
|
numberOfLines
|
|
892
1089
|
},
|
|
893
1090
|
children
|
|
1091
|
+
));
|
|
1092
|
+
if (responsive && isAdaptive) {
|
|
1093
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1094
|
+
View,
|
|
1095
|
+
{
|
|
1096
|
+
onLayout: (e) => {
|
|
1097
|
+
const w = e.nativeEvent.layout.width;
|
|
1098
|
+
if (w > 0) setContainerWidth(w);
|
|
1099
|
+
},
|
|
1100
|
+
style: { width: "100%" }
|
|
1101
|
+
},
|
|
1102
|
+
textNode
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
return textNode;
|
|
1106
|
+
}
|
|
1107
|
+
function TextSpan({ children, color, weight, italic, underline, highlight, style }) {
|
|
1108
|
+
const tokens = useTokens(1);
|
|
1109
|
+
const scopeCtx = useContext(TextScopeContext);
|
|
1110
|
+
const spanStyle = useMemo(() => {
|
|
1111
|
+
const s = {};
|
|
1112
|
+
if (color) s.color = resolveTextColor(color, tokens);
|
|
1113
|
+
if (weight && scopeCtx) s.fontWeight = String(scopeCtx.weights[weight]);
|
|
1114
|
+
if (italic) s.fontStyle = "italic";
|
|
1115
|
+
if (underline) s.textDecorationLine = "underline";
|
|
1116
|
+
if (highlight) s.backgroundColor = resolveTextColor(highlight, tokens);
|
|
1117
|
+
return s;
|
|
1118
|
+
}, [tokens, scopeCtx, color, weight, italic, underline, highlight]);
|
|
1119
|
+
return React14.createElement(
|
|
1120
|
+
Text,
|
|
1121
|
+
{ style: style ? [spanStyle, ...Array.isArray(style) ? style : [style]] : spanStyle },
|
|
1122
|
+
children
|
|
894
1123
|
);
|
|
895
1124
|
}
|
|
1125
|
+
function TextBold(props) {
|
|
1126
|
+
return React14.createElement(TextSpan, { ...props, weight: "bold" });
|
|
1127
|
+
}
|
|
1128
|
+
function TextMedium(props) {
|
|
1129
|
+
return React14.createElement(TextSpan, { ...props, weight: "medium" });
|
|
1130
|
+
}
|
|
1131
|
+
function TextItalic(props) {
|
|
1132
|
+
return React14.createElement(TextSpan, { ...props, italic: true });
|
|
1133
|
+
}
|
|
1134
|
+
function TextUnderline(props) {
|
|
1135
|
+
return React14.createElement(TextSpan, { ...props, underline: true });
|
|
1136
|
+
}
|
|
1137
|
+
function TextHighlight(props) {
|
|
1138
|
+
return React14.createElement(TextSpan, props);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// src/primitives/Text/index.ts
|
|
1142
|
+
var Text2 = Object.assign(TextBase, {
|
|
1143
|
+
Span: TextSpan,
|
|
1144
|
+
Bold: TextBold,
|
|
1145
|
+
Medium: TextMedium,
|
|
1146
|
+
Italic: TextItalic,
|
|
1147
|
+
Underline: TextUnderline,
|
|
1148
|
+
Highlight: TextHighlight
|
|
1149
|
+
});
|
|
896
1150
|
|
|
897
1151
|
// src/primitives/Frame/Frame.utils.ts
|
|
898
1152
|
function resolveSpacing(value, tokens) {
|
|
@@ -1096,7 +1350,7 @@ function Wrapper({
|
|
|
1096
1350
|
]
|
|
1097
1351
|
);
|
|
1098
1352
|
const userStyles = Array.isArray(style) ? style : style ? [style] : [];
|
|
1099
|
-
return /* @__PURE__ */
|
|
1353
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1100
1354
|
View,
|
|
1101
1355
|
{
|
|
1102
1356
|
ref,
|
|
@@ -1123,17 +1377,17 @@ function Button({
|
|
|
1123
1377
|
...pressableProps
|
|
1124
1378
|
}) {
|
|
1125
1379
|
const tokens = useTokens();
|
|
1126
|
-
const { variantColors, sizeTokens } =
|
|
1380
|
+
const { variantColors, sizeTokens } = React14.useMemo(
|
|
1127
1381
|
() => getButtonConfig(variant, semantic, size, disabled, tokens),
|
|
1128
1382
|
[variant, semantic, size, disabled, tokens]
|
|
1129
1383
|
);
|
|
1130
|
-
const padding =
|
|
1384
|
+
const padding = React14.useMemo(
|
|
1131
1385
|
() => computeButtonPadding(size, !!icon, !!children, iconPosition),
|
|
1132
1386
|
[size, icon, children, iconPosition]
|
|
1133
1387
|
);
|
|
1134
|
-
return /* @__PURE__ */
|
|
1388
|
+
return /* @__PURE__ */ React14.createElement(Pressable, { disabled, ...pressableProps }, ({ pressed, hovered }) => (
|
|
1135
1389
|
// Wrapper handles layout: direction, gap, alignment (padding via style)
|
|
1136
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ React14.createElement(
|
|
1137
1391
|
Wrapper,
|
|
1138
1392
|
{
|
|
1139
1393
|
direction: "horizontal",
|
|
@@ -1154,13 +1408,14 @@ function Button({
|
|
|
1154
1408
|
...Array.isArray(style) ? style : style ? [style] : []
|
|
1155
1409
|
]
|
|
1156
1410
|
},
|
|
1157
|
-
icon && iconPosition === "left" && /* @__PURE__ */
|
|
1411
|
+
icon && iconPosition === "left" && /* @__PURE__ */ React14.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor }),
|
|
1158
1412
|
children && // Text primitive with semantic props + color style override
|
|
1159
|
-
/* @__PURE__ */
|
|
1413
|
+
/* @__PURE__ */ React14.createElement(
|
|
1160
1414
|
Text2,
|
|
1161
1415
|
{
|
|
1416
|
+
role: "label",
|
|
1162
1417
|
size: sizeTokens.textSize,
|
|
1163
|
-
|
|
1418
|
+
centerVertically: true,
|
|
1164
1419
|
style: [
|
|
1165
1420
|
{ color: variantColors.textColor },
|
|
1166
1421
|
...Array.isArray(textStyle) ? textStyle : textStyle ? [textStyle] : []
|
|
@@ -1168,7 +1423,7 @@ function Button({
|
|
|
1168
1423
|
},
|
|
1169
1424
|
children
|
|
1170
1425
|
),
|
|
1171
|
-
icon && iconPosition === "right" && /* @__PURE__ */
|
|
1426
|
+
icon && iconPosition === "right" && /* @__PURE__ */ React14.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor })
|
|
1172
1427
|
)
|
|
1173
1428
|
));
|
|
1174
1429
|
}
|
|
@@ -1193,11 +1448,11 @@ function Card({
|
|
|
1193
1448
|
disabled = false
|
|
1194
1449
|
}) {
|
|
1195
1450
|
const tokens = useTokens(elevation);
|
|
1196
|
-
const styles =
|
|
1451
|
+
const styles = React14.useMemo(
|
|
1197
1452
|
() => getCardStyles(tokens, disabled),
|
|
1198
1453
|
[tokens, disabled]
|
|
1199
1454
|
);
|
|
1200
|
-
return /* @__PURE__ */
|
|
1455
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, children);
|
|
1201
1456
|
}
|
|
1202
1457
|
var hadKeyboardEvent = false;
|
|
1203
1458
|
var isListenerSetup = false;
|
|
@@ -1348,9 +1603,9 @@ function getFrameStyles(input) {
|
|
|
1348
1603
|
|
|
1349
1604
|
// src/primitives/Frame/Frame.tsx
|
|
1350
1605
|
function wrapTextChildren(children, textStyle) {
|
|
1351
|
-
return
|
|
1606
|
+
return React14.Children.map(children, (child) => {
|
|
1352
1607
|
if (typeof child === "string" || typeof child === "number") {
|
|
1353
|
-
return /* @__PURE__ */
|
|
1608
|
+
return /* @__PURE__ */ React14.createElement(Text, { style: textStyle }, child);
|
|
1354
1609
|
}
|
|
1355
1610
|
return child;
|
|
1356
1611
|
});
|
|
@@ -1489,9 +1744,9 @@ function Frame({
|
|
|
1489
1744
|
const textStyle = useMemo(
|
|
1490
1745
|
() => ({
|
|
1491
1746
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
1492
|
-
fontSize: tokens.typography.
|
|
1493
|
-
fontFamily: tokens.typography.fonts.
|
|
1494
|
-
lineHeight: tokens.typography.
|
|
1747
|
+
fontSize: tokens.typography.fontSizes["05"],
|
|
1748
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1749
|
+
lineHeight: tokens.typography.lineHeights["06"]
|
|
1495
1750
|
}),
|
|
1496
1751
|
[tokens]
|
|
1497
1752
|
);
|
|
@@ -1499,10 +1754,10 @@ function Frame({
|
|
|
1499
1754
|
() => wrapTextChildren(children, textStyle),
|
|
1500
1755
|
[children, textStyle]
|
|
1501
1756
|
);
|
|
1502
|
-
return /* @__PURE__ */
|
|
1757
|
+
return /* @__PURE__ */ React14.createElement(FrameContext.Provider, { value: contextValue }, isInteractive ? (
|
|
1503
1758
|
// Pressable handles taps. When href is set, react-native-web renders
|
|
1504
1759
|
// it as an <a> tag so it works like a regular link on the web.
|
|
1505
|
-
/* @__PURE__ */
|
|
1760
|
+
/* @__PURE__ */ React14.createElement(
|
|
1506
1761
|
Pressable,
|
|
1507
1762
|
{
|
|
1508
1763
|
ref,
|
|
@@ -1527,7 +1782,7 @@ function Frame({
|
|
|
1527
1782
|
)
|
|
1528
1783
|
) : (
|
|
1529
1784
|
// Non-interactive Frame: just a plain View with no tap handling.
|
|
1530
|
-
/* @__PURE__ */
|
|
1785
|
+
/* @__PURE__ */ React14.createElement(
|
|
1531
1786
|
View,
|
|
1532
1787
|
{
|
|
1533
1788
|
ref,
|
|
@@ -1547,20 +1802,20 @@ function getTextInputStyles(tokens, disabled) {
|
|
|
1547
1802
|
gap: tokens.spacing["04"]
|
|
1548
1803
|
},
|
|
1549
1804
|
label: {
|
|
1550
|
-
fontFamily: tokens.typography.fonts.
|
|
1551
|
-
fontSize: tokens.typography.
|
|
1552
|
-
fontWeight: tokens.typography.
|
|
1805
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1806
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
1807
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1553
1808
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
1554
1809
|
},
|
|
1555
1810
|
input: {
|
|
1556
|
-
fontFamily: tokens.typography.fonts.
|
|
1811
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1557
1812
|
backgroundColor: srgbToHex(tokens.backgroundSunken.srgb),
|
|
1558
1813
|
borderWidth: 1,
|
|
1559
1814
|
borderColor: srgbToHex(tokens.border.srgb),
|
|
1560
1815
|
borderRadius: tokens.radius.md,
|
|
1561
1816
|
paddingVertical: tokens.spacing["08"],
|
|
1562
1817
|
paddingHorizontal: tokens.spacing["12"],
|
|
1563
|
-
fontSize: tokens.typography.
|
|
1818
|
+
fontSize: tokens.typography.fontSizes["05"],
|
|
1564
1819
|
color: disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb),
|
|
1565
1820
|
opacity: disabled ? 0.5 : 1
|
|
1566
1821
|
}
|
|
@@ -1573,11 +1828,11 @@ function TextInput({
|
|
|
1573
1828
|
...textInputProps
|
|
1574
1829
|
}) {
|
|
1575
1830
|
const tokens = useTokens(1);
|
|
1576
|
-
const styles =
|
|
1831
|
+
const styles = React14.useMemo(
|
|
1577
1832
|
() => getTextInputStyles(tokens, disabled),
|
|
1578
1833
|
[tokens, disabled]
|
|
1579
1834
|
);
|
|
1580
|
-
return /* @__PURE__ */
|
|
1835
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label), /* @__PURE__ */ React14.createElement(
|
|
1581
1836
|
TextInput$1,
|
|
1582
1837
|
{
|
|
1583
1838
|
style: styles.input,
|
|
@@ -1680,15 +1935,15 @@ function Popover({
|
|
|
1680
1935
|
[styles.content, contentStyle]
|
|
1681
1936
|
);
|
|
1682
1937
|
const webProps = { onKeyDown: handleKeyDown };
|
|
1683
|
-
return /* @__PURE__ */
|
|
1938
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1684
1939
|
View,
|
|
1685
1940
|
{
|
|
1686
1941
|
ref: containerRef,
|
|
1687
1942
|
style: containerStyles,
|
|
1688
1943
|
...webProps
|
|
1689
1944
|
},
|
|
1690
|
-
/* @__PURE__ */
|
|
1691
|
-
isOpen && /* @__PURE__ */
|
|
1945
|
+
/* @__PURE__ */ React14.createElement(View, { onLayout: onTriggerLayout }, trigger),
|
|
1946
|
+
isOpen && /* @__PURE__ */ React14.createElement(View, { style: mergedContentStyles }, children)
|
|
1692
1947
|
);
|
|
1693
1948
|
}
|
|
1694
1949
|
function usePopover(options) {
|
|
@@ -1717,7 +1972,7 @@ function isOptionGroup(item) {
|
|
|
1717
1972
|
}
|
|
1718
1973
|
function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
1719
1974
|
const isSm = size === "sm";
|
|
1720
|
-
const fontSize = isSm ? tokens.typography.
|
|
1975
|
+
const fontSize = isSm ? tokens.typography.fontSizes["04"] : tokens.typography.fontSizes["05"];
|
|
1721
1976
|
const iconSize = fontSize + 2;
|
|
1722
1977
|
const iconSpace = iconSize + tokens.spacing["08"];
|
|
1723
1978
|
const paddingVertical = isSm ? tokens.spacing["04"] : tokens.spacing["08"];
|
|
@@ -1728,9 +1983,9 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1728
1983
|
zIndex: isOpen ? 999 : 0
|
|
1729
1984
|
},
|
|
1730
1985
|
label: {
|
|
1731
|
-
fontFamily: tokens.typography.fonts.
|
|
1732
|
-
fontSize: tokens.typography.
|
|
1733
|
-
fontWeight: tokens.typography.
|
|
1986
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1987
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
1988
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1734
1989
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
1735
1990
|
},
|
|
1736
1991
|
trigger: {
|
|
@@ -1747,7 +2002,7 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1747
2002
|
},
|
|
1748
2003
|
triggerText: {
|
|
1749
2004
|
flex: 1,
|
|
1750
|
-
fontFamily: tokens.typography.fonts.
|
|
2005
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1751
2006
|
fontSize,
|
|
1752
2007
|
color: disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb)
|
|
1753
2008
|
},
|
|
@@ -1759,9 +2014,9 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1759
2014
|
justifyContent: "center"
|
|
1760
2015
|
},
|
|
1761
2016
|
groupLabel: {
|
|
1762
|
-
fontFamily: tokens.typography.fonts.
|
|
1763
|
-
fontSize: tokens.typography.
|
|
1764
|
-
fontWeight: tokens.typography.
|
|
2017
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2018
|
+
fontSize: tokens.typography.fontSizes["01"],
|
|
2019
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1765
2020
|
color: srgbToHex(tokens.textSecondary.srgb),
|
|
1766
2021
|
textTransform: "uppercase",
|
|
1767
2022
|
letterSpacing: 0.5,
|
|
@@ -1883,9 +2138,9 @@ function SelectOptionRow({
|
|
|
1883
2138
|
const tokens = useTokens(1);
|
|
1884
2139
|
const paddingVertical = size === "sm" ? tokens.spacing["04"] : tokens.spacing["08"];
|
|
1885
2140
|
const paddingHorizontal = size === "sm" ? tokens.spacing["08"] : tokens.spacing["12"];
|
|
1886
|
-
const fontSize = size === "sm" ? tokens.typography.
|
|
2141
|
+
const fontSize = size === "sm" ? tokens.typography.fontSizes["04"] : tokens.typography.fontSizes["05"];
|
|
1887
2142
|
if (renderOption) {
|
|
1888
|
-
return /* @__PURE__ */
|
|
2143
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1889
2144
|
Pressable,
|
|
1890
2145
|
{
|
|
1891
2146
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1896,7 +2151,7 @@ function SelectOptionRow({
|
|
|
1896
2151
|
renderOption(option, { isSelected, isFocused })
|
|
1897
2152
|
);
|
|
1898
2153
|
}
|
|
1899
|
-
return /* @__PURE__ */
|
|
2154
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1900
2155
|
Pressable,
|
|
1901
2156
|
{
|
|
1902
2157
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1925,18 +2180,18 @@ function SelectOptionRow({
|
|
|
1925
2180
|
}
|
|
1926
2181
|
]
|
|
1927
2182
|
},
|
|
1928
|
-
/* @__PURE__ */
|
|
2183
|
+
/* @__PURE__ */ React14.createElement(
|
|
1929
2184
|
Text,
|
|
1930
2185
|
{
|
|
1931
2186
|
style: [
|
|
1932
2187
|
{
|
|
1933
2188
|
flex: 1,
|
|
1934
|
-
fontFamily: tokens.typography.fonts.
|
|
2189
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1935
2190
|
fontSize,
|
|
1936
2191
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
1937
2192
|
},
|
|
1938
2193
|
isSelected && {
|
|
1939
|
-
fontWeight: tokens.typography.
|
|
2194
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1940
2195
|
color: srgbToHex(tokens.accent.fill.srgb)
|
|
1941
2196
|
},
|
|
1942
2197
|
option.disabled && {
|
|
@@ -1947,7 +2202,7 @@ function SelectOptionRow({
|
|
|
1947
2202
|
},
|
|
1948
2203
|
option.label
|
|
1949
2204
|
),
|
|
1950
|
-
isSelected && /* @__PURE__ */
|
|
2205
|
+
isSelected && /* @__PURE__ */ React14.createElement(View, { style: { marginLeft: tokens.spacing["08"] } }, /* @__PURE__ */ React14.createElement(
|
|
1951
2206
|
Icon,
|
|
1952
2207
|
{
|
|
1953
2208
|
name: "check",
|
|
@@ -2002,7 +2257,7 @@ function Select({
|
|
|
2002
2257
|
const displayLabel = selectedOption?.label ?? placeholder ?? value;
|
|
2003
2258
|
const iconColor = disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb);
|
|
2004
2259
|
const triggerWebProps = { onKeyDown: handleKeyDown };
|
|
2005
|
-
const trigger = /* @__PURE__ */
|
|
2260
|
+
const trigger = /* @__PURE__ */ React14.createElement(
|
|
2006
2261
|
Pressable,
|
|
2007
2262
|
{
|
|
2008
2263
|
onPress: disabled ? void 0 : toggle,
|
|
@@ -2012,24 +2267,24 @@ function Select({
|
|
|
2012
2267
|
...triggerWebProps,
|
|
2013
2268
|
style: styles.trigger
|
|
2014
2269
|
},
|
|
2015
|
-
renderValue ? renderValue(selectedOption) : /* @__PURE__ */
|
|
2016
|
-
/* @__PURE__ */
|
|
2270
|
+
renderValue ? renderValue(selectedOption) : /* @__PURE__ */ React14.createElement(Text, { style: styles.triggerText, numberOfLines: 1 }, displayLabel),
|
|
2271
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.iconWrapper, pointerEvents: "none" }, /* @__PURE__ */ React14.createElement(
|
|
2017
2272
|
Icon,
|
|
2018
2273
|
{
|
|
2019
2274
|
name: isOpen ? "expand_less" : "expand_more",
|
|
2020
|
-
size: size === "sm" ? tokens.typography.
|
|
2275
|
+
size: size === "sm" ? tokens.typography.fontSizes["04"] + 2 : tokens.typography.fontSizes["05"] + 2,
|
|
2021
2276
|
color: iconColor
|
|
2022
2277
|
}
|
|
2023
2278
|
))
|
|
2024
2279
|
);
|
|
2025
|
-
return /* @__PURE__ */
|
|
2280
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : style ? [style] : []] }, label && /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label), /* @__PURE__ */ React14.createElement(
|
|
2026
2281
|
Popover,
|
|
2027
2282
|
{
|
|
2028
2283
|
isOpen: isOpen && !disabled,
|
|
2029
2284
|
onClose: close,
|
|
2030
2285
|
trigger
|
|
2031
2286
|
},
|
|
2032
|
-
/* @__PURE__ */
|
|
2287
|
+
/* @__PURE__ */ React14.createElement(
|
|
2033
2288
|
ScrollView,
|
|
2034
2289
|
{
|
|
2035
2290
|
bounces: false,
|
|
@@ -2038,7 +2293,7 @@ function Select({
|
|
|
2038
2293
|
},
|
|
2039
2294
|
options.map((item) => {
|
|
2040
2295
|
if (isOptionGroup(item)) {
|
|
2041
|
-
return /* @__PURE__ */
|
|
2296
|
+
return /* @__PURE__ */ React14.createElement(View, { key: item.label }, /* @__PURE__ */ React14.createElement(Text, { style: styles.groupLabel }, item.label), item.options.map((opt) => /* @__PURE__ */ React14.createElement(
|
|
2042
2297
|
SelectOptionRow,
|
|
2043
2298
|
{
|
|
2044
2299
|
key: opt.value,
|
|
@@ -2054,7 +2309,7 @@ function Select({
|
|
|
2054
2309
|
}
|
|
2055
2310
|
)));
|
|
2056
2311
|
}
|
|
2057
|
-
return /* @__PURE__ */
|
|
2312
|
+
return /* @__PURE__ */ React14.createElement(
|
|
2058
2313
|
SelectOptionRow,
|
|
2059
2314
|
{
|
|
2060
2315
|
key: item.value,
|
|
@@ -2086,9 +2341,9 @@ function getToggleStyles(tokens, value, disabled) {
|
|
|
2086
2341
|
opacity: disabled ? 0.5 : 1
|
|
2087
2342
|
},
|
|
2088
2343
|
label: {
|
|
2089
|
-
fontFamily: tokens.typography.fonts.
|
|
2090
|
-
fontSize: tokens.typography.
|
|
2091
|
-
fontWeight: tokens.typography.
|
|
2344
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2345
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2346
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2092
2347
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2093
2348
|
},
|
|
2094
2349
|
track: {
|
|
@@ -2118,16 +2373,16 @@ function Toggle({
|
|
|
2118
2373
|
style
|
|
2119
2374
|
}) {
|
|
2120
2375
|
const tokens = useTokens(1);
|
|
2121
|
-
const styles =
|
|
2376
|
+
const styles = React14.useMemo(
|
|
2122
2377
|
() => getToggleStyles(tokens, value, disabled),
|
|
2123
2378
|
[tokens, value, disabled]
|
|
2124
2379
|
);
|
|
2125
|
-
const handlePress =
|
|
2380
|
+
const handlePress = React14.useCallback(() => {
|
|
2126
2381
|
if (!disabled) {
|
|
2127
2382
|
onValueChange(!value);
|
|
2128
2383
|
}
|
|
2129
2384
|
}, [disabled, value, onValueChange]);
|
|
2130
|
-
return /* @__PURE__ */
|
|
2385
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label), /* @__PURE__ */ React14.createElement(
|
|
2131
2386
|
Pressable,
|
|
2132
2387
|
{
|
|
2133
2388
|
onPress: handlePress,
|
|
@@ -2135,7 +2390,7 @@ function Toggle({
|
|
|
2135
2390
|
accessibilityRole: "switch",
|
|
2136
2391
|
accessibilityState: { checked: value, disabled }
|
|
2137
2392
|
},
|
|
2138
|
-
/* @__PURE__ */
|
|
2393
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.track }, /* @__PURE__ */ React14.createElement(View, { style: styles.thumb }))
|
|
2139
2394
|
));
|
|
2140
2395
|
}
|
|
2141
2396
|
var TRACK_HEIGHT2 = 6;
|
|
@@ -2152,15 +2407,15 @@ function getSliderStyles(tokens, disabled) {
|
|
|
2152
2407
|
alignItems: "center"
|
|
2153
2408
|
},
|
|
2154
2409
|
label: {
|
|
2155
|
-
fontFamily: tokens.typography.fonts.
|
|
2156
|
-
fontSize: tokens.typography.
|
|
2157
|
-
fontWeight: tokens.typography.
|
|
2410
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2411
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2412
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2158
2413
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2159
2414
|
},
|
|
2160
2415
|
value: {
|
|
2161
|
-
fontFamily: tokens.typography.fonts.
|
|
2162
|
-
fontSize: tokens.typography.
|
|
2163
|
-
fontWeight: tokens.typography.
|
|
2416
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2417
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2418
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2164
2419
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
2165
2420
|
},
|
|
2166
2421
|
valueInput: {
|
|
@@ -2172,9 +2427,9 @@ function getSliderStyles(tokens, disabled) {
|
|
|
2172
2427
|
borderRadius: 4,
|
|
2173
2428
|
backgroundColor: "transparent",
|
|
2174
2429
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
2175
|
-
fontFamily: tokens.typography.fonts.
|
|
2176
|
-
fontSize: tokens.typography.
|
|
2177
|
-
fontWeight: tokens.typography.
|
|
2430
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2431
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2432
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2178
2433
|
textAlign: "right"
|
|
2179
2434
|
},
|
|
2180
2435
|
trackContainer: {
|
|
@@ -2221,41 +2476,41 @@ function Slider({
|
|
|
2221
2476
|
style
|
|
2222
2477
|
}) {
|
|
2223
2478
|
const tokens = useTokens(1);
|
|
2224
|
-
const styles =
|
|
2479
|
+
const styles = React14.useMemo(
|
|
2225
2480
|
() => getSliderStyles(tokens, disabled),
|
|
2226
2481
|
[tokens, disabled]
|
|
2227
2482
|
);
|
|
2228
|
-
const trackRef =
|
|
2229
|
-
const trackWidth =
|
|
2230
|
-
const trackPageX =
|
|
2231
|
-
const onValueChangeRef =
|
|
2232
|
-
const minRef =
|
|
2233
|
-
const maxRef =
|
|
2234
|
-
const stepRef =
|
|
2235
|
-
const disabledRef =
|
|
2236
|
-
|
|
2483
|
+
const trackRef = React14.useRef(null);
|
|
2484
|
+
const trackWidth = React14.useRef(0);
|
|
2485
|
+
const trackPageX = React14.useRef(0);
|
|
2486
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2487
|
+
const minRef = React14.useRef(min);
|
|
2488
|
+
const maxRef = React14.useRef(max);
|
|
2489
|
+
const stepRef = React14.useRef(step);
|
|
2490
|
+
const disabledRef = React14.useRef(disabled);
|
|
2491
|
+
React14.useEffect(() => {
|
|
2237
2492
|
onValueChangeRef.current = onValueChange;
|
|
2238
2493
|
}, [onValueChange]);
|
|
2239
|
-
|
|
2494
|
+
React14.useEffect(() => {
|
|
2240
2495
|
minRef.current = min;
|
|
2241
2496
|
}, [min]);
|
|
2242
|
-
|
|
2497
|
+
React14.useEffect(() => {
|
|
2243
2498
|
maxRef.current = max;
|
|
2244
2499
|
}, [max]);
|
|
2245
|
-
|
|
2500
|
+
React14.useEffect(() => {
|
|
2246
2501
|
stepRef.current = step;
|
|
2247
2502
|
}, [step]);
|
|
2248
|
-
|
|
2503
|
+
React14.useEffect(() => {
|
|
2249
2504
|
disabledRef.current = disabled;
|
|
2250
2505
|
}, [disabled]);
|
|
2251
|
-
const computeValue =
|
|
2506
|
+
const computeValue = React14.useCallback((pageX) => {
|
|
2252
2507
|
const localX = pageX - trackPageX.current;
|
|
2253
2508
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2254
2509
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
2255
2510
|
const stepped = Math.round(raw / stepRef.current) * stepRef.current;
|
|
2256
2511
|
return Math.min(maxRef.current, Math.max(minRef.current, stepped));
|
|
2257
2512
|
}, []);
|
|
2258
|
-
const panResponder =
|
|
2513
|
+
const panResponder = React14.useRef(
|
|
2259
2514
|
PanResponder.create({
|
|
2260
2515
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2261
2516
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2271,7 +2526,7 @@ function Slider({
|
|
|
2271
2526
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE2);
|
|
2272
2527
|
const thumbLeft = ratio * usableWidth;
|
|
2273
2528
|
const fillWidth = thumbLeft + THUMB_SIZE2 / 2;
|
|
2274
|
-
const handleValueTextSubmit =
|
|
2529
|
+
const handleValueTextSubmit = React14.useCallback(
|
|
2275
2530
|
(text) => {
|
|
2276
2531
|
const raw = Number(text);
|
|
2277
2532
|
if (!Number.isNaN(raw)) {
|
|
@@ -2280,12 +2535,12 @@ function Slider({
|
|
|
2280
2535
|
},
|
|
2281
2536
|
[onValueChange, min, max]
|
|
2282
2537
|
);
|
|
2283
|
-
const [editText, setEditText] =
|
|
2284
|
-
|
|
2538
|
+
const [editText, setEditText] = React14.useState(String(value));
|
|
2539
|
+
React14.useEffect(() => {
|
|
2285
2540
|
setEditText(String(value));
|
|
2286
2541
|
}, [value]);
|
|
2287
2542
|
const showLabel = label || showValue || editableValue;
|
|
2288
|
-
return /* @__PURE__ */
|
|
2543
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, showLabel && /* @__PURE__ */ React14.createElement(View, { style: styles.labelRow }, label && /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label), editableValue ? /* @__PURE__ */ React14.createElement(
|
|
2289
2544
|
TextInput$1,
|
|
2290
2545
|
{
|
|
2291
2546
|
style: styles.valueInput,
|
|
@@ -2297,7 +2552,7 @@ function Slider({
|
|
|
2297
2552
|
selectTextOnFocus: true,
|
|
2298
2553
|
editable: !disabled
|
|
2299
2554
|
}
|
|
2300
|
-
) : showValue && /* @__PURE__ */
|
|
2555
|
+
) : showValue && /* @__PURE__ */ React14.createElement(Text, { style: styles.value }, value)), /* @__PURE__ */ React14.createElement(
|
|
2301
2556
|
View,
|
|
2302
2557
|
{
|
|
2303
2558
|
ref: trackRef,
|
|
@@ -2310,9 +2565,9 @@ function Slider({
|
|
|
2310
2565
|
},
|
|
2311
2566
|
...panResponder.panHandlers
|
|
2312
2567
|
},
|
|
2313
|
-
/* @__PURE__ */
|
|
2314
|
-
/* @__PURE__ */
|
|
2315
|
-
/* @__PURE__ */
|
|
2568
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.trackRail }),
|
|
2569
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.trackFill, { width: fillWidth }] }),
|
|
2570
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2316
2571
|
));
|
|
2317
2572
|
}
|
|
2318
2573
|
var TRACK_HEIGHT3 = 22;
|
|
@@ -2368,15 +2623,15 @@ function getHueSliderStyles(tokens, disabled) {
|
|
|
2368
2623
|
alignItems: "center"
|
|
2369
2624
|
},
|
|
2370
2625
|
label: {
|
|
2371
|
-
fontFamily: tokens.typography.fonts.
|
|
2372
|
-
fontSize: tokens.typography.
|
|
2373
|
-
fontWeight: tokens.typography.
|
|
2626
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2627
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2628
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2374
2629
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2375
2630
|
},
|
|
2376
2631
|
value: {
|
|
2377
|
-
fontFamily: tokens.typography.fonts.
|
|
2378
|
-
fontSize: tokens.typography.
|
|
2379
|
-
fontWeight: tokens.typography.
|
|
2632
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2633
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2634
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2380
2635
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
2381
2636
|
},
|
|
2382
2637
|
valueInput: {
|
|
@@ -2388,9 +2643,9 @@ function getHueSliderStyles(tokens, disabled) {
|
|
|
2388
2643
|
borderRadius: 4,
|
|
2389
2644
|
backgroundColor: "transparent",
|
|
2390
2645
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
2391
|
-
fontFamily: tokens.typography.fonts.
|
|
2392
|
-
fontSize: tokens.typography.
|
|
2393
|
-
fontWeight: tokens.typography.
|
|
2646
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2647
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2648
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2394
2649
|
textAlign: "right"
|
|
2395
2650
|
},
|
|
2396
2651
|
trackContainer: {
|
|
@@ -2435,41 +2690,41 @@ function HueSlider({
|
|
|
2435
2690
|
style
|
|
2436
2691
|
}) {
|
|
2437
2692
|
const tokens = useTokens(1);
|
|
2438
|
-
const styles =
|
|
2693
|
+
const styles = React14.useMemo(
|
|
2439
2694
|
() => getHueSliderStyles(tokens, disabled),
|
|
2440
2695
|
[tokens, disabled]
|
|
2441
2696
|
);
|
|
2442
|
-
const segments =
|
|
2697
|
+
const segments = React14.useMemo(
|
|
2443
2698
|
() => buildHueSegments(min, max),
|
|
2444
2699
|
[min, max]
|
|
2445
2700
|
);
|
|
2446
|
-
const trackRef =
|
|
2447
|
-
const trackWidth =
|
|
2448
|
-
const trackPageX =
|
|
2449
|
-
const onValueChangeRef =
|
|
2450
|
-
const minRef =
|
|
2451
|
-
const maxRef =
|
|
2452
|
-
const disabledRef =
|
|
2453
|
-
|
|
2701
|
+
const trackRef = React14.useRef(null);
|
|
2702
|
+
const trackWidth = React14.useRef(0);
|
|
2703
|
+
const trackPageX = React14.useRef(0);
|
|
2704
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2705
|
+
const minRef = React14.useRef(min);
|
|
2706
|
+
const maxRef = React14.useRef(max);
|
|
2707
|
+
const disabledRef = React14.useRef(disabled);
|
|
2708
|
+
React14.useEffect(() => {
|
|
2454
2709
|
onValueChangeRef.current = onValueChange;
|
|
2455
2710
|
}, [onValueChange]);
|
|
2456
|
-
|
|
2711
|
+
React14.useEffect(() => {
|
|
2457
2712
|
minRef.current = min;
|
|
2458
2713
|
}, [min]);
|
|
2459
|
-
|
|
2714
|
+
React14.useEffect(() => {
|
|
2460
2715
|
maxRef.current = max;
|
|
2461
2716
|
}, [max]);
|
|
2462
|
-
|
|
2717
|
+
React14.useEffect(() => {
|
|
2463
2718
|
disabledRef.current = disabled;
|
|
2464
2719
|
}, [disabled]);
|
|
2465
|
-
const computeHue =
|
|
2720
|
+
const computeHue = React14.useCallback((pageX) => {
|
|
2466
2721
|
const localX = pageX - trackPageX.current;
|
|
2467
2722
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2468
2723
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
2469
2724
|
const stepped = Math.round(raw);
|
|
2470
2725
|
return (stepped % 360 + 360) % 360;
|
|
2471
2726
|
}, []);
|
|
2472
|
-
const panResponder =
|
|
2727
|
+
const panResponder = React14.useRef(
|
|
2473
2728
|
PanResponder.create({
|
|
2474
2729
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2475
2730
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2485,7 +2740,7 @@ function HueSlider({
|
|
|
2485
2740
|
const ratio = max > min ? (sliderValue - min) / (max - min) : 0;
|
|
2486
2741
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE3);
|
|
2487
2742
|
const thumbLeft = ratio * usableWidth;
|
|
2488
|
-
const handleValueTextSubmit =
|
|
2743
|
+
const handleValueTextSubmit = React14.useCallback(
|
|
2489
2744
|
(text) => {
|
|
2490
2745
|
const raw = Number(text);
|
|
2491
2746
|
if (!Number.isNaN(raw)) {
|
|
@@ -2494,12 +2749,12 @@ function HueSlider({
|
|
|
2494
2749
|
},
|
|
2495
2750
|
[onValueChange]
|
|
2496
2751
|
);
|
|
2497
|
-
const [editText, setEditText] =
|
|
2498
|
-
|
|
2752
|
+
const [editText, setEditText] = React14.useState(String(value));
|
|
2753
|
+
React14.useEffect(() => {
|
|
2499
2754
|
setEditText(String(value));
|
|
2500
2755
|
}, [value]);
|
|
2501
2756
|
const showLabel = label || showValue || editableValue;
|
|
2502
|
-
return /* @__PURE__ */
|
|
2757
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, showLabel && /* @__PURE__ */ React14.createElement(View, { style: styles.labelRow }, label && /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label), editableValue ? /* @__PURE__ */ React14.createElement(
|
|
2503
2758
|
TextInput$1,
|
|
2504
2759
|
{
|
|
2505
2760
|
style: styles.valueInput,
|
|
@@ -2511,7 +2766,7 @@ function HueSlider({
|
|
|
2511
2766
|
selectTextOnFocus: true,
|
|
2512
2767
|
editable: !disabled
|
|
2513
2768
|
}
|
|
2514
|
-
) : showValue && /* @__PURE__ */
|
|
2769
|
+
) : showValue && /* @__PURE__ */ React14.createElement(Text, { style: styles.value }, value, "\xB0")), /* @__PURE__ */ React14.createElement(
|
|
2515
2770
|
View,
|
|
2516
2771
|
{
|
|
2517
2772
|
ref: trackRef,
|
|
@@ -2524,8 +2779,8 @@ function HueSlider({
|
|
|
2524
2779
|
},
|
|
2525
2780
|
...panResponder.panHandlers
|
|
2526
2781
|
},
|
|
2527
|
-
/* @__PURE__ */
|
|
2528
|
-
/* @__PURE__ */
|
|
2782
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.gradientTrack }, segments.map((color, i) => /* @__PURE__ */ React14.createElement(View, { key: i, style: [styles.segment, { backgroundColor: color }] }))),
|
|
2783
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2529
2784
|
));
|
|
2530
2785
|
}
|
|
2531
2786
|
var TRACK_HEIGHT4 = 22;
|
|
@@ -2542,9 +2797,9 @@ function getColorScaleSliderStyles(tokens, disabled) {
|
|
|
2542
2797
|
alignItems: "center"
|
|
2543
2798
|
},
|
|
2544
2799
|
label: {
|
|
2545
|
-
fontFamily: tokens.typography.fonts.
|
|
2546
|
-
fontSize: tokens.typography.
|
|
2547
|
-
fontWeight: tokens.typography.
|
|
2800
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2801
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2802
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2548
2803
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2549
2804
|
},
|
|
2550
2805
|
trackContainer: {
|
|
@@ -2574,9 +2829,9 @@ function getColorScaleSliderStyles(tokens, disabled) {
|
|
|
2574
2829
|
borderColor: srgbToHex(tokens.border.srgb)
|
|
2575
2830
|
},
|
|
2576
2831
|
warning: {
|
|
2577
|
-
fontFamily: tokens.typography.fonts.
|
|
2578
|
-
fontSize: tokens.typography.
|
|
2579
|
-
fontWeight: tokens.typography.
|
|
2832
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2833
|
+
fontSize: tokens.typography.fontSizes["01"],
|
|
2834
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2580
2835
|
color: srgbToHex(tokens.error.fill.srgb)
|
|
2581
2836
|
}
|
|
2582
2837
|
});
|
|
@@ -2596,36 +2851,36 @@ function ColorScaleSlider({
|
|
|
2596
2851
|
style
|
|
2597
2852
|
}) {
|
|
2598
2853
|
const tokens = useTokens(1);
|
|
2599
|
-
const styles =
|
|
2854
|
+
const styles = React14.useMemo(
|
|
2600
2855
|
() => getColorScaleSliderStyles(tokens, disabled),
|
|
2601
2856
|
[tokens, disabled]
|
|
2602
2857
|
);
|
|
2603
|
-
const trackRef =
|
|
2604
|
-
const trackWidth =
|
|
2605
|
-
const trackPageX =
|
|
2606
|
-
const isDragging =
|
|
2607
|
-
const thumbAnim =
|
|
2608
|
-
const onValueChangeRef =
|
|
2609
|
-
const disabledRef =
|
|
2610
|
-
const colorsLengthRef =
|
|
2611
|
-
const trimEndsRef =
|
|
2612
|
-
const snapRef =
|
|
2613
|
-
|
|
2858
|
+
const trackRef = React14.useRef(null);
|
|
2859
|
+
const trackWidth = React14.useRef(0);
|
|
2860
|
+
const trackPageX = React14.useRef(0);
|
|
2861
|
+
const isDragging = React14.useRef(false);
|
|
2862
|
+
const thumbAnim = React14.useRef(new Animated.Value(0)).current;
|
|
2863
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2864
|
+
const disabledRef = React14.useRef(disabled);
|
|
2865
|
+
const colorsLengthRef = React14.useRef(colors.length);
|
|
2866
|
+
const trimEndsRef = React14.useRef(trimEnds);
|
|
2867
|
+
const snapRef = React14.useRef(snap);
|
|
2868
|
+
React14.useEffect(() => {
|
|
2614
2869
|
onValueChangeRef.current = onValueChange;
|
|
2615
2870
|
}, [onValueChange]);
|
|
2616
|
-
|
|
2871
|
+
React14.useEffect(() => {
|
|
2617
2872
|
disabledRef.current = disabled;
|
|
2618
2873
|
}, [disabled]);
|
|
2619
|
-
|
|
2874
|
+
React14.useEffect(() => {
|
|
2620
2875
|
colorsLengthRef.current = colors.length;
|
|
2621
2876
|
}, [colors.length]);
|
|
2622
|
-
|
|
2877
|
+
React14.useEffect(() => {
|
|
2623
2878
|
trimEndsRef.current = trimEnds;
|
|
2624
2879
|
}, [trimEnds]);
|
|
2625
|
-
|
|
2880
|
+
React14.useEffect(() => {
|
|
2626
2881
|
snapRef.current = snap;
|
|
2627
2882
|
}, [snap]);
|
|
2628
|
-
const computeNv =
|
|
2883
|
+
const computeNv = React14.useCallback((pageX) => {
|
|
2629
2884
|
const localX = pageX - trackPageX.current;
|
|
2630
2885
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2631
2886
|
const totalSteps2 = colorsLengthRef.current - 1;
|
|
@@ -2640,7 +2895,7 @@ function ColorScaleSlider({
|
|
|
2640
2895
|
}
|
|
2641
2896
|
return nv;
|
|
2642
2897
|
}, []);
|
|
2643
|
-
const panResponder =
|
|
2898
|
+
const panResponder = React14.useRef(
|
|
2644
2899
|
PanResponder.create({
|
|
2645
2900
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2646
2901
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2668,7 +2923,7 @@ function ColorScaleSlider({
|
|
|
2668
2923
|
const ratio = range > 0 ? (maxNV - clampedValue) / range : 0.5;
|
|
2669
2924
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE4);
|
|
2670
2925
|
const thumbLeft = ratio * usableWidth;
|
|
2671
|
-
|
|
2926
|
+
React14.useEffect(() => {
|
|
2672
2927
|
if (isDragging.current || !animateValue) {
|
|
2673
2928
|
thumbAnim.setValue(thumbLeft);
|
|
2674
2929
|
} else {
|
|
@@ -2679,7 +2934,7 @@ function ColorScaleSlider({
|
|
|
2679
2934
|
}).start();
|
|
2680
2935
|
}
|
|
2681
2936
|
}, [thumbLeft, animateValue, thumbAnim]);
|
|
2682
|
-
return /* @__PURE__ */
|
|
2937
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React14.createElement(View, { style: styles.labelRow }, /* @__PURE__ */ React14.createElement(Text, { style: styles.label }, label)), /* @__PURE__ */ React14.createElement(
|
|
2683
2938
|
View,
|
|
2684
2939
|
{
|
|
2685
2940
|
ref: trackRef,
|
|
@@ -2694,9 +2949,9 @@ function ColorScaleSlider({
|
|
|
2694
2949
|
},
|
|
2695
2950
|
...panResponder.panHandlers
|
|
2696
2951
|
},
|
|
2697
|
-
/* @__PURE__ */
|
|
2698
|
-
/* @__PURE__ */
|
|
2699
|
-
), warning && /* @__PURE__ */
|
|
2952
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.gradientTrack }, visibleColors.map((color, i) => /* @__PURE__ */ React14.createElement(View, { key: i, style: [styles.segment, { backgroundColor: srgbToHex(color.srgb) }] }))),
|
|
2953
|
+
/* @__PURE__ */ React14.createElement(Animated.View, { style: [styles.thumb, { left: thumbAnim }] })
|
|
2954
|
+
), warning && /* @__PURE__ */ React14.createElement(Text, { style: styles.warning }, warning));
|
|
2700
2955
|
}
|
|
2701
2956
|
function getAppShellStyles(tokens) {
|
|
2702
2957
|
return StyleSheet.create({
|
|
@@ -2718,8 +2973,8 @@ function getAppShellStyles(tokens) {
|
|
|
2718
2973
|
// src/composites/layout/AppShell/AppShell.tsx
|
|
2719
2974
|
function AppShell({ sidebar, children }) {
|
|
2720
2975
|
const tokens = useTokens();
|
|
2721
|
-
const styles =
|
|
2722
|
-
return /* @__PURE__ */
|
|
2976
|
+
const styles = React14.useMemo(() => getAppShellStyles(tokens), [tokens]);
|
|
2977
|
+
return /* @__PURE__ */ React14.createElement(View, { style: styles.container }, sidebar, /* @__PURE__ */ React14.createElement(View, { style: styles.main }, children));
|
|
2723
2978
|
}
|
|
2724
2979
|
function getSidebarStyles({ tokens, width, bordered }) {
|
|
2725
2980
|
const borderColor = srgbToHex(tokens.border.srgb);
|
|
@@ -2757,11 +3012,11 @@ function Sidebar({
|
|
|
2757
3012
|
bordered = true
|
|
2758
3013
|
}) {
|
|
2759
3014
|
const tokens = useTokens();
|
|
2760
|
-
const styles =
|
|
3015
|
+
const styles = React14.useMemo(
|
|
2761
3016
|
() => getSidebarStyles({ tokens, width, bordered }),
|
|
2762
3017
|
[tokens, width, bordered]
|
|
2763
3018
|
);
|
|
2764
|
-
return /* @__PURE__ */
|
|
3019
|
+
return /* @__PURE__ */ React14.createElement(View, { style: styles.container }, header && /* @__PURE__ */ React14.createElement(View, { style: styles.header }, header), /* @__PURE__ */ React14.createElement(ScrollView, { style: styles.body }, children), footer && /* @__PURE__ */ React14.createElement(View, { style: styles.footer }, footer));
|
|
2765
3020
|
}
|
|
2766
3021
|
function getNavbarStyles({ tokens, height, bordered }) {
|
|
2767
3022
|
const borderColor = srgbToHex(tokens.border.srgb);
|
|
@@ -2799,28 +3054,27 @@ function Navbar({
|
|
|
2799
3054
|
bordered = true
|
|
2800
3055
|
}) {
|
|
2801
3056
|
const tokens = useTokens();
|
|
2802
|
-
const styles =
|
|
3057
|
+
const styles = React14.useMemo(
|
|
2803
3058
|
() => getNavbarStyles({ tokens, height, bordered }),
|
|
2804
3059
|
[tokens, height, bordered]
|
|
2805
3060
|
);
|
|
2806
|
-
return /* @__PURE__ */
|
|
3061
|
+
return /* @__PURE__ */ React14.createElement(View, { style: styles.container }, children ? children : /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(View, { style: styles.left }, left), /* @__PURE__ */ React14.createElement(View, { style: styles.right }, right)));
|
|
2807
3062
|
}
|
|
2808
3063
|
|
|
2809
3064
|
// src/registry/registry.ts
|
|
2810
3065
|
var CATEGORIES = [
|
|
2811
|
-
{ id: "
|
|
2812
|
-
{ id: "
|
|
2813
|
-
{ id: "
|
|
2814
|
-
{ id: "
|
|
2815
|
-
{ id: "
|
|
2816
|
-
{ id: "overlays", name: "Overlays", description: "Floating and portal-based UI elements" }
|
|
3066
|
+
{ id: "colors", name: "Colors", description: "Color palettes and token visualization", icon: "palette" },
|
|
3067
|
+
{ id: "typography", name: "Typography", description: "Text roles, scopes, and weight control", icon: "text_fields" },
|
|
3068
|
+
{ id: "symbols", name: "Symbols", description: "Material Symbols icon browser", icon: "grid_view" },
|
|
3069
|
+
{ id: "layout", name: "Layout", description: "Structural containers \u2014 Frame and Wrapper", icon: "grid_on" },
|
|
3070
|
+
{ id: "components", name: "Components", description: "Interactive UI components", icon: "widgets" }
|
|
2817
3071
|
];
|
|
2818
3072
|
var COMPONENTS = [
|
|
2819
3073
|
{
|
|
2820
3074
|
id: "button",
|
|
2821
3075
|
name: "Button",
|
|
2822
3076
|
importName: "Button",
|
|
2823
|
-
categoryId: "
|
|
3077
|
+
categoryId: "components",
|
|
2824
3078
|
description: "Interactive button with multiple variants, sizes, and optional icon",
|
|
2825
3079
|
hasChildren: true,
|
|
2826
3080
|
variants: [
|
|
@@ -2902,7 +3156,7 @@ var COMPONENTS = [
|
|
|
2902
3156
|
id: "text-input",
|
|
2903
3157
|
name: "TextInput",
|
|
2904
3158
|
importName: "TextInput",
|
|
2905
|
-
categoryId: "
|
|
3159
|
+
categoryId: "components",
|
|
2906
3160
|
description: "Text input field with label support",
|
|
2907
3161
|
hasChildren: false,
|
|
2908
3162
|
variants: [
|
|
@@ -2929,7 +3183,7 @@ var COMPONENTS = [
|
|
|
2929
3183
|
id: "select",
|
|
2930
3184
|
name: "Select",
|
|
2931
3185
|
importName: "Select",
|
|
2932
|
-
categoryId: "
|
|
3186
|
+
categoryId: "components",
|
|
2933
3187
|
description: "Dropdown selector with options",
|
|
2934
3188
|
hasChildren: false,
|
|
2935
3189
|
variants: [
|
|
@@ -2976,7 +3230,7 @@ var COMPONENTS = [
|
|
|
2976
3230
|
id: "toggle",
|
|
2977
3231
|
name: "Toggle",
|
|
2978
3232
|
importName: "Toggle",
|
|
2979
|
-
categoryId: "
|
|
3233
|
+
categoryId: "components",
|
|
2980
3234
|
description: "Binary switch component",
|
|
2981
3235
|
hasChildren: false,
|
|
2982
3236
|
variants: [
|
|
@@ -3003,7 +3257,7 @@ var COMPONENTS = [
|
|
|
3003
3257
|
id: "slider",
|
|
3004
3258
|
name: "Slider",
|
|
3005
3259
|
importName: "Slider",
|
|
3006
|
-
categoryId: "
|
|
3260
|
+
categoryId: "components",
|
|
3007
3261
|
description: "Numeric range slider",
|
|
3008
3262
|
hasChildren: false,
|
|
3009
3263
|
variants: [
|
|
@@ -3047,7 +3301,7 @@ var COMPONENTS = [
|
|
|
3047
3301
|
id: "hue-slider",
|
|
3048
3302
|
name: "HueSlider",
|
|
3049
3303
|
importName: "HueSlider",
|
|
3050
|
-
categoryId: "
|
|
3304
|
+
categoryId: "components",
|
|
3051
3305
|
description: "Specialized slider for hue selection (0-360\xB0)",
|
|
3052
3306
|
hasChildren: false,
|
|
3053
3307
|
variants: [
|
|
@@ -3183,7 +3437,7 @@ var COMPONENTS = [
|
|
|
3183
3437
|
id: "card",
|
|
3184
3438
|
name: "Card",
|
|
3185
3439
|
importName: "Card",
|
|
3186
|
-
categoryId: "
|
|
3440
|
+
categoryId: "components",
|
|
3187
3441
|
description: "Surface container with elevation levels",
|
|
3188
3442
|
hasChildren: true,
|
|
3189
3443
|
variants: [
|
|
@@ -3216,45 +3470,59 @@ var COMPONENTS = [
|
|
|
3216
3470
|
id: "text",
|
|
3217
3471
|
name: "Text",
|
|
3218
3472
|
importName: "Text",
|
|
3219
|
-
categoryId: "
|
|
3220
|
-
description: "Typography primitive with semantic
|
|
3473
|
+
categoryId: "typography",
|
|
3474
|
+
description: "Typography primitive with semantic scope (font family) and role (purpose)",
|
|
3221
3475
|
hasChildren: true,
|
|
3476
|
+
previewLayout: "list",
|
|
3222
3477
|
variants: [
|
|
3223
|
-
{ id: "
|
|
3224
|
-
{ id: "
|
|
3225
|
-
{ id: "
|
|
3226
|
-
{ id: "
|
|
3227
|
-
{ id: "
|
|
3228
|
-
{ id: "
|
|
3229
|
-
{ id: "
|
|
3478
|
+
{ id: "body", label: "Body", props: { role: "body" } },
|
|
3479
|
+
{ id: "headline", label: "Headline", props: { role: "headline", scope: "display" } },
|
|
3480
|
+
{ id: "title", label: "Title", props: { role: "title", scope: "display" } },
|
|
3481
|
+
{ id: "heading", label: "Heading", props: { role: "heading" } },
|
|
3482
|
+
{ id: "subheading", label: "Subheading", props: { role: "subheading" } },
|
|
3483
|
+
{ id: "label", label: "Label", props: { role: "label" } },
|
|
3484
|
+
{ id: "caption", label: "Caption", props: { role: "caption", color: "secondary" } },
|
|
3485
|
+
{ id: "mono", label: "Monospace", props: { scope: "mono", role: "body" } },
|
|
3486
|
+
{ id: "currency", label: "Currency", props: { scope: "currency", role: "body" } }
|
|
3230
3487
|
],
|
|
3231
3488
|
editableProps: [
|
|
3232
3489
|
{
|
|
3233
|
-
name: "
|
|
3234
|
-
label: "
|
|
3490
|
+
name: "scope",
|
|
3491
|
+
label: "Scope",
|
|
3235
3492
|
control: "select",
|
|
3236
3493
|
options: [
|
|
3237
|
-
{ label: "
|
|
3238
|
-
{ label: "
|
|
3239
|
-
{ label: "
|
|
3240
|
-
{ label: "
|
|
3241
|
-
{ label: "Large", value: "lg" },
|
|
3242
|
-
{ label: "Extra Large", value: "xl" },
|
|
3243
|
-
{ label: "XXL", value: "xxl" }
|
|
3494
|
+
{ label: "Main", value: "main" },
|
|
3495
|
+
{ label: "Display", value: "display" },
|
|
3496
|
+
{ label: "Mono", value: "mono" },
|
|
3497
|
+
{ label: "Currency", value: "currency" }
|
|
3244
3498
|
],
|
|
3245
|
-
defaultValue: "
|
|
3499
|
+
defaultValue: "main"
|
|
3246
3500
|
},
|
|
3247
3501
|
{
|
|
3248
|
-
name: "
|
|
3249
|
-
label: "
|
|
3502
|
+
name: "role",
|
|
3503
|
+
label: "Role",
|
|
3250
3504
|
control: "select",
|
|
3251
3505
|
options: [
|
|
3252
|
-
{ label: "
|
|
3253
|
-
{ label: "
|
|
3254
|
-
{ label: "
|
|
3255
|
-
{ label: "
|
|
3506
|
+
{ label: "Headline", value: "headline" },
|
|
3507
|
+
{ label: "Title", value: "title" },
|
|
3508
|
+
{ label: "Heading", value: "heading" },
|
|
3509
|
+
{ label: "Subheading", value: "subheading" },
|
|
3510
|
+
{ label: "Body", value: "body" },
|
|
3511
|
+
{ label: "Label", value: "label" },
|
|
3512
|
+
{ label: "Caption", value: "caption" }
|
|
3256
3513
|
],
|
|
3257
|
-
defaultValue: "
|
|
3514
|
+
defaultValue: "body"
|
|
3515
|
+
},
|
|
3516
|
+
{
|
|
3517
|
+
name: "size",
|
|
3518
|
+
label: "Size",
|
|
3519
|
+
control: "select",
|
|
3520
|
+
options: [
|
|
3521
|
+
{ label: "Small", value: "sm" },
|
|
3522
|
+
{ label: "Medium", value: "md" },
|
|
3523
|
+
{ label: "Large", value: "lg" }
|
|
3524
|
+
],
|
|
3525
|
+
defaultValue: "md"
|
|
3258
3526
|
},
|
|
3259
3527
|
{
|
|
3260
3528
|
name: "color",
|
|
@@ -3271,17 +3539,6 @@ var COMPONENTS = [
|
|
|
3271
3539
|
{ label: "Error", value: "error" }
|
|
3272
3540
|
],
|
|
3273
3541
|
defaultValue: "primary"
|
|
3274
|
-
},
|
|
3275
|
-
{
|
|
3276
|
-
name: "font",
|
|
3277
|
-
label: "Font",
|
|
3278
|
-
control: "select",
|
|
3279
|
-
options: [
|
|
3280
|
-
{ label: "Default", value: "default" },
|
|
3281
|
-
{ label: "Display", value: "display" },
|
|
3282
|
-
{ label: "Mono", value: "mono" }
|
|
3283
|
-
],
|
|
3284
|
-
defaultValue: "default"
|
|
3285
3542
|
}
|
|
3286
3543
|
]
|
|
3287
3544
|
},
|
|
@@ -3289,7 +3546,7 @@ var COMPONENTS = [
|
|
|
3289
3546
|
id: "icon",
|
|
3290
3547
|
name: "Icon",
|
|
3291
3548
|
importName: "Icon",
|
|
3292
|
-
categoryId: "
|
|
3549
|
+
categoryId: "symbols",
|
|
3293
3550
|
description: "Material Symbols icon with size and fill",
|
|
3294
3551
|
hasChildren: false,
|
|
3295
3552
|
variants: [
|
|
@@ -3326,7 +3583,7 @@ var COMPONENTS = [
|
|
|
3326
3583
|
id: "wrapper",
|
|
3327
3584
|
name: "Wrapper",
|
|
3328
3585
|
importName: "Wrapper",
|
|
3329
|
-
categoryId: "
|
|
3586
|
+
categoryId: "layout",
|
|
3330
3587
|
description: "Lightweight layout container with direction, spacing, and alignment (no theming)",
|
|
3331
3588
|
hasChildren: true,
|
|
3332
3589
|
variants: [
|
|
@@ -3400,7 +3657,7 @@ var COMPONENTS = [
|
|
|
3400
3657
|
id: "color-scale-slider",
|
|
3401
3658
|
name: "ColorScaleSlider",
|
|
3402
3659
|
importName: "ColorScaleSlider",
|
|
3403
|
-
categoryId: "
|
|
3660
|
+
categoryId: "components",
|
|
3404
3661
|
description: "Interactive palette preview slider with color segments",
|
|
3405
3662
|
hasChildren: false,
|
|
3406
3663
|
variants: [
|
|
@@ -3443,6 +3700,7 @@ var HANDLER_PROPS = {
|
|
|
3443
3700
|
};
|
|
3444
3701
|
var CHILDREN_CONTENT = {
|
|
3445
3702
|
button: "Button",
|
|
3703
|
+
text: "The quick brown fox",
|
|
3446
3704
|
card: "{/* content */}",
|
|
3447
3705
|
frame: "{/* content */}"
|
|
3448
3706
|
};
|
|
@@ -3748,72 +4006,6 @@ var ICON_CATALOG = [
|
|
|
3748
4006
|
}
|
|
3749
4007
|
];
|
|
3750
4008
|
|
|
3751
|
-
|
|
3752
|
-
var GOOGLE_FONTS = [
|
|
3753
|
-
// Sans-serif
|
|
3754
|
-
{ family: "Inter", category: "sans-serif", fallback: "sans-serif" },
|
|
3755
|
-
{ family: "Roboto", category: "sans-serif", fallback: "sans-serif" },
|
|
3756
|
-
{ family: "Open Sans", category: "sans-serif", fallback: "sans-serif" },
|
|
3757
|
-
{ family: "Lato", category: "sans-serif", fallback: "sans-serif" },
|
|
3758
|
-
{ family: "Montserrat", category: "sans-serif", fallback: "sans-serif" },
|
|
3759
|
-
{ family: "Poppins", category: "sans-serif", fallback: "sans-serif" },
|
|
3760
|
-
{ family: "Nunito", category: "sans-serif", fallback: "sans-serif" },
|
|
3761
|
-
{ family: "Source Sans 3", category: "sans-serif", fallback: "sans-serif" },
|
|
3762
|
-
{ family: "Work Sans", category: "sans-serif", fallback: "sans-serif" },
|
|
3763
|
-
{ family: "Raleway", category: "sans-serif", fallback: "sans-serif" },
|
|
3764
|
-
{ family: "DM Sans", category: "sans-serif", fallback: "sans-serif" },
|
|
3765
|
-
{ family: "Plus Jakarta Sans", category: "sans-serif", fallback: "sans-serif" },
|
|
3766
|
-
{ family: "Outfit", category: "sans-serif", fallback: "sans-serif" },
|
|
3767
|
-
{ family: "Space Grotesk", category: "sans-serif", fallback: "sans-serif" },
|
|
3768
|
-
{ family: "Manrope", category: "sans-serif", fallback: "sans-serif" },
|
|
3769
|
-
// Serif
|
|
3770
|
-
{ family: "Playfair Display", category: "serif", fallback: "serif" },
|
|
3771
|
-
{ family: "Merriweather", category: "serif", fallback: "serif" },
|
|
3772
|
-
{ family: "Lora", category: "serif", fallback: "serif" },
|
|
3773
|
-
{ family: "Libre Baskerville", category: "serif", fallback: "serif" },
|
|
3774
|
-
{ family: "Source Serif 4", category: "serif", fallback: "serif" },
|
|
3775
|
-
{ family: "Bitter", category: "serif", fallback: "serif" },
|
|
3776
|
-
{ family: "Cormorant Garamond", category: "serif", fallback: "serif" },
|
|
3777
|
-
{ family: "EB Garamond", category: "serif", fallback: "serif" },
|
|
3778
|
-
{ family: "Crimson Text", category: "serif", fallback: "serif" },
|
|
3779
|
-
{ family: "Noto Serif", category: "serif", fallback: "serif" },
|
|
3780
|
-
// Monospace
|
|
3781
|
-
{ family: "Fira Code", category: "monospace", fallback: "monospace" },
|
|
3782
|
-
{ family: "JetBrains Mono", category: "monospace", fallback: "monospace" },
|
|
3783
|
-
{ family: "Source Code Pro", category: "monospace", fallback: "monospace" },
|
|
3784
|
-
{ family: "IBM Plex Mono", category: "monospace", fallback: "monospace" },
|
|
3785
|
-
{ family: "Roboto Mono", category: "monospace", fallback: "monospace" },
|
|
3786
|
-
{ family: "Space Mono", category: "monospace", fallback: "monospace" },
|
|
3787
|
-
{ family: "Ubuntu Mono", category: "monospace", fallback: "monospace" },
|
|
3788
|
-
{ family: "Inconsolata", category: "monospace", fallback: "monospace" },
|
|
3789
|
-
// Display
|
|
3790
|
-
{ family: "Abril Fatface", category: "display", fallback: "serif" },
|
|
3791
|
-
{ family: "Bebas Neue", category: "display", fallback: "sans-serif" },
|
|
3792
|
-
{ family: "Oswald", category: "display", fallback: "sans-serif" },
|
|
3793
|
-
{ family: "Righteous", category: "display", fallback: "sans-serif" },
|
|
3794
|
-
{ family: "Lobster", category: "display", fallback: "cursive" },
|
|
3795
|
-
{ family: "Pacifico", category: "display", fallback: "cursive" },
|
|
3796
|
-
{ family: "Comfortaa", category: "display", fallback: "sans-serif" },
|
|
3797
|
-
{ family: "Fredoka", category: "display", fallback: "sans-serif" }
|
|
3798
|
-
];
|
|
3799
|
-
var SYSTEM_FONTS = [
|
|
3800
|
-
{
|
|
3801
|
-
family: "system-ui",
|
|
3802
|
-
category: "sans-serif",
|
|
3803
|
-
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
3804
|
-
},
|
|
3805
|
-
{
|
|
3806
|
-
family: "ui-monospace",
|
|
3807
|
-
category: "monospace",
|
|
3808
|
-
fallback: "SFMono-Regular, Menlo, Monaco, Consolas, monospace"
|
|
3809
|
-
},
|
|
3810
|
-
{
|
|
3811
|
-
family: "ui-serif",
|
|
3812
|
-
category: "serif",
|
|
3813
|
-
fallback: 'Georgia, "Times New Roman", serif'
|
|
3814
|
-
}
|
|
3815
|
-
];
|
|
3816
|
-
|
|
3817
|
-
export { ACCENT_DEFAULTS, AppShell, Button, CATEGORIES, COMPONENTS, Card, ColorScaleSlider, DEFAULT_THEME_CONFIG, ERROR_DEFAULTS, Frame, GOOGLE_FONTS, HueSlider, ICON_CATALOG, Icon, NEUTRAL_DEFAULTS, Navbar, NewtoneProvider, Popover, SUCCESS_DEFAULTS, SYSTEM_FONTS, Select, Sidebar, Slider, Text2 as Text, TextInput, Toggle, WARNING_DEFAULTS, Wrapper, buildGoogleFontsUrl, computeTokens, generateComponentCode, getCategory, getComponent, getComponentsByCategory, isOptionGroup, useFocusVisible, useFrameContext, useNewtoneTheme, usePopover, useTokens };
|
|
4009
|
+
export { ACCENT_DEFAULTS, AppShell, Button, CATEGORIES, COMPONENTS, Card, ColorScaleSlider, DEFAULT_THEME_CONFIG, ERROR_DEFAULTS, Frame, HueSlider, ICON_CATALOG, Icon, NEUTRAL_DEFAULTS, Navbar, NewtoneProvider, Popover, SUCCESS_DEFAULTS, Select, Sidebar, Slider, Text2 as Text, TextInput, Toggle, WARNING_DEFAULTS, Wrapper, computeTokens, generateComponentCode, getCategory, getComponent, getComponentsByCategory, isOptionGroup, measureAvgCharWidth, useFocusVisible, useFrameContext, useLocalCalibration, useNewtoneTheme, usePopover, useTokens, useTypographyCalibrations };
|
|
3818
4010
|
//# sourceMappingURL=index.js.map
|
|
3819
4011
|
//# sourceMappingURL=index.js.map
|