@newtonedev/components 0.1.14 → 0.1.15
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 +17 -30
- package/dist/composites/actions/Button/Button.d.ts.map +1 -1
- package/dist/composites/actions/Button/Button.styles.d.ts +12 -24
- package/dist/composites/actions/Button/Button.styles.d.ts.map +1 -1
- package/dist/composites/actions/Button/Button.types.d.ts +4 -13
- package/dist/composites/actions/Button/Button.types.d.ts.map +1 -1
- package/dist/composites/actions/Button/index.d.ts +1 -1
- package/dist/composites/actions/Button/index.d.ts.map +1 -1
- package/dist/index.cjs +120 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +117 -216
- package/dist/index.js.map +1 -1
- package/dist/primitives/Frame/Frame.d.ts.map +1 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/composites/actions/Button/Button.styles.ts +90 -198
- package/src/composites/actions/Button/Button.tsx +32 -49
- package/src/composites/actions/Button/Button.types.ts +4 -15
- package/src/composites/actions/Button/index.ts +1 -1
- package/src/index.ts +6 -1
- package/src/primitives/Frame/Frame.tsx +1 -0
- package/src/registry/registry.ts +5 -21
- package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts +0 -70
- package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts.map +0 -1
- package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts +0 -23
- package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts.map +0 -1
- package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts +0 -45
- package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts.map +0 -1
- package/dist/_COMPONENT_TEMPLATE/index.d.ts +0 -3
- package/dist/_COMPONENT_TEMPLATE/index.d.ts.map +0 -1
|
@@ -1,47 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ButtonProps } from './Button.types';
|
|
3
3
|
/**
|
|
4
|
-
* Button — A composite component
|
|
4
|
+
* Button — A composite component that inherits its color theme from the
|
|
5
|
+
* nearest parent Frame's `theme` prop (defaults to 'primary').
|
|
5
6
|
*
|
|
6
|
-
* **
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* - Text (primitive) — handles typography with theme tokens
|
|
7
|
+
* **Variants:**
|
|
8
|
+
* - `primary` — Filled background (highest visual weight)
|
|
9
|
+
* - `secondary` — Outlined with subtle hover
|
|
10
|
+
* - `ghost` — No border, transparent, subtle hover
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* **Sizes (fixed heights):**
|
|
13
|
+
* - `sm` — 40px
|
|
14
|
+
* - `md` — 48px
|
|
15
|
+
* - `lg` — 56px
|
|
16
|
+
* - `xl` — 64px
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```tsx
|
|
19
|
-
* <Button variant="primary"
|
|
20
|
+
* <Button variant="primary" size="md" onPress={() => console.log('Pressed')}>
|
|
20
21
|
* Click me
|
|
21
22
|
* </Button>
|
|
22
23
|
* ```
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
26
|
* ```tsx
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* </Button>
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <Button icon="delete" variant="tertiary" semantic="neutral" size="sm" onPress={handleDelete} />
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* <Button variant="link" semantic="accent" onPress={handleNav}>Learn more</Button>
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```tsx
|
|
43
|
-
* <Button loading onPress={handleSubmit}>Saving...</Button>
|
|
27
|
+
* // Inherits theme from parent Frame
|
|
28
|
+
* <Frame theme="error">
|
|
29
|
+
* <Button variant="primary">Delete</Button>
|
|
30
|
+
* </Frame>
|
|
44
31
|
* ```
|
|
45
32
|
*/
|
|
46
|
-
export declare function Button({ children, icon, iconPosition, variant,
|
|
33
|
+
export declare function Button({ children, icon, iconPosition, variant, size, disabled, loading, fullWidth, style, textStyle, ...pressableProps }: ButtonProps): React.JSX.Element;
|
|
47
34
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,IAAI,EACJ,YAAqB,EACrB,OAAmB,EACnB,IAAW,EACX,QAAgB,EAChB,OAAe,EACf,SAAiB,EACjB,KAAK,EACL,SAAS,EACT,GAAG,cAAc,EAClB,EAAE,WAAW,qBAuEb"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { UseTokensResult } from 'newtone-api';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ThemeName } from 'newtone-api';
|
|
3
|
+
import type { ButtonVariant, ButtonSize } from './Button.types';
|
|
3
4
|
import type { TextSize } from '../../../primitives/Text/Text.types';
|
|
5
|
+
/**
|
|
6
|
+
* Fixed heights per size (px)
|
|
7
|
+
*/
|
|
8
|
+
export declare const BUTTON_HEIGHTS: Record<ButtonSize, number>;
|
|
4
9
|
/**
|
|
5
10
|
* Configuration returned by getButtonConfig
|
|
6
11
|
*/
|
|
@@ -15,6 +20,7 @@ export interface ButtonConfig {
|
|
|
15
20
|
borderColor?: string;
|
|
16
21
|
};
|
|
17
22
|
sizeTokens: {
|
|
23
|
+
height: number;
|
|
18
24
|
padding: number;
|
|
19
25
|
gap: number;
|
|
20
26
|
borderRadius: number;
|
|
@@ -28,38 +34,20 @@ export interface ButtonConfig {
|
|
|
28
34
|
export interface ButtonPadding {
|
|
29
35
|
paddingLeft: number;
|
|
30
36
|
paddingRight: number;
|
|
31
|
-
paddingTop: number;
|
|
32
|
-
paddingBottom: number;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Compute asymmetric button padding based on icon/text presence.
|
|
36
40
|
*
|
|
37
41
|
* Text appears visually closer to borders than icons, so we add 8px extra
|
|
38
42
|
* horizontal padding on the text side for optical balance.
|
|
39
|
-
*
|
|
40
|
-
* @param size - Button size (determines base padding)
|
|
41
|
-
* @param hasIcon - Whether button has an icon
|
|
42
|
-
* @param hasText - Whether button has text
|
|
43
|
-
* @param iconPosition - Icon position relative to text
|
|
44
|
-
* @returns Padding object with all four sides
|
|
45
43
|
*/
|
|
46
44
|
export declare function computeButtonPadding(size: ButtonSize, hasIcon: boolean, hasText: boolean, iconPosition: 'left' | 'right'): ButtonPadding;
|
|
47
45
|
/**
|
|
48
|
-
* Compute button configuration based on variant,
|
|
49
|
-
*
|
|
50
|
-
* This function ONLY computes variant colors + size tokens.
|
|
51
|
-
* Layout concerns (flexbox, spacing, alignment) are handled by Wrapper primitive.
|
|
52
|
-
* Typography concerns (font, size, weight) are handled by Text primitive.
|
|
53
|
-
*
|
|
54
|
-
* Elevation-aware: neutral primary uses backgroundInteractive for consistent contrast.
|
|
55
|
-
* Semantic variants use proper PaletteTokens — no opacity hacks.
|
|
46
|
+
* Compute button configuration based on variant, size, and state.
|
|
56
47
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @param disabled - Whether button is disabled
|
|
61
|
-
* @param tokens - Resolved tokens for current elevation
|
|
62
|
-
* @returns ButtonConfig with variantColors and sizeTokens
|
|
48
|
+
* Colors are derived from the inherited theme (via FrameContext) rather than
|
|
49
|
+
* hardcoded to the primary palette. The `theme` parameter comes from the
|
|
50
|
+
* nearest Frame's `theme` prop, defaulting to 'primary'.
|
|
63
51
|
*/
|
|
64
|
-
export declare function getButtonConfig(variant: ButtonVariant,
|
|
52
|
+
export declare function getButtonConfig(variant: ButtonVariant, size: ButtonSize, disabled: boolean, tokens: UseTokensResult, theme: ThemeName): ButtonConfig;
|
|
65
53
|
//# sourceMappingURL=Button.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.styles.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"Button.styles.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAKrD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE;QACb,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,QAAQ,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAAG,OAAO,GAC7B,aAAa,CA+Bf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,SAAS,GACf,YAAY,CAed"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import type { PressableProps, ViewStyle, TextStyle } from 'react-native';
|
|
2
2
|
/**
|
|
3
|
-
* Visual
|
|
3
|
+
* Visual variant for the Button component (describes visual weight)
|
|
4
4
|
*/
|
|
5
|
-
export type ButtonVariant = 'primary' | 'secondary' | '
|
|
6
|
-
/**
|
|
7
|
-
* Semantic meaning for the Button component (describes color purpose)
|
|
8
|
-
*/
|
|
9
|
-
export type ButtonSemantic = 'neutral' | 'accent' | 'success' | 'error' | 'warning';
|
|
5
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
10
6
|
/**
|
|
11
7
|
* Size presets for the Button component
|
|
12
8
|
*/
|
|
13
|
-
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
9
|
+
export type ButtonSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
14
10
|
/**
|
|
15
11
|
* Icon position relative to button text
|
|
16
12
|
*/
|
|
@@ -35,15 +31,10 @@ export interface ButtonProps extends Omit<PressableProps, 'children' | 'style'>
|
|
|
35
31
|
*/
|
|
36
32
|
readonly iconPosition?: ButtonIconPosition;
|
|
37
33
|
/**
|
|
38
|
-
* Visual
|
|
34
|
+
* Visual variant (describes visual weight: filled, outlined, ghost)
|
|
39
35
|
* @default 'primary'
|
|
40
36
|
*/
|
|
41
37
|
readonly variant?: ButtonVariant;
|
|
42
|
-
/**
|
|
43
|
-
* Semantic meaning (describes color purpose: neutral, accent, success, error, warning)
|
|
44
|
-
* @default 'neutral'
|
|
45
|
-
*/
|
|
46
|
-
readonly semantic?: ButtonSemantic;
|
|
47
38
|
/**
|
|
48
39
|
* Size preset
|
|
49
40
|
* @default 'md'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"Button.types.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/Button.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC;IAC7E;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/composites/actions/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|