@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.
Files changed (32) hide show
  1. package/dist/composites/actions/Button/Button.d.ts +17 -30
  2. package/dist/composites/actions/Button/Button.d.ts.map +1 -1
  3. package/dist/composites/actions/Button/Button.styles.d.ts +12 -24
  4. package/dist/composites/actions/Button/Button.styles.d.ts.map +1 -1
  5. package/dist/composites/actions/Button/Button.types.d.ts +4 -13
  6. package/dist/composites/actions/Button/Button.types.d.ts.map +1 -1
  7. package/dist/composites/actions/Button/index.d.ts +1 -1
  8. package/dist/composites/actions/Button/index.d.ts.map +1 -1
  9. package/dist/index.cjs +120 -215
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +117 -216
  14. package/dist/index.js.map +1 -1
  15. package/dist/primitives/Frame/Frame.d.ts.map +1 -1
  16. package/dist/registry/registry.d.ts.map +1 -1
  17. package/package.json +1 -1
  18. package/src/composites/actions/Button/Button.styles.ts +90 -198
  19. package/src/composites/actions/Button/Button.tsx +32 -49
  20. package/src/composites/actions/Button/Button.types.ts +4 -15
  21. package/src/composites/actions/Button/index.ts +1 -1
  22. package/src/index.ts +6 -1
  23. package/src/primitives/Frame/Frame.tsx +1 -0
  24. package/src/registry/registry.ts +5 -21
  25. package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts +0 -70
  26. package/dist/_COMPONENT_TEMPLATE/ComponentName.d.ts.map +0 -1
  27. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts +0 -23
  28. package/dist/_COMPONENT_TEMPLATE/ComponentName.styles.d.ts.map +0 -1
  29. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts +0 -45
  30. package/dist/_COMPONENT_TEMPLATE/ComponentName.types.d.ts.map +0 -1
  31. package/dist/_COMPONENT_TEMPLATE/index.d.ts +0 -3
  32. 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 demonstrating the primitive composition pattern.
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
- * **Composition Architecture:**
7
- * - Pressable (RN primitive) handles interaction
8
- * - Wrapper (primitive) handles layout (direction, gap, padding, alignment)
9
- * - Icon (primitive) handles icon rendering with theme tokens
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
- * This component does NOT manually compute flexbox, spacing, or typography styles.
13
- * Instead, it delegates to primitives which already handle these concerns.
14
- *
15
- * Automatically adapts to the current theme and mode from NewtoneProvider.
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" semantic="accent" size="md" onPress={() => console.log('Pressed')}>
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
- * <Button icon="add" variant="primary" semantic="accent" onPress={handleAdd}>
27
- * New Item
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, semantic, size, disabled, loading, fullWidth, style, textStyle, ...pressableProps }: ButtonProps): React.JSX.Element;
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;AAOlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,IAAI,EACJ,YAAqB,EACrB,OAAmB,EACnB,QAAoB,EACpB,IAAW,EACX,QAAgB,EAChB,OAAe,EACf,SAAiB,EACjB,KAAK,EACL,SAAS,EACT,GAAG,cAAc,EAClB,EAAE,WAAW,qBA2Eb"}
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 { ButtonVariant, ButtonSemantic, ButtonSize } from './Button.types';
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, semantic, size, and state.
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
- * @param variant - Button type (primary, secondary, tertiary)
58
- * @param semantic - Button semantic meaning (neutral, accent, success, error, warning)
59
- * @param size - Button size (sm, md, lg)
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, semantic: ButtonSemantic, size: ButtonSize, disabled: boolean, tokens: UseTokensResult): ButtonConfig;
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,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEpE;;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,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;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,MAAM,GAAG,OAAO,GAC7B,aAAa,CAyDf;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,eAAe,GACtB,YAAY,CAiBd"}
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 type for the Button component (describes visual weight)
3
+ * Visual variant for the Button component (describes visual weight)
4
4
  */
5
- export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'link';
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 type (describes visual weight: filled, outlined, ghost)
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,UAAU,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;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,QAAQ,CAAC,EAAE,cAAc,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC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AO,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,3 +1,3 @@
1
1
  export { Button } from './Button';
2
- export type { ButtonProps, ButtonVariant, ButtonSize } from './Button.types';
2
+ export type { ButtonProps, ButtonVariant, ButtonSize, ButtonIconPosition } from './Button.types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -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"}