@newtonedev/components 0.1.3 → 0.1.5
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 +37 -0
- package/dist/composites/actions/Button/Button.d.ts.map +1 -0
- package/dist/composites/actions/Button/Button.styles.d.ts +63 -0
- package/dist/composites/actions/Button/Button.styles.d.ts.map +1 -0
- package/dist/{Button → composites/actions/Button}/Button.types.d.ts +12 -3
- package/dist/composites/actions/Button/Button.types.d.ts.map +1 -0
- package/dist/composites/actions/Button/index.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/Select.d.ts.map +1 -0
- package/dist/{Select → composites/form-controls/Select}/Select.styles.d.ts +1 -1
- package/dist/composites/form-controls/Select/Select.styles.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/Select.types.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/SelectOption.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/index.d.ts.map +1 -0
- package/dist/composites/form-controls/Select/useSelect.d.ts.map +1 -0
- package/dist/composites/form-controls/TextInput/TextInput.d.ts.map +1 -0
- package/dist/{TextInput → composites/form-controls/TextInput}/TextInput.styles.d.ts +1 -1
- package/dist/composites/form-controls/TextInput/TextInput.styles.d.ts.map +1 -0
- package/dist/composites/form-controls/TextInput/TextInput.types.d.ts.map +1 -0
- package/dist/composites/form-controls/TextInput/index.d.ts.map +1 -0
- package/dist/composites/form-controls/Toggle/Toggle.d.ts.map +1 -0
- package/dist/{Toggle → composites/form-controls/Toggle}/Toggle.styles.d.ts +1 -1
- package/dist/composites/form-controls/Toggle/Toggle.styles.d.ts.map +1 -0
- package/dist/composites/form-controls/Toggle/Toggle.types.d.ts.map +1 -0
- package/dist/composites/form-controls/Toggle/index.d.ts.map +1 -0
- package/dist/composites/layout/AppShell/AppShell.d.ts.map +1 -0
- package/dist/{AppShell → composites/layout/AppShell}/AppShell.styles.d.ts +1 -1
- package/dist/composites/layout/AppShell/AppShell.styles.d.ts.map +1 -0
- package/dist/composites/layout/AppShell/AppShell.types.d.ts.map +1 -0
- package/dist/composites/layout/AppShell/index.d.ts.map +1 -0
- package/dist/composites/layout/Card/Card.d.ts.map +1 -0
- package/dist/{Card → composites/layout/Card}/Card.styles.d.ts +1 -1
- package/dist/composites/layout/Card/Card.styles.d.ts.map +1 -0
- package/dist/{Card → composites/layout/Card}/Card.types.d.ts +1 -1
- package/dist/composites/layout/Card/Card.types.d.ts.map +1 -0
- package/dist/composites/layout/Card/index.d.ts.map +1 -0
- package/dist/composites/layout/Navbar/Navbar.d.ts.map +1 -0
- package/dist/{Navbar → composites/layout/Navbar}/Navbar.styles.d.ts +1 -1
- package/dist/composites/layout/Navbar/Navbar.styles.d.ts.map +1 -0
- package/dist/composites/layout/Navbar/Navbar.types.d.ts.map +1 -0
- package/dist/composites/layout/Navbar/index.d.ts.map +1 -0
- package/dist/composites/layout/Sidebar/Sidebar.d.ts.map +1 -0
- package/dist/{Sidebar → composites/layout/Sidebar}/Sidebar.styles.d.ts +1 -1
- package/dist/composites/layout/Sidebar/Sidebar.styles.d.ts.map +1 -0
- package/dist/composites/layout/Sidebar/Sidebar.types.d.ts.map +1 -0
- package/dist/composites/layout/Sidebar/index.d.ts.map +1 -0
- package/dist/composites/overlays/Popover/Popover.d.ts.map +1 -0
- package/dist/{Popover → composites/overlays/Popover}/Popover.styles.d.ts +1 -1
- package/dist/composites/overlays/Popover/Popover.styles.d.ts.map +1 -0
- package/dist/composites/overlays/Popover/Popover.types.d.ts.map +1 -0
- package/dist/composites/overlays/Popover/index.d.ts.map +1 -0
- package/dist/composites/overlays/Popover/usePopover.d.ts.map +1 -0
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.d.ts.map +1 -0
- package/dist/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.styles.d.ts +1 -1
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +1 -0
- package/dist/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.types.d.ts.map +1 -0
- package/dist/composites/range-inputs/ColorScaleSlider/index.d.ts.map +1 -0
- package/dist/composites/range-inputs/HueSlider/HueSlider.d.ts.map +1 -0
- package/dist/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.styles.d.ts +1 -1
- package/dist/composites/range-inputs/HueSlider/HueSlider.styles.d.ts.map +1 -0
- package/dist/composites/range-inputs/HueSlider/HueSlider.types.d.ts.map +1 -0
- package/dist/composites/range-inputs/HueSlider/index.d.ts.map +1 -0
- package/dist/composites/range-inputs/Slider/Slider.d.ts.map +1 -0
- package/dist/{Slider → composites/range-inputs/Slider}/Slider.styles.d.ts +1 -1
- package/dist/composites/range-inputs/Slider/Slider.styles.d.ts.map +1 -0
- package/dist/composites/range-inputs/Slider/Slider.types.d.ts.map +1 -0
- package/dist/composites/range-inputs/Slider/index.d.ts.map +1 -0
- package/dist/index.cjs +999 -620
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +955 -576
- package/dist/index.js.map +1 -1
- package/dist/primitives/Icon/Icon.d.ts.map +1 -1
- package/dist/primitives/Wrapper/Wrapper.types.d.ts +1 -1
- package/dist/primitives/Wrapper/Wrapper.types.d.ts.map +1 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/tokens/computeTokens.d.ts.map +1 -1
- package/dist/tokens/types.d.ts +10 -0
- package/dist/tokens/types.d.ts.map +1 -1
- package/dist/tokens/useTokens.d.ts +20 -2
- package/dist/tokens/useTokens.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/composites/actions/Button/Button.styles.ts +365 -0
- package/src/composites/actions/Button/Button.tsx +115 -0
- package/src/{Button → composites/actions/Button}/Button.types.ts +14 -3
- package/src/{Select → composites/form-controls/Select}/Select.styles.ts +1 -1
- package/src/{Select → composites/form-controls/Select}/Select.tsx +4 -4
- package/src/{Select → composites/form-controls/Select}/SelectOption.tsx +2 -2
- package/src/{TextInput → composites/form-controls/TextInput}/TextInput.styles.ts +1 -1
- package/src/{TextInput → composites/form-controls/TextInput}/TextInput.tsx +1 -1
- package/src/{Toggle → composites/form-controls/Toggle}/Toggle.styles.ts +1 -1
- package/src/{Toggle → composites/form-controls/Toggle}/Toggle.tsx +1 -1
- package/src/{AppShell → composites/layout/AppShell}/AppShell.styles.ts +1 -1
- package/src/{AppShell → composites/layout/AppShell}/AppShell.tsx +1 -1
- package/src/{Card → composites/layout/Card}/Card.styles.ts +1 -1
- package/src/{Card → composites/layout/Card}/Card.tsx +1 -1
- package/src/{Card → composites/layout/Card}/Card.types.ts +1 -1
- package/src/{Navbar → composites/layout/Navbar}/Navbar.styles.ts +1 -1
- package/src/{Navbar → composites/layout/Navbar}/Navbar.tsx +1 -1
- package/src/{Sidebar → composites/layout/Sidebar}/Sidebar.styles.ts +1 -1
- package/src/{Sidebar → composites/layout/Sidebar}/Sidebar.tsx +1 -1
- package/src/{Popover → composites/overlays/Popover}/Popover.styles.ts +1 -1
- package/src/{Popover → composites/overlays/Popover}/Popover.tsx +1 -1
- package/src/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.styles.ts +1 -1
- package/src/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.tsx +1 -1
- package/src/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.styles.ts +1 -1
- package/src/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.tsx +1 -1
- package/src/{Slider → composites/range-inputs/Slider}/Slider.styles.ts +1 -1
- package/src/{Slider → composites/range-inputs/Slider}/Slider.tsx +1 -1
- package/src/index.ts +27 -27
- package/src/primitives/Icon/Icon.tsx +16 -1
- package/src/primitives/Wrapper/Wrapper.types.ts +1 -1
- package/src/registry/registry.ts +213 -1
- package/src/tokens/computeTokens.ts +16 -0
- package/src/tokens/types.ts +10 -0
- package/src/tokens/useTokens.ts +25 -3
- package/dist/AppShell/AppShell.d.ts.map +0 -1
- package/dist/AppShell/AppShell.styles.d.ts.map +0 -1
- package/dist/AppShell/AppShell.types.d.ts.map +0 -1
- package/dist/AppShell/index.d.ts.map +0 -1
- package/dist/Button/Button.d.ts +0 -28
- package/dist/Button/Button.d.ts.map +0 -1
- package/dist/Button/Button.styles.d.ts +0 -46
- package/dist/Button/Button.styles.d.ts.map +0 -1
- package/dist/Button/Button.types.d.ts.map +0 -1
- package/dist/Button/index.d.ts.map +0 -1
- package/dist/Card/Card.d.ts.map +0 -1
- package/dist/Card/Card.styles.d.ts.map +0 -1
- package/dist/Card/Card.types.d.ts.map +0 -1
- package/dist/Card/index.d.ts.map +0 -1
- package/dist/ColorScaleSlider/ColorScaleSlider.d.ts.map +0 -1
- package/dist/ColorScaleSlider/ColorScaleSlider.styles.d.ts.map +0 -1
- package/dist/ColorScaleSlider/ColorScaleSlider.types.d.ts.map +0 -1
- package/dist/ColorScaleSlider/index.d.ts.map +0 -1
- package/dist/HueSlider/HueSlider.d.ts.map +0 -1
- package/dist/HueSlider/HueSlider.styles.d.ts.map +0 -1
- package/dist/HueSlider/HueSlider.types.d.ts.map +0 -1
- package/dist/HueSlider/index.d.ts.map +0 -1
- package/dist/Navbar/Navbar.d.ts.map +0 -1
- package/dist/Navbar/Navbar.styles.d.ts.map +0 -1
- package/dist/Navbar/Navbar.types.d.ts.map +0 -1
- package/dist/Navbar/index.d.ts.map +0 -1
- package/dist/Popover/Popover.d.ts.map +0 -1
- package/dist/Popover/Popover.styles.d.ts.map +0 -1
- package/dist/Popover/Popover.types.d.ts.map +0 -1
- package/dist/Popover/index.d.ts.map +0 -1
- package/dist/Popover/usePopover.d.ts.map +0 -1
- package/dist/Select/Select.d.ts.map +0 -1
- package/dist/Select/Select.styles.d.ts.map +0 -1
- package/dist/Select/Select.types.d.ts.map +0 -1
- package/dist/Select/SelectOption.d.ts.map +0 -1
- package/dist/Select/index.d.ts.map +0 -1
- package/dist/Select/useSelect.d.ts.map +0 -1
- package/dist/Sidebar/Sidebar.d.ts.map +0 -1
- package/dist/Sidebar/Sidebar.styles.d.ts.map +0 -1
- package/dist/Sidebar/Sidebar.types.d.ts.map +0 -1
- package/dist/Sidebar/index.d.ts.map +0 -1
- package/dist/Slider/Slider.d.ts.map +0 -1
- package/dist/Slider/Slider.styles.d.ts.map +0 -1
- package/dist/Slider/Slider.types.d.ts.map +0 -1
- package/dist/Slider/index.d.ts.map +0 -1
- package/dist/TextInput/TextInput.d.ts.map +0 -1
- package/dist/TextInput/TextInput.styles.d.ts.map +0 -1
- package/dist/TextInput/TextInput.types.d.ts.map +0 -1
- package/dist/TextInput/index.d.ts.map +0 -1
- package/dist/Toggle/Toggle.d.ts.map +0 -1
- package/dist/Toggle/Toggle.styles.d.ts.map +0 -1
- package/dist/Toggle/Toggle.types.d.ts.map +0 -1
- package/dist/Toggle/index.d.ts.map +0 -1
- package/src/Button/Button.styles.ts +0 -133
- package/src/Button/Button.tsx +0 -86
- /package/dist/{Button → composites/actions/Button}/index.d.ts +0 -0
- /package/dist/{Select → composites/form-controls/Select}/Select.d.ts +0 -0
- /package/dist/{Select → composites/form-controls/Select}/Select.types.d.ts +0 -0
- /package/dist/{Select → composites/form-controls/Select}/SelectOption.d.ts +0 -0
- /package/dist/{Select → composites/form-controls/Select}/index.d.ts +0 -0
- /package/dist/{Select → composites/form-controls/Select}/useSelect.d.ts +0 -0
- /package/dist/{TextInput → composites/form-controls/TextInput}/TextInput.d.ts +0 -0
- /package/dist/{TextInput → composites/form-controls/TextInput}/TextInput.types.d.ts +0 -0
- /package/dist/{TextInput → composites/form-controls/TextInput}/index.d.ts +0 -0
- /package/dist/{Toggle → composites/form-controls/Toggle}/Toggle.d.ts +0 -0
- /package/dist/{Toggle → composites/form-controls/Toggle}/Toggle.types.d.ts +0 -0
- /package/dist/{Toggle → composites/form-controls/Toggle}/index.d.ts +0 -0
- /package/dist/{AppShell → composites/layout/AppShell}/AppShell.d.ts +0 -0
- /package/dist/{AppShell → composites/layout/AppShell}/AppShell.types.d.ts +0 -0
- /package/dist/{AppShell → composites/layout/AppShell}/index.d.ts +0 -0
- /package/dist/{Card → composites/layout/Card}/Card.d.ts +0 -0
- /package/dist/{Card → composites/layout/Card}/index.d.ts +0 -0
- /package/dist/{Navbar → composites/layout/Navbar}/Navbar.d.ts +0 -0
- /package/dist/{Navbar → composites/layout/Navbar}/Navbar.types.d.ts +0 -0
- /package/dist/{Navbar → composites/layout/Navbar}/index.d.ts +0 -0
- /package/dist/{Sidebar → composites/layout/Sidebar}/Sidebar.d.ts +0 -0
- /package/dist/{Sidebar → composites/layout/Sidebar}/Sidebar.types.d.ts +0 -0
- /package/dist/{Sidebar → composites/layout/Sidebar}/index.d.ts +0 -0
- /package/dist/{Popover → composites/overlays/Popover}/Popover.d.ts +0 -0
- /package/dist/{Popover → composites/overlays/Popover}/Popover.types.d.ts +0 -0
- /package/dist/{Popover → composites/overlays/Popover}/index.d.ts +0 -0
- /package/dist/{Popover → composites/overlays/Popover}/usePopover.d.ts +0 -0
- /package/dist/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.d.ts +0 -0
- /package/dist/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.types.d.ts +0 -0
- /package/dist/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/index.d.ts +0 -0
- /package/dist/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.d.ts +0 -0
- /package/dist/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.types.d.ts +0 -0
- /package/dist/{HueSlider → composites/range-inputs/HueSlider}/index.d.ts +0 -0
- /package/dist/{Slider → composites/range-inputs/Slider}/Slider.d.ts +0 -0
- /package/dist/{Slider → composites/range-inputs/Slider}/Slider.types.d.ts +0 -0
- /package/dist/{Slider → composites/range-inputs/Slider}/index.d.ts +0 -0
- /package/src/{Button → composites/actions/Button}/index.ts +0 -0
- /package/src/{Select → composites/form-controls/Select}/Select.types.ts +0 -0
- /package/src/{Select → composites/form-controls/Select}/index.ts +0 -0
- /package/src/{Select → composites/form-controls/Select}/useSelect.ts +0 -0
- /package/src/{TextInput → composites/form-controls/TextInput}/TextInput.types.ts +0 -0
- /package/src/{TextInput → composites/form-controls/TextInput}/index.ts +0 -0
- /package/src/{Toggle → composites/form-controls/Toggle}/Toggle.types.ts +0 -0
- /package/src/{Toggle → composites/form-controls/Toggle}/index.ts +0 -0
- /package/src/{AppShell → composites/layout/AppShell}/AppShell.types.ts +0 -0
- /package/src/{AppShell → composites/layout/AppShell}/index.ts +0 -0
- /package/src/{Card → composites/layout/Card}/index.ts +0 -0
- /package/src/{Navbar → composites/layout/Navbar}/Navbar.types.ts +0 -0
- /package/src/{Navbar → composites/layout/Navbar}/index.ts +0 -0
- /package/src/{Sidebar → composites/layout/Sidebar}/Sidebar.types.ts +0 -0
- /package/src/{Sidebar → composites/layout/Sidebar}/index.ts +0 -0
- /package/src/{Popover → composites/overlays/Popover}/Popover.types.ts +0 -0
- /package/src/{Popover → composites/overlays/Popover}/index.ts +0 -0
- /package/src/{Popover → composites/overlays/Popover}/usePopover.ts +0 -0
- /package/src/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/ColorScaleSlider.types.ts +0 -0
- /package/src/{ColorScaleSlider → composites/range-inputs/ColorScaleSlider}/index.ts +0 -0
- /package/src/{HueSlider → composites/range-inputs/HueSlider}/HueSlider.types.ts +0 -0
- /package/src/{HueSlider → composites/range-inputs/HueSlider}/index.ts +0 -0
- /package/src/{Slider → composites/range-inputs/Slider}/Slider.types.ts +0 -0
- /package/src/{Slider → composites/range-inputs/Slider}/index.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React13 = require('react');
|
|
4
4
|
var newtone = require('newtone');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
|
|
7
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var React13__default = /*#__PURE__*/_interopDefault(React13);
|
|
10
10
|
|
|
11
11
|
// src/theme/NewtoneProvider.tsx
|
|
12
12
|
var DEFAULT_THEME_CONFIG = {
|
|
@@ -131,8 +131,8 @@ function buildGoogleFontsUrl(fonts) {
|
|
|
131
131
|
|
|
132
132
|
// src/fonts/GoogleFontLoader.tsx
|
|
133
133
|
function GoogleFontLoader({ fonts }) {
|
|
134
|
-
const linkRef =
|
|
135
|
-
|
|
134
|
+
const linkRef = React13.useRef(null);
|
|
135
|
+
React13.useEffect(() => {
|
|
136
136
|
if (typeof document === "undefined") return;
|
|
137
137
|
const url = buildGoogleFontsUrl(fonts);
|
|
138
138
|
if (linkRef.current) {
|
|
@@ -164,8 +164,8 @@ function GoogleFontLoader({ fonts }) {
|
|
|
164
164
|
return null;
|
|
165
165
|
}
|
|
166
166
|
function IconFontLoader({ icons }) {
|
|
167
|
-
const linkRef =
|
|
168
|
-
|
|
167
|
+
const linkRef = React13.useRef(null);
|
|
168
|
+
React13.useEffect(() => {
|
|
169
169
|
if (typeof document === "undefined") return;
|
|
170
170
|
const variantName = icons.variant.charAt(0).toUpperCase() + icons.variant.slice(1);
|
|
171
171
|
const family = `Material+Symbols+${variantName}`;
|
|
@@ -192,16 +192,16 @@ function IconFontLoader({ icons }) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/theme/NewtoneProvider.tsx
|
|
195
|
-
var ThemeContext =
|
|
195
|
+
var ThemeContext = React13.createContext(null);
|
|
196
196
|
function NewtoneProvider({
|
|
197
197
|
config = DEFAULT_THEME_CONFIG,
|
|
198
198
|
initialMode = "light",
|
|
199
199
|
initialTheme = "neutral",
|
|
200
200
|
children
|
|
201
201
|
}) {
|
|
202
|
-
const [mode, setMode] =
|
|
203
|
-
const [theme, setTheme] =
|
|
204
|
-
const value =
|
|
202
|
+
const [mode, setMode] = React13.useState(initialMode);
|
|
203
|
+
const [theme, setTheme] = React13.useState(initialTheme);
|
|
204
|
+
const value = React13.useMemo(
|
|
205
205
|
() => ({
|
|
206
206
|
config,
|
|
207
207
|
mode,
|
|
@@ -211,18 +211,18 @@ function NewtoneProvider({
|
|
|
211
211
|
}),
|
|
212
212
|
[config, mode, theme]
|
|
213
213
|
);
|
|
214
|
-
return /* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ React13__default.default.createElement(ThemeContext.Provider, { value }, /* @__PURE__ */ React13__default.default.createElement(GoogleFontLoader, { fonts: config.typography.fonts }), /* @__PURE__ */ React13__default.default.createElement(IconFontLoader, { icons: config.icons }), children);
|
|
215
215
|
}
|
|
216
216
|
function useNewtoneTheme() {
|
|
217
|
-
const context =
|
|
217
|
+
const context = React13.useContext(ThemeContext);
|
|
218
218
|
if (!context) {
|
|
219
219
|
throw new Error("useNewtoneTheme must be used within NewtoneProvider");
|
|
220
220
|
}
|
|
221
221
|
return context;
|
|
222
222
|
}
|
|
223
|
-
var FrameContext =
|
|
223
|
+
var FrameContext = React13.createContext(null);
|
|
224
224
|
function useFrameContext() {
|
|
225
|
-
return
|
|
225
|
+
return React13.useContext(FrameContext);
|
|
226
226
|
}
|
|
227
227
|
function fontConfigToFamily(font) {
|
|
228
228
|
const family = font.family.includes(" ") ? `"${font.family}"` : font.family;
|
|
@@ -264,6 +264,16 @@ function computeTokens(config, mode, themeMapping, elevation, elevationOffsets,
|
|
|
264
264
|
palette.desaturation,
|
|
265
265
|
palette.paletteHueGrading
|
|
266
266
|
);
|
|
267
|
+
const INTERACTIVE_COMPONENT_OFFSET = -0.035;
|
|
268
|
+
const interactiveComponentNv = Math.max(0, Math.min(1, backgroundNv + INTERACTIVE_COMPONENT_OFFSET));
|
|
269
|
+
const backgroundInteractive = newtone.getColor(
|
|
270
|
+
palette.hue,
|
|
271
|
+
palette.saturation,
|
|
272
|
+
dynamicRange,
|
|
273
|
+
interactiveComponentNv,
|
|
274
|
+
palette.desaturation,
|
|
275
|
+
palette.paletteHueGrading
|
|
276
|
+
);
|
|
267
277
|
const textPrimary = newtone.getColorByContrast(
|
|
268
278
|
palette.hue,
|
|
269
279
|
palette.saturation,
|
|
@@ -394,6 +404,7 @@ function computeTokens(config, mode, themeMapping, elevation, elevationOffsets,
|
|
|
394
404
|
background,
|
|
395
405
|
backgroundElevated,
|
|
396
406
|
backgroundSunken,
|
|
407
|
+
backgroundInteractive,
|
|
397
408
|
textPrimary,
|
|
398
409
|
textSecondary,
|
|
399
410
|
interactive,
|
|
@@ -429,9 +440,9 @@ function useTokens(elevation) {
|
|
|
429
440
|
const frameCtx = useFrameContext();
|
|
430
441
|
const resolvedTheme = frameCtx?.theme ?? providerTheme;
|
|
431
442
|
const resolvedElevation = elevation ?? frameCtx?.elevation ?? 1;
|
|
432
|
-
return
|
|
443
|
+
return React13.useMemo(() => {
|
|
433
444
|
const themeMapping = config.themes[resolvedTheme];
|
|
434
|
-
|
|
445
|
+
const tokens = computeTokens(
|
|
435
446
|
config.colorSystem,
|
|
436
447
|
mode,
|
|
437
448
|
themeMapping,
|
|
@@ -442,102 +453,228 @@ function useTokens(elevation) {
|
|
|
442
453
|
config.typography,
|
|
443
454
|
config.icons
|
|
444
455
|
);
|
|
456
|
+
return { ...tokens, elevation: resolvedElevation };
|
|
445
457
|
}, [config, mode, resolvedTheme, resolvedElevation]);
|
|
446
458
|
}
|
|
447
|
-
function
|
|
459
|
+
function withOpacity(hexColor, opacity) {
|
|
460
|
+
const alpha = Math.round(opacity * 255).toString(16).padStart(2, "0");
|
|
461
|
+
return `${hexColor}${alpha}`;
|
|
462
|
+
}
|
|
463
|
+
function computeButtonPadding(size, hasIcon, hasText, iconPosition) {
|
|
464
|
+
const basePadding = {
|
|
465
|
+
sm: 8,
|
|
466
|
+
md: 12,
|
|
467
|
+
lg: 16
|
|
468
|
+
};
|
|
469
|
+
const base = basePadding[size];
|
|
470
|
+
const textExtra = 8;
|
|
471
|
+
if (!hasText && hasIcon) {
|
|
472
|
+
return {
|
|
473
|
+
paddingLeft: base,
|
|
474
|
+
paddingRight: base,
|
|
475
|
+
paddingTop: base,
|
|
476
|
+
paddingBottom: base
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
if (hasText && !hasIcon) {
|
|
480
|
+
return {
|
|
481
|
+
paddingLeft: base + textExtra,
|
|
482
|
+
paddingRight: base + textExtra,
|
|
483
|
+
paddingTop: base,
|
|
484
|
+
paddingBottom: base
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
if (hasText && hasIcon) {
|
|
488
|
+
if (iconPosition === "left") {
|
|
489
|
+
return {
|
|
490
|
+
paddingLeft: base,
|
|
491
|
+
paddingRight: base + textExtra,
|
|
492
|
+
paddingTop: base,
|
|
493
|
+
paddingBottom: base
|
|
494
|
+
};
|
|
495
|
+
} else {
|
|
496
|
+
return {
|
|
497
|
+
paddingLeft: base + textExtra,
|
|
498
|
+
paddingRight: base,
|
|
499
|
+
paddingTop: base,
|
|
500
|
+
paddingBottom: base
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
paddingLeft: base,
|
|
506
|
+
paddingRight: base,
|
|
507
|
+
paddingTop: base,
|
|
508
|
+
paddingBottom: base
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function getNeutralPrimaryBg(tokens) {
|
|
512
|
+
return newtone.srgbToHex(tokens.backgroundInteractive.srgb);
|
|
513
|
+
}
|
|
514
|
+
function getButtonConfig(variant, semantic, size, disabled, tokens) {
|
|
515
|
+
const sizeConfig = getSizeConfig(size, tokens);
|
|
516
|
+
const variantColors = getVariantColors(variant, semantic, disabled, tokens);
|
|
448
517
|
return {
|
|
518
|
+
variantColors,
|
|
519
|
+
sizeTokens: {
|
|
520
|
+
padding: sizeConfig.padding,
|
|
521
|
+
gap: sizeConfig.gap,
|
|
522
|
+
borderRadius: sizeConfig.borderRadius,
|
|
523
|
+
textSize: sizeConfig.textSize,
|
|
524
|
+
iconSize: sizeConfig.iconSize
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function getSizeConfig(size, tokens) {
|
|
529
|
+
const configs = {
|
|
449
530
|
sm: {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
iconSize:
|
|
531
|
+
padding: 8,
|
|
532
|
+
gap: tokens.spacing["08"],
|
|
533
|
+
borderRadius: 8,
|
|
534
|
+
textSize: "base",
|
|
535
|
+
// 16px
|
|
536
|
+
iconSize: 24
|
|
456
537
|
},
|
|
457
538
|
md: {
|
|
458
|
-
|
|
459
|
-
paddingHorizontal: tokens.spacing["16"],
|
|
460
|
-
fontSize: tokens.typography.size.base,
|
|
461
|
-
borderRadius: tokens.radius.md,
|
|
539
|
+
padding: 12,
|
|
462
540
|
gap: tokens.spacing["08"],
|
|
463
|
-
|
|
541
|
+
borderRadius: 12,
|
|
542
|
+
textSize: "base",
|
|
543
|
+
// 16px
|
|
544
|
+
iconSize: 24
|
|
464
545
|
},
|
|
465
546
|
lg: {
|
|
466
|
-
|
|
467
|
-
paddingHorizontal: tokens.spacing["24"],
|
|
468
|
-
fontSize: tokens.typography.size.base,
|
|
469
|
-
borderRadius: tokens.radius.lg,
|
|
547
|
+
padding: 16,
|
|
470
548
|
gap: tokens.spacing["08"],
|
|
471
|
-
|
|
549
|
+
borderRadius: 16,
|
|
550
|
+
textSize: "base",
|
|
551
|
+
// 16px
|
|
552
|
+
iconSize: 24
|
|
472
553
|
}
|
|
473
554
|
};
|
|
555
|
+
return configs[size];
|
|
474
556
|
}
|
|
475
|
-
function
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
557
|
+
function getVariantColors(variant, semantic, disabled, tokens) {
|
|
558
|
+
if (disabled) {
|
|
559
|
+
const baseColors = getVariantColorsForState(variant, semantic, tokens);
|
|
560
|
+
return {
|
|
561
|
+
...baseColors,
|
|
562
|
+
bg: newtone.srgbToHex(tokens.backgroundSunken.srgb),
|
|
563
|
+
pressedBg: newtone.srgbToHex(tokens.backgroundSunken.srgb),
|
|
564
|
+
textColor: newtone.srgbToHex(tokens.textSecondary.srgb),
|
|
565
|
+
iconColor: newtone.srgbToHex(tokens.textSecondary.srgb)
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
return getVariantColorsForState(variant, semantic, tokens);
|
|
569
|
+
}
|
|
570
|
+
function getVariantColorsForState(variant, semantic, tokens) {
|
|
571
|
+
const getSemanticColor = () => {
|
|
572
|
+
switch (semantic) {
|
|
573
|
+
case "accent":
|
|
574
|
+
return newtone.srgbToHex(tokens.interactive.srgb);
|
|
575
|
+
case "success":
|
|
576
|
+
return newtone.srgbToHex(tokens.success.srgb);
|
|
577
|
+
case "error":
|
|
578
|
+
return newtone.srgbToHex(tokens.error.srgb);
|
|
579
|
+
case "warning":
|
|
580
|
+
return newtone.srgbToHex(tokens.warning.srgb);
|
|
581
|
+
default:
|
|
582
|
+
return newtone.srgbToHex(tokens.textPrimary.srgb);
|
|
583
|
+
}
|
|
485
584
|
};
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
585
|
+
if (variant === "primary") {
|
|
586
|
+
if (semantic === "neutral") {
|
|
587
|
+
const bg = getNeutralPrimaryBg(tokens);
|
|
588
|
+
return {
|
|
589
|
+
bg,
|
|
590
|
+
pressedBg: withOpacity(bg, 0.8),
|
|
591
|
+
// Slightly darker on press
|
|
592
|
+
textColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
593
|
+
iconColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
594
|
+
borderWidth: 1,
|
|
595
|
+
borderColor: "transparent"
|
|
596
|
+
// Invisible border for consistent sizing
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (semantic === "accent") {
|
|
600
|
+
return {
|
|
601
|
+
bg: newtone.srgbToHex(tokens.interactive.srgb),
|
|
602
|
+
pressedBg: newtone.srgbToHex(tokens.interactiveActive.srgb),
|
|
603
|
+
textColor: newtone.srgbToHex(tokens.background.srgb),
|
|
604
|
+
// Contrast inversion
|
|
605
|
+
iconColor: newtone.srgbToHex(tokens.background.srgb),
|
|
606
|
+
borderWidth: 1,
|
|
607
|
+
borderColor: "transparent"
|
|
608
|
+
// Invisible border for consistent sizing
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const semanticColor = getSemanticColor();
|
|
612
|
+
return {
|
|
613
|
+
bg: semanticColor,
|
|
614
|
+
pressedBg: withOpacity(semanticColor, 0.8),
|
|
615
|
+
// Darken on press
|
|
616
|
+
textColor: newtone.srgbToHex(tokens.background.srgb),
|
|
617
|
+
// Contrast text
|
|
618
|
+
iconColor: newtone.srgbToHex(tokens.background.srgb),
|
|
619
|
+
borderWidth: 1,
|
|
620
|
+
borderColor: "transparent"
|
|
621
|
+
// Invisible border for consistent sizing
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
if (variant === "secondary") {
|
|
625
|
+
if (semantic === "neutral") {
|
|
626
|
+
return {
|
|
627
|
+
bg: "transparent",
|
|
628
|
+
pressedBg: newtone.srgbToHex(tokens.backgroundSunken.srgb),
|
|
629
|
+
textColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
630
|
+
iconColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
631
|
+
borderWidth: 1,
|
|
632
|
+
borderColor: newtone.srgbToHex(tokens.border.srgb)
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
const semanticColor = getSemanticColor();
|
|
636
|
+
return {
|
|
637
|
+
bg: withOpacity(semanticColor, 0.1),
|
|
638
|
+
// Light background tint
|
|
639
|
+
pressedBg: withOpacity(semanticColor, 0.15),
|
|
640
|
+
// Slightly darker on press
|
|
641
|
+
textColor: semanticColor,
|
|
642
|
+
iconColor: semanticColor,
|
|
643
|
+
borderWidth: 1,
|
|
644
|
+
borderColor: "transparent"
|
|
645
|
+
// Invisible border for consistent sizing
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
if (variant === "tertiary") {
|
|
649
|
+
if (semantic === "neutral") {
|
|
650
|
+
return {
|
|
651
|
+
bg: "transparent",
|
|
652
|
+
pressedBg: newtone.srgbToHex(tokens.backgroundSunken.srgb),
|
|
653
|
+
textColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
654
|
+
iconColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
655
|
+
borderWidth: 1,
|
|
656
|
+
borderColor: "transparent"
|
|
657
|
+
// Invisible border for consistent sizing
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
const semanticColor = getSemanticColor();
|
|
661
|
+
return {
|
|
662
|
+
bg: "transparent",
|
|
663
|
+
pressedBg: withOpacity(semanticColor, 0.1),
|
|
664
|
+
// Subtle background tint
|
|
665
|
+
textColor: semanticColor,
|
|
666
|
+
iconColor: semanticColor,
|
|
667
|
+
borderWidth: 1,
|
|
668
|
+
borderColor: "transparent"
|
|
669
|
+
// Invisible border for consistent sizing
|
|
670
|
+
};
|
|
509
671
|
}
|
|
510
|
-
const resolvedTextColor = disabled ? newtone.srgbToHex(tokens.textSecondary.srgb) : textColor;
|
|
511
672
|
return {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
backgroundColor: disabled ? newtone.srgbToHex(tokens.backgroundSunken.srgb) : backgroundColor,
|
|
518
|
-
borderWidth,
|
|
519
|
-
...borderColor && { borderColor }
|
|
520
|
-
},
|
|
521
|
-
pressed: {
|
|
522
|
-
backgroundColor: variant === "primary" ? newtone.srgbToHex(tokens.interactiveActive.srgb) : variant === "secondary" ? newtone.srgbToHex(tokens.backgroundSunken.srgb) : "transparent",
|
|
523
|
-
opacity: variant === "ghost" || variant === "outline" ? 0.7 : 1
|
|
524
|
-
},
|
|
525
|
-
disabled: {
|
|
526
|
-
opacity: 0.4
|
|
527
|
-
},
|
|
528
|
-
text: {
|
|
529
|
-
fontFamily: tokens.typography.fonts.default,
|
|
530
|
-
fontSize: sizeConfig.fontSize,
|
|
531
|
-
fontWeight: tokens.typography.weight.semibold,
|
|
532
|
-
color: resolvedTextColor
|
|
533
|
-
},
|
|
534
|
-
textPressed: {
|
|
535
|
-
// Color changes handled by parent opacity
|
|
536
|
-
},
|
|
537
|
-
textDisabled: {
|
|
538
|
-
// Color already set in text style via disabled check
|
|
539
|
-
}
|
|
540
|
-
})
|
|
673
|
+
bg: "transparent",
|
|
674
|
+
pressedBg: "transparent",
|
|
675
|
+
textColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
676
|
+
iconColor: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
677
|
+
borderWidth: 0
|
|
541
678
|
};
|
|
542
679
|
}
|
|
543
680
|
function Icon({
|
|
@@ -557,15 +694,27 @@ function Icon({
|
|
|
557
694
|
ref
|
|
558
695
|
}) {
|
|
559
696
|
const tokens = useTokens(elevation);
|
|
560
|
-
const iconStyle =
|
|
697
|
+
const iconStyle = React13.useMemo(() => {
|
|
561
698
|
const fontSize = size ?? tokens.typography.size.base;
|
|
562
|
-
const
|
|
699
|
+
const getOpticalSize = (size2) => {
|
|
700
|
+
if (size2 <= 22) return 20;
|
|
701
|
+
if (size2 <= 32) return 24;
|
|
702
|
+
if (size2 <= 44) return 40;
|
|
703
|
+
return 48;
|
|
704
|
+
};
|
|
705
|
+
const opsz = opticalSize ?? getOpticalSize(fontSize);
|
|
563
706
|
const iconColor = color ?? newtone.srgbToHex(tokens.textPrimary.srgb);
|
|
564
707
|
const fontFamily = `Material Symbols ${tokens.icons.variant.charAt(0).toUpperCase() + tokens.icons.variant.slice(1)}`;
|
|
565
708
|
const fontVariationSettings = `'FILL' ${fill}, 'wght' ${tokens.icons.weight}, 'GRAD' ${tokens.icons.grade}, 'opsz' ${opsz}`;
|
|
566
709
|
return {
|
|
567
710
|
fontFamily,
|
|
568
711
|
fontSize,
|
|
712
|
+
width: fontSize,
|
|
713
|
+
// Explicit width ensures square rendering
|
|
714
|
+
height: fontSize,
|
|
715
|
+
// Explicit height ensures square rendering
|
|
716
|
+
lineHeight: fontSize,
|
|
717
|
+
// Prevent text line-height from affecting total height
|
|
569
718
|
color: iconColor,
|
|
570
719
|
userSelect: "none",
|
|
571
720
|
// web-only: prevents users from selecting the icon as text
|
|
@@ -574,7 +723,7 @@ function Icon({
|
|
|
574
723
|
...style
|
|
575
724
|
};
|
|
576
725
|
}, [tokens, size, opticalSize, fill, color, style]);
|
|
577
|
-
return /* @__PURE__ */
|
|
726
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
578
727
|
reactNative.Text,
|
|
579
728
|
{
|
|
580
729
|
ref,
|
|
@@ -588,121 +737,57 @@ function Icon({
|
|
|
588
737
|
name
|
|
589
738
|
);
|
|
590
739
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
variant = "primary",
|
|
598
|
-
size = "md",
|
|
599
|
-
disabled = false,
|
|
600
|
-
style,
|
|
601
|
-
textStyle,
|
|
602
|
-
...pressableProps
|
|
603
|
-
}) {
|
|
604
|
-
const tokens = useTokens(1);
|
|
605
|
-
const isIconOnly = !!icon && !children;
|
|
606
|
-
const { styles, iconColor, iconSize } = React11__default.default.useMemo(
|
|
607
|
-
() => getButtonStyles(tokens, variant, size, disabled, isIconOnly),
|
|
608
|
-
[tokens, variant, size, disabled, isIconOnly]
|
|
609
|
-
);
|
|
610
|
-
const renderIcon = () => /* @__PURE__ */ React11__default.default.createElement(Icon, { name: icon, size: iconSize, color: iconColor });
|
|
611
|
-
return /* @__PURE__ */ React11__default.default.createElement(
|
|
612
|
-
reactNative.Pressable,
|
|
613
|
-
{
|
|
614
|
-
style: ({ pressed }) => [
|
|
615
|
-
styles.base,
|
|
616
|
-
pressed && !disabled && styles.pressed,
|
|
617
|
-
disabled && styles.disabled,
|
|
618
|
-
...Array.isArray(style) ? style : [style]
|
|
619
|
-
],
|
|
620
|
-
disabled,
|
|
621
|
-
...pressableProps
|
|
622
|
-
},
|
|
623
|
-
({ pressed }) => /* @__PURE__ */ React11__default.default.createElement(React11__default.default.Fragment, null, icon && iconPosition === "left" && renderIcon(), children != null && /* @__PURE__ */ React11__default.default.createElement(
|
|
624
|
-
reactNative.Text,
|
|
625
|
-
{
|
|
626
|
-
style: [
|
|
627
|
-
styles.text,
|
|
628
|
-
pressed && !disabled && styles.textPressed,
|
|
629
|
-
disabled && styles.textDisabled,
|
|
630
|
-
...Array.isArray(textStyle) ? textStyle : [textStyle]
|
|
631
|
-
]
|
|
632
|
-
},
|
|
633
|
-
children
|
|
634
|
-
), icon && iconPosition === "right" && renderIcon())
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
function getCardStyles(tokens, disabled) {
|
|
638
|
-
return reactNative.StyleSheet.create({
|
|
639
|
-
container: {
|
|
640
|
-
backgroundColor: newtone.srgbToHex(tokens.background.srgb),
|
|
641
|
-
borderWidth: 1,
|
|
642
|
-
borderColor: newtone.srgbToHex(tokens.border.srgb),
|
|
643
|
-
borderRadius: tokens.radius.lg,
|
|
644
|
-
padding: tokens.spacing["16"],
|
|
645
|
-
opacity: disabled ? 0.5 : 1
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
// src/Card/Card.tsx
|
|
651
|
-
function Card({
|
|
740
|
+
var COLOR_MAP = {
|
|
741
|
+
primary: "textPrimary",
|
|
742
|
+
secondary: "textSecondary",
|
|
743
|
+
interactive: "interactive"
|
|
744
|
+
};
|
|
745
|
+
function Text2({
|
|
652
746
|
children,
|
|
747
|
+
size = "base",
|
|
748
|
+
weight = "regular",
|
|
749
|
+
color = "primary",
|
|
750
|
+
font = "default",
|
|
751
|
+
lineHeight = "normal",
|
|
752
|
+
align,
|
|
753
|
+
numberOfLines,
|
|
653
754
|
elevation = 1,
|
|
654
755
|
style,
|
|
655
|
-
|
|
756
|
+
// Accessibility
|
|
757
|
+
accessibilityRole,
|
|
758
|
+
// Testing & platform
|
|
759
|
+
testID,
|
|
760
|
+
nativeID,
|
|
761
|
+
ref
|
|
656
762
|
}) {
|
|
657
763
|
const tokens = useTokens(elevation);
|
|
658
|
-
const
|
|
659
|
-
|
|
660
|
-
|
|
764
|
+
const resolvedStyle = React13.useMemo(() => {
|
|
765
|
+
const fontSize = tokens.typography.size[size];
|
|
766
|
+
return {
|
|
767
|
+
// Font family from the theme (e.g. 'default' → 'Inter', 'mono' → 'JetBrains Mono').
|
|
768
|
+
fontFamily: tokens.typography.fonts[font],
|
|
769
|
+
fontSize,
|
|
770
|
+
// Font weight is stored as a number (e.g. 400, 600) but React Native expects a string.
|
|
771
|
+
fontWeight: String(tokens.typography.weight[weight]),
|
|
772
|
+
// Convert the theme color from internal sRGB format to a hex string (e.g. '#1a1a1a').
|
|
773
|
+
color: newtone.srgbToHex(tokens[COLOR_MAP[color]].srgb),
|
|
774
|
+
// Line height = font size × multiplier (e.g. 16px × 1.5 = 24px line height).
|
|
775
|
+
lineHeight: fontSize * tokens.typography.lineHeight[lineHeight],
|
|
776
|
+
textAlign: align
|
|
777
|
+
};
|
|
778
|
+
}, [tokens, size, weight, color, font, lineHeight, align]);
|
|
779
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
780
|
+
reactNative.Text,
|
|
781
|
+
{
|
|
782
|
+
ref,
|
|
783
|
+
testID,
|
|
784
|
+
nativeID,
|
|
785
|
+
accessibilityRole,
|
|
786
|
+
style: style ? [resolvedStyle, ...Array.isArray(style) ? style : [style]] : resolvedStyle,
|
|
787
|
+
numberOfLines
|
|
788
|
+
},
|
|
789
|
+
children
|
|
661
790
|
);
|
|
662
|
-
return /* @__PURE__ */ React11__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, children);
|
|
663
|
-
}
|
|
664
|
-
var hadKeyboardEvent = false;
|
|
665
|
-
var isListenerSetup = false;
|
|
666
|
-
function setupModality() {
|
|
667
|
-
if (isListenerSetup || typeof document === "undefined") return;
|
|
668
|
-
isListenerSetup = true;
|
|
669
|
-
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
670
|
-
"Tab",
|
|
671
|
-
"ArrowUp",
|
|
672
|
-
"ArrowDown",
|
|
673
|
-
"ArrowLeft",
|
|
674
|
-
"ArrowRight",
|
|
675
|
-
"Enter",
|
|
676
|
-
" ",
|
|
677
|
-
"Escape"
|
|
678
|
-
]);
|
|
679
|
-
document.addEventListener("keydown", (e) => {
|
|
680
|
-
if (NAVIGATION_KEYS.has(e.key)) {
|
|
681
|
-
hadKeyboardEvent = true;
|
|
682
|
-
}
|
|
683
|
-
}, true);
|
|
684
|
-
document.addEventListener("pointerdown", () => {
|
|
685
|
-
hadKeyboardEvent = false;
|
|
686
|
-
}, true);
|
|
687
|
-
document.addEventListener("mousedown", () => {
|
|
688
|
-
hadKeyboardEvent = false;
|
|
689
|
-
}, true);
|
|
690
|
-
}
|
|
691
|
-
function useFocusVisible() {
|
|
692
|
-
const [isFocusVisible, setIsFocusVisible] = React11.useState(false);
|
|
693
|
-
React11.useEffect(() => {
|
|
694
|
-
setupModality();
|
|
695
|
-
}, []);
|
|
696
|
-
const onFocus = React11.useCallback(() => {
|
|
697
|
-
if (hadKeyboardEvent) {
|
|
698
|
-
setIsFocusVisible(true);
|
|
699
|
-
}
|
|
700
|
-
}, []);
|
|
701
|
-
const onBlur = React11.useCallback(() => {
|
|
702
|
-
setIsFocusVisible(false);
|
|
703
|
-
}, []);
|
|
704
|
-
const focusProps = { onFocus, onBlur };
|
|
705
|
-
return { isFocusVisible, focusProps };
|
|
706
791
|
}
|
|
707
792
|
|
|
708
793
|
// src/primitives/Frame/Frame.utils.ts
|
|
@@ -799,14 +884,260 @@ function resolveAlignment(align) {
|
|
|
799
884
|
function resolveJustification(justify) {
|
|
800
885
|
return JUSTIFY_MAP[justify];
|
|
801
886
|
}
|
|
802
|
-
function resolveFlexDirection(direction, reverse) {
|
|
803
|
-
if (direction === "horizontal") {
|
|
804
|
-
return reverse ? "row-reverse" : "row";
|
|
805
|
-
}
|
|
806
|
-
return reverse ? "column-reverse" : "column";
|
|
887
|
+
function resolveFlexDirection(direction, reverse) {
|
|
888
|
+
if (direction === "horizontal") {
|
|
889
|
+
return reverse ? "row-reverse" : "row";
|
|
890
|
+
}
|
|
891
|
+
return reverse ? "column-reverse" : "column";
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// src/primitives/Wrapper/Wrapper.styles.ts
|
|
895
|
+
function getWrapperStyles(input) {
|
|
896
|
+
const {
|
|
897
|
+
tokens,
|
|
898
|
+
direction = "vertical",
|
|
899
|
+
wrap = false,
|
|
900
|
+
reverse = false,
|
|
901
|
+
align,
|
|
902
|
+
justify,
|
|
903
|
+
padding,
|
|
904
|
+
gap,
|
|
905
|
+
width,
|
|
906
|
+
height,
|
|
907
|
+
minWidth,
|
|
908
|
+
maxWidth,
|
|
909
|
+
minHeight,
|
|
910
|
+
maxHeight
|
|
911
|
+
} = input;
|
|
912
|
+
const container = {};
|
|
913
|
+
container.flexDirection = resolveFlexDirection(direction, reverse);
|
|
914
|
+
if (wrap) container.flexWrap = "wrap";
|
|
915
|
+
if (align) container.alignItems = resolveAlignment(align);
|
|
916
|
+
if (justify) container.justifyContent = resolveJustification(justify);
|
|
917
|
+
if (padding !== void 0) {
|
|
918
|
+
const p = resolvePadding(padding, tokens);
|
|
919
|
+
container.paddingTop = p.top;
|
|
920
|
+
container.paddingRight = p.right;
|
|
921
|
+
container.paddingBottom = p.bottom;
|
|
922
|
+
container.paddingLeft = p.left;
|
|
923
|
+
}
|
|
924
|
+
if (gap !== void 0) {
|
|
925
|
+
const g = resolveGap(gap, tokens);
|
|
926
|
+
container.rowGap = g.rowGap;
|
|
927
|
+
container.columnGap = g.columnGap;
|
|
928
|
+
}
|
|
929
|
+
Object.assign(container, resolveSizing(width, height));
|
|
930
|
+
if (minWidth !== void 0) container.minWidth = minWidth;
|
|
931
|
+
if (maxWidth !== void 0) container.maxWidth = maxWidth;
|
|
932
|
+
if (minHeight !== void 0) container.minHeight = minHeight;
|
|
933
|
+
if (maxHeight !== void 0) container.maxHeight = maxHeight;
|
|
934
|
+
return reactNative.StyleSheet.create({ c: container }).c;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// src/primitives/Wrapper/Wrapper.tsx
|
|
938
|
+
function Wrapper({
|
|
939
|
+
children,
|
|
940
|
+
direction,
|
|
941
|
+
wrap,
|
|
942
|
+
reverse,
|
|
943
|
+
align,
|
|
944
|
+
justify,
|
|
945
|
+
padding,
|
|
946
|
+
gap,
|
|
947
|
+
width,
|
|
948
|
+
height,
|
|
949
|
+
minWidth,
|
|
950
|
+
maxWidth,
|
|
951
|
+
minHeight,
|
|
952
|
+
maxHeight,
|
|
953
|
+
style,
|
|
954
|
+
// Testing & platform
|
|
955
|
+
testID,
|
|
956
|
+
nativeID,
|
|
957
|
+
ref
|
|
958
|
+
}) {
|
|
959
|
+
const tokens = useTokens(1);
|
|
960
|
+
const containerStyle = React13.useMemo(
|
|
961
|
+
() => getWrapperStyles({
|
|
962
|
+
tokens,
|
|
963
|
+
direction,
|
|
964
|
+
wrap,
|
|
965
|
+
reverse,
|
|
966
|
+
align,
|
|
967
|
+
justify,
|
|
968
|
+
padding,
|
|
969
|
+
gap,
|
|
970
|
+
width,
|
|
971
|
+
height,
|
|
972
|
+
minWidth,
|
|
973
|
+
maxWidth,
|
|
974
|
+
minHeight,
|
|
975
|
+
maxHeight
|
|
976
|
+
}),
|
|
977
|
+
[
|
|
978
|
+
tokens,
|
|
979
|
+
direction,
|
|
980
|
+
wrap,
|
|
981
|
+
reverse,
|
|
982
|
+
align,
|
|
983
|
+
justify,
|
|
984
|
+
padding,
|
|
985
|
+
gap,
|
|
986
|
+
width,
|
|
987
|
+
height,
|
|
988
|
+
minWidth,
|
|
989
|
+
maxWidth,
|
|
990
|
+
minHeight,
|
|
991
|
+
maxHeight
|
|
992
|
+
]
|
|
993
|
+
);
|
|
994
|
+
const userStyles = Array.isArray(style) ? style : style ? [style] : [];
|
|
995
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
996
|
+
reactNative.View,
|
|
997
|
+
{
|
|
998
|
+
ref,
|
|
999
|
+
testID,
|
|
1000
|
+
nativeID,
|
|
1001
|
+
accessibilityRole: "none",
|
|
1002
|
+
style: [containerStyle, ...userStyles]
|
|
1003
|
+
},
|
|
1004
|
+
children
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/composites/actions/Button/Button.tsx
|
|
1009
|
+
function Button({
|
|
1010
|
+
children,
|
|
1011
|
+
icon,
|
|
1012
|
+
iconPosition = "left",
|
|
1013
|
+
variant = "primary",
|
|
1014
|
+
semantic = "neutral",
|
|
1015
|
+
size = "md",
|
|
1016
|
+
disabled = false,
|
|
1017
|
+
style,
|
|
1018
|
+
textStyle,
|
|
1019
|
+
...pressableProps
|
|
1020
|
+
}) {
|
|
1021
|
+
const tokens = useTokens();
|
|
1022
|
+
const { variantColors, sizeTokens } = React13__default.default.useMemo(
|
|
1023
|
+
() => getButtonConfig(variant, semantic, size, disabled, tokens),
|
|
1024
|
+
[variant, semantic, size, disabled, tokens]
|
|
1025
|
+
);
|
|
1026
|
+
const padding = React13__default.default.useMemo(
|
|
1027
|
+
() => computeButtonPadding(size, !!icon, !!children, iconPosition),
|
|
1028
|
+
[size, icon, children, iconPosition]
|
|
1029
|
+
);
|
|
1030
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.Pressable, { disabled, ...pressableProps }, ({ pressed }) => (
|
|
1031
|
+
// Wrapper handles layout: direction, gap, alignment (padding via style)
|
|
1032
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1033
|
+
Wrapper,
|
|
1034
|
+
{
|
|
1035
|
+
direction: "horizontal",
|
|
1036
|
+
align: "center",
|
|
1037
|
+
justify: "center",
|
|
1038
|
+
gap: sizeTokens.gap,
|
|
1039
|
+
style: [
|
|
1040
|
+
{
|
|
1041
|
+
...padding,
|
|
1042
|
+
// Asymmetric horizontal padding for text optical balance
|
|
1043
|
+
backgroundColor: pressed && !disabled ? variantColors.pressedBg : variantColors.bg,
|
|
1044
|
+
borderRadius: sizeTokens.borderRadius,
|
|
1045
|
+
borderWidth: variantColors.borderWidth,
|
|
1046
|
+
// Always 1 for consistent sizing
|
|
1047
|
+
borderColor: variantColors.borderColor || "transparent",
|
|
1048
|
+
opacity: disabled ? 0.4 : 1
|
|
1049
|
+
},
|
|
1050
|
+
...Array.isArray(style) ? style : style ? [style] : []
|
|
1051
|
+
]
|
|
1052
|
+
},
|
|
1053
|
+
icon && iconPosition === "left" && /* @__PURE__ */ React13__default.default.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor }),
|
|
1054
|
+
children && // Text primitive with semantic props + color style override
|
|
1055
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1056
|
+
Text2,
|
|
1057
|
+
{
|
|
1058
|
+
size: sizeTokens.textSize,
|
|
1059
|
+
weight: "semibold",
|
|
1060
|
+
style: [
|
|
1061
|
+
{ color: variantColors.textColor },
|
|
1062
|
+
...Array.isArray(textStyle) ? textStyle : textStyle ? [textStyle] : []
|
|
1063
|
+
]
|
|
1064
|
+
},
|
|
1065
|
+
children
|
|
1066
|
+
),
|
|
1067
|
+
icon && iconPosition === "right" && /* @__PURE__ */ React13__default.default.createElement(Icon, { name: icon, size: sizeTokens.iconSize, color: variantColors.iconColor })
|
|
1068
|
+
)
|
|
1069
|
+
));
|
|
1070
|
+
}
|
|
1071
|
+
function getCardStyles(tokens, disabled) {
|
|
1072
|
+
return reactNative.StyleSheet.create({
|
|
1073
|
+
container: {
|
|
1074
|
+
backgroundColor: newtone.srgbToHex(tokens.background.srgb),
|
|
1075
|
+
borderWidth: 1,
|
|
1076
|
+
borderColor: newtone.srgbToHex(tokens.border.srgb),
|
|
1077
|
+
borderRadius: tokens.radius.lg,
|
|
1078
|
+
padding: tokens.spacing["16"],
|
|
1079
|
+
opacity: disabled ? 0.5 : 1
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// src/composites/layout/Card/Card.tsx
|
|
1085
|
+
function Card({
|
|
1086
|
+
children,
|
|
1087
|
+
elevation = 1,
|
|
1088
|
+
style,
|
|
1089
|
+
disabled = false
|
|
1090
|
+
}) {
|
|
1091
|
+
const tokens = useTokens(elevation);
|
|
1092
|
+
const styles = React13__default.default.useMemo(
|
|
1093
|
+
() => getCardStyles(tokens, disabled),
|
|
1094
|
+
[tokens, disabled]
|
|
1095
|
+
);
|
|
1096
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, children);
|
|
1097
|
+
}
|
|
1098
|
+
var hadKeyboardEvent = false;
|
|
1099
|
+
var isListenerSetup = false;
|
|
1100
|
+
function setupModality() {
|
|
1101
|
+
if (isListenerSetup || typeof document === "undefined") return;
|
|
1102
|
+
isListenerSetup = true;
|
|
1103
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
1104
|
+
"Tab",
|
|
1105
|
+
"ArrowUp",
|
|
1106
|
+
"ArrowDown",
|
|
1107
|
+
"ArrowLeft",
|
|
1108
|
+
"ArrowRight",
|
|
1109
|
+
"Enter",
|
|
1110
|
+
" ",
|
|
1111
|
+
"Escape"
|
|
1112
|
+
]);
|
|
1113
|
+
document.addEventListener("keydown", (e) => {
|
|
1114
|
+
if (NAVIGATION_KEYS.has(e.key)) {
|
|
1115
|
+
hadKeyboardEvent = true;
|
|
1116
|
+
}
|
|
1117
|
+
}, true);
|
|
1118
|
+
document.addEventListener("pointerdown", () => {
|
|
1119
|
+
hadKeyboardEvent = false;
|
|
1120
|
+
}, true);
|
|
1121
|
+
document.addEventListener("mousedown", () => {
|
|
1122
|
+
hadKeyboardEvent = false;
|
|
1123
|
+
}, true);
|
|
1124
|
+
}
|
|
1125
|
+
function useFocusVisible() {
|
|
1126
|
+
const [isFocusVisible, setIsFocusVisible] = React13.useState(false);
|
|
1127
|
+
React13.useEffect(() => {
|
|
1128
|
+
setupModality();
|
|
1129
|
+
}, []);
|
|
1130
|
+
const onFocus = React13.useCallback(() => {
|
|
1131
|
+
if (hadKeyboardEvent) {
|
|
1132
|
+
setIsFocusVisible(true);
|
|
1133
|
+
}
|
|
1134
|
+
}, []);
|
|
1135
|
+
const onBlur = React13.useCallback(() => {
|
|
1136
|
+
setIsFocusVisible(false);
|
|
1137
|
+
}, []);
|
|
1138
|
+
const focusProps = { onFocus, onBlur };
|
|
1139
|
+
return { isFocusVisible, focusProps };
|
|
807
1140
|
}
|
|
808
|
-
|
|
809
|
-
// src/primitives/Frame/Frame.styles.ts
|
|
810
1141
|
function getFrameStyles(input) {
|
|
811
1142
|
const {
|
|
812
1143
|
tokens,
|
|
@@ -913,9 +1244,9 @@ function getFrameStyles(input) {
|
|
|
913
1244
|
|
|
914
1245
|
// src/primitives/Frame/Frame.tsx
|
|
915
1246
|
function wrapTextChildren(children, textStyle) {
|
|
916
|
-
return
|
|
1247
|
+
return React13__default.default.Children.map(children, (child) => {
|
|
917
1248
|
if (typeof child === "string" || typeof child === "number") {
|
|
918
|
-
return /* @__PURE__ */
|
|
1249
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: textStyle }, child);
|
|
919
1250
|
}
|
|
920
1251
|
return child;
|
|
921
1252
|
});
|
|
@@ -972,7 +1303,7 @@ function Frame({
|
|
|
972
1303
|
const resolvedTheme = theme ?? parentFrameCtx?.theme ?? providerTheme;
|
|
973
1304
|
const resolvedFrameElevation = elevation ?? 0;
|
|
974
1305
|
const resolvedElevation = elevation !== void 0 ? toElevationLevel(elevation) : parentFrameCtx?.elevation ?? 1;
|
|
975
|
-
const tokens =
|
|
1306
|
+
const tokens = React13.useMemo(() => {
|
|
976
1307
|
const themeMapping = config.themes[resolvedTheme];
|
|
977
1308
|
return computeTokens(
|
|
978
1309
|
config.colorSystem,
|
|
@@ -986,7 +1317,7 @@ function Frame({
|
|
|
986
1317
|
config.icons
|
|
987
1318
|
);
|
|
988
1319
|
}, [config, mode, resolvedTheme, resolvedElevation]);
|
|
989
|
-
const styles =
|
|
1320
|
+
const styles = React13.useMemo(
|
|
990
1321
|
() => getFrameStyles({
|
|
991
1322
|
tokens,
|
|
992
1323
|
frameElevation: resolvedFrameElevation,
|
|
@@ -1034,7 +1365,7 @@ function Frame({
|
|
|
1034
1365
|
disabled
|
|
1035
1366
|
]
|
|
1036
1367
|
);
|
|
1037
|
-
const contextValue =
|
|
1368
|
+
const contextValue = React13.useMemo(
|
|
1038
1369
|
() => ({ theme: resolvedTheme, elevation: resolvedElevation }),
|
|
1039
1370
|
[resolvedTheme, resolvedElevation]
|
|
1040
1371
|
);
|
|
@@ -1055,7 +1386,7 @@ function Frame({
|
|
|
1055
1386
|
outlineOffset: 2
|
|
1056
1387
|
} : void 0;
|
|
1057
1388
|
const webFocusProps = isInteractive ? focusProps : {};
|
|
1058
|
-
const textStyle =
|
|
1389
|
+
const textStyle = React13.useMemo(
|
|
1059
1390
|
() => ({
|
|
1060
1391
|
color: newtone.srgbToHex(tokens.textPrimary.srgb),
|
|
1061
1392
|
fontSize: tokens.typography.size.base,
|
|
@@ -1064,14 +1395,14 @@ function Frame({
|
|
|
1064
1395
|
}),
|
|
1065
1396
|
[tokens]
|
|
1066
1397
|
);
|
|
1067
|
-
const wrappedChildren =
|
|
1398
|
+
const wrappedChildren = React13.useMemo(
|
|
1068
1399
|
() => wrapTextChildren(children, textStyle),
|
|
1069
1400
|
[children, textStyle]
|
|
1070
1401
|
);
|
|
1071
|
-
return /* @__PURE__ */
|
|
1402
|
+
return /* @__PURE__ */ React13__default.default.createElement(FrameContext.Provider, { value: contextValue }, isInteractive ? (
|
|
1072
1403
|
// Pressable handles taps. When href is set, react-native-web renders
|
|
1073
1404
|
// it as an <a> tag so it works like a regular link on the web.
|
|
1074
|
-
/* @__PURE__ */
|
|
1405
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1075
1406
|
reactNative.Pressable,
|
|
1076
1407
|
{
|
|
1077
1408
|
ref,
|
|
@@ -1096,7 +1427,7 @@ function Frame({
|
|
|
1096
1427
|
)
|
|
1097
1428
|
) : (
|
|
1098
1429
|
// Non-interactive Frame: just a plain View with no tap handling.
|
|
1099
|
-
/* @__PURE__ */
|
|
1430
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1100
1431
|
reactNative.View,
|
|
1101
1432
|
{
|
|
1102
1433
|
ref,
|
|
@@ -1142,11 +1473,11 @@ function TextInput({
|
|
|
1142
1473
|
...textInputProps
|
|
1143
1474
|
}) {
|
|
1144
1475
|
const tokens = useTokens(1);
|
|
1145
|
-
const styles =
|
|
1476
|
+
const styles = React13__default.default.useMemo(
|
|
1146
1477
|
() => getTextInputStyles(tokens, disabled),
|
|
1147
1478
|
[tokens, disabled]
|
|
1148
1479
|
);
|
|
1149
|
-
return /* @__PURE__ */
|
|
1480
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label), /* @__PURE__ */ React13__default.default.createElement(
|
|
1150
1481
|
reactNative.TextInput,
|
|
1151
1482
|
{
|
|
1152
1483
|
style: styles.input,
|
|
@@ -1183,7 +1514,7 @@ function getPopoverStyles(tokens, triggerHeight, offset, maxHeight, width, isOpe
|
|
|
1183
1514
|
});
|
|
1184
1515
|
}
|
|
1185
1516
|
|
|
1186
|
-
// src/Popover/Popover.tsx
|
|
1517
|
+
// src/composites/overlays/Popover/Popover.tsx
|
|
1187
1518
|
var openPopovers = /* @__PURE__ */ new Set();
|
|
1188
1519
|
function Popover({
|
|
1189
1520
|
isOpen,
|
|
@@ -1198,15 +1529,15 @@ function Popover({
|
|
|
1198
1529
|
contentStyle
|
|
1199
1530
|
}) {
|
|
1200
1531
|
const tokens = useTokens(1);
|
|
1201
|
-
const containerRef =
|
|
1202
|
-
const [triggerHeight, setTriggerHeight] =
|
|
1203
|
-
const onTriggerLayout =
|
|
1532
|
+
const containerRef = React13.useRef(null);
|
|
1533
|
+
const [triggerHeight, setTriggerHeight] = React13.useState(0);
|
|
1534
|
+
const onTriggerLayout = React13.useCallback(
|
|
1204
1535
|
(e) => {
|
|
1205
1536
|
setTriggerHeight(e.nativeEvent.layout.height);
|
|
1206
1537
|
},
|
|
1207
1538
|
[]
|
|
1208
1539
|
);
|
|
1209
|
-
|
|
1540
|
+
React13.useEffect(() => {
|
|
1210
1541
|
if (!isOpen) return;
|
|
1211
1542
|
openPopovers.forEach((closeFn) => closeFn());
|
|
1212
1543
|
openPopovers.clear();
|
|
@@ -1215,7 +1546,7 @@ function Popover({
|
|
|
1215
1546
|
openPopovers.delete(onClose);
|
|
1216
1547
|
};
|
|
1217
1548
|
}, [isOpen, onClose]);
|
|
1218
|
-
|
|
1549
|
+
React13.useEffect(() => {
|
|
1219
1550
|
if (!isOpen) return;
|
|
1220
1551
|
if (typeof document === "undefined") return;
|
|
1221
1552
|
const handleMouseDown = (e) => {
|
|
@@ -1227,7 +1558,7 @@ function Popover({
|
|
|
1227
1558
|
document.addEventListener("mousedown", handleMouseDown, true);
|
|
1228
1559
|
return () => document.removeEventListener("mousedown", handleMouseDown, true);
|
|
1229
1560
|
}, [isOpen, onClose]);
|
|
1230
|
-
const handleKeyDown =
|
|
1561
|
+
const handleKeyDown = React13.useCallback(
|
|
1231
1562
|
(e) => {
|
|
1232
1563
|
if (closeOnEscape && e.key === "Escape") {
|
|
1233
1564
|
e.stopPropagation();
|
|
@@ -1236,41 +1567,41 @@ function Popover({
|
|
|
1236
1567
|
},
|
|
1237
1568
|
[closeOnEscape, onClose]
|
|
1238
1569
|
);
|
|
1239
|
-
const styles =
|
|
1570
|
+
const styles = React13.useMemo(
|
|
1240
1571
|
() => getPopoverStyles(tokens, triggerHeight, offset, maxHeight, width, isOpen),
|
|
1241
1572
|
[tokens, triggerHeight, offset, maxHeight, width, isOpen]
|
|
1242
1573
|
);
|
|
1243
|
-
const containerStyles =
|
|
1574
|
+
const containerStyles = React13.useMemo(
|
|
1244
1575
|
() => [styles.container, ...Array.isArray(style) ? style : style ? [style] : []],
|
|
1245
1576
|
[styles.container, style]
|
|
1246
1577
|
);
|
|
1247
|
-
const mergedContentStyles =
|
|
1578
|
+
const mergedContentStyles = React13.useMemo(
|
|
1248
1579
|
() => [styles.content, ...Array.isArray(contentStyle) ? contentStyle : contentStyle ? [contentStyle] : []],
|
|
1249
1580
|
[styles.content, contentStyle]
|
|
1250
1581
|
);
|
|
1251
1582
|
const webProps = { onKeyDown: handleKeyDown };
|
|
1252
|
-
return /* @__PURE__ */
|
|
1583
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
1253
1584
|
reactNative.View,
|
|
1254
1585
|
{
|
|
1255
1586
|
ref: containerRef,
|
|
1256
1587
|
style: containerStyles,
|
|
1257
1588
|
...webProps
|
|
1258
1589
|
},
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
isOpen && /* @__PURE__ */
|
|
1590
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { onLayout: onTriggerLayout }, trigger),
|
|
1591
|
+
isOpen && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: mergedContentStyles }, children)
|
|
1261
1592
|
);
|
|
1262
1593
|
}
|
|
1263
1594
|
function usePopover(options) {
|
|
1264
|
-
const [isOpen, setIsOpen] =
|
|
1265
|
-
const open =
|
|
1595
|
+
const [isOpen, setIsOpen] = React13.useState(options?.initialOpen ?? false);
|
|
1596
|
+
const open = React13.useCallback(() => {
|
|
1266
1597
|
setIsOpen(true);
|
|
1267
1598
|
options?.onOpenChange?.(true);
|
|
1268
1599
|
}, [options]);
|
|
1269
|
-
const close =
|
|
1600
|
+
const close = React13.useCallback(() => {
|
|
1270
1601
|
setIsOpen(false);
|
|
1271
1602
|
options?.onOpenChange?.(false);
|
|
1272
1603
|
}, [options]);
|
|
1273
|
-
const toggle =
|
|
1604
|
+
const toggle = React13.useCallback(() => {
|
|
1274
1605
|
setIsOpen((prev) => {
|
|
1275
1606
|
const next = !prev;
|
|
1276
1607
|
options?.onOpenChange?.(next);
|
|
@@ -1280,7 +1611,7 @@ function usePopover(options) {
|
|
|
1280
1611
|
return { isOpen, open, close, toggle };
|
|
1281
1612
|
}
|
|
1282
1613
|
|
|
1283
|
-
// src/Select/Select.types.ts
|
|
1614
|
+
// src/composites/form-controls/Select/Select.types.ts
|
|
1284
1615
|
function isOptionGroup(item) {
|
|
1285
1616
|
return "options" in item;
|
|
1286
1617
|
}
|
|
@@ -1357,10 +1688,10 @@ function useSelect({
|
|
|
1357
1688
|
onClose,
|
|
1358
1689
|
onOpen
|
|
1359
1690
|
}) {
|
|
1360
|
-
const [focusedIndex, setFocusedIndex] =
|
|
1361
|
-
const typeAheadRef =
|
|
1362
|
-
const typeAheadTimerRef =
|
|
1363
|
-
|
|
1691
|
+
const [focusedIndex, setFocusedIndex] = React13.useState(-1);
|
|
1692
|
+
const typeAheadRef = React13.useRef("");
|
|
1693
|
+
const typeAheadTimerRef = React13.useRef();
|
|
1694
|
+
React13.useEffect(() => {
|
|
1364
1695
|
if (isOpen) {
|
|
1365
1696
|
const selectedIdx = flatOptions.findIndex((o) => o.value === value);
|
|
1366
1697
|
if (selectedIdx >= 0 && !flatOptions[selectedIdx].disabled) {
|
|
@@ -1373,7 +1704,7 @@ function useSelect({
|
|
|
1373
1704
|
setFocusedIndex(-1);
|
|
1374
1705
|
}
|
|
1375
1706
|
}, [isOpen, flatOptions, value]);
|
|
1376
|
-
const handleKeyDown =
|
|
1707
|
+
const handleKeyDown = React13.useCallback(
|
|
1377
1708
|
(e) => {
|
|
1378
1709
|
const key = e.key;
|
|
1379
1710
|
if (!isOpen) {
|
|
@@ -1454,7 +1785,7 @@ function SelectOptionRow({
|
|
|
1454
1785
|
const paddingHorizontal = size === "sm" ? tokens.spacing["08"] : tokens.spacing["12"];
|
|
1455
1786
|
const fontSize = size === "sm" ? tokens.typography.size.sm : tokens.typography.size.base;
|
|
1456
1787
|
if (renderOption) {
|
|
1457
|
-
return /* @__PURE__ */
|
|
1788
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
1458
1789
|
reactNative.Pressable,
|
|
1459
1790
|
{
|
|
1460
1791
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1465,7 +1796,7 @@ function SelectOptionRow({
|
|
|
1465
1796
|
renderOption(option, { isSelected, isFocused })
|
|
1466
1797
|
);
|
|
1467
1798
|
}
|
|
1468
|
-
return /* @__PURE__ */
|
|
1799
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
1469
1800
|
reactNative.Pressable,
|
|
1470
1801
|
{
|
|
1471
1802
|
onPress: option.disabled ? void 0 : onSelect,
|
|
@@ -1494,7 +1825,7 @@ function SelectOptionRow({
|
|
|
1494
1825
|
}
|
|
1495
1826
|
]
|
|
1496
1827
|
},
|
|
1497
|
-
/* @__PURE__ */
|
|
1828
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1498
1829
|
reactNative.Text,
|
|
1499
1830
|
{
|
|
1500
1831
|
style: [
|
|
@@ -1516,7 +1847,7 @@ function SelectOptionRow({
|
|
|
1516
1847
|
},
|
|
1517
1848
|
option.label
|
|
1518
1849
|
),
|
|
1519
|
-
isSelected && /* @__PURE__ */
|
|
1850
|
+
isSelected && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: { marginLeft: tokens.spacing["08"] } }, /* @__PURE__ */ React13__default.default.createElement(
|
|
1520
1851
|
Icon,
|
|
1521
1852
|
{
|
|
1522
1853
|
name: "check",
|
|
@@ -1551,7 +1882,7 @@ function Select({
|
|
|
1551
1882
|
}) {
|
|
1552
1883
|
const tokens = useTokens(1);
|
|
1553
1884
|
const { isOpen, open, close, toggle } = usePopover();
|
|
1554
|
-
const flatOptions =
|
|
1885
|
+
const flatOptions = React13.useMemo(() => flattenOptions(options), [options]);
|
|
1555
1886
|
const { focusedIndex, handleKeyDown } = useSelect({
|
|
1556
1887
|
flatOptions,
|
|
1557
1888
|
value,
|
|
@@ -1563,7 +1894,7 @@ function Select({
|
|
|
1563
1894
|
onClose: close,
|
|
1564
1895
|
onOpen: open
|
|
1565
1896
|
});
|
|
1566
|
-
const styles =
|
|
1897
|
+
const styles = React13.useMemo(
|
|
1567
1898
|
() => getSelectStyles(tokens, disabled, size, isOpen),
|
|
1568
1899
|
[tokens, disabled, size, isOpen]
|
|
1569
1900
|
);
|
|
@@ -1571,7 +1902,7 @@ function Select({
|
|
|
1571
1902
|
const displayLabel = selectedOption?.label ?? placeholder ?? value;
|
|
1572
1903
|
const iconColor = disabled ? newtone.srgbToHex(tokens.textSecondary.srgb) : newtone.srgbToHex(tokens.textPrimary.srgb);
|
|
1573
1904
|
const triggerWebProps = { onKeyDown: handleKeyDown };
|
|
1574
|
-
const trigger = /* @__PURE__ */
|
|
1905
|
+
const trigger = /* @__PURE__ */ React13__default.default.createElement(
|
|
1575
1906
|
reactNative.Pressable,
|
|
1576
1907
|
{
|
|
1577
1908
|
onPress: disabled ? void 0 : toggle,
|
|
@@ -1581,8 +1912,8 @@ function Select({
|
|
|
1581
1912
|
...triggerWebProps,
|
|
1582
1913
|
style: styles.trigger
|
|
1583
1914
|
},
|
|
1584
|
-
renderValue ? renderValue(selectedOption) : /* @__PURE__ */
|
|
1585
|
-
/* @__PURE__ */
|
|
1915
|
+
renderValue ? renderValue(selectedOption) : /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.triggerText, numberOfLines: 1 }, displayLabel),
|
|
1916
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.iconWrapper, pointerEvents: "none" }, /* @__PURE__ */ React13__default.default.createElement(
|
|
1586
1917
|
Icon,
|
|
1587
1918
|
{
|
|
1588
1919
|
name: isOpen ? "expand_less" : "expand_more",
|
|
@@ -1591,14 +1922,14 @@ function Select({
|
|
|
1591
1922
|
}
|
|
1592
1923
|
))
|
|
1593
1924
|
);
|
|
1594
|
-
return /* @__PURE__ */
|
|
1925
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : style ? [style] : []] }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label), /* @__PURE__ */ React13__default.default.createElement(
|
|
1595
1926
|
Popover,
|
|
1596
1927
|
{
|
|
1597
1928
|
isOpen: isOpen && !disabled,
|
|
1598
1929
|
onClose: close,
|
|
1599
1930
|
trigger
|
|
1600
1931
|
},
|
|
1601
|
-
/* @__PURE__ */
|
|
1932
|
+
/* @__PURE__ */ React13__default.default.createElement(
|
|
1602
1933
|
reactNative.ScrollView,
|
|
1603
1934
|
{
|
|
1604
1935
|
bounces: false,
|
|
@@ -1607,7 +1938,7 @@ function Select({
|
|
|
1607
1938
|
},
|
|
1608
1939
|
options.map((item) => {
|
|
1609
1940
|
if (isOptionGroup(item)) {
|
|
1610
|
-
return /* @__PURE__ */
|
|
1941
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { key: item.label }, /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.groupLabel }, item.label), item.options.map((opt) => /* @__PURE__ */ React13__default.default.createElement(
|
|
1611
1942
|
SelectOptionRow,
|
|
1612
1943
|
{
|
|
1613
1944
|
key: opt.value,
|
|
@@ -1623,7 +1954,7 @@ function Select({
|
|
|
1623
1954
|
}
|
|
1624
1955
|
)));
|
|
1625
1956
|
}
|
|
1626
|
-
return /* @__PURE__ */
|
|
1957
|
+
return /* @__PURE__ */ React13__default.default.createElement(
|
|
1627
1958
|
SelectOptionRow,
|
|
1628
1959
|
{
|
|
1629
1960
|
key: item.value,
|
|
@@ -1678,7 +2009,7 @@ function getToggleStyles(tokens, value, disabled) {
|
|
|
1678
2009
|
});
|
|
1679
2010
|
}
|
|
1680
2011
|
|
|
1681
|
-
// src/Toggle/Toggle.tsx
|
|
2012
|
+
// src/composites/form-controls/Toggle/Toggle.tsx
|
|
1682
2013
|
function Toggle({
|
|
1683
2014
|
value,
|
|
1684
2015
|
onValueChange,
|
|
@@ -1687,16 +2018,16 @@ function Toggle({
|
|
|
1687
2018
|
style
|
|
1688
2019
|
}) {
|
|
1689
2020
|
const tokens = useTokens(1);
|
|
1690
|
-
const styles =
|
|
2021
|
+
const styles = React13__default.default.useMemo(
|
|
1691
2022
|
() => getToggleStyles(tokens, value, disabled),
|
|
1692
2023
|
[tokens, value, disabled]
|
|
1693
2024
|
);
|
|
1694
|
-
const handlePress =
|
|
2025
|
+
const handlePress = React13__default.default.useCallback(() => {
|
|
1695
2026
|
if (!disabled) {
|
|
1696
2027
|
onValueChange(!value);
|
|
1697
2028
|
}
|
|
1698
2029
|
}, [disabled, value, onValueChange]);
|
|
1699
|
-
return /* @__PURE__ */
|
|
2030
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label), /* @__PURE__ */ React13__default.default.createElement(
|
|
1700
2031
|
reactNative.Pressable,
|
|
1701
2032
|
{
|
|
1702
2033
|
onPress: handlePress,
|
|
@@ -1704,7 +2035,7 @@ function Toggle({
|
|
|
1704
2035
|
accessibilityRole: "switch",
|
|
1705
2036
|
accessibilityState: { checked: value, disabled }
|
|
1706
2037
|
},
|
|
1707
|
-
/* @__PURE__ */
|
|
2038
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.track }, /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.thumb }))
|
|
1708
2039
|
));
|
|
1709
2040
|
}
|
|
1710
2041
|
var TRACK_HEIGHT2 = 6;
|
|
@@ -1776,7 +2107,7 @@ function getSliderStyles(tokens, disabled) {
|
|
|
1776
2107
|
});
|
|
1777
2108
|
}
|
|
1778
2109
|
|
|
1779
|
-
// src/Slider/Slider.tsx
|
|
2110
|
+
// src/composites/range-inputs/Slider/Slider.tsx
|
|
1780
2111
|
function Slider({
|
|
1781
2112
|
value,
|
|
1782
2113
|
onValueChange,
|
|
@@ -1790,41 +2121,41 @@ function Slider({
|
|
|
1790
2121
|
style
|
|
1791
2122
|
}) {
|
|
1792
2123
|
const tokens = useTokens(1);
|
|
1793
|
-
const styles =
|
|
2124
|
+
const styles = React13__default.default.useMemo(
|
|
1794
2125
|
() => getSliderStyles(tokens, disabled),
|
|
1795
2126
|
[tokens, disabled]
|
|
1796
2127
|
);
|
|
1797
|
-
const trackRef =
|
|
1798
|
-
const trackWidth =
|
|
1799
|
-
const trackPageX =
|
|
1800
|
-
const onValueChangeRef =
|
|
1801
|
-
const minRef =
|
|
1802
|
-
const maxRef =
|
|
1803
|
-
const stepRef =
|
|
1804
|
-
const disabledRef =
|
|
1805
|
-
|
|
2128
|
+
const trackRef = React13__default.default.useRef(null);
|
|
2129
|
+
const trackWidth = React13__default.default.useRef(0);
|
|
2130
|
+
const trackPageX = React13__default.default.useRef(0);
|
|
2131
|
+
const onValueChangeRef = React13__default.default.useRef(onValueChange);
|
|
2132
|
+
const minRef = React13__default.default.useRef(min);
|
|
2133
|
+
const maxRef = React13__default.default.useRef(max);
|
|
2134
|
+
const stepRef = React13__default.default.useRef(step);
|
|
2135
|
+
const disabledRef = React13__default.default.useRef(disabled);
|
|
2136
|
+
React13__default.default.useEffect(() => {
|
|
1806
2137
|
onValueChangeRef.current = onValueChange;
|
|
1807
2138
|
}, [onValueChange]);
|
|
1808
|
-
|
|
2139
|
+
React13__default.default.useEffect(() => {
|
|
1809
2140
|
minRef.current = min;
|
|
1810
2141
|
}, [min]);
|
|
1811
|
-
|
|
2142
|
+
React13__default.default.useEffect(() => {
|
|
1812
2143
|
maxRef.current = max;
|
|
1813
2144
|
}, [max]);
|
|
1814
|
-
|
|
2145
|
+
React13__default.default.useEffect(() => {
|
|
1815
2146
|
stepRef.current = step;
|
|
1816
2147
|
}, [step]);
|
|
1817
|
-
|
|
2148
|
+
React13__default.default.useEffect(() => {
|
|
1818
2149
|
disabledRef.current = disabled;
|
|
1819
2150
|
}, [disabled]);
|
|
1820
|
-
const computeValue =
|
|
2151
|
+
const computeValue = React13__default.default.useCallback((pageX) => {
|
|
1821
2152
|
const localX = pageX - trackPageX.current;
|
|
1822
2153
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
1823
2154
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
1824
2155
|
const stepped = Math.round(raw / stepRef.current) * stepRef.current;
|
|
1825
2156
|
return Math.min(maxRef.current, Math.max(minRef.current, stepped));
|
|
1826
2157
|
}, []);
|
|
1827
|
-
const panResponder =
|
|
2158
|
+
const panResponder = React13__default.default.useRef(
|
|
1828
2159
|
reactNative.PanResponder.create({
|
|
1829
2160
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
1830
2161
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -1840,7 +2171,7 @@ function Slider({
|
|
|
1840
2171
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE2);
|
|
1841
2172
|
const thumbLeft = ratio * usableWidth;
|
|
1842
2173
|
const fillWidth = thumbLeft + THUMB_SIZE2 / 2;
|
|
1843
|
-
const handleValueTextSubmit =
|
|
2174
|
+
const handleValueTextSubmit = React13__default.default.useCallback(
|
|
1844
2175
|
(text) => {
|
|
1845
2176
|
const raw = Number(text);
|
|
1846
2177
|
if (!Number.isNaN(raw)) {
|
|
@@ -1849,12 +2180,12 @@ function Slider({
|
|
|
1849
2180
|
},
|
|
1850
2181
|
[onValueChange, min, max]
|
|
1851
2182
|
);
|
|
1852
|
-
const [editText, setEditText] =
|
|
1853
|
-
|
|
2183
|
+
const [editText, setEditText] = React13__default.default.useState(String(value));
|
|
2184
|
+
React13__default.default.useEffect(() => {
|
|
1854
2185
|
setEditText(String(value));
|
|
1855
2186
|
}, [value]);
|
|
1856
2187
|
const showLabel = label || showValue || editableValue;
|
|
1857
|
-
return /* @__PURE__ */
|
|
2188
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, showLabel && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.labelRow }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label), editableValue ? /* @__PURE__ */ React13__default.default.createElement(
|
|
1858
2189
|
reactNative.TextInput,
|
|
1859
2190
|
{
|
|
1860
2191
|
style: styles.valueInput,
|
|
@@ -1866,7 +2197,7 @@ function Slider({
|
|
|
1866
2197
|
selectTextOnFocus: true,
|
|
1867
2198
|
editable: !disabled
|
|
1868
2199
|
}
|
|
1869
|
-
) : showValue && /* @__PURE__ */
|
|
2200
|
+
) : showValue && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.value }, value)), /* @__PURE__ */ React13__default.default.createElement(
|
|
1870
2201
|
reactNative.View,
|
|
1871
2202
|
{
|
|
1872
2203
|
ref: trackRef,
|
|
@@ -1879,9 +2210,9 @@ function Slider({
|
|
|
1879
2210
|
},
|
|
1880
2211
|
...panResponder.panHandlers
|
|
1881
2212
|
},
|
|
1882
|
-
/* @__PURE__ */
|
|
1883
|
-
/* @__PURE__ */
|
|
1884
|
-
/* @__PURE__ */
|
|
2213
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.trackRail }),
|
|
2214
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.trackFill, { width: fillWidth }] }),
|
|
2215
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
1885
2216
|
));
|
|
1886
2217
|
}
|
|
1887
2218
|
var TRACK_HEIGHT3 = 22;
|
|
@@ -1991,7 +2322,7 @@ function getHueSliderStyles(tokens, disabled) {
|
|
|
1991
2322
|
});
|
|
1992
2323
|
}
|
|
1993
2324
|
|
|
1994
|
-
// src/HueSlider/HueSlider.tsx
|
|
2325
|
+
// src/composites/range-inputs/HueSlider/HueSlider.tsx
|
|
1995
2326
|
function HueSlider({
|
|
1996
2327
|
value,
|
|
1997
2328
|
onValueChange,
|
|
@@ -2004,41 +2335,41 @@ function HueSlider({
|
|
|
2004
2335
|
style
|
|
2005
2336
|
}) {
|
|
2006
2337
|
const tokens = useTokens(1);
|
|
2007
|
-
const styles =
|
|
2338
|
+
const styles = React13__default.default.useMemo(
|
|
2008
2339
|
() => getHueSliderStyles(tokens, disabled),
|
|
2009
2340
|
[tokens, disabled]
|
|
2010
2341
|
);
|
|
2011
|
-
const segments =
|
|
2342
|
+
const segments = React13__default.default.useMemo(
|
|
2012
2343
|
() => buildHueSegments(min, max),
|
|
2013
2344
|
[min, max]
|
|
2014
2345
|
);
|
|
2015
|
-
const trackRef =
|
|
2016
|
-
const trackWidth =
|
|
2017
|
-
const trackPageX =
|
|
2018
|
-
const onValueChangeRef =
|
|
2019
|
-
const minRef =
|
|
2020
|
-
const maxRef =
|
|
2021
|
-
const disabledRef =
|
|
2022
|
-
|
|
2346
|
+
const trackRef = React13__default.default.useRef(null);
|
|
2347
|
+
const trackWidth = React13__default.default.useRef(0);
|
|
2348
|
+
const trackPageX = React13__default.default.useRef(0);
|
|
2349
|
+
const onValueChangeRef = React13__default.default.useRef(onValueChange);
|
|
2350
|
+
const minRef = React13__default.default.useRef(min);
|
|
2351
|
+
const maxRef = React13__default.default.useRef(max);
|
|
2352
|
+
const disabledRef = React13__default.default.useRef(disabled);
|
|
2353
|
+
React13__default.default.useEffect(() => {
|
|
2023
2354
|
onValueChangeRef.current = onValueChange;
|
|
2024
2355
|
}, [onValueChange]);
|
|
2025
|
-
|
|
2356
|
+
React13__default.default.useEffect(() => {
|
|
2026
2357
|
minRef.current = min;
|
|
2027
2358
|
}, [min]);
|
|
2028
|
-
|
|
2359
|
+
React13__default.default.useEffect(() => {
|
|
2029
2360
|
maxRef.current = max;
|
|
2030
2361
|
}, [max]);
|
|
2031
|
-
|
|
2362
|
+
React13__default.default.useEffect(() => {
|
|
2032
2363
|
disabledRef.current = disabled;
|
|
2033
2364
|
}, [disabled]);
|
|
2034
|
-
const computeHue =
|
|
2365
|
+
const computeHue = React13__default.default.useCallback((pageX) => {
|
|
2035
2366
|
const localX = pageX - trackPageX.current;
|
|
2036
2367
|
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2037
2368
|
const raw = minRef.current + ratio2 * (maxRef.current - minRef.current);
|
|
2038
2369
|
const stepped = Math.round(raw);
|
|
2039
2370
|
return (stepped % 360 + 360) % 360;
|
|
2040
2371
|
}, []);
|
|
2041
|
-
const panResponder =
|
|
2372
|
+
const panResponder = React13__default.default.useRef(
|
|
2042
2373
|
reactNative.PanResponder.create({
|
|
2043
2374
|
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2044
2375
|
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
@@ -2054,7 +2385,7 @@ function HueSlider({
|
|
|
2054
2385
|
const ratio = max > min ? (sliderValue - min) / (max - min) : 0;
|
|
2055
2386
|
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE3);
|
|
2056
2387
|
const thumbLeft = ratio * usableWidth;
|
|
2057
|
-
const handleValueTextSubmit =
|
|
2388
|
+
const handleValueTextSubmit = React13__default.default.useCallback(
|
|
2058
2389
|
(text) => {
|
|
2059
2390
|
const raw = Number(text);
|
|
2060
2391
|
if (!Number.isNaN(raw)) {
|
|
@@ -2063,12 +2394,12 @@ function HueSlider({
|
|
|
2063
2394
|
},
|
|
2064
2395
|
[onValueChange]
|
|
2065
2396
|
);
|
|
2066
|
-
const [editText, setEditText] =
|
|
2067
|
-
|
|
2397
|
+
const [editText, setEditText] = React13__default.default.useState(String(value));
|
|
2398
|
+
React13__default.default.useEffect(() => {
|
|
2068
2399
|
setEditText(String(value));
|
|
2069
2400
|
}, [value]);
|
|
2070
2401
|
const showLabel = label || showValue || editableValue;
|
|
2071
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, showLabel && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.labelRow }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label), editableValue ? /* @__PURE__ */ React13__default.default.createElement(
|
|
2072
2403
|
reactNative.TextInput,
|
|
2073
2404
|
{
|
|
2074
2405
|
style: styles.valueInput,
|
|
@@ -2080,7 +2411,7 @@ function HueSlider({
|
|
|
2080
2411
|
selectTextOnFocus: true,
|
|
2081
2412
|
editable: !disabled
|
|
2082
2413
|
}
|
|
2083
|
-
) : showValue && /* @__PURE__ */
|
|
2414
|
+
) : showValue && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.value }, value, "\xB0")), /* @__PURE__ */ React13__default.default.createElement(
|
|
2084
2415
|
reactNative.View,
|
|
2085
2416
|
{
|
|
2086
2417
|
ref: trackRef,
|
|
@@ -2093,8 +2424,8 @@ function HueSlider({
|
|
|
2093
2424
|
},
|
|
2094
2425
|
...panResponder.panHandlers
|
|
2095
2426
|
},
|
|
2096
|
-
/* @__PURE__ */
|
|
2097
|
-
/* @__PURE__ */
|
|
2427
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.gradientTrack }, segments.map((color, i) => /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { key: i, style: [styles.segment, { backgroundColor: color }] }))),
|
|
2428
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.thumb, { left: thumbLeft }] })
|
|
2098
2429
|
));
|
|
2099
2430
|
}
|
|
2100
2431
|
var TRACK_HEIGHT4 = 22;
|
|
@@ -2135,301 +2466,137 @@ function getColorScaleSliderStyles(tokens, disabled) {
|
|
|
2135
2466
|
},
|
|
2136
2467
|
thumb: {
|
|
2137
2468
|
position: "absolute",
|
|
2138
|
-
width: THUMB_SIZE4,
|
|
2139
|
-
height: THUMB_SIZE4,
|
|
2140
|
-
borderRadius: THUMB_SIZE4 / 2,
|
|
2141
|
-
backgroundColor: "#ffffff",
|
|
2142
|
-
borderWidth: 2,
|
|
2143
|
-
borderColor: newtone.srgbToHex(tokens.border.srgb)
|
|
2144
|
-
},
|
|
2145
|
-
warning: {
|
|
2146
|
-
fontFamily: tokens.typography.fonts.default,
|
|
2147
|
-
fontSize: tokens.typography.size.xs,
|
|
2148
|
-
fontWeight: tokens.typography.weight.medium,
|
|
2149
|
-
color: newtone.srgbToHex(tokens.error.srgb)
|
|
2150
|
-
}
|
|
2151
|
-
});
|
|
2152
|
-
}
|
|
2153
|
-
|
|
2154
|
-
// src/ColorScaleSlider/ColorScaleSlider.tsx
|
|
2155
|
-
function ColorScaleSlider({
|
|
2156
|
-
colors,
|
|
2157
|
-
value,
|
|
2158
|
-
onValueChange,
|
|
2159
|
-
label,
|
|
2160
|
-
warning,
|
|
2161
|
-
trimEnds = false,
|
|
2162
|
-
snap = false,
|
|
2163
|
-
disabled = false,
|
|
2164
|
-
animateValue = false,
|
|
2165
|
-
style
|
|
2166
|
-
}) {
|
|
2167
|
-
const tokens = useTokens(1);
|
|
2168
|
-
const styles = React11__default.default.useMemo(
|
|
2169
|
-
() => getColorScaleSliderStyles(tokens, disabled),
|
|
2170
|
-
[tokens, disabled]
|
|
2171
|
-
);
|
|
2172
|
-
const trackRef = React11__default.default.useRef(null);
|
|
2173
|
-
const trackWidth = React11__default.default.useRef(0);
|
|
2174
|
-
const trackPageX = React11__default.default.useRef(0);
|
|
2175
|
-
const isDragging = React11__default.default.useRef(false);
|
|
2176
|
-
const thumbAnim = React11__default.default.useRef(new reactNative.Animated.Value(0)).current;
|
|
2177
|
-
const onValueChangeRef = React11__default.default.useRef(onValueChange);
|
|
2178
|
-
const disabledRef = React11__default.default.useRef(disabled);
|
|
2179
|
-
const colorsLengthRef = React11__default.default.useRef(colors.length);
|
|
2180
|
-
const trimEndsRef = React11__default.default.useRef(trimEnds);
|
|
2181
|
-
const snapRef = React11__default.default.useRef(snap);
|
|
2182
|
-
React11__default.default.useEffect(() => {
|
|
2183
|
-
onValueChangeRef.current = onValueChange;
|
|
2184
|
-
}, [onValueChange]);
|
|
2185
|
-
React11__default.default.useEffect(() => {
|
|
2186
|
-
disabledRef.current = disabled;
|
|
2187
|
-
}, [disabled]);
|
|
2188
|
-
React11__default.default.useEffect(() => {
|
|
2189
|
-
colorsLengthRef.current = colors.length;
|
|
2190
|
-
}, [colors.length]);
|
|
2191
|
-
React11__default.default.useEffect(() => {
|
|
2192
|
-
trimEndsRef.current = trimEnds;
|
|
2193
|
-
}, [trimEnds]);
|
|
2194
|
-
React11__default.default.useEffect(() => {
|
|
2195
|
-
snapRef.current = snap;
|
|
2196
|
-
}, [snap]);
|
|
2197
|
-
const computeNv = React11__default.default.useCallback((pageX) => {
|
|
2198
|
-
const localX = pageX - trackPageX.current;
|
|
2199
|
-
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2200
|
-
const totalSteps2 = colorsLengthRef.current - 1;
|
|
2201
|
-
const minNV2 = trimEndsRef.current ? 1 / totalSteps2 : 0;
|
|
2202
|
-
const maxNV2 = trimEndsRef.current ? 1 - 1 / totalSteps2 : 1;
|
|
2203
|
-
const range2 = maxNV2 - minNV2;
|
|
2204
|
-
let nv = maxNV2 - ratio2 * range2;
|
|
2205
|
-
if (snapRef.current && totalSteps2 > 0) {
|
|
2206
|
-
const stepNv = 1 / totalSteps2;
|
|
2207
|
-
nv = Math.round(nv / stepNv) * stepNv;
|
|
2208
|
-
nv = Math.min(maxNV2, Math.max(minNV2, nv));
|
|
2209
|
-
}
|
|
2210
|
-
return nv;
|
|
2211
|
-
}, []);
|
|
2212
|
-
const panResponder = React11__default.default.useRef(
|
|
2213
|
-
reactNative.PanResponder.create({
|
|
2214
|
-
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2215
|
-
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
2216
|
-
onPanResponderGrant: (evt) => {
|
|
2217
|
-
isDragging.current = true;
|
|
2218
|
-
onValueChangeRef.current(computeNv(evt.nativeEvent.pageX));
|
|
2219
|
-
},
|
|
2220
|
-
onPanResponderMove: (_evt, gestureState) => {
|
|
2221
|
-
onValueChangeRef.current(computeNv(gestureState.moveX));
|
|
2222
|
-
},
|
|
2223
|
-
onPanResponderRelease: () => {
|
|
2224
|
-
isDragging.current = false;
|
|
2225
|
-
},
|
|
2226
|
-
onPanResponderTerminate: () => {
|
|
2227
|
-
isDragging.current = false;
|
|
2228
|
-
}
|
|
2229
|
-
})
|
|
2230
|
-
).current;
|
|
2231
|
-
const visibleColors = trimEnds ? colors.slice(1, -1) : colors;
|
|
2232
|
-
const totalSteps = colors.length - 1;
|
|
2233
|
-
const minNV = trimEnds ? 1 / totalSteps : 0;
|
|
2234
|
-
const maxNV = trimEnds ? 1 - 1 / totalSteps : 1;
|
|
2235
|
-
const range = maxNV - minNV;
|
|
2236
|
-
const clampedValue = value !== void 0 ? Math.min(maxNV, Math.max(minNV, value)) : (maxNV + minNV) / 2;
|
|
2237
|
-
const ratio = range > 0 ? (maxNV - clampedValue) / range : 0.5;
|
|
2238
|
-
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE4);
|
|
2239
|
-
const thumbLeft = ratio * usableWidth;
|
|
2240
|
-
React11__default.default.useEffect(() => {
|
|
2241
|
-
if (isDragging.current || !animateValue) {
|
|
2242
|
-
thumbAnim.setValue(thumbLeft);
|
|
2243
|
-
} else {
|
|
2244
|
-
reactNative.Animated.timing(thumbAnim, {
|
|
2245
|
-
toValue: thumbLeft,
|
|
2246
|
-
duration: 300,
|
|
2247
|
-
useNativeDriver: false
|
|
2248
|
-
}).start();
|
|
2249
|
-
}
|
|
2250
|
-
}, [thumbLeft, animateValue, thumbAnim]);
|
|
2251
|
-
return /* @__PURE__ */ React11__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React11__default.default.createElement(reactNative.View, { style: styles.labelRow }, /* @__PURE__ */ React11__default.default.createElement(reactNative.Text, { style: styles.label }, label)), /* @__PURE__ */ React11__default.default.createElement(
|
|
2252
|
-
reactNative.View,
|
|
2253
|
-
{
|
|
2254
|
-
ref: trackRef,
|
|
2255
|
-
style: styles.trackContainer,
|
|
2256
|
-
onLayout: (e) => {
|
|
2257
|
-
trackWidth.current = e.nativeEvent.layout.width;
|
|
2258
|
-
const newUsableWidth = Math.max(0, e.nativeEvent.layout.width - THUMB_SIZE4);
|
|
2259
|
-
thumbAnim.setValue(ratio * newUsableWidth);
|
|
2260
|
-
trackRef.current?.measure((_x, _y, _w, _h, pageX) => {
|
|
2261
|
-
if (pageX != null) trackPageX.current = pageX;
|
|
2262
|
-
});
|
|
2263
|
-
},
|
|
2264
|
-
...panResponder.panHandlers
|
|
2265
|
-
},
|
|
2266
|
-
/* @__PURE__ */ React11__default.default.createElement(reactNative.View, { style: styles.gradientTrack }, visibleColors.map((color, i) => /* @__PURE__ */ React11__default.default.createElement(reactNative.View, { key: i, style: [styles.segment, { backgroundColor: newtone.srgbToHex(color.srgb) }] }))),
|
|
2267
|
-
/* @__PURE__ */ React11__default.default.createElement(reactNative.Animated.View, { style: [styles.thumb, { left: thumbAnim }] })
|
|
2268
|
-
), warning && /* @__PURE__ */ React11__default.default.createElement(reactNative.Text, { style: styles.warning }, warning));
|
|
2269
|
-
}
|
|
2270
|
-
function getWrapperStyles(input) {
|
|
2271
|
-
const {
|
|
2272
|
-
tokens,
|
|
2273
|
-
direction = "vertical",
|
|
2274
|
-
wrap = false,
|
|
2275
|
-
reverse = false,
|
|
2276
|
-
align,
|
|
2277
|
-
justify,
|
|
2278
|
-
padding,
|
|
2279
|
-
gap,
|
|
2280
|
-
width,
|
|
2281
|
-
height,
|
|
2282
|
-
minWidth,
|
|
2283
|
-
maxWidth,
|
|
2284
|
-
minHeight,
|
|
2285
|
-
maxHeight
|
|
2286
|
-
} = input;
|
|
2287
|
-
const container = {};
|
|
2288
|
-
container.flexDirection = resolveFlexDirection(direction, reverse);
|
|
2289
|
-
if (wrap) container.flexWrap = "wrap";
|
|
2290
|
-
if (align) container.alignItems = resolveAlignment(align);
|
|
2291
|
-
if (justify) container.justifyContent = resolveJustification(justify);
|
|
2292
|
-
if (padding !== void 0) {
|
|
2293
|
-
const p = resolvePadding(padding, tokens);
|
|
2294
|
-
container.paddingTop = p.top;
|
|
2295
|
-
container.paddingRight = p.right;
|
|
2296
|
-
container.paddingBottom = p.bottom;
|
|
2297
|
-
container.paddingLeft = p.left;
|
|
2298
|
-
}
|
|
2299
|
-
if (gap !== void 0) {
|
|
2300
|
-
const g = resolveGap(gap, tokens);
|
|
2301
|
-
container.rowGap = g.rowGap;
|
|
2302
|
-
container.columnGap = g.columnGap;
|
|
2303
|
-
}
|
|
2304
|
-
Object.assign(container, resolveSizing(width, height));
|
|
2305
|
-
if (minWidth !== void 0) container.minWidth = minWidth;
|
|
2306
|
-
if (maxWidth !== void 0) container.maxWidth = maxWidth;
|
|
2307
|
-
if (minHeight !== void 0) container.minHeight = minHeight;
|
|
2308
|
-
if (maxHeight !== void 0) container.maxHeight = maxHeight;
|
|
2309
|
-
return reactNative.StyleSheet.create({ c: container }).c;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
// src/primitives/Wrapper/Wrapper.tsx
|
|
2313
|
-
function Wrapper({
|
|
2314
|
-
children,
|
|
2315
|
-
direction,
|
|
2316
|
-
wrap,
|
|
2317
|
-
reverse,
|
|
2318
|
-
align,
|
|
2319
|
-
justify,
|
|
2320
|
-
padding,
|
|
2321
|
-
gap,
|
|
2322
|
-
width,
|
|
2323
|
-
height,
|
|
2324
|
-
minWidth,
|
|
2325
|
-
maxWidth,
|
|
2326
|
-
minHeight,
|
|
2327
|
-
maxHeight,
|
|
2328
|
-
style,
|
|
2329
|
-
// Testing & platform
|
|
2330
|
-
testID,
|
|
2331
|
-
nativeID,
|
|
2332
|
-
ref
|
|
2333
|
-
}) {
|
|
2334
|
-
const tokens = useTokens(1);
|
|
2335
|
-
const containerStyle = React11.useMemo(
|
|
2336
|
-
() => getWrapperStyles({
|
|
2337
|
-
tokens,
|
|
2338
|
-
direction,
|
|
2339
|
-
wrap,
|
|
2340
|
-
reverse,
|
|
2341
|
-
align,
|
|
2342
|
-
justify,
|
|
2343
|
-
padding,
|
|
2344
|
-
gap,
|
|
2345
|
-
width,
|
|
2346
|
-
height,
|
|
2347
|
-
minWidth,
|
|
2348
|
-
maxWidth,
|
|
2349
|
-
minHeight,
|
|
2350
|
-
maxHeight
|
|
2351
|
-
}),
|
|
2352
|
-
[
|
|
2353
|
-
tokens,
|
|
2354
|
-
direction,
|
|
2355
|
-
wrap,
|
|
2356
|
-
reverse,
|
|
2357
|
-
align,
|
|
2358
|
-
justify,
|
|
2359
|
-
padding,
|
|
2360
|
-
gap,
|
|
2361
|
-
width,
|
|
2362
|
-
height,
|
|
2363
|
-
minWidth,
|
|
2364
|
-
maxWidth,
|
|
2365
|
-
minHeight,
|
|
2366
|
-
maxHeight
|
|
2367
|
-
]
|
|
2368
|
-
);
|
|
2369
|
-
const userStyles = Array.isArray(style) ? style : style ? [style] : [];
|
|
2370
|
-
return /* @__PURE__ */ React11__default.default.createElement(
|
|
2371
|
-
reactNative.View,
|
|
2372
|
-
{
|
|
2373
|
-
ref,
|
|
2374
|
-
testID,
|
|
2375
|
-
nativeID,
|
|
2376
|
-
accessibilityRole: "none",
|
|
2377
|
-
style: [containerStyle, ...userStyles]
|
|
2378
|
-
},
|
|
2379
|
-
children
|
|
2380
|
-
);
|
|
2381
|
-
}
|
|
2382
|
-
var COLOR_MAP = {
|
|
2383
|
-
primary: "textPrimary",
|
|
2384
|
-
secondary: "textSecondary",
|
|
2385
|
-
interactive: "interactive"
|
|
2386
|
-
};
|
|
2387
|
-
function Text11({
|
|
2388
|
-
children,
|
|
2389
|
-
size = "base",
|
|
2390
|
-
weight = "regular",
|
|
2391
|
-
color = "primary",
|
|
2392
|
-
font = "default",
|
|
2393
|
-
lineHeight = "normal",
|
|
2394
|
-
align,
|
|
2395
|
-
numberOfLines,
|
|
2396
|
-
elevation = 1,
|
|
2397
|
-
style,
|
|
2398
|
-
// Accessibility
|
|
2399
|
-
accessibilityRole,
|
|
2400
|
-
// Testing & platform
|
|
2401
|
-
testID,
|
|
2402
|
-
nativeID,
|
|
2403
|
-
ref
|
|
2469
|
+
width: THUMB_SIZE4,
|
|
2470
|
+
height: THUMB_SIZE4,
|
|
2471
|
+
borderRadius: THUMB_SIZE4 / 2,
|
|
2472
|
+
backgroundColor: "#ffffff",
|
|
2473
|
+
borderWidth: 2,
|
|
2474
|
+
borderColor: newtone.srgbToHex(tokens.border.srgb)
|
|
2475
|
+
},
|
|
2476
|
+
warning: {
|
|
2477
|
+
fontFamily: tokens.typography.fonts.default,
|
|
2478
|
+
fontSize: tokens.typography.size.xs,
|
|
2479
|
+
fontWeight: tokens.typography.weight.medium,
|
|
2480
|
+
color: newtone.srgbToHex(tokens.error.srgb)
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// src/composites/range-inputs/ColorScaleSlider/ColorScaleSlider.tsx
|
|
2486
|
+
function ColorScaleSlider({
|
|
2487
|
+
colors,
|
|
2488
|
+
value,
|
|
2489
|
+
onValueChange,
|
|
2490
|
+
label,
|
|
2491
|
+
warning,
|
|
2492
|
+
trimEnds = false,
|
|
2493
|
+
snap = false,
|
|
2494
|
+
disabled = false,
|
|
2495
|
+
animateValue = false,
|
|
2496
|
+
style
|
|
2404
2497
|
}) {
|
|
2405
|
-
const tokens = useTokens(
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2498
|
+
const tokens = useTokens(1);
|
|
2499
|
+
const styles = React13__default.default.useMemo(
|
|
2500
|
+
() => getColorScaleSliderStyles(tokens, disabled),
|
|
2501
|
+
[tokens, disabled]
|
|
2502
|
+
);
|
|
2503
|
+
const trackRef = React13__default.default.useRef(null);
|
|
2504
|
+
const trackWidth = React13__default.default.useRef(0);
|
|
2505
|
+
const trackPageX = React13__default.default.useRef(0);
|
|
2506
|
+
const isDragging = React13__default.default.useRef(false);
|
|
2507
|
+
const thumbAnim = React13__default.default.useRef(new reactNative.Animated.Value(0)).current;
|
|
2508
|
+
const onValueChangeRef = React13__default.default.useRef(onValueChange);
|
|
2509
|
+
const disabledRef = React13__default.default.useRef(disabled);
|
|
2510
|
+
const colorsLengthRef = React13__default.default.useRef(colors.length);
|
|
2511
|
+
const trimEndsRef = React13__default.default.useRef(trimEnds);
|
|
2512
|
+
const snapRef = React13__default.default.useRef(snap);
|
|
2513
|
+
React13__default.default.useEffect(() => {
|
|
2514
|
+
onValueChangeRef.current = onValueChange;
|
|
2515
|
+
}, [onValueChange]);
|
|
2516
|
+
React13__default.default.useEffect(() => {
|
|
2517
|
+
disabledRef.current = disabled;
|
|
2518
|
+
}, [disabled]);
|
|
2519
|
+
React13__default.default.useEffect(() => {
|
|
2520
|
+
colorsLengthRef.current = colors.length;
|
|
2521
|
+
}, [colors.length]);
|
|
2522
|
+
React13__default.default.useEffect(() => {
|
|
2523
|
+
trimEndsRef.current = trimEnds;
|
|
2524
|
+
}, [trimEnds]);
|
|
2525
|
+
React13__default.default.useEffect(() => {
|
|
2526
|
+
snapRef.current = snap;
|
|
2527
|
+
}, [snap]);
|
|
2528
|
+
const computeNv = React13__default.default.useCallback((pageX) => {
|
|
2529
|
+
const localX = pageX - trackPageX.current;
|
|
2530
|
+
const ratio2 = Math.min(1, Math.max(0, localX / trackWidth.current));
|
|
2531
|
+
const totalSteps2 = colorsLengthRef.current - 1;
|
|
2532
|
+
const minNV2 = trimEndsRef.current ? 1 / totalSteps2 : 0;
|
|
2533
|
+
const maxNV2 = trimEndsRef.current ? 1 - 1 / totalSteps2 : 1;
|
|
2534
|
+
const range2 = maxNV2 - minNV2;
|
|
2535
|
+
let nv = maxNV2 - ratio2 * range2;
|
|
2536
|
+
if (snapRef.current && totalSteps2 > 0) {
|
|
2537
|
+
const stepNv = 1 / totalSteps2;
|
|
2538
|
+
nv = Math.round(nv / stepNv) * stepNv;
|
|
2539
|
+
nv = Math.min(maxNV2, Math.max(minNV2, nv));
|
|
2540
|
+
}
|
|
2541
|
+
return nv;
|
|
2542
|
+
}, []);
|
|
2543
|
+
const panResponder = React13__default.default.useRef(
|
|
2544
|
+
reactNative.PanResponder.create({
|
|
2545
|
+
onStartShouldSetPanResponder: () => !disabledRef.current,
|
|
2546
|
+
onMoveShouldSetPanResponder: () => !disabledRef.current,
|
|
2547
|
+
onPanResponderGrant: (evt) => {
|
|
2548
|
+
isDragging.current = true;
|
|
2549
|
+
onValueChangeRef.current(computeNv(evt.nativeEvent.pageX));
|
|
2550
|
+
},
|
|
2551
|
+
onPanResponderMove: (_evt, gestureState) => {
|
|
2552
|
+
onValueChangeRef.current(computeNv(gestureState.moveX));
|
|
2553
|
+
},
|
|
2554
|
+
onPanResponderRelease: () => {
|
|
2555
|
+
isDragging.current = false;
|
|
2556
|
+
},
|
|
2557
|
+
onPanResponderTerminate: () => {
|
|
2558
|
+
isDragging.current = false;
|
|
2559
|
+
}
|
|
2560
|
+
})
|
|
2561
|
+
).current;
|
|
2562
|
+
const visibleColors = trimEnds ? colors.slice(1, -1) : colors;
|
|
2563
|
+
const totalSteps = colors.length - 1;
|
|
2564
|
+
const minNV = trimEnds ? 1 / totalSteps : 0;
|
|
2565
|
+
const maxNV = trimEnds ? 1 - 1 / totalSteps : 1;
|
|
2566
|
+
const range = maxNV - minNV;
|
|
2567
|
+
const clampedValue = value !== void 0 ? Math.min(maxNV, Math.max(minNV, value)) : (maxNV + minNV) / 2;
|
|
2568
|
+
const ratio = range > 0 ? (maxNV - clampedValue) / range : 0.5;
|
|
2569
|
+
const usableWidth = Math.max(0, trackWidth.current - THUMB_SIZE4);
|
|
2570
|
+
const thumbLeft = ratio * usableWidth;
|
|
2571
|
+
React13__default.default.useEffect(() => {
|
|
2572
|
+
if (isDragging.current || !animateValue) {
|
|
2573
|
+
thumbAnim.setValue(thumbLeft);
|
|
2574
|
+
} else {
|
|
2575
|
+
reactNative.Animated.timing(thumbAnim, {
|
|
2576
|
+
toValue: thumbLeft,
|
|
2577
|
+
duration: 300,
|
|
2578
|
+
useNativeDriver: false
|
|
2579
|
+
}).start();
|
|
2580
|
+
}
|
|
2581
|
+
}, [thumbLeft, animateValue, thumbAnim]);
|
|
2582
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: [styles.container, ...Array.isArray(style) ? style : [style]] }, label && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.labelRow }, /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.label }, label)), /* @__PURE__ */ React13__default.default.createElement(
|
|
2583
|
+
reactNative.View,
|
|
2423
2584
|
{
|
|
2424
|
-
ref,
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2585
|
+
ref: trackRef,
|
|
2586
|
+
style: styles.trackContainer,
|
|
2587
|
+
onLayout: (e) => {
|
|
2588
|
+
trackWidth.current = e.nativeEvent.layout.width;
|
|
2589
|
+
const newUsableWidth = Math.max(0, e.nativeEvent.layout.width - THUMB_SIZE4);
|
|
2590
|
+
thumbAnim.setValue(ratio * newUsableWidth);
|
|
2591
|
+
trackRef.current?.measure((_x, _y, _w, _h, pageX) => {
|
|
2592
|
+
if (pageX != null) trackPageX.current = pageX;
|
|
2593
|
+
});
|
|
2594
|
+
},
|
|
2595
|
+
...panResponder.panHandlers
|
|
2430
2596
|
},
|
|
2431
|
-
|
|
2432
|
-
|
|
2597
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.gradientTrack }, visibleColors.map((color, i) => /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { key: i, style: [styles.segment, { backgroundColor: newtone.srgbToHex(color.srgb) }] }))),
|
|
2598
|
+
/* @__PURE__ */ React13__default.default.createElement(reactNative.Animated.View, { style: [styles.thumb, { left: thumbAnim }] })
|
|
2599
|
+
), warning && /* @__PURE__ */ React13__default.default.createElement(reactNative.Text, { style: styles.warning }, warning));
|
|
2433
2600
|
}
|
|
2434
2601
|
function getAppShellStyles(tokens) {
|
|
2435
2602
|
return reactNative.StyleSheet.create({
|
|
@@ -2448,11 +2615,11 @@ function getAppShellStyles(tokens) {
|
|
|
2448
2615
|
});
|
|
2449
2616
|
}
|
|
2450
2617
|
|
|
2451
|
-
// src/AppShell/AppShell.tsx
|
|
2618
|
+
// src/composites/layout/AppShell/AppShell.tsx
|
|
2452
2619
|
function AppShell({ sidebar, children }) {
|
|
2453
2620
|
const tokens = useTokens();
|
|
2454
|
-
const styles =
|
|
2455
|
-
return /* @__PURE__ */
|
|
2621
|
+
const styles = React13__default.default.useMemo(() => getAppShellStyles(tokens), [tokens]);
|
|
2622
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.container }, sidebar, /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.main }, children));
|
|
2456
2623
|
}
|
|
2457
2624
|
function getSidebarStyles({ tokens, width, bordered }) {
|
|
2458
2625
|
const borderColor = newtone.srgbToHex(tokens.border.srgb);
|
|
@@ -2481,7 +2648,7 @@ function getSidebarStyles({ tokens, width, bordered }) {
|
|
|
2481
2648
|
});
|
|
2482
2649
|
}
|
|
2483
2650
|
|
|
2484
|
-
// src/Sidebar/Sidebar.tsx
|
|
2651
|
+
// src/composites/layout/Sidebar/Sidebar.tsx
|
|
2485
2652
|
function Sidebar({
|
|
2486
2653
|
children,
|
|
2487
2654
|
header,
|
|
@@ -2490,11 +2657,11 @@ function Sidebar({
|
|
|
2490
2657
|
bordered = true
|
|
2491
2658
|
}) {
|
|
2492
2659
|
const tokens = useTokens();
|
|
2493
|
-
const styles =
|
|
2660
|
+
const styles = React13__default.default.useMemo(
|
|
2494
2661
|
() => getSidebarStyles({ tokens, width, bordered }),
|
|
2495
2662
|
[tokens, width, bordered]
|
|
2496
2663
|
);
|
|
2497
|
-
return /* @__PURE__ */
|
|
2664
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.container }, header && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.header }, header), /* @__PURE__ */ React13__default.default.createElement(reactNative.ScrollView, { style: styles.body }, children), footer && /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.footer }, footer));
|
|
2498
2665
|
}
|
|
2499
2666
|
function getNavbarStyles({ tokens, height, bordered }) {
|
|
2500
2667
|
const borderColor = newtone.srgbToHex(tokens.border.srgb);
|
|
@@ -2523,7 +2690,7 @@ function getNavbarStyles({ tokens, height, bordered }) {
|
|
|
2523
2690
|
});
|
|
2524
2691
|
}
|
|
2525
2692
|
|
|
2526
|
-
// src/Navbar/Navbar.tsx
|
|
2693
|
+
// src/composites/layout/Navbar/Navbar.tsx
|
|
2527
2694
|
function Navbar({
|
|
2528
2695
|
children,
|
|
2529
2696
|
left,
|
|
@@ -2532,19 +2699,21 @@ function Navbar({
|
|
|
2532
2699
|
bordered = true
|
|
2533
2700
|
}) {
|
|
2534
2701
|
const tokens = useTokens();
|
|
2535
|
-
const styles =
|
|
2702
|
+
const styles = React13__default.default.useMemo(
|
|
2536
2703
|
() => getNavbarStyles({ tokens, height, bordered }),
|
|
2537
2704
|
[tokens, height, bordered]
|
|
2538
2705
|
);
|
|
2539
|
-
return /* @__PURE__ */
|
|
2706
|
+
return /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.container }, children ? children : /* @__PURE__ */ React13__default.default.createElement(React13__default.default.Fragment, null, /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.left }, left), /* @__PURE__ */ React13__default.default.createElement(reactNative.View, { style: styles.right }, right)));
|
|
2540
2707
|
}
|
|
2541
2708
|
|
|
2542
2709
|
// src/registry/registry.ts
|
|
2543
2710
|
var CATEGORIES = [
|
|
2711
|
+
{ id: "primitives", name: "Design Primitives", description: "Core building blocks for theme-aware layouts and typography" },
|
|
2544
2712
|
{ id: "actions", name: "Actions", description: "Interactive elements that trigger actions" },
|
|
2545
2713
|
{ id: "form-controls", name: "Form Controls", description: "Input elements for user data entry" },
|
|
2546
|
-
{ id: "range-inputs", name: "Range Inputs", description: "Slider controls for numeric values" },
|
|
2547
|
-
{ id: "layout", name: "Layout", description: "Structural and container components" }
|
|
2714
|
+
{ id: "range-inputs", name: "Range Inputs", description: "Slider controls for numeric and continuous values" },
|
|
2715
|
+
{ id: "layout", name: "Layout", description: "Structural and container components" },
|
|
2716
|
+
{ id: "overlays", name: "Overlays", description: "Floating and portal-based UI elements" }
|
|
2548
2717
|
];
|
|
2549
2718
|
var COMPONENTS = [
|
|
2550
2719
|
{
|
|
@@ -2925,6 +3094,216 @@ var COMPONENTS = [
|
|
|
2925
3094
|
defaultValue: false
|
|
2926
3095
|
}
|
|
2927
3096
|
]
|
|
3097
|
+
},
|
|
3098
|
+
// ── Design Primitives ──
|
|
3099
|
+
{
|
|
3100
|
+
id: "text",
|
|
3101
|
+
name: "Text",
|
|
3102
|
+
importName: "Text",
|
|
3103
|
+
categoryId: "primitives",
|
|
3104
|
+
description: "Typography primitive with semantic size, weight, color, font, and lineHeight",
|
|
3105
|
+
hasChildren: true,
|
|
3106
|
+
variants: [
|
|
3107
|
+
{ id: "default", label: "Default", props: {} },
|
|
3108
|
+
{ id: "heading", label: "Heading", props: { size: "xl", weight: "bold" } },
|
|
3109
|
+
{ id: "subheading", label: "Subheading", props: { size: "lg", weight: "semibold" } },
|
|
3110
|
+
{ id: "body", label: "Body", props: { size: "base" } },
|
|
3111
|
+
{ id: "caption", label: "Caption", props: { size: "sm", color: "secondary" } },
|
|
3112
|
+
{ id: "link", label: "Link", props: { color: "interactive", weight: "medium" } },
|
|
3113
|
+
{ id: "mono", label: "Monospace", props: { font: "mono", size: "sm" } }
|
|
3114
|
+
],
|
|
3115
|
+
editableProps: [
|
|
3116
|
+
{
|
|
3117
|
+
name: "size",
|
|
3118
|
+
label: "Size",
|
|
3119
|
+
control: "select",
|
|
3120
|
+
options: [
|
|
3121
|
+
{ label: "Extra Small", value: "xs" },
|
|
3122
|
+
{ label: "Small", value: "sm" },
|
|
3123
|
+
{ label: "Base", value: "base" },
|
|
3124
|
+
{ label: "Medium", value: "md" },
|
|
3125
|
+
{ label: "Large", value: "lg" },
|
|
3126
|
+
{ label: "Extra Large", value: "xl" },
|
|
3127
|
+
{ label: "XXL", value: "xxl" }
|
|
3128
|
+
],
|
|
3129
|
+
defaultValue: "base"
|
|
3130
|
+
},
|
|
3131
|
+
{
|
|
3132
|
+
name: "weight",
|
|
3133
|
+
label: "Weight",
|
|
3134
|
+
control: "select",
|
|
3135
|
+
options: [
|
|
3136
|
+
{ label: "Regular", value: "regular" },
|
|
3137
|
+
{ label: "Medium", value: "medium" },
|
|
3138
|
+
{ label: "Semibold", value: "semibold" },
|
|
3139
|
+
{ label: "Bold", value: "bold" }
|
|
3140
|
+
],
|
|
3141
|
+
defaultValue: "regular"
|
|
3142
|
+
},
|
|
3143
|
+
{
|
|
3144
|
+
name: "color",
|
|
3145
|
+
label: "Color",
|
|
3146
|
+
control: "select",
|
|
3147
|
+
options: [
|
|
3148
|
+
{ label: "Primary", value: "primary" },
|
|
3149
|
+
{ label: "Secondary", value: "secondary" },
|
|
3150
|
+
{ label: "Interactive", value: "interactive" }
|
|
3151
|
+
],
|
|
3152
|
+
defaultValue: "primary"
|
|
3153
|
+
},
|
|
3154
|
+
{
|
|
3155
|
+
name: "font",
|
|
3156
|
+
label: "Font",
|
|
3157
|
+
control: "select",
|
|
3158
|
+
options: [
|
|
3159
|
+
{ label: "Default", value: "default" },
|
|
3160
|
+
{ label: "Display", value: "display" },
|
|
3161
|
+
{ label: "Mono", value: "mono" }
|
|
3162
|
+
],
|
|
3163
|
+
defaultValue: "default"
|
|
3164
|
+
}
|
|
3165
|
+
]
|
|
3166
|
+
},
|
|
3167
|
+
{
|
|
3168
|
+
id: "icon",
|
|
3169
|
+
name: "Icon",
|
|
3170
|
+
importName: "Icon",
|
|
3171
|
+
categoryId: "primitives",
|
|
3172
|
+
description: "Material Symbols icon with size, fill, and color",
|
|
3173
|
+
hasChildren: false,
|
|
3174
|
+
variants: [
|
|
3175
|
+
{ id: "home", label: "Home", props: { name: "home" } },
|
|
3176
|
+
{ id: "settings", label: "Settings", props: { name: "settings" } },
|
|
3177
|
+
{ id: "check", label: "Check", props: { name: "check" } },
|
|
3178
|
+
{ id: "add", label: "Add", props: { name: "add" } },
|
|
3179
|
+
{ id: "delete", label: "Delete", props: { name: "delete" } },
|
|
3180
|
+
{ id: "search", label: "Search", props: { name: "search" } },
|
|
3181
|
+
{ id: "filled", label: "Filled Icon", props: { name: "favorite", fill: 1 } },
|
|
3182
|
+
{ id: "large", label: "Large Icon", props: { name: "star", size: 32 } }
|
|
3183
|
+
],
|
|
3184
|
+
editableProps: [
|
|
3185
|
+
{
|
|
3186
|
+
name: "name",
|
|
3187
|
+
label: "Icon Name",
|
|
3188
|
+
control: "text",
|
|
3189
|
+
defaultValue: "home"
|
|
3190
|
+
},
|
|
3191
|
+
{
|
|
3192
|
+
name: "size",
|
|
3193
|
+
label: "Size",
|
|
3194
|
+
control: "number",
|
|
3195
|
+
defaultValue: 24
|
|
3196
|
+
},
|
|
3197
|
+
{
|
|
3198
|
+
name: "fill",
|
|
3199
|
+
label: "Fill",
|
|
3200
|
+
control: "select",
|
|
3201
|
+
options: [
|
|
3202
|
+
{ label: "Outlined", value: 0 },
|
|
3203
|
+
{ label: "Filled", value: 1 }
|
|
3204
|
+
],
|
|
3205
|
+
defaultValue: 0
|
|
3206
|
+
}
|
|
3207
|
+
]
|
|
3208
|
+
},
|
|
3209
|
+
{
|
|
3210
|
+
id: "wrapper",
|
|
3211
|
+
name: "Wrapper",
|
|
3212
|
+
importName: "Wrapper",
|
|
3213
|
+
categoryId: "primitives",
|
|
3214
|
+
description: "Lightweight layout container with direction, spacing, and alignment (no theming)",
|
|
3215
|
+
hasChildren: true,
|
|
3216
|
+
variants: [
|
|
3217
|
+
{ id: "vertical", label: "Vertical Stack", props: { direction: "vertical", gap: "md" } },
|
|
3218
|
+
{ id: "horizontal", label: "Horizontal Row", props: { direction: "horizontal", gap: "md", align: "center" } },
|
|
3219
|
+
{ id: "padded", label: "Padded", props: { padding: "lg", gap: "md" } },
|
|
3220
|
+
{ id: "centered", label: "Centered", props: { align: "center", justify: "center", padding: "xl" } }
|
|
3221
|
+
],
|
|
3222
|
+
editableProps: [
|
|
3223
|
+
{
|
|
3224
|
+
name: "direction",
|
|
3225
|
+
label: "Direction",
|
|
3226
|
+
control: "select",
|
|
3227
|
+
options: [
|
|
3228
|
+
{ label: "Vertical", value: "vertical" },
|
|
3229
|
+
{ label: "Horizontal", value: "horizontal" }
|
|
3230
|
+
],
|
|
3231
|
+
defaultValue: "vertical"
|
|
3232
|
+
},
|
|
3233
|
+
{
|
|
3234
|
+
name: "gap",
|
|
3235
|
+
label: "Gap",
|
|
3236
|
+
control: "select",
|
|
3237
|
+
options: [
|
|
3238
|
+
{ label: "None", value: "" },
|
|
3239
|
+
{ label: "Small", value: "sm" },
|
|
3240
|
+
{ label: "Medium", value: "md" },
|
|
3241
|
+
{ label: "Large", value: "lg" }
|
|
3242
|
+
],
|
|
3243
|
+
defaultValue: ""
|
|
3244
|
+
},
|
|
3245
|
+
{
|
|
3246
|
+
name: "padding",
|
|
3247
|
+
label: "Padding",
|
|
3248
|
+
control: "select",
|
|
3249
|
+
options: [
|
|
3250
|
+
{ label: "None", value: "" },
|
|
3251
|
+
{ label: "Small", value: "sm" },
|
|
3252
|
+
{ label: "Medium", value: "md" },
|
|
3253
|
+
{ label: "Large", value: "lg" }
|
|
3254
|
+
],
|
|
3255
|
+
defaultValue: ""
|
|
3256
|
+
},
|
|
3257
|
+
{
|
|
3258
|
+
name: "align",
|
|
3259
|
+
label: "Align",
|
|
3260
|
+
control: "select",
|
|
3261
|
+
options: [
|
|
3262
|
+
{ label: "Start", value: "start" },
|
|
3263
|
+
{ label: "Center", value: "center" },
|
|
3264
|
+
{ label: "End", value: "end" }
|
|
3265
|
+
],
|
|
3266
|
+
defaultValue: "start"
|
|
3267
|
+
},
|
|
3268
|
+
{
|
|
3269
|
+
name: "justify",
|
|
3270
|
+
label: "Justify",
|
|
3271
|
+
control: "select",
|
|
3272
|
+
options: [
|
|
3273
|
+
{ label: "Start", value: "start" },
|
|
3274
|
+
{ label: "Center", value: "center" },
|
|
3275
|
+
{ label: "End", value: "end" },
|
|
3276
|
+
{ label: "Space Between", value: "space-between" }
|
|
3277
|
+
],
|
|
3278
|
+
defaultValue: "start"
|
|
3279
|
+
}
|
|
3280
|
+
]
|
|
3281
|
+
},
|
|
3282
|
+
// ── Range Inputs (Addition: ColorScaleSlider) ──
|
|
3283
|
+
{
|
|
3284
|
+
id: "color-scale-slider",
|
|
3285
|
+
name: "ColorScaleSlider",
|
|
3286
|
+
importName: "ColorScaleSlider",
|
|
3287
|
+
categoryId: "range-inputs",
|
|
3288
|
+
description: "Interactive palette preview slider with color segments",
|
|
3289
|
+
hasChildren: false,
|
|
3290
|
+
variants: [
|
|
3291
|
+
{ id: "default", label: "Default", props: { label: "Key Color" } }
|
|
3292
|
+
],
|
|
3293
|
+
editableProps: [
|
|
3294
|
+
{
|
|
3295
|
+
name: "label",
|
|
3296
|
+
label: "Label",
|
|
3297
|
+
control: "text",
|
|
3298
|
+
defaultValue: "Key Color"
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
name: "disabled",
|
|
3302
|
+
label: "Disabled",
|
|
3303
|
+
control: "toggle",
|
|
3304
|
+
defaultValue: false
|
|
3305
|
+
}
|
|
3306
|
+
]
|
|
2928
3307
|
}
|
|
2929
3308
|
];
|
|
2930
3309
|
function getComponent(id) {
|
|
@@ -3111,7 +3490,7 @@ exports.SYSTEM_FONTS = SYSTEM_FONTS;
|
|
|
3111
3490
|
exports.Select = Select;
|
|
3112
3491
|
exports.Sidebar = Sidebar;
|
|
3113
3492
|
exports.Slider = Slider;
|
|
3114
|
-
exports.Text =
|
|
3493
|
+
exports.Text = Text2;
|
|
3115
3494
|
exports.TextInput = TextInput;
|
|
3116
3495
|
exports.Toggle = Toggle;
|
|
3117
3496
|
exports.Wrapper = Wrapper;
|