@newtonedev/components 0.1.6 → 0.1.8
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 +863 -437
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +801 -391
- package/dist/index.js.map +1 -1
- package/dist/primitives/Icon/Icon.d.ts +1 -1
- package/dist/primitives/Icon/Icon.d.ts.map +1 -1
- package/dist/primitives/Icon/Icon.types.d.ts +8 -13
- 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 +75 -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/icons.d.ts +7 -0
- package/dist/registry/icons.d.ts.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/types.d.ts +3 -1
- 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 +18 -7
- package/src/primitives/Frame/Frame.tsx +3 -3
- package/src/primitives/Icon/Icon.tsx +5 -7
- package/src/primitives/Icon/Icon.types.ts +8 -15
- package/src/primitives/Text/Text.spans.ts +57 -0
- package/src/primitives/Text/Text.tsx +205 -53
- package/src/primitives/Text/Text.types.ts +80 -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/icons.ts +111 -0
- package/src/registry/index.ts +3 -0
- package/src/registry/registry.ts +67 -70
- package/src/registry/types.ts +3 -1
- 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 { ROLE_DEFAULT_WEIGHTS, BREAKPOINT_ROLE_SCALE, scaleRoleStep, SEMANTIC_WEIGHT_MAP, 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
|
}
|
|
@@ -774,9 +780,7 @@ function Icon({
|
|
|
774
780
|
opticalSize,
|
|
775
781
|
fill = 0,
|
|
776
782
|
color,
|
|
777
|
-
elevation = 1,
|
|
778
783
|
style,
|
|
779
|
-
onPress,
|
|
780
784
|
// Accessibility
|
|
781
785
|
accessibilityLabel,
|
|
782
786
|
// Testing & platform
|
|
@@ -784,9 +788,9 @@ function Icon({
|
|
|
784
788
|
nativeID,
|
|
785
789
|
ref
|
|
786
790
|
}) {
|
|
787
|
-
const tokens = useTokens(
|
|
791
|
+
const tokens = useTokens();
|
|
788
792
|
const iconStyle = useMemo(() => {
|
|
789
|
-
const fontSize = size ?? tokens.typography.
|
|
793
|
+
const fontSize = size ?? tokens.typography.fontSizes["05"];
|
|
790
794
|
const getOpticalSize = (size2) => {
|
|
791
795
|
if (size2 <= 22) return 20;
|
|
792
796
|
if (size2 <= 32) return 24;
|
|
@@ -796,7 +800,8 @@ function Icon({
|
|
|
796
800
|
const opsz = opticalSize ?? getOpticalSize(fontSize);
|
|
797
801
|
const iconColor = color ?? srgbToHex(tokens.textPrimary.srgb);
|
|
798
802
|
const fontFamily = `Material Symbols ${tokens.icons.variant.charAt(0).toUpperCase() + tokens.icons.variant.slice(1)}`;
|
|
799
|
-
const
|
|
803
|
+
const fillValue = typeof fill === "boolean" ? fill ? 1 : 0 : fill;
|
|
804
|
+
const fontVariationSettings = `'FILL' ${fillValue}, 'wght' ${tokens.icons.weight}, 'GRAD' ${tokens.icons.grade}, 'opsz' ${opsz}`;
|
|
800
805
|
return {
|
|
801
806
|
fontFamily,
|
|
802
807
|
fontSize,
|
|
@@ -814,7 +819,7 @@ function Icon({
|
|
|
814
819
|
...style
|
|
815
820
|
};
|
|
816
821
|
}, [tokens, size, opticalSize, fill, color, style]);
|
|
817
|
-
return /* @__PURE__ */
|
|
822
|
+
return /* @__PURE__ */ React14.createElement(
|
|
818
823
|
Text,
|
|
819
824
|
{
|
|
820
825
|
ref,
|
|
@@ -822,12 +827,123 @@ function Icon({
|
|
|
822
827
|
nativeID,
|
|
823
828
|
accessibilityLabel,
|
|
824
829
|
importantForAccessibility: accessibilityLabel ? "yes" : "no-hide-descendants",
|
|
825
|
-
style: iconStyle
|
|
826
|
-
onPress
|
|
830
|
+
style: iconStyle
|
|
827
831
|
},
|
|
828
832
|
name
|
|
829
833
|
);
|
|
830
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);
|
|
831
947
|
function resolveTextColor(color, tokens) {
|
|
832
948
|
switch (color) {
|
|
833
949
|
case "primary":
|
|
@@ -848,53 +964,188 @@ function resolveTextColor(color, tokens) {
|
|
|
848
964
|
return srgbToHex(tokens.error.fill.srgb);
|
|
849
965
|
}
|
|
850
966
|
}
|
|
851
|
-
|
|
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({
|
|
852
986
|
children,
|
|
853
|
-
|
|
854
|
-
|
|
987
|
+
scope = "main",
|
|
988
|
+
role = "body",
|
|
855
989
|
color = "primary",
|
|
856
|
-
|
|
857
|
-
lineHeight = "normal",
|
|
990
|
+
size: sizeOverride,
|
|
858
991
|
align,
|
|
859
992
|
numberOfLines,
|
|
860
993
|
elevation = 1,
|
|
861
994
|
style,
|
|
862
|
-
|
|
863
|
-
accessibilityRole,
|
|
864
|
-
// Testing & platform
|
|
995
|
+
accessibilityRole: accessibilityRoleOverride,
|
|
865
996
|
testID,
|
|
866
997
|
nativeID,
|
|
867
|
-
ref
|
|
998
|
+
ref,
|
|
999
|
+
responsive = false,
|
|
1000
|
+
centerVertically = false,
|
|
1001
|
+
features
|
|
868
1002
|
}) {
|
|
869
1003
|
const tokens = useTokens(elevation);
|
|
1004
|
+
const { config, reportingEndpoint } = useNewtoneTheme();
|
|
1005
|
+
const size = sizeOverride ?? "md";
|
|
1006
|
+
const fontSlot = tokens.typography.fonts[scope];
|
|
1007
|
+
const resolvedFontWeight = config.typography.roleWeights?.[role] ?? ROLE_DEFAULT_WEIGHTS[role];
|
|
1008
|
+
const breakpoint = useBreakpoint();
|
|
1009
|
+
const baseStep = config.typography.roles[role][size];
|
|
1010
|
+
const bpScale = BREAKPOINT_ROLE_SCALE[breakpoint][role];
|
|
1011
|
+
const step = bpScale === 1 ? baseStep : scaleRoleStep(baseStep, bpScale);
|
|
1012
|
+
const calibrations = useTypographyCalibrations();
|
|
1013
|
+
const fontSlotFull = config.typography.fonts[scope];
|
|
1014
|
+
const localRatio = useLocalCalibration(
|
|
1015
|
+
fontSlot.family,
|
|
1016
|
+
SEMANTIC_WEIGHT_MAP.regular,
|
|
1017
|
+
fontSlotFull.config.fallback,
|
|
1018
|
+
calibrations[fontSlot.family]
|
|
1019
|
+
);
|
|
1020
|
+
const isAdaptive = ADAPTIVE_ROLES.has(role);
|
|
1021
|
+
const [containerWidth, setContainerWidth] = useState(null);
|
|
1022
|
+
const characterCount = useMemo(() => extractCharacterCount(children), [children]);
|
|
1023
|
+
const resolvedStep = useMemo(
|
|
1024
|
+
() => resolveResponsiveSize(
|
|
1025
|
+
{
|
|
1026
|
+
role,
|
|
1027
|
+
size,
|
|
1028
|
+
responsive: responsive && isAdaptive,
|
|
1029
|
+
fontFamily: fontSlot.family,
|
|
1030
|
+
maxFontSize: step.fontSize,
|
|
1031
|
+
minFontSize: Math.max(8, Math.round(step.fontSize * 0.7))
|
|
1032
|
+
},
|
|
1033
|
+
config.typography.roles,
|
|
1034
|
+
containerWidth != null ? { containerWidth, characterCount } : void 0,
|
|
1035
|
+
{ [fontSlot.family]: localRatio }
|
|
1036
|
+
),
|
|
1037
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1038
|
+
[role, size, responsive, isAdaptive, fontSlot.family, step.fontSize, config.typography.roles, containerWidth, characterCount, localRatio]
|
|
1039
|
+
);
|
|
1040
|
+
useEffect(() => {
|
|
1041
|
+
if (!reportingEndpoint || !responsive || !isAdaptive || containerWidth == null) return;
|
|
1042
|
+
const lineWidths = estimateLineWidths(characterCount, containerWidth, resolvedStep.fontSize, localRatio);
|
|
1043
|
+
const lastLine = lineWidths[lineWidths.length - 1];
|
|
1044
|
+
enqueueObservation(reportingEndpoint, {
|
|
1045
|
+
fontFamily: fontSlot.family,
|
|
1046
|
+
fontWeight: resolvedFontWeight,
|
|
1047
|
+
role,
|
|
1048
|
+
size,
|
|
1049
|
+
fontSize: resolvedStep.fontSize,
|
|
1050
|
+
containerWidth,
|
|
1051
|
+
characterCount,
|
|
1052
|
+
lineCount: lineWidths.length,
|
|
1053
|
+
lastLineRatio: containerWidth > 0 ? lastLine / containerWidth : 1
|
|
1054
|
+
});
|
|
1055
|
+
}, [reportingEndpoint, resolvedStep.fontSize, containerWidth]);
|
|
870
1056
|
const resolvedStyle = useMemo(() => {
|
|
871
|
-
const
|
|
1057
|
+
const activeStep = responsive && isAdaptive ? resolvedStep : step;
|
|
1058
|
+
const currentMetrics = config.typography.fontMetrics?.[fontSlot.family];
|
|
1059
|
+
const correctedLineHeight = currentMetrics ? Math.round(activeStep.lineHeight * currentMetrics.naturalLineHeightRatio / REFERENCE_LINE_HEIGHT_RATIO / 4) * 4 : activeStep.lineHeight;
|
|
1060
|
+
const vcOffset = centerVertically && currentMetrics ? Math.round(currentMetrics.verticalCenterOffset * activeStep.fontSize * 2) / 2 : 0;
|
|
1061
|
+
const activeFeatures = features ? currentMetrics?.features ? features.filter((tag) => currentMetrics.features.includes(tag)) : [...features] : [];
|
|
1062
|
+
const featureSettings = activeFeatures.length > 0 ? buildFontFeatureSettings(activeFeatures) : void 0;
|
|
872
1063
|
return {
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
// Font weight is stored as a number (e.g. 400, 600) but React Native expects a string.
|
|
877
|
-
fontWeight: String(tokens.typography.weight[weight]),
|
|
878
|
-
// Convert the theme color from internal sRGB format to a hex string (e.g. '#1a1a1a').
|
|
1064
|
+
fontFamily: fontSlot.family,
|
|
1065
|
+
fontSize: activeStep.fontSize,
|
|
1066
|
+
fontWeight: String(resolvedFontWeight),
|
|
879
1067
|
color: resolveTextColor(color, tokens),
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1068
|
+
lineHeight: correctedLineHeight,
|
|
1069
|
+
textAlign: align,
|
|
1070
|
+
...vcOffset !== 0 ? { transform: [{ translateY: vcOffset }] } : {},
|
|
1071
|
+
...featureSettings ? { fontFeatureSettings: featureSettings } : {}
|
|
883
1072
|
};
|
|
884
|
-
}, [tokens,
|
|
885
|
-
|
|
1073
|
+
}, [tokens, fontSlot, step, resolvedStep, responsive, isAdaptive, resolvedFontWeight, color, align, config.typography.fontMetrics, centerVertically, features]);
|
|
1074
|
+
const inferredA11yRole = role === "headline" || role === "title" || role === "heading" ? "header" : void 0;
|
|
1075
|
+
const effectiveA11yRole = accessibilityRoleOverride ?? inferredA11yRole;
|
|
1076
|
+
const ariaLevel = effectiveA11yRole === "header" ? ROLE_HEADING_LEVEL[role] : void 0;
|
|
1077
|
+
const scopeCtx = useMemo(() => ({ weights: SEMANTIC_WEIGHT_MAP }), []);
|
|
1078
|
+
const textNode = /* @__PURE__ */ React14.createElement(TextScopeContext.Provider, { value: scopeCtx }, /* @__PURE__ */ React14.createElement(
|
|
886
1079
|
Text,
|
|
887
1080
|
{
|
|
888
1081
|
ref,
|
|
889
1082
|
testID,
|
|
890
1083
|
nativeID,
|
|
891
|
-
accessibilityRole,
|
|
1084
|
+
accessibilityRole: effectiveA11yRole,
|
|
1085
|
+
"aria-level": ariaLevel,
|
|
892
1086
|
style: style ? [resolvedStyle, ...Array.isArray(style) ? style : [style]] : resolvedStyle,
|
|
893
1087
|
numberOfLines
|
|
894
1088
|
},
|
|
895
1089
|
children
|
|
1090
|
+
));
|
|
1091
|
+
if (responsive && isAdaptive) {
|
|
1092
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1093
|
+
View,
|
|
1094
|
+
{
|
|
1095
|
+
onLayout: (e) => {
|
|
1096
|
+
const w = e.nativeEvent.layout.width;
|
|
1097
|
+
if (w > 0) setContainerWidth(w);
|
|
1098
|
+
},
|
|
1099
|
+
style: { width: "100%" }
|
|
1100
|
+
},
|
|
1101
|
+
textNode
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
return textNode;
|
|
1105
|
+
}
|
|
1106
|
+
function TextSpan({ children, color, weight, italic, underline, highlight, style }) {
|
|
1107
|
+
const tokens = useTokens(1);
|
|
1108
|
+
const scopeCtx = useContext(TextScopeContext);
|
|
1109
|
+
const spanStyle = useMemo(() => {
|
|
1110
|
+
const s = {};
|
|
1111
|
+
if (color) s.color = resolveTextColor(color, tokens);
|
|
1112
|
+
if (weight && scopeCtx) s.fontWeight = String(scopeCtx.weights[weight]);
|
|
1113
|
+
if (italic) s.fontStyle = "italic";
|
|
1114
|
+
if (underline) s.textDecorationLine = "underline";
|
|
1115
|
+
if (highlight) s.backgroundColor = resolveTextColor(highlight, tokens);
|
|
1116
|
+
return s;
|
|
1117
|
+
}, [tokens, scopeCtx, color, weight, italic, underline, highlight]);
|
|
1118
|
+
return React14.createElement(
|
|
1119
|
+
Text,
|
|
1120
|
+
{ style: style ? [spanStyle, ...Array.isArray(style) ? style : [style]] : spanStyle },
|
|
1121
|
+
children
|
|
896
1122
|
);
|
|
897
1123
|
}
|
|
1124
|
+
function TextBold(props) {
|
|
1125
|
+
return React14.createElement(TextSpan, { ...props, weight: "bold" });
|
|
1126
|
+
}
|
|
1127
|
+
function TextMedium(props) {
|
|
1128
|
+
return React14.createElement(TextSpan, { ...props, weight: "medium" });
|
|
1129
|
+
}
|
|
1130
|
+
function TextItalic(props) {
|
|
1131
|
+
return React14.createElement(TextSpan, { ...props, italic: true });
|
|
1132
|
+
}
|
|
1133
|
+
function TextUnderline(props) {
|
|
1134
|
+
return React14.createElement(TextSpan, { ...props, underline: true });
|
|
1135
|
+
}
|
|
1136
|
+
function TextHighlight(props) {
|
|
1137
|
+
return React14.createElement(TextSpan, props);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// src/primitives/Text/index.ts
|
|
1141
|
+
var Text2 = Object.assign(TextBase, {
|
|
1142
|
+
Span: TextSpan,
|
|
1143
|
+
Bold: TextBold,
|
|
1144
|
+
Medium: TextMedium,
|
|
1145
|
+
Italic: TextItalic,
|
|
1146
|
+
Underline: TextUnderline,
|
|
1147
|
+
Highlight: TextHighlight
|
|
1148
|
+
});
|
|
898
1149
|
|
|
899
1150
|
// src/primitives/Frame/Frame.utils.ts
|
|
900
1151
|
function resolveSpacing(value, tokens) {
|
|
@@ -1098,7 +1349,7 @@ function Wrapper({
|
|
|
1098
1349
|
]
|
|
1099
1350
|
);
|
|
1100
1351
|
const userStyles = Array.isArray(style) ? style : style ? [style] : [];
|
|
1101
|
-
return /* @__PURE__ */
|
|
1352
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1102
1353
|
View,
|
|
1103
1354
|
{
|
|
1104
1355
|
ref,
|
|
@@ -1125,17 +1376,17 @@ function Button({
|
|
|
1125
1376
|
...pressableProps
|
|
1126
1377
|
}) {
|
|
1127
1378
|
const tokens = useTokens();
|
|
1128
|
-
const { variantColors, sizeTokens } =
|
|
1379
|
+
const { variantColors, sizeTokens } = React14.useMemo(
|
|
1129
1380
|
() => getButtonConfig(variant, semantic, size, disabled, tokens),
|
|
1130
1381
|
[variant, semantic, size, disabled, tokens]
|
|
1131
1382
|
);
|
|
1132
|
-
const padding =
|
|
1383
|
+
const padding = React14.useMemo(
|
|
1133
1384
|
() => computeButtonPadding(size, !!icon, !!children, iconPosition),
|
|
1134
1385
|
[size, icon, children, iconPosition]
|
|
1135
1386
|
);
|
|
1136
|
-
return /* @__PURE__ */
|
|
1387
|
+
return /* @__PURE__ */ React14.createElement(Pressable, { disabled, ...pressableProps }, ({ pressed, hovered }) => (
|
|
1137
1388
|
// Wrapper handles layout: direction, gap, alignment (padding via style)
|
|
1138
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ React14.createElement(
|
|
1139
1390
|
Wrapper,
|
|
1140
1391
|
{
|
|
1141
1392
|
direction: "horizontal",
|
|
@@ -1156,13 +1407,14 @@ function Button({
|
|
|
1156
1407
|
...Array.isArray(style) ? style : style ? [style] : []
|
|
1157
1408
|
]
|
|
1158
1409
|
},
|
|
1159
|
-
icon && iconPosition === "left" && /* @__PURE__ */
|
|
1410
|
+
icon && iconPosition === "left" && /* @__PURE__ */ React14.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor }),
|
|
1160
1411
|
children && // Text primitive with semantic props + color style override
|
|
1161
|
-
/* @__PURE__ */
|
|
1412
|
+
/* @__PURE__ */ React14.createElement(
|
|
1162
1413
|
Text2,
|
|
1163
1414
|
{
|
|
1415
|
+
role: "label",
|
|
1164
1416
|
size: sizeTokens.textSize,
|
|
1165
|
-
|
|
1417
|
+
centerVertically: true,
|
|
1166
1418
|
style: [
|
|
1167
1419
|
{ color: variantColors.textColor },
|
|
1168
1420
|
...Array.isArray(textStyle) ? textStyle : textStyle ? [textStyle] : []
|
|
@@ -1170,7 +1422,7 @@ function Button({
|
|
|
1170
1422
|
},
|
|
1171
1423
|
children
|
|
1172
1424
|
),
|
|
1173
|
-
icon && iconPosition === "right" && /* @__PURE__ */
|
|
1425
|
+
icon && iconPosition === "right" && /* @__PURE__ */ React14.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor })
|
|
1174
1426
|
)
|
|
1175
1427
|
));
|
|
1176
1428
|
}
|
|
@@ -1195,11 +1447,11 @@ function Card({
|
|
|
1195
1447
|
disabled = false
|
|
1196
1448
|
}) {
|
|
1197
1449
|
const tokens = useTokens(elevation);
|
|
1198
|
-
const styles =
|
|
1450
|
+
const styles = React14.useMemo(
|
|
1199
1451
|
() => getCardStyles(tokens, disabled),
|
|
1200
1452
|
[tokens, disabled]
|
|
1201
1453
|
);
|
|
1202
|
-
return /* @__PURE__ */
|
|
1454
|
+
return /* @__PURE__ */ React14.createElement(View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, children);
|
|
1203
1455
|
}
|
|
1204
1456
|
var hadKeyboardEvent = false;
|
|
1205
1457
|
var isListenerSetup = false;
|
|
@@ -1350,9 +1602,9 @@ function getFrameStyles(input) {
|
|
|
1350
1602
|
|
|
1351
1603
|
// src/primitives/Frame/Frame.tsx
|
|
1352
1604
|
function wrapTextChildren(children, textStyle) {
|
|
1353
|
-
return
|
|
1605
|
+
return React14.Children.map(children, (child) => {
|
|
1354
1606
|
if (typeof child === "string" || typeof child === "number") {
|
|
1355
|
-
return /* @__PURE__ */
|
|
1607
|
+
return /* @__PURE__ */ React14.createElement(Text, { style: textStyle }, child);
|
|
1356
1608
|
}
|
|
1357
1609
|
return child;
|
|
1358
1610
|
});
|
|
@@ -1491,9 +1743,9 @@ function Frame({
|
|
|
1491
1743
|
const textStyle = useMemo(
|
|
1492
1744
|
() => ({
|
|
1493
1745
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
1494
|
-
fontSize: tokens.typography.
|
|
1495
|
-
fontFamily: tokens.typography.fonts.
|
|
1496
|
-
lineHeight: tokens.typography.
|
|
1746
|
+
fontSize: tokens.typography.fontSizes["05"],
|
|
1747
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1748
|
+
lineHeight: tokens.typography.lineHeights["06"]
|
|
1497
1749
|
}),
|
|
1498
1750
|
[tokens]
|
|
1499
1751
|
);
|
|
@@ -1501,10 +1753,10 @@ function Frame({
|
|
|
1501
1753
|
() => wrapTextChildren(children, textStyle),
|
|
1502
1754
|
[children, textStyle]
|
|
1503
1755
|
);
|
|
1504
|
-
return /* @__PURE__ */
|
|
1756
|
+
return /* @__PURE__ */ React14.createElement(FrameContext.Provider, { value: contextValue }, isInteractive ? (
|
|
1505
1757
|
// Pressable handles taps. When href is set, react-native-web renders
|
|
1506
1758
|
// it as an <a> tag so it works like a regular link on the web.
|
|
1507
|
-
/* @__PURE__ */
|
|
1759
|
+
/* @__PURE__ */ React14.createElement(
|
|
1508
1760
|
Pressable,
|
|
1509
1761
|
{
|
|
1510
1762
|
ref,
|
|
@@ -1529,7 +1781,7 @@ function Frame({
|
|
|
1529
1781
|
)
|
|
1530
1782
|
) : (
|
|
1531
1783
|
// Non-interactive Frame: just a plain View with no tap handling.
|
|
1532
|
-
/* @__PURE__ */
|
|
1784
|
+
/* @__PURE__ */ React14.createElement(
|
|
1533
1785
|
View,
|
|
1534
1786
|
{
|
|
1535
1787
|
ref,
|
|
@@ -1549,20 +1801,20 @@ function getTextInputStyles(tokens, disabled) {
|
|
|
1549
1801
|
gap: tokens.spacing["04"]
|
|
1550
1802
|
},
|
|
1551
1803
|
label: {
|
|
1552
|
-
fontFamily: tokens.typography.fonts.
|
|
1553
|
-
fontSize: tokens.typography.
|
|
1554
|
-
fontWeight: tokens.typography.
|
|
1804
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1805
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
1806
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1555
1807
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
1556
1808
|
},
|
|
1557
1809
|
input: {
|
|
1558
|
-
fontFamily: tokens.typography.fonts.
|
|
1810
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1559
1811
|
backgroundColor: srgbToHex(tokens.backgroundSunken.srgb),
|
|
1560
1812
|
borderWidth: 1,
|
|
1561
1813
|
borderColor: srgbToHex(tokens.border.srgb),
|
|
1562
1814
|
borderRadius: tokens.radius.md,
|
|
1563
1815
|
paddingVertical: tokens.spacing["08"],
|
|
1564
1816
|
paddingHorizontal: tokens.spacing["12"],
|
|
1565
|
-
fontSize: tokens.typography.
|
|
1817
|
+
fontSize: tokens.typography.fontSizes["05"],
|
|
1566
1818
|
color: disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb),
|
|
1567
1819
|
opacity: disabled ? 0.5 : 1
|
|
1568
1820
|
}
|
|
@@ -1575,11 +1827,11 @@ function TextInput({
|
|
|
1575
1827
|
...textInputProps
|
|
1576
1828
|
}) {
|
|
1577
1829
|
const tokens = useTokens(1);
|
|
1578
|
-
const styles =
|
|
1830
|
+
const styles = React14.useMemo(
|
|
1579
1831
|
() => getTextInputStyles(tokens, disabled),
|
|
1580
1832
|
[tokens, disabled]
|
|
1581
1833
|
);
|
|
1582
|
-
return /* @__PURE__ */
|
|
1834
|
+
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(
|
|
1583
1835
|
TextInput$1,
|
|
1584
1836
|
{
|
|
1585
1837
|
style: styles.input,
|
|
@@ -1682,15 +1934,15 @@ function Popover({
|
|
|
1682
1934
|
[styles.content, contentStyle]
|
|
1683
1935
|
);
|
|
1684
1936
|
const webProps = { onKeyDown: handleKeyDown };
|
|
1685
|
-
return /* @__PURE__ */
|
|
1937
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1686
1938
|
View,
|
|
1687
1939
|
{
|
|
1688
1940
|
ref: containerRef,
|
|
1689
1941
|
style: containerStyles,
|
|
1690
1942
|
...webProps
|
|
1691
1943
|
},
|
|
1692
|
-
/* @__PURE__ */
|
|
1693
|
-
isOpen && /* @__PURE__ */
|
|
1944
|
+
/* @__PURE__ */ React14.createElement(View, { onLayout: onTriggerLayout }, trigger),
|
|
1945
|
+
isOpen && /* @__PURE__ */ React14.createElement(View, { style: mergedContentStyles }, children)
|
|
1694
1946
|
);
|
|
1695
1947
|
}
|
|
1696
1948
|
function usePopover(options) {
|
|
@@ -1719,7 +1971,7 @@ function isOptionGroup(item) {
|
|
|
1719
1971
|
}
|
|
1720
1972
|
function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
1721
1973
|
const isSm = size === "sm";
|
|
1722
|
-
const fontSize = isSm ? tokens.typography.
|
|
1974
|
+
const fontSize = isSm ? tokens.typography.fontSizes["04"] : tokens.typography.fontSizes["05"];
|
|
1723
1975
|
const iconSize = fontSize + 2;
|
|
1724
1976
|
const iconSpace = iconSize + tokens.spacing["08"];
|
|
1725
1977
|
const paddingVertical = isSm ? tokens.spacing["04"] : tokens.spacing["08"];
|
|
@@ -1730,9 +1982,9 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1730
1982
|
zIndex: isOpen ? 999 : 0
|
|
1731
1983
|
},
|
|
1732
1984
|
label: {
|
|
1733
|
-
fontFamily: tokens.typography.fonts.
|
|
1734
|
-
fontSize: tokens.typography.
|
|
1735
|
-
fontWeight: tokens.typography.
|
|
1985
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1986
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
1987
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1736
1988
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
1737
1989
|
},
|
|
1738
1990
|
trigger: {
|
|
@@ -1749,7 +2001,7 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1749
2001
|
},
|
|
1750
2002
|
triggerText: {
|
|
1751
2003
|
flex: 1,
|
|
1752
|
-
fontFamily: tokens.typography.fonts.
|
|
2004
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1753
2005
|
fontSize,
|
|
1754
2006
|
color: disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb)
|
|
1755
2007
|
},
|
|
@@ -1761,9 +2013,9 @@ function getSelectStyles(tokens, disabled, size, isOpen) {
|
|
|
1761
2013
|
justifyContent: "center"
|
|
1762
2014
|
},
|
|
1763
2015
|
groupLabel: {
|
|
1764
|
-
fontFamily: tokens.typography.fonts.
|
|
1765
|
-
fontSize: tokens.typography.
|
|
1766
|
-
fontWeight: tokens.typography.
|
|
2016
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2017
|
+
fontSize: tokens.typography.fontSizes["01"],
|
|
2018
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1767
2019
|
color: srgbToHex(tokens.textSecondary.srgb),
|
|
1768
2020
|
textTransform: "uppercase",
|
|
1769
2021
|
letterSpacing: 0.5,
|
|
@@ -1885,9 +2137,9 @@ function SelectOptionRow({
|
|
|
1885
2137
|
const tokens = useTokens(1);
|
|
1886
2138
|
const paddingVertical = size === "sm" ? tokens.spacing["04"] : tokens.spacing["08"];
|
|
1887
2139
|
const paddingHorizontal = size === "sm" ? tokens.spacing["08"] : tokens.spacing["12"];
|
|
1888
|
-
const fontSize = size === "sm" ? tokens.typography.
|
|
2140
|
+
const fontSize = size === "sm" ? tokens.typography.fontSizes["04"] : tokens.typography.fontSizes["05"];
|
|
1889
2141
|
if (renderOption) {
|
|
1890
|
-
return /* @__PURE__ */
|
|
2142
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1891
2143
|
Pressable,
|
|
1892
2144
|
{
|
|
1893
2145
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1898,7 +2150,7 @@ function SelectOptionRow({
|
|
|
1898
2150
|
renderOption(option, { isSelected, isFocused })
|
|
1899
2151
|
);
|
|
1900
2152
|
}
|
|
1901
|
-
return /* @__PURE__ */
|
|
2153
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1902
2154
|
Pressable,
|
|
1903
2155
|
{
|
|
1904
2156
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1927,18 +2179,18 @@ function SelectOptionRow({
|
|
|
1927
2179
|
}
|
|
1928
2180
|
]
|
|
1929
2181
|
},
|
|
1930
|
-
/* @__PURE__ */
|
|
2182
|
+
/* @__PURE__ */ React14.createElement(
|
|
1931
2183
|
Text,
|
|
1932
2184
|
{
|
|
1933
2185
|
style: [
|
|
1934
2186
|
{
|
|
1935
2187
|
flex: 1,
|
|
1936
|
-
fontFamily: tokens.typography.fonts.
|
|
2188
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
1937
2189
|
fontSize,
|
|
1938
2190
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
1939
2191
|
},
|
|
1940
2192
|
isSelected && {
|
|
1941
|
-
fontWeight: tokens.typography.
|
|
2193
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
1942
2194
|
color: srgbToHex(tokens.accent.fill.srgb)
|
|
1943
2195
|
},
|
|
1944
2196
|
option.disabled && {
|
|
@@ -1949,7 +2201,7 @@ function SelectOptionRow({
|
|
|
1949
2201
|
},
|
|
1950
2202
|
option.label
|
|
1951
2203
|
),
|
|
1952
|
-
isSelected && /* @__PURE__ */
|
|
2204
|
+
isSelected && /* @__PURE__ */ React14.createElement(View, { style: { marginLeft: tokens.spacing["08"] } }, /* @__PURE__ */ React14.createElement(
|
|
1953
2205
|
Icon,
|
|
1954
2206
|
{
|
|
1955
2207
|
name: "check",
|
|
@@ -2004,7 +2256,7 @@ function Select({
|
|
|
2004
2256
|
const displayLabel = selectedOption?.label ?? placeholder ?? value;
|
|
2005
2257
|
const iconColor = disabled ? srgbToHex(tokens.textSecondary.srgb) : srgbToHex(tokens.textPrimary.srgb);
|
|
2006
2258
|
const triggerWebProps = { onKeyDown: handleKeyDown };
|
|
2007
|
-
const trigger = /* @__PURE__ */
|
|
2259
|
+
const trigger = /* @__PURE__ */ React14.createElement(
|
|
2008
2260
|
Pressable,
|
|
2009
2261
|
{
|
|
2010
2262
|
onPress: disabled ? void 0 : toggle,
|
|
@@ -2014,24 +2266,24 @@ function Select({
|
|
|
2014
2266
|
...triggerWebProps,
|
|
2015
2267
|
style: styles.trigger
|
|
2016
2268
|
},
|
|
2017
|
-
renderValue ? renderValue(selectedOption) : /* @__PURE__ */
|
|
2018
|
-
/* @__PURE__ */
|
|
2269
|
+
renderValue ? renderValue(selectedOption) : /* @__PURE__ */ React14.createElement(Text, { style: styles.triggerText, numberOfLines: 1 }, displayLabel),
|
|
2270
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.iconWrapper, pointerEvents: "none" }, /* @__PURE__ */ React14.createElement(
|
|
2019
2271
|
Icon,
|
|
2020
2272
|
{
|
|
2021
2273
|
name: isOpen ? "expand_less" : "expand_more",
|
|
2022
|
-
size: size === "sm" ? tokens.typography.
|
|
2274
|
+
size: size === "sm" ? tokens.typography.fontSizes["04"] + 2 : tokens.typography.fontSizes["05"] + 2,
|
|
2023
2275
|
color: iconColor
|
|
2024
2276
|
}
|
|
2025
2277
|
))
|
|
2026
2278
|
);
|
|
2027
|
-
return /* @__PURE__ */
|
|
2279
|
+
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(
|
|
2028
2280
|
Popover,
|
|
2029
2281
|
{
|
|
2030
2282
|
isOpen: isOpen && !disabled,
|
|
2031
2283
|
onClose: close,
|
|
2032
2284
|
trigger
|
|
2033
2285
|
},
|
|
2034
|
-
/* @__PURE__ */
|
|
2286
|
+
/* @__PURE__ */ React14.createElement(
|
|
2035
2287
|
ScrollView,
|
|
2036
2288
|
{
|
|
2037
2289
|
bounces: false,
|
|
@@ -2040,7 +2292,7 @@ function Select({
|
|
|
2040
2292
|
},
|
|
2041
2293
|
options.map((item) => {
|
|
2042
2294
|
if (isOptionGroup(item)) {
|
|
2043
|
-
return /* @__PURE__ */
|
|
2295
|
+
return /* @__PURE__ */ React14.createElement(View, { key: item.label }, /* @__PURE__ */ React14.createElement(Text, { style: styles.groupLabel }, item.label), item.options.map((opt) => /* @__PURE__ */ React14.createElement(
|
|
2044
2296
|
SelectOptionRow,
|
|
2045
2297
|
{
|
|
2046
2298
|
key: opt.value,
|
|
@@ -2056,7 +2308,7 @@ function Select({
|
|
|
2056
2308
|
}
|
|
2057
2309
|
)));
|
|
2058
2310
|
}
|
|
2059
|
-
return /* @__PURE__ */
|
|
2311
|
+
return /* @__PURE__ */ React14.createElement(
|
|
2060
2312
|
SelectOptionRow,
|
|
2061
2313
|
{
|
|
2062
2314
|
key: item.value,
|
|
@@ -2088,9 +2340,9 @@ function getToggleStyles(tokens, value, disabled) {
|
|
|
2088
2340
|
opacity: disabled ? 0.5 : 1
|
|
2089
2341
|
},
|
|
2090
2342
|
label: {
|
|
2091
|
-
fontFamily: tokens.typography.fonts.
|
|
2092
|
-
fontSize: tokens.typography.
|
|
2093
|
-
fontWeight: tokens.typography.
|
|
2343
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2344
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2345
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2094
2346
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2095
2347
|
},
|
|
2096
2348
|
track: {
|
|
@@ -2120,16 +2372,16 @@ function Toggle({
|
|
|
2120
2372
|
style
|
|
2121
2373
|
}) {
|
|
2122
2374
|
const tokens = useTokens(1);
|
|
2123
|
-
const styles =
|
|
2375
|
+
const styles = React14.useMemo(
|
|
2124
2376
|
() => getToggleStyles(tokens, value, disabled),
|
|
2125
2377
|
[tokens, value, disabled]
|
|
2126
2378
|
);
|
|
2127
|
-
const handlePress =
|
|
2379
|
+
const handlePress = React14.useCallback(() => {
|
|
2128
2380
|
if (!disabled) {
|
|
2129
2381
|
onValueChange(!value);
|
|
2130
2382
|
}
|
|
2131
2383
|
}, [disabled, value, onValueChange]);
|
|
2132
|
-
return /* @__PURE__ */
|
|
2384
|
+
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(
|
|
2133
2385
|
Pressable,
|
|
2134
2386
|
{
|
|
2135
2387
|
onPress: handlePress,
|
|
@@ -2137,7 +2389,7 @@ function Toggle({
|
|
|
2137
2389
|
accessibilityRole: "switch",
|
|
2138
2390
|
accessibilityState: { checked: value, disabled }
|
|
2139
2391
|
},
|
|
2140
|
-
/* @__PURE__ */
|
|
2392
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.track }, /* @__PURE__ */ React14.createElement(View, { style: styles.thumb }))
|
|
2141
2393
|
));
|
|
2142
2394
|
}
|
|
2143
2395
|
var TRACK_HEIGHT2 = 6;
|
|
@@ -2154,15 +2406,15 @@ function getSliderStyles(tokens, disabled) {
|
|
|
2154
2406
|
alignItems: "center"
|
|
2155
2407
|
},
|
|
2156
2408
|
label: {
|
|
2157
|
-
fontFamily: tokens.typography.fonts.
|
|
2158
|
-
fontSize: tokens.typography.
|
|
2159
|
-
fontWeight: tokens.typography.
|
|
2409
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2410
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2411
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2160
2412
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2161
2413
|
},
|
|
2162
2414
|
value: {
|
|
2163
|
-
fontFamily: tokens.typography.fonts.
|
|
2164
|
-
fontSize: tokens.typography.
|
|
2165
|
-
fontWeight: tokens.typography.
|
|
2415
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2416
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2417
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2166
2418
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
2167
2419
|
},
|
|
2168
2420
|
valueInput: {
|
|
@@ -2174,9 +2426,9 @@ function getSliderStyles(tokens, disabled) {
|
|
|
2174
2426
|
borderRadius: 4,
|
|
2175
2427
|
backgroundColor: "transparent",
|
|
2176
2428
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
2177
|
-
fontFamily: tokens.typography.fonts.
|
|
2178
|
-
fontSize: tokens.typography.
|
|
2179
|
-
fontWeight: tokens.typography.
|
|
2429
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2430
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2431
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2180
2432
|
textAlign: "right"
|
|
2181
2433
|
},
|
|
2182
2434
|
trackContainer: {
|
|
@@ -2223,41 +2475,41 @@ function Slider({
|
|
|
2223
2475
|
style
|
|
2224
2476
|
}) {
|
|
2225
2477
|
const tokens = useTokens(1);
|
|
2226
|
-
const styles =
|
|
2478
|
+
const styles = React14.useMemo(
|
|
2227
2479
|
() => getSliderStyles(tokens, disabled),
|
|
2228
2480
|
[tokens, disabled]
|
|
2229
2481
|
);
|
|
2230
|
-
const trackRef =
|
|
2231
|
-
const trackWidth =
|
|
2232
|
-
const trackPageX =
|
|
2233
|
-
const onValueChangeRef =
|
|
2234
|
-
const minRef =
|
|
2235
|
-
const maxRef =
|
|
2236
|
-
const stepRef =
|
|
2237
|
-
const disabledRef =
|
|
2238
|
-
|
|
2482
|
+
const trackRef = React14.useRef(null);
|
|
2483
|
+
const trackWidth = React14.useRef(0);
|
|
2484
|
+
const trackPageX = React14.useRef(0);
|
|
2485
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2486
|
+
const minRef = React14.useRef(min);
|
|
2487
|
+
const maxRef = React14.useRef(max);
|
|
2488
|
+
const stepRef = React14.useRef(step);
|
|
2489
|
+
const disabledRef = React14.useRef(disabled);
|
|
2490
|
+
React14.useEffect(() => {
|
|
2239
2491
|
onValueChangeRef.current = onValueChange;
|
|
2240
2492
|
}, [onValueChange]);
|
|
2241
|
-
|
|
2493
|
+
React14.useEffect(() => {
|
|
2242
2494
|
minRef.current = min;
|
|
2243
2495
|
}, [min]);
|
|
2244
|
-
|
|
2496
|
+
React14.useEffect(() => {
|
|
2245
2497
|
maxRef.current = max;
|
|
2246
2498
|
}, [max]);
|
|
2247
|
-
|
|
2499
|
+
React14.useEffect(() => {
|
|
2248
2500
|
stepRef.current = step;
|
|
2249
2501
|
}, [step]);
|
|
2250
|
-
|
|
2502
|
+
React14.useEffect(() => {
|
|
2251
2503
|
disabledRef.current = disabled;
|
|
2252
2504
|
}, [disabled]);
|
|
2253
|
-
const computeValue =
|
|
2505
|
+
const computeValue = React14.useCallback((pageX) => {
|
|
2254
2506
|
const localX = pageX - trackPageX.current;
|
|
2255
2507
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2256
2508
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
2257
2509
|
const stepped = Math.round(raw / stepRef.current) * stepRef.current;
|
|
2258
2510
|
return Math.min(maxRef.current, Math.max(minRef.current, stepped));
|
|
2259
2511
|
}, []);
|
|
2260
|
-
const panResponder =
|
|
2512
|
+
const panResponder = React14.useRef(
|
|
2261
2513
|
PanResponder.create({
|
|
2262
2514
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2263
2515
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2273,7 +2525,7 @@ function Slider({
|
|
|
2273
2525
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE2);
|
|
2274
2526
|
const thumbLeft = ratio * usableWidth;
|
|
2275
2527
|
const fillWidth = thumbLeft + THUMB_SIZE2 / 2;
|
|
2276
|
-
const handleValueTextSubmit =
|
|
2528
|
+
const handleValueTextSubmit = React14.useCallback(
|
|
2277
2529
|
(text) => {
|
|
2278
2530
|
const raw = Number(text);
|
|
2279
2531
|
if (!Number.isNaN(raw)) {
|
|
@@ -2282,12 +2534,12 @@ function Slider({
|
|
|
2282
2534
|
},
|
|
2283
2535
|
[onValueChange, min, max]
|
|
2284
2536
|
);
|
|
2285
|
-
const [editText, setEditText] =
|
|
2286
|
-
|
|
2537
|
+
const [editText, setEditText] = React14.useState(String(value));
|
|
2538
|
+
React14.useEffect(() => {
|
|
2287
2539
|
setEditText(String(value));
|
|
2288
2540
|
}, [value]);
|
|
2289
2541
|
const showLabel = label || showValue || editableValue;
|
|
2290
|
-
return /* @__PURE__ */
|
|
2542
|
+
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(
|
|
2291
2543
|
TextInput$1,
|
|
2292
2544
|
{
|
|
2293
2545
|
style: styles.valueInput,
|
|
@@ -2299,7 +2551,7 @@ function Slider({
|
|
|
2299
2551
|
selectTextOnFocus: true,
|
|
2300
2552
|
editable: !disabled
|
|
2301
2553
|
}
|
|
2302
|
-
) : showValue && /* @__PURE__ */
|
|
2554
|
+
) : showValue && /* @__PURE__ */ React14.createElement(Text, { style: styles.value }, value)), /* @__PURE__ */ React14.createElement(
|
|
2303
2555
|
View,
|
|
2304
2556
|
{
|
|
2305
2557
|
ref: trackRef,
|
|
@@ -2312,9 +2564,9 @@ function Slider({
|
|
|
2312
2564
|
},
|
|
2313
2565
|
...panResponder.panHandlers
|
|
2314
2566
|
},
|
|
2315
|
-
/* @__PURE__ */
|
|
2316
|
-
/* @__PURE__ */
|
|
2317
|
-
/* @__PURE__ */
|
|
2567
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.trackRail }),
|
|
2568
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.trackFill, { width: fillWidth }] }),
|
|
2569
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2318
2570
|
));
|
|
2319
2571
|
}
|
|
2320
2572
|
var TRACK_HEIGHT3 = 22;
|
|
@@ -2370,15 +2622,15 @@ function getHueSliderStyles(tokens, disabled) {
|
|
|
2370
2622
|
alignItems: "center"
|
|
2371
2623
|
},
|
|
2372
2624
|
label: {
|
|
2373
|
-
fontFamily: tokens.typography.fonts.
|
|
2374
|
-
fontSize: tokens.typography.
|
|
2375
|
-
fontWeight: tokens.typography.
|
|
2625
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2626
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2627
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2376
2628
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2377
2629
|
},
|
|
2378
2630
|
value: {
|
|
2379
|
-
fontFamily: tokens.typography.fonts.
|
|
2380
|
-
fontSize: tokens.typography.
|
|
2381
|
-
fontWeight: tokens.typography.
|
|
2631
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2632
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2633
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2382
2634
|
color: srgbToHex(tokens.textPrimary.srgb)
|
|
2383
2635
|
},
|
|
2384
2636
|
valueInput: {
|
|
@@ -2390,9 +2642,9 @@ function getHueSliderStyles(tokens, disabled) {
|
|
|
2390
2642
|
borderRadius: 4,
|
|
2391
2643
|
backgroundColor: "transparent",
|
|
2392
2644
|
color: srgbToHex(tokens.textPrimary.srgb),
|
|
2393
|
-
fontFamily: tokens.typography.fonts.
|
|
2394
|
-
fontSize: tokens.typography.
|
|
2395
|
-
fontWeight: tokens.typography.
|
|
2645
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2646
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2647
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2396
2648
|
textAlign: "right"
|
|
2397
2649
|
},
|
|
2398
2650
|
trackContainer: {
|
|
@@ -2437,41 +2689,41 @@ function HueSlider({
|
|
|
2437
2689
|
style
|
|
2438
2690
|
}) {
|
|
2439
2691
|
const tokens = useTokens(1);
|
|
2440
|
-
const styles =
|
|
2692
|
+
const styles = React14.useMemo(
|
|
2441
2693
|
() => getHueSliderStyles(tokens, disabled),
|
|
2442
2694
|
[tokens, disabled]
|
|
2443
2695
|
);
|
|
2444
|
-
const segments =
|
|
2696
|
+
const segments = React14.useMemo(
|
|
2445
2697
|
() => buildHueSegments(min, max),
|
|
2446
2698
|
[min, max]
|
|
2447
2699
|
);
|
|
2448
|
-
const trackRef =
|
|
2449
|
-
const trackWidth =
|
|
2450
|
-
const trackPageX =
|
|
2451
|
-
const onValueChangeRef =
|
|
2452
|
-
const minRef =
|
|
2453
|
-
const maxRef =
|
|
2454
|
-
const disabledRef =
|
|
2455
|
-
|
|
2700
|
+
const trackRef = React14.useRef(null);
|
|
2701
|
+
const trackWidth = React14.useRef(0);
|
|
2702
|
+
const trackPageX = React14.useRef(0);
|
|
2703
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2704
|
+
const minRef = React14.useRef(min);
|
|
2705
|
+
const maxRef = React14.useRef(max);
|
|
2706
|
+
const disabledRef = React14.useRef(disabled);
|
|
2707
|
+
React14.useEffect(() => {
|
|
2456
2708
|
onValueChangeRef.current = onValueChange;
|
|
2457
2709
|
}, [onValueChange]);
|
|
2458
|
-
|
|
2710
|
+
React14.useEffect(() => {
|
|
2459
2711
|
minRef.current = min;
|
|
2460
2712
|
}, [min]);
|
|
2461
|
-
|
|
2713
|
+
React14.useEffect(() => {
|
|
2462
2714
|
maxRef.current = max;
|
|
2463
2715
|
}, [max]);
|
|
2464
|
-
|
|
2716
|
+
React14.useEffect(() => {
|
|
2465
2717
|
disabledRef.current = disabled;
|
|
2466
2718
|
}, [disabled]);
|
|
2467
|
-
const computeHue =
|
|
2719
|
+
const computeHue = React14.useCallback((pageX) => {
|
|
2468
2720
|
const localX = pageX - trackPageX.current;
|
|
2469
2721
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2470
2722
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
2471
2723
|
const stepped = Math.round(raw);
|
|
2472
2724
|
return (stepped % 360 + 360) % 360;
|
|
2473
2725
|
}, []);
|
|
2474
|
-
const panResponder =
|
|
2726
|
+
const panResponder = React14.useRef(
|
|
2475
2727
|
PanResponder.create({
|
|
2476
2728
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2477
2729
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2487,7 +2739,7 @@ function HueSlider({
|
|
|
2487
2739
|
const ratio = max > min ? (sliderValue - min) / (max - min) : 0;
|
|
2488
2740
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE3);
|
|
2489
2741
|
const thumbLeft = ratio * usableWidth;
|
|
2490
|
-
const handleValueTextSubmit =
|
|
2742
|
+
const handleValueTextSubmit = React14.useCallback(
|
|
2491
2743
|
(text) => {
|
|
2492
2744
|
const raw = Number(text);
|
|
2493
2745
|
if (!Number.isNaN(raw)) {
|
|
@@ -2496,12 +2748,12 @@ function HueSlider({
|
|
|
2496
2748
|
},
|
|
2497
2749
|
[onValueChange]
|
|
2498
2750
|
);
|
|
2499
|
-
const [editText, setEditText] =
|
|
2500
|
-
|
|
2751
|
+
const [editText, setEditText] = React14.useState(String(value));
|
|
2752
|
+
React14.useEffect(() => {
|
|
2501
2753
|
setEditText(String(value));
|
|
2502
2754
|
}, [value]);
|
|
2503
2755
|
const showLabel = label || showValue || editableValue;
|
|
2504
|
-
return /* @__PURE__ */
|
|
2756
|
+
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(
|
|
2505
2757
|
TextInput$1,
|
|
2506
2758
|
{
|
|
2507
2759
|
style: styles.valueInput,
|
|
@@ -2513,7 +2765,7 @@ function HueSlider({
|
|
|
2513
2765
|
selectTextOnFocus: true,
|
|
2514
2766
|
editable: !disabled
|
|
2515
2767
|
}
|
|
2516
|
-
) : showValue && /* @__PURE__ */
|
|
2768
|
+
) : showValue && /* @__PURE__ */ React14.createElement(Text, { style: styles.value }, value, "\xB0")), /* @__PURE__ */ React14.createElement(
|
|
2517
2769
|
View,
|
|
2518
2770
|
{
|
|
2519
2771
|
ref: trackRef,
|
|
@@ -2526,8 +2778,8 @@ function HueSlider({
|
|
|
2526
2778
|
},
|
|
2527
2779
|
...panResponder.panHandlers
|
|
2528
2780
|
},
|
|
2529
|
-
/* @__PURE__ */
|
|
2530
|
-
/* @__PURE__ */
|
|
2781
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.gradientTrack }, segments.map((color, i) => /* @__PURE__ */ React14.createElement(View, { key: i, style: [styles.segment, { backgroundColor: color }] }))),
|
|
2782
|
+
/* @__PURE__ */ React14.createElement(View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2531
2783
|
));
|
|
2532
2784
|
}
|
|
2533
2785
|
var TRACK_HEIGHT4 = 22;
|
|
@@ -2544,9 +2796,9 @@ function getColorScaleSliderStyles(tokens, disabled) {
|
|
|
2544
2796
|
alignItems: "center"
|
|
2545
2797
|
},
|
|
2546
2798
|
label: {
|
|
2547
|
-
fontFamily: tokens.typography.fonts.
|
|
2548
|
-
fontSize: tokens.typography.
|
|
2549
|
-
fontWeight: tokens.typography.
|
|
2799
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2800
|
+
fontSize: tokens.typography.fontSizes["04"],
|
|
2801
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2550
2802
|
color: srgbToHex(tokens.textSecondary.srgb)
|
|
2551
2803
|
},
|
|
2552
2804
|
trackContainer: {
|
|
@@ -2576,9 +2828,9 @@ function getColorScaleSliderStyles(tokens, disabled) {
|
|
|
2576
2828
|
borderColor: srgbToHex(tokens.border.srgb)
|
|
2577
2829
|
},
|
|
2578
2830
|
warning: {
|
|
2579
|
-
fontFamily: tokens.typography.fonts.
|
|
2580
|
-
fontSize: tokens.typography.
|
|
2581
|
-
fontWeight: tokens.typography.
|
|
2831
|
+
fontFamily: tokens.typography.fonts.main.family,
|
|
2832
|
+
fontSize: tokens.typography.fontSizes["01"],
|
|
2833
|
+
fontWeight: tokens.typography.fonts.main.weights.medium,
|
|
2582
2834
|
color: srgbToHex(tokens.error.fill.srgb)
|
|
2583
2835
|
}
|
|
2584
2836
|
});
|
|
@@ -2598,36 +2850,36 @@ function ColorScaleSlider({
|
|
|
2598
2850
|
style
|
|
2599
2851
|
}) {
|
|
2600
2852
|
const tokens = useTokens(1);
|
|
2601
|
-
const styles =
|
|
2853
|
+
const styles = React14.useMemo(
|
|
2602
2854
|
() => getColorScaleSliderStyles(tokens, disabled),
|
|
2603
2855
|
[tokens, disabled]
|
|
2604
2856
|
);
|
|
2605
|
-
const trackRef =
|
|
2606
|
-
const trackWidth =
|
|
2607
|
-
const trackPageX =
|
|
2608
|
-
const isDragging =
|
|
2609
|
-
const thumbAnim =
|
|
2610
|
-
const onValueChangeRef =
|
|
2611
|
-
const disabledRef =
|
|
2612
|
-
const colorsLengthRef =
|
|
2613
|
-
const trimEndsRef =
|
|
2614
|
-
const snapRef =
|
|
2615
|
-
|
|
2857
|
+
const trackRef = React14.useRef(null);
|
|
2858
|
+
const trackWidth = React14.useRef(0);
|
|
2859
|
+
const trackPageX = React14.useRef(0);
|
|
2860
|
+
const isDragging = React14.useRef(false);
|
|
2861
|
+
const thumbAnim = React14.useRef(new Animated.Value(0)).current;
|
|
2862
|
+
const onValueChangeRef = React14.useRef(onValueChange);
|
|
2863
|
+
const disabledRef = React14.useRef(disabled);
|
|
2864
|
+
const colorsLengthRef = React14.useRef(colors.length);
|
|
2865
|
+
const trimEndsRef = React14.useRef(trimEnds);
|
|
2866
|
+
const snapRef = React14.useRef(snap);
|
|
2867
|
+
React14.useEffect(() => {
|
|
2616
2868
|
onValueChangeRef.current = onValueChange;
|
|
2617
2869
|
}, [onValueChange]);
|
|
2618
|
-
|
|
2870
|
+
React14.useEffect(() => {
|
|
2619
2871
|
disabledRef.current = disabled;
|
|
2620
2872
|
}, [disabled]);
|
|
2621
|
-
|
|
2873
|
+
React14.useEffect(() => {
|
|
2622
2874
|
colorsLengthRef.current = colors.length;
|
|
2623
2875
|
}, [colors.length]);
|
|
2624
|
-
|
|
2876
|
+
React14.useEffect(() => {
|
|
2625
2877
|
trimEndsRef.current = trimEnds;
|
|
2626
2878
|
}, [trimEnds]);
|
|
2627
|
-
|
|
2879
|
+
React14.useEffect(() => {
|
|
2628
2880
|
snapRef.current = snap;
|
|
2629
2881
|
}, [snap]);
|
|
2630
|
-
const computeNv =
|
|
2882
|
+
const computeNv = React14.useCallback((pageX) => {
|
|
2631
2883
|
const localX = pageX - trackPageX.current;
|
|
2632
2884
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2633
2885
|
const totalSteps2 = colorsLengthRef.current - 1;
|
|
@@ -2642,7 +2894,7 @@ function ColorScaleSlider({
|
|
|
2642
2894
|
}
|
|
2643
2895
|
return nv;
|
|
2644
2896
|
}, []);
|
|
2645
|
-
const panResponder =
|
|
2897
|
+
const panResponder = React14.useRef(
|
|
2646
2898
|
PanResponder.create({
|
|
2647
2899
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2648
2900
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2670,7 +2922,7 @@ function ColorScaleSlider({
|
|
|
2670
2922
|
const ratio = range > 0 ? (maxNV - clampedValue) / range : 0.5;
|
|
2671
2923
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE4);
|
|
2672
2924
|
const thumbLeft = ratio * usableWidth;
|
|
2673
|
-
|
|
2925
|
+
React14.useEffect(() => {
|
|
2674
2926
|
if (isDragging.current || !animateValue) {
|
|
2675
2927
|
thumbAnim.setValue(thumbLeft);
|
|
2676
2928
|
} else {
|
|
@@ -2681,7 +2933,7 @@ function ColorScaleSlider({
|
|
|
2681
2933
|
}).start();
|
|
2682
2934
|
}
|
|
2683
2935
|
}, [thumbLeft, animateValue, thumbAnim]);
|
|
2684
|
-
return /* @__PURE__ */
|
|
2936
|
+
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(
|
|
2685
2937
|
View,
|
|
2686
2938
|
{
|
|
2687
2939
|
ref: trackRef,
|
|
@@ -2696,9 +2948,9 @@ function ColorScaleSlider({
|
|
|
2696
2948
|
},
|
|
2697
2949
|
...panResponder.panHandlers
|
|
2698
2950
|
},
|
|
2699
|
-
/* @__PURE__ */
|
|
2700
|
-
/* @__PURE__ */
|
|
2701
|
-
), warning && /* @__PURE__ */
|
|
2951
|
+
/* @__PURE__ */ React14.createElement(View, { style: styles.gradientTrack }, visibleColors.map((color, i) => /* @__PURE__ */ React14.createElement(View, { key: i, style: [styles.segment, { backgroundColor: srgbToHex(color.srgb) }] }))),
|
|
2952
|
+
/* @__PURE__ */ React14.createElement(Animated.View, { style: [styles.thumb, { left: thumbAnim }] })
|
|
2953
|
+
), warning && /* @__PURE__ */ React14.createElement(Text, { style: styles.warning }, warning));
|
|
2702
2954
|
}
|
|
2703
2955
|
function getAppShellStyles(tokens) {
|
|
2704
2956
|
return StyleSheet.create({
|
|
@@ -2720,8 +2972,8 @@ function getAppShellStyles(tokens) {
|
|
|
2720
2972
|
// src/composites/layout/AppShell/AppShell.tsx
|
|
2721
2973
|
function AppShell({ sidebar, children }) {
|
|
2722
2974
|
const tokens = useTokens();
|
|
2723
|
-
const styles =
|
|
2724
|
-
return /* @__PURE__ */
|
|
2975
|
+
const styles = React14.useMemo(() => getAppShellStyles(tokens), [tokens]);
|
|
2976
|
+
return /* @__PURE__ */ React14.createElement(View, { style: styles.container }, sidebar, /* @__PURE__ */ React14.createElement(View, { style: styles.main }, children));
|
|
2725
2977
|
}
|
|
2726
2978
|
function getSidebarStyles({ tokens, width, bordered }) {
|
|
2727
2979
|
const borderColor = srgbToHex(tokens.border.srgb);
|
|
@@ -2759,11 +3011,11 @@ function Sidebar({
|
|
|
2759
3011
|
bordered = true
|
|
2760
3012
|
}) {
|
|
2761
3013
|
const tokens = useTokens();
|
|
2762
|
-
const styles =
|
|
3014
|
+
const styles = React14.useMemo(
|
|
2763
3015
|
() => getSidebarStyles({ tokens, width, bordered }),
|
|
2764
3016
|
[tokens, width, bordered]
|
|
2765
3017
|
);
|
|
2766
|
-
return /* @__PURE__ */
|
|
3018
|
+
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));
|
|
2767
3019
|
}
|
|
2768
3020
|
function getNavbarStyles({ tokens, height, bordered }) {
|
|
2769
3021
|
const borderColor = srgbToHex(tokens.border.srgb);
|
|
@@ -2801,28 +3053,27 @@ function Navbar({
|
|
|
2801
3053
|
bordered = true
|
|
2802
3054
|
}) {
|
|
2803
3055
|
const tokens = useTokens();
|
|
2804
|
-
const styles =
|
|
3056
|
+
const styles = React14.useMemo(
|
|
2805
3057
|
() => getNavbarStyles({ tokens, height, bordered }),
|
|
2806
3058
|
[tokens, height, bordered]
|
|
2807
3059
|
);
|
|
2808
|
-
return /* @__PURE__ */
|
|
3060
|
+
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)));
|
|
2809
3061
|
}
|
|
2810
3062
|
|
|
2811
3063
|
// src/registry/registry.ts
|
|
2812
3064
|
var CATEGORIES = [
|
|
2813
|
-
{ id: "
|
|
2814
|
-
{ id: "
|
|
2815
|
-
{ id: "
|
|
2816
|
-
{ id: "
|
|
2817
|
-
{ id: "
|
|
2818
|
-
{ id: "overlays", name: "Overlays", description: "Floating and portal-based UI elements" }
|
|
3065
|
+
{ id: "colors", name: "Colors", description: "Color palettes and token visualization", icon: "palette" },
|
|
3066
|
+
{ id: "typography", name: "Typography", description: "Text roles, scopes, and weight control", icon: "text_fields" },
|
|
3067
|
+
{ id: "symbols", name: "Symbols", description: "Material Symbols icon browser", icon: "grid_view" },
|
|
3068
|
+
{ id: "layout", name: "Layout", description: "Structural containers \u2014 Frame and Wrapper", icon: "grid_on" },
|
|
3069
|
+
{ id: "components", name: "Components", description: "Interactive UI components", icon: "widgets" }
|
|
2819
3070
|
];
|
|
2820
3071
|
var COMPONENTS = [
|
|
2821
3072
|
{
|
|
2822
3073
|
id: "button",
|
|
2823
3074
|
name: "Button",
|
|
2824
3075
|
importName: "Button",
|
|
2825
|
-
categoryId: "
|
|
3076
|
+
categoryId: "components",
|
|
2826
3077
|
description: "Interactive button with multiple variants, sizes, and optional icon",
|
|
2827
3078
|
hasChildren: true,
|
|
2828
3079
|
variants: [
|
|
@@ -2904,7 +3155,7 @@ var COMPONENTS = [
|
|
|
2904
3155
|
id: "text-input",
|
|
2905
3156
|
name: "TextInput",
|
|
2906
3157
|
importName: "TextInput",
|
|
2907
|
-
categoryId: "
|
|
3158
|
+
categoryId: "components",
|
|
2908
3159
|
description: "Text input field with label support",
|
|
2909
3160
|
hasChildren: false,
|
|
2910
3161
|
variants: [
|
|
@@ -2931,7 +3182,7 @@ var COMPONENTS = [
|
|
|
2931
3182
|
id: "select",
|
|
2932
3183
|
name: "Select",
|
|
2933
3184
|
importName: "Select",
|
|
2934
|
-
categoryId: "
|
|
3185
|
+
categoryId: "components",
|
|
2935
3186
|
description: "Dropdown selector with options",
|
|
2936
3187
|
hasChildren: false,
|
|
2937
3188
|
variants: [
|
|
@@ -2978,7 +3229,7 @@ var COMPONENTS = [
|
|
|
2978
3229
|
id: "toggle",
|
|
2979
3230
|
name: "Toggle",
|
|
2980
3231
|
importName: "Toggle",
|
|
2981
|
-
categoryId: "
|
|
3232
|
+
categoryId: "components",
|
|
2982
3233
|
description: "Binary switch component",
|
|
2983
3234
|
hasChildren: false,
|
|
2984
3235
|
variants: [
|
|
@@ -3005,7 +3256,7 @@ var COMPONENTS = [
|
|
|
3005
3256
|
id: "slider",
|
|
3006
3257
|
name: "Slider",
|
|
3007
3258
|
importName: "Slider",
|
|
3008
|
-
categoryId: "
|
|
3259
|
+
categoryId: "components",
|
|
3009
3260
|
description: "Numeric range slider",
|
|
3010
3261
|
hasChildren: false,
|
|
3011
3262
|
variants: [
|
|
@@ -3049,7 +3300,7 @@ var COMPONENTS = [
|
|
|
3049
3300
|
id: "hue-slider",
|
|
3050
3301
|
name: "HueSlider",
|
|
3051
3302
|
importName: "HueSlider",
|
|
3052
|
-
categoryId: "
|
|
3303
|
+
categoryId: "components",
|
|
3053
3304
|
description: "Specialized slider for hue selection (0-360\xB0)",
|
|
3054
3305
|
hasChildren: false,
|
|
3055
3306
|
variants: [
|
|
@@ -3185,7 +3436,7 @@ var COMPONENTS = [
|
|
|
3185
3436
|
id: "card",
|
|
3186
3437
|
name: "Card",
|
|
3187
3438
|
importName: "Card",
|
|
3188
|
-
categoryId: "
|
|
3439
|
+
categoryId: "components",
|
|
3189
3440
|
description: "Surface container with elevation levels",
|
|
3190
3441
|
hasChildren: true,
|
|
3191
3442
|
variants: [
|
|
@@ -3218,45 +3469,59 @@ var COMPONENTS = [
|
|
|
3218
3469
|
id: "text",
|
|
3219
3470
|
name: "Text",
|
|
3220
3471
|
importName: "Text",
|
|
3221
|
-
categoryId: "
|
|
3222
|
-
description: "Typography primitive with semantic
|
|
3472
|
+
categoryId: "typography",
|
|
3473
|
+
description: "Typography primitive with semantic scope (font family) and role (purpose)",
|
|
3223
3474
|
hasChildren: true,
|
|
3475
|
+
previewLayout: "list",
|
|
3224
3476
|
variants: [
|
|
3225
|
-
{ id: "
|
|
3226
|
-
{ id: "
|
|
3227
|
-
{ id: "
|
|
3228
|
-
{ id: "
|
|
3229
|
-
{ id: "
|
|
3230
|
-
{ id: "
|
|
3231
|
-
{ id: "
|
|
3477
|
+
{ id: "body", label: "Body", props: { role: "body" } },
|
|
3478
|
+
{ id: "headline", label: "Headline", props: { role: "headline", scope: "display" } },
|
|
3479
|
+
{ id: "title", label: "Title", props: { role: "title", scope: "display" } },
|
|
3480
|
+
{ id: "heading", label: "Heading", props: { role: "heading" } },
|
|
3481
|
+
{ id: "subheading", label: "Subheading", props: { role: "subheading" } },
|
|
3482
|
+
{ id: "label", label: "Label", props: { role: "label" } },
|
|
3483
|
+
{ id: "caption", label: "Caption", props: { role: "caption", color: "secondary" } },
|
|
3484
|
+
{ id: "mono", label: "Monospace", props: { scope: "mono", role: "body" } },
|
|
3485
|
+
{ id: "currency", label: "Currency", props: { scope: "currency", role: "body" } }
|
|
3232
3486
|
],
|
|
3233
3487
|
editableProps: [
|
|
3234
3488
|
{
|
|
3235
|
-
name: "
|
|
3236
|
-
label: "
|
|
3489
|
+
name: "scope",
|
|
3490
|
+
label: "Scope",
|
|
3237
3491
|
control: "select",
|
|
3238
3492
|
options: [
|
|
3239
|
-
{ label: "
|
|
3240
|
-
{ label: "
|
|
3241
|
-
{ label: "
|
|
3242
|
-
{ label: "
|
|
3243
|
-
{ label: "Large", value: "lg" },
|
|
3244
|
-
{ label: "Extra Large", value: "xl" },
|
|
3245
|
-
{ label: "XXL", value: "xxl" }
|
|
3493
|
+
{ label: "Main", value: "main" },
|
|
3494
|
+
{ label: "Display", value: "display" },
|
|
3495
|
+
{ label: "Mono", value: "mono" },
|
|
3496
|
+
{ label: "Currency", value: "currency" }
|
|
3246
3497
|
],
|
|
3247
|
-
defaultValue: "
|
|
3498
|
+
defaultValue: "main"
|
|
3248
3499
|
},
|
|
3249
3500
|
{
|
|
3250
|
-
name: "
|
|
3251
|
-
label: "
|
|
3501
|
+
name: "role",
|
|
3502
|
+
label: "Role",
|
|
3503
|
+
control: "select",
|
|
3504
|
+
options: [
|
|
3505
|
+
{ label: "Headline", value: "headline" },
|
|
3506
|
+
{ label: "Title", value: "title" },
|
|
3507
|
+
{ label: "Heading", value: "heading" },
|
|
3508
|
+
{ label: "Subheading", value: "subheading" },
|
|
3509
|
+
{ label: "Body", value: "body" },
|
|
3510
|
+
{ label: "Label", value: "label" },
|
|
3511
|
+
{ label: "Caption", value: "caption" }
|
|
3512
|
+
],
|
|
3513
|
+
defaultValue: "body"
|
|
3514
|
+
},
|
|
3515
|
+
{
|
|
3516
|
+
name: "size",
|
|
3517
|
+
label: "Size",
|
|
3252
3518
|
control: "select",
|
|
3253
3519
|
options: [
|
|
3254
|
-
{ label: "
|
|
3255
|
-
{ label: "Medium", value: "
|
|
3256
|
-
{ label: "
|
|
3257
|
-
{ label: "Bold", value: "bold" }
|
|
3520
|
+
{ label: "Small", value: "sm" },
|
|
3521
|
+
{ label: "Medium", value: "md" },
|
|
3522
|
+
{ label: "Large", value: "lg" }
|
|
3258
3523
|
],
|
|
3259
|
-
defaultValue: "
|
|
3524
|
+
defaultValue: "md"
|
|
3260
3525
|
},
|
|
3261
3526
|
{
|
|
3262
3527
|
name: "color",
|
|
@@ -3273,17 +3538,6 @@ var COMPONENTS = [
|
|
|
3273
3538
|
{ label: "Error", value: "error" }
|
|
3274
3539
|
],
|
|
3275
3540
|
defaultValue: "primary"
|
|
3276
|
-
},
|
|
3277
|
-
{
|
|
3278
|
-
name: "font",
|
|
3279
|
-
label: "Font",
|
|
3280
|
-
control: "select",
|
|
3281
|
-
options: [
|
|
3282
|
-
{ label: "Default", value: "default" },
|
|
3283
|
-
{ label: "Display", value: "display" },
|
|
3284
|
-
{ label: "Mono", value: "mono" }
|
|
3285
|
-
],
|
|
3286
|
-
defaultValue: "default"
|
|
3287
3541
|
}
|
|
3288
3542
|
]
|
|
3289
3543
|
},
|
|
@@ -3291,41 +3545,36 @@ var COMPONENTS = [
|
|
|
3291
3545
|
id: "icon",
|
|
3292
3546
|
name: "Icon",
|
|
3293
3547
|
importName: "Icon",
|
|
3294
|
-
categoryId: "
|
|
3295
|
-
description: "Material Symbols icon with size
|
|
3548
|
+
categoryId: "symbols",
|
|
3549
|
+
description: "Material Symbols icon with size and fill",
|
|
3296
3550
|
hasChildren: false,
|
|
3297
3551
|
variants: [
|
|
3298
|
-
{ id: "
|
|
3299
|
-
{ id: "settings", label: "Settings", props: { name: "settings" } },
|
|
3300
|
-
{ id: "check", label: "Check", props: { name: "check" } },
|
|
3301
|
-
{ id: "add", label: "Add", props: { name: "add" } },
|
|
3302
|
-
{ id: "delete", label: "Delete", props: { name: "delete" } },
|
|
3303
|
-
{ id: "search", label: "Search", props: { name: "search" } },
|
|
3304
|
-
{ id: "filled", label: "Filled Icon", props: { name: "favorite", fill: 1 } },
|
|
3305
|
-
{ id: "large", label: "Large Icon", props: { name: "star", size: 32 } }
|
|
3552
|
+
{ id: "default", label: "Default", props: { name: "add" } }
|
|
3306
3553
|
],
|
|
3307
3554
|
editableProps: [
|
|
3308
3555
|
{
|
|
3309
3556
|
name: "name",
|
|
3310
3557
|
label: "Icon Name",
|
|
3311
3558
|
control: "text",
|
|
3312
|
-
defaultValue: "
|
|
3559
|
+
defaultValue: "add"
|
|
3313
3560
|
},
|
|
3314
3561
|
{
|
|
3315
3562
|
name: "size",
|
|
3316
3563
|
label: "Size",
|
|
3317
|
-
control: "
|
|
3564
|
+
control: "discrete-slider",
|
|
3565
|
+
options: [
|
|
3566
|
+
{ label: "20", value: 20 },
|
|
3567
|
+
{ label: "24", value: 24 },
|
|
3568
|
+
{ label: "40", value: 40 },
|
|
3569
|
+
{ label: "48", value: 48 }
|
|
3570
|
+
],
|
|
3318
3571
|
defaultValue: 24
|
|
3319
3572
|
},
|
|
3320
3573
|
{
|
|
3321
3574
|
name: "fill",
|
|
3322
3575
|
label: "Fill",
|
|
3323
|
-
control: "
|
|
3324
|
-
|
|
3325
|
-
{ label: "Outlined", value: 0 },
|
|
3326
|
-
{ label: "Filled", value: 1 }
|
|
3327
|
-
],
|
|
3328
|
-
defaultValue: 0
|
|
3576
|
+
control: "toggle",
|
|
3577
|
+
defaultValue: false
|
|
3329
3578
|
}
|
|
3330
3579
|
]
|
|
3331
3580
|
},
|
|
@@ -3333,7 +3582,7 @@ var COMPONENTS = [
|
|
|
3333
3582
|
id: "wrapper",
|
|
3334
3583
|
name: "Wrapper",
|
|
3335
3584
|
importName: "Wrapper",
|
|
3336
|
-
categoryId: "
|
|
3585
|
+
categoryId: "layout",
|
|
3337
3586
|
description: "Lightweight layout container with direction, spacing, and alignment (no theming)",
|
|
3338
3587
|
hasChildren: true,
|
|
3339
3588
|
variants: [
|
|
@@ -3407,7 +3656,7 @@ var COMPONENTS = [
|
|
|
3407
3656
|
id: "color-scale-slider",
|
|
3408
3657
|
name: "ColorScaleSlider",
|
|
3409
3658
|
importName: "ColorScaleSlider",
|
|
3410
|
-
categoryId: "
|
|
3659
|
+
categoryId: "components",
|
|
3411
3660
|
description: "Interactive palette preview slider with color segments",
|
|
3412
3661
|
hasChildren: false,
|
|
3413
3662
|
variants: [
|
|
@@ -3450,6 +3699,7 @@ var HANDLER_PROPS = {
|
|
|
3450
3699
|
};
|
|
3451
3700
|
var CHILDREN_CONTENT = {
|
|
3452
3701
|
button: "Button",
|
|
3702
|
+
text: "The quick brown fox",
|
|
3453
3703
|
card: "{/* content */}",
|
|
3454
3704
|
frame: "{/* content */}"
|
|
3455
3705
|
};
|
|
@@ -3529,72 +3779,232 @@ function formatProp(name, value) {
|
|
|
3529
3779
|
return `${name}={${JSON.stringify(value)}}`;
|
|
3530
3780
|
}
|
|
3531
3781
|
|
|
3532
|
-
// src/
|
|
3533
|
-
var
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
{
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3782
|
+
// src/registry/icons.ts
|
|
3783
|
+
var ICON_CATALOG = [
|
|
3784
|
+
{
|
|
3785
|
+
id: "navigation",
|
|
3786
|
+
label: "Navigation",
|
|
3787
|
+
icons: [
|
|
3788
|
+
"home",
|
|
3789
|
+
"menu",
|
|
3790
|
+
"close",
|
|
3791
|
+
"arrow_back",
|
|
3792
|
+
"arrow_forward",
|
|
3793
|
+
"arrow_upward",
|
|
3794
|
+
"arrow_downward",
|
|
3795
|
+
"chevron_left",
|
|
3796
|
+
"chevron_right",
|
|
3797
|
+
"expand_more",
|
|
3798
|
+
"expand_less",
|
|
3799
|
+
"first_page",
|
|
3800
|
+
"last_page",
|
|
3801
|
+
"more_vert",
|
|
3802
|
+
"more_horiz",
|
|
3803
|
+
"unfold_more",
|
|
3804
|
+
"unfold_less",
|
|
3805
|
+
"subdirectory_arrow_right"
|
|
3806
|
+
]
|
|
3807
|
+
},
|
|
3808
|
+
{
|
|
3809
|
+
id: "actions",
|
|
3810
|
+
label: "Actions",
|
|
3811
|
+
icons: [
|
|
3812
|
+
"search",
|
|
3813
|
+
"settings",
|
|
3814
|
+
"done",
|
|
3815
|
+
"add",
|
|
3816
|
+
"remove",
|
|
3817
|
+
"delete",
|
|
3818
|
+
"edit",
|
|
3819
|
+
"save",
|
|
3820
|
+
"refresh",
|
|
3821
|
+
"undo",
|
|
3822
|
+
"redo",
|
|
3823
|
+
"download",
|
|
3824
|
+
"upload",
|
|
3825
|
+
"share",
|
|
3826
|
+
"print",
|
|
3827
|
+
"content_copy",
|
|
3828
|
+
"content_paste",
|
|
3829
|
+
"open_in_new",
|
|
3830
|
+
"launch",
|
|
3831
|
+
"drag_indicator",
|
|
3832
|
+
"tune",
|
|
3833
|
+
"sort",
|
|
3834
|
+
"filter_list"
|
|
3835
|
+
]
|
|
3836
|
+
},
|
|
3581
3837
|
{
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3838
|
+
id: "communication",
|
|
3839
|
+
label: "Communication",
|
|
3840
|
+
icons: [
|
|
3841
|
+
"mail",
|
|
3842
|
+
"chat",
|
|
3843
|
+
"call",
|
|
3844
|
+
"notifications",
|
|
3845
|
+
"forum",
|
|
3846
|
+
"send",
|
|
3847
|
+
"inbox",
|
|
3848
|
+
"drafts",
|
|
3849
|
+
"mark_email_read",
|
|
3850
|
+
"contact_mail",
|
|
3851
|
+
"alternate_email",
|
|
3852
|
+
"comment",
|
|
3853
|
+
"chat_bubble",
|
|
3854
|
+
"sms",
|
|
3855
|
+
"voicemail"
|
|
3856
|
+
]
|
|
3857
|
+
},
|
|
3858
|
+
{
|
|
3859
|
+
id: "content",
|
|
3860
|
+
label: "Content",
|
|
3861
|
+
icons: [
|
|
3862
|
+
"add_circle",
|
|
3863
|
+
"remove_circle",
|
|
3864
|
+
"check_circle",
|
|
3865
|
+
"cancel",
|
|
3866
|
+
"flag",
|
|
3867
|
+
"bookmark",
|
|
3868
|
+
"star",
|
|
3869
|
+
"favorite",
|
|
3870
|
+
"thumb_up",
|
|
3871
|
+
"thumb_down",
|
|
3872
|
+
"push_pin",
|
|
3873
|
+
"link",
|
|
3874
|
+
"link_off",
|
|
3875
|
+
"bolt",
|
|
3876
|
+
"label",
|
|
3877
|
+
"inventory_2",
|
|
3878
|
+
"visibility",
|
|
3879
|
+
"visibility_off"
|
|
3880
|
+
]
|
|
3881
|
+
},
|
|
3882
|
+
{
|
|
3883
|
+
id: "media",
|
|
3884
|
+
label: "Media",
|
|
3885
|
+
icons: [
|
|
3886
|
+
"play_arrow",
|
|
3887
|
+
"pause",
|
|
3888
|
+
"stop",
|
|
3889
|
+
"skip_next",
|
|
3890
|
+
"skip_previous",
|
|
3891
|
+
"fast_forward",
|
|
3892
|
+
"fast_rewind",
|
|
3893
|
+
"replay",
|
|
3894
|
+
"shuffle",
|
|
3895
|
+
"repeat",
|
|
3896
|
+
"volume_up",
|
|
3897
|
+
"volume_off",
|
|
3898
|
+
"music_note",
|
|
3899
|
+
"image",
|
|
3900
|
+
"photo_camera",
|
|
3901
|
+
"videocam",
|
|
3902
|
+
"mic"
|
|
3903
|
+
]
|
|
3904
|
+
},
|
|
3905
|
+
{
|
|
3906
|
+
id: "file",
|
|
3907
|
+
label: "File & Folder",
|
|
3908
|
+
icons: [
|
|
3909
|
+
"folder",
|
|
3910
|
+
"folder_open",
|
|
3911
|
+
"create_new_folder",
|
|
3912
|
+
"description",
|
|
3913
|
+
"file_copy",
|
|
3914
|
+
"attach_file",
|
|
3915
|
+
"cloud",
|
|
3916
|
+
"cloud_upload",
|
|
3917
|
+
"cloud_download",
|
|
3918
|
+
"cloud_off",
|
|
3919
|
+
"storage",
|
|
3920
|
+
"snippet_folder"
|
|
3921
|
+
]
|
|
3585
3922
|
},
|
|
3586
3923
|
{
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3924
|
+
id: "social",
|
|
3925
|
+
label: "Social & People",
|
|
3926
|
+
icons: [
|
|
3927
|
+
"person",
|
|
3928
|
+
"group",
|
|
3929
|
+
"person_add",
|
|
3930
|
+
"person_remove",
|
|
3931
|
+
"people",
|
|
3932
|
+
"face",
|
|
3933
|
+
"sentiment_satisfied",
|
|
3934
|
+
"sentiment_dissatisfied",
|
|
3935
|
+
"public",
|
|
3936
|
+
"workspace_premium",
|
|
3937
|
+
"emoji_events",
|
|
3938
|
+
"military_tech"
|
|
3939
|
+
]
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
id: "alerts",
|
|
3943
|
+
label: "Alerts & Status",
|
|
3944
|
+
icons: [
|
|
3945
|
+
"error",
|
|
3946
|
+
"warning",
|
|
3947
|
+
"info",
|
|
3948
|
+
"help",
|
|
3949
|
+
"check_circle",
|
|
3950
|
+
"report",
|
|
3951
|
+
"new_releases",
|
|
3952
|
+
"notification_important",
|
|
3953
|
+
"priority_high",
|
|
3954
|
+
"verified",
|
|
3955
|
+
"shield",
|
|
3956
|
+
"security",
|
|
3957
|
+
"lock",
|
|
3958
|
+
"lock_open"
|
|
3959
|
+
]
|
|
3590
3960
|
},
|
|
3591
3961
|
{
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3962
|
+
id: "device",
|
|
3963
|
+
label: "Device & Hardware",
|
|
3964
|
+
icons: [
|
|
3965
|
+
"phone_android",
|
|
3966
|
+
"computer",
|
|
3967
|
+
"tablet_mac",
|
|
3968
|
+
"watch",
|
|
3969
|
+
"keyboard",
|
|
3970
|
+
"mouse",
|
|
3971
|
+
"headphones",
|
|
3972
|
+
"speaker",
|
|
3973
|
+
"monitor",
|
|
3974
|
+
"devices",
|
|
3975
|
+
"memory",
|
|
3976
|
+
"battery_full",
|
|
3977
|
+
"wifi",
|
|
3978
|
+
"bluetooth",
|
|
3979
|
+
"usb",
|
|
3980
|
+
"dark_mode",
|
|
3981
|
+
"light_mode"
|
|
3982
|
+
]
|
|
3983
|
+
},
|
|
3984
|
+
{
|
|
3985
|
+
id: "editor",
|
|
3986
|
+
label: "Editor & Formatting",
|
|
3987
|
+
icons: [
|
|
3988
|
+
"format_bold",
|
|
3989
|
+
"format_italic",
|
|
3990
|
+
"format_underlined",
|
|
3991
|
+
"format_list_bulleted",
|
|
3992
|
+
"format_list_numbered",
|
|
3993
|
+
"format_quote",
|
|
3994
|
+
"format_align_left",
|
|
3995
|
+
"format_align_center",
|
|
3996
|
+
"format_align_right",
|
|
3997
|
+
"title",
|
|
3998
|
+
"text_fields",
|
|
3999
|
+
"code",
|
|
4000
|
+
"palette",
|
|
4001
|
+
"color_lens",
|
|
4002
|
+
"brush",
|
|
4003
|
+
"auto_fix_high"
|
|
4004
|
+
]
|
|
3595
4005
|
}
|
|
3596
4006
|
];
|
|
3597
4007
|
|
|
3598
|
-
export { ACCENT_DEFAULTS, AppShell, Button, CATEGORIES, COMPONENTS, Card, ColorScaleSlider, DEFAULT_THEME_CONFIG, ERROR_DEFAULTS, Frame,
|
|
4008
|
+
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 };
|
|
3599
4009
|
//# sourceMappingURL=index.js.map
|
|
3600
4010
|
//# sourceMappingURL=index.js.map
|