@mapples/ui 1.1.3 → 1.5.0

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 (89) hide show
  1. package/dist/components/form/SubmitButton/SubmitButton.d.ts +13 -26
  2. package/dist/components/form/SubmitButton/SubmitButton.d.ts.map +1 -1
  3. package/dist/components/form/SubmitButton/SubmitButton.js +12 -21
  4. package/dist/components/form/SubmitButton/SubmitButton.js.map +1 -1
  5. package/dist/components/inputs/Button/Button.d.ts +42 -5
  6. package/dist/components/inputs/Button/Button.d.ts.map +1 -1
  7. package/dist/components/inputs/Button/Button.js +177 -10
  8. package/dist/components/inputs/Button/Button.js.map +1 -1
  9. package/dist/components/inputs/Button/ButtonGroupContext.d.ts +19 -0
  10. package/dist/components/inputs/Button/ButtonGroupContext.d.ts.map +1 -0
  11. package/dist/components/inputs/Button/ButtonGroupContext.js +4 -0
  12. package/dist/components/inputs/Button/ButtonGroupContext.js.map +1 -0
  13. package/dist/components/inputs/Button/index.d.ts +1 -0
  14. package/dist/components/inputs/Button/index.d.ts.map +1 -1
  15. package/dist/components/inputs/Button/index.js +1 -0
  16. package/dist/components/inputs/Button/index.js.map +1 -1
  17. package/dist/components/inputs/IconButton/IconButton.d.ts +61 -19
  18. package/dist/components/inputs/IconButton/IconButton.d.ts.map +1 -1
  19. package/dist/components/inputs/IconButton/IconButton.js +185 -38
  20. package/dist/components/inputs/IconButton/IconButton.js.map +1 -1
  21. package/dist/components/inputs/TextInput/TextInput.d.ts +5 -0
  22. package/dist/components/inputs/TextInput/TextInput.d.ts.map +1 -1
  23. package/dist/components/inputs/TextInput/TextInput.js +15 -3
  24. package/dist/components/inputs/TextInput/TextInput.js.map +1 -1
  25. package/dist/components/media/BarCode/BarCodeEncoder.d.ts.map +1 -1
  26. package/dist/components/media/BarCode/BarCodeEncoder.js +22 -3
  27. package/dist/components/media/BarCode/BarCodeEncoder.js.map +1 -1
  28. package/dist/components/media/Icon/Icon.d.ts +40 -21
  29. package/dist/components/media/Icon/Icon.d.ts.map +1 -1
  30. package/dist/components/media/Icon/Icon.js +31 -33
  31. package/dist/components/media/Icon/Icon.js.map +1 -1
  32. package/dist/components/media/Icon/families.d.ts +66 -0
  33. package/dist/components/media/Icon/families.d.ts.map +1 -0
  34. package/dist/components/media/Icon/families.js +316 -0
  35. package/dist/components/media/Icon/families.js.map +1 -0
  36. package/dist/components/media/Icon/index.d.ts +2 -0
  37. package/dist/components/media/Icon/index.d.ts.map +1 -1
  38. package/dist/components/media/Icon/index.js +2 -0
  39. package/dist/components/media/Icon/index.js.map +1 -1
  40. package/dist/components/media/QRCode/QRCode.d.ts.map +1 -1
  41. package/dist/components/media/QRCode/QRCode.js +19 -2
  42. package/dist/components/media/QRCode/QRCode.js.map +1 -1
  43. package/dist/components/media/Vector/MockIcon.d.ts.map +1 -0
  44. package/dist/components/media/Vector/MockIcon.js.map +1 -0
  45. package/dist/components/media/Vector/Vector.d.ts +56 -0
  46. package/dist/components/media/Vector/Vector.d.ts.map +1 -0
  47. package/dist/components/media/Vector/Vector.js +59 -0
  48. package/dist/components/media/Vector/Vector.js.map +1 -0
  49. package/dist/components/media/Vector/index.d.ts +5 -0
  50. package/dist/components/media/Vector/index.d.ts.map +1 -0
  51. package/dist/components/media/Vector/index.js +5 -0
  52. package/dist/components/media/Vector/index.js.map +1 -0
  53. package/dist/components/media/Vector/schematics.d.ts +11 -0
  54. package/dist/components/media/Vector/schematics.d.ts.map +1 -0
  55. package/dist/components/media/Vector/schematics.js +14 -0
  56. package/dist/components/media/Vector/schematics.js.map +1 -0
  57. package/dist/components/media/Video/Video.d.ts +1 -1
  58. package/dist/components/media/Video/Video.d.ts.map +1 -1
  59. package/dist/components/media/Video/Video.js +26 -3
  60. package/dist/components/media/Video/Video.js.map +1 -1
  61. package/dist/components/media/index.d.ts +2 -0
  62. package/dist/components/media/index.d.ts.map +1 -1
  63. package/dist/components/media/index.js +2 -0
  64. package/dist/components/media/index.js.map +1 -1
  65. package/dist/components/media/schematics.d.ts +3 -3
  66. package/dist/components/media/schematics.d.ts.map +1 -1
  67. package/dist/components/media/schematics.js +5 -3
  68. package/dist/components/media/schematics.js.map +1 -1
  69. package/dist/hooks/index.d.ts +3 -0
  70. package/dist/hooks/index.d.ts.map +1 -0
  71. package/dist/hooks/index.js +3 -0
  72. package/dist/hooks/index.js.map +1 -0
  73. package/dist/hooks/useTones.d.ts +54 -0
  74. package/dist/hooks/useTones.d.ts.map +1 -0
  75. package/dist/hooks/useTones.js +79 -0
  76. package/dist/hooks/useTones.js.map +1 -0
  77. package/dist/index.d.ts +2 -0
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +2 -0
  80. package/dist/index.js.map +1 -1
  81. package/dist/tokens.d.ts +111 -0
  82. package/dist/tokens.d.ts.map +1 -0
  83. package/dist/tokens.js +133 -0
  84. package/dist/tokens.js.map +1 -0
  85. package/package.json +76 -1
  86. package/dist/components/media/Icon/MockIcon.d.ts.map +0 -1
  87. package/dist/components/media/Icon/MockIcon.js.map +0 -1
  88. /package/dist/components/media/{Icon → Vector}/MockIcon.d.ts +0 -0
  89. /package/dist/components/media/{Icon → Vector}/MockIcon.js +0 -0
@@ -1,37 +1,24 @@
1
- import { StyledProp, StyledProps } from '@mapples/style';
2
- import { PressableProps, TextStyle, View } from 'react-native';
1
+ import { View } from 'react-native';
2
+ import { ButtonProps } from '../../inputs/Button/Button';
3
3
  /**
4
- * Props for the SubmitButton component.
4
+ * Props for the SubmitButton component — every `Button` prop except
5
+ * `onPress`, which the form owns.
5
6
  *
6
7
  * @public
7
8
  */
8
- export interface SubmitButtonProps extends PressableProps {
9
- /** The text label to display on the button */
10
- label?: string;
11
- /** Styling configuration for the button and its typography */
12
- styled?: StyledProps<PressableProps> & {
13
- /** Typography-specific styling for the button label */
14
- styleTypography?: StyledProp<TextStyle>;
15
- };
16
- /** Typography variant to apply to the button label */
17
- typographyVariant?: string;
18
- }
9
+ export type SubmitButtonProps = Omit<ButtonProps, 'onPress'>;
19
10
  /**
20
- * A customizable button component with built-in styling support.
21
- *
22
- * The SubmitButton component extends React Native's Pressable with additional styling
23
- * capabilities and typography support. It can display a text label and supports
24
- * all standard pressable interactions.
11
+ * A `Button` that submits the nearest `FormView`. Shares every appearance
12
+ * prop with `Button` (`variant`, `size`, `tone`, glyphs, `fullWidth`); while
13
+ * the form is submitting it shows the loading state unless `loading` is set
14
+ * explicitly.
25
15
  *
26
16
  * @example
27
17
  * ```tsx
28
- * <SubmitButton
29
- * label="Click me"
30
- * styled={{
31
- * style: { backgroundColor: 'blue', padding: 16 },
32
- * styleTypography: { color: 'white', fontSize: 16 }
33
- * }}
34
- * />
18
+ * <FormView initialValues={{ email: '' }} onSubmit={signIn}>
19
+ * <TextField fieldName="email" placeholder="Email" />
20
+ * <SubmitButton label="Sign in" variant="filled" size="lg" fullWidth />
21
+ * </FormView>
35
22
  * ```
36
23
  *
37
24
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"SubmitButton.d.ts","sourceRoot":"","sources":["../../../../src/components/form/SubmitButton/SubmitButton.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,UAAU,EACV,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACvD,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,GAAG;QACrC,uDAAuD;QACvD,eAAe,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;KACzC,CAAC;IACF,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,QAAA,MAAM,YAAY;;wCAuBjB,CAAC;AAGF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"SubmitButton.d.ts","sourceRoot":"","sources":["../../../../src/components/form/SubmitButton/SubmitButton.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAe,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,YAAY;;wCAajB,CAAC;AAGF,eAAe,YAAY,CAAC"}
@@ -1,34 +1,25 @@
1
1
  import { forwardRef } from 'react';
2
2
  import { useFormSubmit } from '@mapples/form';
3
- import { StyledPressable, Typography, } from '@mapples/style';
3
+ import Button from '../../inputs/Button/Button';
4
4
  /**
5
- * A customizable button component with built-in styling support.
6
- *
7
- * The SubmitButton component extends React Native's Pressable with additional styling
8
- * capabilities and typography support. It can display a text label and supports
9
- * all standard pressable interactions.
5
+ * A `Button` that submits the nearest `FormView`. Shares every appearance
6
+ * prop with `Button` (`variant`, `size`, `tone`, glyphs, `fullWidth`); while
7
+ * the form is submitting it shows the loading state unless `loading` is set
8
+ * explicitly.
10
9
  *
11
10
  * @example
12
11
  * ```tsx
13
- * <SubmitButton
14
- * label="Click me"
15
- * styled={{
16
- * style: { backgroundColor: 'blue', padding: 16 },
17
- * styleTypography: { color: 'white', fontSize: 16 }
18
- * }}
19
- * />
12
+ * <FormView initialValues={{ email: '' }} onSubmit={signIn}>
13
+ * <TextField fieldName="email" placeholder="Email" />
14
+ * <SubmitButton label="Sign in" variant="filled" size="lg" fullWidth />
15
+ * </FormView>
20
16
  * ```
21
17
  *
22
18
  * @public
23
19
  */
24
- const SubmitButton = forwardRef(({ label, styled = {}, typographyVariant, ...props }, ref) => {
25
- const { styleTypography, ...styledPressableProps } = styled;
26
- const { submitForm } = useFormSubmit();
27
- return (<StyledPressable ref={ref} styled={styledPressableProps} {...props} onPress={submitForm}>
28
- {label && (<Typography style={styled?.styleTypography} variant={typographyVariant}>
29
- {label}
30
- </Typography>)}
31
- </StyledPressable>);
20
+ const SubmitButton = forwardRef(({ loading, ...props }, ref) => {
21
+ const { submitForm, submitting } = useFormSubmit();
22
+ return (<Button ref={ref} loading={loading ?? submitting} {...props} onPress={submitForm}/>);
32
23
  });
33
24
  SubmitButton.displayName = 'SubmitButton';
34
25
  export default SubmitButton;
@@ -1 +1 @@
1
- {"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../src/components/form/SubmitButton/SubmitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,eAAe,EAGf,UAAU,GACX,MAAM,gBAAgB,CAAC;AAoBxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,YAAY,GAAG,UAAU,CAC7B,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,iBAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC3D,MAAM,EAAE,eAAe,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,CAAC;IAC5D,MAAM,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,CAAC;IAEvC,OAAO,CACL,CAAC,eAAe,CACd,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAC7B,IAAI,KAAK,CAAC,CACV,OAAO,CAAC,CAAC,UAAU,CAAC,CAEpB;QAAA,CAAC,KAAK,IAAI,CACR,CAAC,UAAU,CACT,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,CAC/B,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAE3B;YAAA,CAAC,KAAK,CACR;UAAA,EAAE,UAAU,CAAC,CACd,CACH;MAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../src/components/form/SubmitButton/SubmitButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,MAAuB,MAAM,4BAA4B,CAAC;AAUjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,YAAY,GAAG,UAAU,CAC7B,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC7B,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,CAAC;IAEnD,OAAO,CACL,CAAC,MAAM,CACL,GAAG,CAAC,CAAC,GAAG,CAAC,CACT,OAAO,CAAC,CAAC,OAAO,IAAI,UAAU,CAAC,CAC/B,IAAI,KAAK,CAAC,CACV,OAAO,CAAC,CAAC,UAAU,CAAC,EACpB,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,eAAe,YAAY,CAAC"}
@@ -1,5 +1,6 @@
1
- import { StyledProp, StyledProps } from '@mapples/style';
1
+ import { StyledProp, StyledProps, SvgStyle } from '@mapples/style';
2
2
  import { PressableProps, TextStyle, View } from 'react-native';
3
+ import { ButtonVariant, ControlSize, Tone } from '../../../tokens';
3
4
  /**
4
5
  * Props for the Button component.
5
6
  *
@@ -12,22 +13,58 @@ export interface ButtonProps extends PressableProps {
12
13
  styled?: StyledProps<PressableProps> & {
13
14
  /** Typography-specific styling for the button label */
14
15
  styleTypography?: StyledProp<TextStyle>;
16
+ /** Glyph styling for the leading/trailing icons (themed variants) */
17
+ styleIcon?: StyledProp<SvgStyle>;
15
18
  };
16
19
  /** Typography variant to apply to the button label */
17
20
  typographyVariant?: string;
21
+ /**
22
+ * Themed appearance. Unset renders the bare pressable exactly as before —
23
+ * the label takes the typography document's colour and every colour comes
24
+ * from `styled`. Set, the button paints itself from the project theme:
25
+ * `filled` (tone fill), `tonal` (tinted container), `outlined`, `text` and
26
+ * `elevated` (surface + shadow).
27
+ */
28
+ variant?: ButtonVariant;
29
+ /** Control size (themed variants): `sm` 36, `md` 44, `lg` 52 points tall. */
30
+ size?: ControlSize;
31
+ /** Colour role of the themed variants. Defaults to `primary`. */
32
+ tone?: Tone;
33
+ /** Glyph shown before the label (project icon family). */
34
+ leadingIconName?: string;
35
+ /** Glyph shown after the label (project icon family). */
36
+ trailingIconName?: string;
37
+ /** Shows an activity indicator in place of the leading glyph and ignores presses. */
38
+ loading?: boolean;
39
+ /** Stretches the button across its parent (themed variants). */
40
+ fullWidth?: boolean;
18
41
  }
19
42
  /**
20
43
  * A customizable button component with built-in styling support.
21
44
  *
22
- * The Button component extends React Native's Pressable with additional styling
23
- * capabilities and typography support. It can display a text label and supports
24
- * all standard pressable interactions.
45
+ * Without `variant` the Button is React Native's Pressable plus a label —
46
+ * every colour comes from `styled`. With `variant` it is a themed control:
47
+ * the fill, label colour, outline and elevation follow the project theme and
48
+ * the chosen `tone`, `size` sets the height and label scale, and glyphs,
49
+ * loading and disabled states are built in. Author styles in `styled` still
50
+ * override every part.
25
51
  *
26
52
  * @example
27
53
  * ```tsx
28
54
  * <Button
29
- * label="Click me"
55
+ * label="Continue"
56
+ * variant="filled"
57
+ * size="lg"
58
+ * trailingIconName="arrow-forward"
30
59
  * onPress={() => console.log('Button pressed')}
60
+ * />
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * // Bare pressable — the legacy render
66
+ * <Button
67
+ * label="Click me"
31
68
  * styled={{
32
69
  * style: { backgroundColor: 'blue', padding: 16 },
33
70
  * styleTypography: { color: 'white', fontSize: 16 }
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EACV,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,GAAG;QACrC,uDAAuD;QACvD,eAAe,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;KACzC,CAAC;IACF,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,MAAM;;wCAiBX,CAAC;AAGF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/Button/Button.tsx"],"names":[],"mappings":"AAQA,OAAO,EAEL,UAAU,EACV,WAAW,EAGX,QAAQ,EAET,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAIL,cAAc,EACd,SAAS,EACT,IAAI,EAEL,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,aAAa,EAEb,WAAW,EAIX,IAAI,EACL,MAAM,iBAAiB,CAAC;AAQzB;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,MAAM,CAAC,EAAE,WAAW,CAAC,cAAc,CAAC,GAAG;QACrC,uDAAuD;QACvD,eAAe,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;QACxC,qEAAqE;QACrE,SAAS,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KAClC,CAAC;IACF,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,iEAAiE;IACjE,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA0DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,MAAM;;wCAmLX,CAAC;AA8BF,eAAe,MAAM,CAAC"}
@@ -1,17 +1,80 @@
1
- import { forwardRef } from 'react';
2
- import { StyledPressable, Typography, } from '@mapples/style';
1
+ import { forwardRef, useCallback, useContext, useState, } from 'react';
2
+ import { StyledPressable, StyledView, Styler, Typography, } from '@mapples/style';
3
+ import { ActivityIndicator, } from 'react-native';
4
+ import useTones from '../../../hooks/useTones';
5
+ import { CONTROL_SIZES, DISABLED_OPACITY, ELEVATION, Tokens, } from '../../../tokens';
6
+ import Icon from '../../media/Icon';
7
+ import { ButtonGroupContext, } from './ButtonGroupContext';
8
+ const variantColors = (variant, palette, tones) => {
9
+ switch (variant) {
10
+ case 'filled':
11
+ return { background: palette.main, label: palette.contrast };
12
+ case 'tonal':
13
+ return { background: palette.container, label: palette.onContainer };
14
+ case 'outlined':
15
+ return {
16
+ background: 'transparent',
17
+ label: palette.main,
18
+ border: tones.outlineStrong,
19
+ };
20
+ case 'text':
21
+ return { background: 'transparent', label: palette.main };
22
+ case 'elevated':
23
+ return {
24
+ background: tones.resolve(Tokens.color.surface),
25
+ label: palette.main,
26
+ // Shadows vanish on dark surfaces — a hairline keeps the edge.
27
+ border: tones.isDark ? tones.outline : undefined,
28
+ elevated: true,
29
+ };
30
+ }
31
+ };
32
+ /**
33
+ * How a button sizes itself inside a group: an equal share of a row (the
34
+ * row's width when the group spans its parent, the labels' otherwise), the
35
+ * full width of a column.
36
+ */
37
+ const groupStyle = (group) => {
38
+ if (!group)
39
+ return null;
40
+ if (group.direction === 'column')
41
+ return { alignSelf: 'stretch' };
42
+ if (!group.equal)
43
+ return null;
44
+ return {
45
+ flexGrow: 1,
46
+ flexShrink: 1,
47
+ flexBasis: group.fill ? 0 : 'auto',
48
+ minWidth: 0,
49
+ alignSelf: 'auto',
50
+ };
51
+ };
3
52
  /**
4
53
  * A customizable button component with built-in styling support.
5
54
  *
6
- * The Button component extends React Native's Pressable with additional styling
7
- * capabilities and typography support. It can display a text label and supports
8
- * all standard pressable interactions.
55
+ * Without `variant` the Button is React Native's Pressable plus a label —
56
+ * every colour comes from `styled`. With `variant` it is a themed control:
57
+ * the fill, label colour, outline and elevation follow the project theme and
58
+ * the chosen `tone`, `size` sets the height and label scale, and glyphs,
59
+ * loading and disabled states are built in. Author styles in `styled` still
60
+ * override every part.
9
61
  *
10
62
  * @example
11
63
  * ```tsx
12
64
  * <Button
13
- * label="Click me"
65
+ * label="Continue"
66
+ * variant="filled"
67
+ * size="lg"
68
+ * trailingIconName="arrow-forward"
14
69
  * onPress={() => console.log('Button pressed')}
70
+ * />
71
+ * ```
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * // Bare pressable — the legacy render
76
+ * <Button
77
+ * label="Click me"
15
78
  * styled={{
16
79
  * style: { backgroundColor: 'blue', padding: 16 },
17
80
  * styleTypography: { color: 'white', fontSize: 16 }
@@ -21,14 +84,118 @@ import { StyledPressable, Typography, } from '@mapples/style';
21
84
  *
22
85
  * @public
23
86
  */
24
- const Button = forwardRef(({ label, styled = {}, typographyVariant, ...props }, ref) => {
25
- const { styleTypography, ...styledPressableProps } = styled;
26
- return (<StyledPressable ref={ref} styled={styledPressableProps} {...props}>
27
- {label && (<Typography style={styled?.styleTypography} variant={typographyVariant}>
87
+ const Button = forwardRef(({ label, styled = {}, typographyVariant, variant, size = 'md', tone = 'primary', leadingIconName, trailingIconName, loading = false, disabled = false, fullWidth = false, onPressIn, onPressOut, onHoverIn, onHoverOut, children, ...props }, ref) => {
88
+ const { styleTypography, styleIcon, ...styledPressableProps } = styled;
89
+ const tones = useTones();
90
+ const [pressed, setPressed] = useState(false);
91
+ const [hovered, setHovered] = useState(false);
92
+ const inGroup = groupStyle(useContext(ButtonGroupContext));
93
+ const handlePressIn = useCallback((event) => {
94
+ setPressed(true);
95
+ onPressIn?.(event);
96
+ }, [onPressIn]);
97
+ const handlePressOut = useCallback((event) => {
98
+ setPressed(false);
99
+ onPressOut?.(event);
100
+ }, [onPressOut]);
101
+ const handleHoverIn = useCallback((event) => {
102
+ setHovered(true);
103
+ onHoverIn?.(event);
104
+ }, [onHoverIn]);
105
+ const handleHoverOut = useCallback((event) => {
106
+ setHovered(false);
107
+ onHoverOut?.(event);
108
+ }, [onHoverOut]);
109
+ if (variant === undefined) {
110
+ return (<StyledPressable ref={ref} styled={{
111
+ ...styledPressableProps,
112
+ style: [inGroup, styledPressableProps.style],
113
+ }} disabled={disabled} onPressIn={onPressIn} onPressOut={onPressOut} onHoverIn={onHoverIn} onHoverOut={onHoverOut} {...props}>
114
+ {label && (<Typography style={styleTypography} variant={typographyVariant}>
115
+ {label}
116
+ </Typography>)}
117
+ {children}
118
+ </StyledPressable>);
119
+ }
120
+ const spec = CONTROL_SIZES[size];
121
+ const colors = variantColors(variant, tones.tone(tone), tones);
122
+ const isDisabled = !!disabled;
123
+ const inactive = isDisabled || loading;
124
+ const iconOnly = !label && (!!leadingIconName || !!trailingIconName || loading);
125
+ // An author colour on the label slot also tints the glyphs and the state layer.
126
+ const authoredLabelColor = Styler.flatten(styleTypography)?.color;
127
+ const labelColor = typeof authoredLabelColor === 'string'
128
+ ? tones.resolve(authoredLabelColor)
129
+ : colors.label;
130
+ const showLayer = !inactive && (pressed || hovered);
131
+ const renderGlyph = (iconName) => iconName ? (<Icon iconName={iconName} size={spec.iconSize} color={labelColor} styled={{ styleSvg: styleIcon }}/>) : null;
132
+ return (<StyledPressable ref={ref} accessibilityRole="button" accessibilityState={{ disabled: inactive, busy: loading }} disabled={inactive} onPressIn={handlePressIn} onPressOut={handlePressOut} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut} styled={{
133
+ ...styledPressableProps,
134
+ style: [
135
+ styler.root,
136
+ {
137
+ height: spec.height,
138
+ minWidth: iconOnly ? spec.height : undefined,
139
+ paddingHorizontal: iconOnly
140
+ ? 0
141
+ : variant === 'text'
142
+ ? spec.paddingX - 4
143
+ : spec.paddingX,
144
+ borderRadius: spec.radius,
145
+ backgroundColor: colors.background,
146
+ borderWidth: colors.border ? 1 : 0,
147
+ borderColor: colors.border ?? 'transparent',
148
+ },
149
+ colors.elevated && styler.elevated,
150
+ fullWidth && styler.fullWidth,
151
+ inGroup,
152
+ styledPressableProps.style,
153
+ isDisabled && styler.disabled,
154
+ ],
155
+ }} {...props}>
156
+ {showLayer && (<StyledView pointerEvents="none" styled={{
157
+ style: [
158
+ styler.stateLayer,
159
+ {
160
+ backgroundColor: tones.stateLayer(labelColor, pressed ? 'pressed' : 'hover'),
161
+ borderRadius: spec.radius,
162
+ },
163
+ ],
164
+ }}/>)}
165
+ {loading ? (<ActivityIndicator size="small" color={labelColor}/>) : (renderGlyph(leadingIconName))}
166
+ {!!label && (<Typography variant={typographyVariant ?? spec.labelVariant} numberOfLines={1} style={[{ color: colors.label }, styleTypography]}>
28
167
  {label}
29
168
  </Typography>)}
169
+ {renderGlyph(trailingIconName)}
170
+ {children}
30
171
  </StyledPressable>);
31
172
  });
32
173
  Button.displayName = 'Button';
174
+ const styler = Styler.create({
175
+ root: {
176
+ flexDirection: 'row',
177
+ alignItems: 'center',
178
+ justifyContent: 'center',
179
+ alignSelf: 'flex-start',
180
+ gap: 8,
181
+ overflow: 'hidden',
182
+ },
183
+ elevated: {
184
+ boxShadow: ELEVATION,
185
+ },
186
+ fullWidth: {
187
+ alignSelf: 'stretch',
188
+ },
189
+ disabled: {
190
+ opacity: DISABLED_OPACITY,
191
+ },
192
+ stateLayer: {
193
+ position: 'absolute',
194
+ top: 0,
195
+ left: 0,
196
+ right: 0,
197
+ bottom: 0,
198
+ },
199
+ });
33
200
  export default Button;
34
201
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/inputs/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EACL,eAAe,EAGf,UAAU,GACX,MAAM,gBAAgB,CAAC;AAoBxB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,GAAG,UAAU,CACvB,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,iBAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC3D,MAAM,EAAE,eAAe,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,CAAC;IAE5D,OAAO,CACL,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,CAAC,IAAI,KAAK,CAAC,CACjE;QAAA,CAAC,KAAK,IAAI,CACR,CAAC,UAAU,CACT,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC,CAC/B,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAE3B;YAAA,CAAC,KAAK,CACR;UAAA,EAAE,UAAU,CAAC,CACd,CACH;MAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AACF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAE9B,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/inputs/Button/Button.tsx"],"names":[],"mappings":"AAAA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AAY;QACvB,GAAG,EAAE,CAAC;QACN,QAAQ,EAAE,QAAQ;KACnB;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,SAAS;KACrB;IACD,SAAS,EAAE;QACT,SAAS,EAAE,SAAS;KACrB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,gBAAgB;KAC1B;IACD,UAAU,EAAE;QACV,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What a button group tells the `Button`s inside it. A context rather than a
3
+ * wrapper per child: the buttons size themselves, so the layout is the same
4
+ * wherever the children come from (the editor renders them through its own
5
+ * drop area, not as direct children of the group).
6
+ *
7
+ * @public
8
+ */
9
+ export interface ButtonGroupContextValue {
10
+ /** Main axis of the group. */
11
+ direction: 'row' | 'column';
12
+ /** Each button takes an equal share of the group's main axis. */
13
+ equal: boolean;
14
+ /** The group spans its parent, so shares split that width rather than the labels'. */
15
+ fill: boolean;
16
+ }
17
+ /** @public */
18
+ export declare const ButtonGroupContext: import("react").Context<ButtonGroupContextValue | null>;
19
+ //# sourceMappingURL=ButtonGroupContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonGroupContext.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/Button/ButtonGroupContext.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,SAAS,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC5B,iEAAiE;IACjE,KAAK,EAAE,OAAO,CAAC;IACf,sFAAsF;IACtF,IAAI,EAAE,OAAO,CAAC;CACf;AAED,cAAc;AACd,eAAO,MAAM,kBAAkB,yDAE9B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createContext } from 'react';
2
+ /** @public */
3
+ export const ButtonGroupContext = createContext(null);
4
+ //# sourceMappingURL=ButtonGroupContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonGroupContext.js","sourceRoot":"","sources":["../../../../src/components/inputs/Button/ButtonGroupContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAmBtC,cAAc;AACd,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,IAAI,CACL,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import Button from './Button';
2
2
  export * from './schematics';
3
3
  export * from './Button';
4
+ export * from './ButtonGroupContext';
4
5
  export default Button;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AAEzB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AAErC,eAAe,MAAM,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import Button from './Button';
2
2
  export * from './schematics';
3
3
  export * from './Button';
4
+ export * from './ButtonGroupContext';
4
5
  export default Button;
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/inputs/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AAEzB,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/inputs/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AAErC,eAAe,MAAM,CAAC"}
@@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react';
2
2
  import { StyledProp, StyledProps, SvgStyle, WithStyledProps } from '@mapples/style';
3
3
  import { SvgSource } from '@mapples/types';
4
4
  import { PressableProps, View, ViewProps } from 'react-native';
5
+ import { ControlSize, IconButtonVariant, Tone } from '../../../tokens';
5
6
  /**
6
7
  * Props for the IconButton component.
7
8
  *
@@ -14,34 +15,55 @@ export type IconProps = PropsWithChildren<Omit<WithStyledProps<PressableProps>,
14
15
  styleSvg?: StyledProp<SvgStyle>;
15
16
  };
16
17
  }> & {
17
- /** URI for the SVG icon to display */
18
+ /** URI for the SVG icon to display (legacy vector icons) */
18
19
  uri?: string | SvgSource;
20
+ /**
21
+ * Glyph name from the project icon family. Set, the button renders as a
22
+ * themed icon button (`variant`, `size`, `tone`, toggle state, badge);
23
+ * unset, it renders the legacy `uri` vector exactly as before.
24
+ */
25
+ iconName?: string;
26
+ /** Themed appearance: `standard` (no fill), `filled`, `tonal` or `outlined`. */
27
+ variant?: IconButtonVariant;
28
+ /** Square size: `sm` 36, `md` 44, `lg` 52 points. */
29
+ size?: ControlSize;
30
+ /** Colour role. Defaults to `primary`. */
31
+ tone?: Tone;
32
+ /** Toggle state (controlled). Omit for an uncontrolled toggle, or leave both unset for a plain button. */
33
+ selected?: boolean;
34
+ /** Fires with the next toggle state after a press. */
35
+ onSelectedChange?: (selected: boolean) => void;
36
+ /** Glyph shown while selected (e.g. the filled heart). */
37
+ selectedIconName?: string;
38
+ /** Count pinned to the top-right corner; hidden at 0. */
39
+ badgeCount?: number;
19
40
  };
20
41
  /**
21
- * A customizable icon button component with SVG support.
42
+ * An icon-only button.
22
43
  *
23
- * The IconButton component displays an SVG icon that can be pressed.
24
- * It supports both remote SVG URIs and fallback mock icons, with
25
- * comprehensive styling support for both the button container and the icon.
44
+ * With `iconName` it is a themed control: a square of `size`, painted by
45
+ * `variant` and `tone`, optionally a toggle (`selected`) with its own glyph,
46
+ * and a count badge. With only `uri` it renders the legacy SVG vector.
47
+ * Icon-only controls need an `accessibilityLabel`.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * <IconButton
52
+ * iconName="heart-outline"
53
+ * selectedIconName="heart"
54
+ * variant="standard"
55
+ * selected={liked}
56
+ * onSelectedChange={setLiked}
57
+ * accessibilityLabel="Like"
58
+ * />
59
+ * ```
26
60
  *
27
61
  * @example
28
62
  * ```tsx
29
63
  * <IconButton
30
64
  * uri="https://example.com/icon.svg"
31
65
  * onPress={() => console.log('Icon pressed')}
32
- * styled={{
33
- * style: {
34
- * width: 48,
35
- * height: 48,
36
- * backgroundColor: 'lightblue',
37
- * borderRadius: 24,
38
- * },
39
- * styleSvg: {
40
- * width: 24,
41
- * height: 24,
42
- * color: 'blue',
43
- * },
44
- * }}
66
+ * styled={{ styleSvg: { width: 24, height: 24, color: 'blue' } }}
45
67
  * />
46
68
  * ```
47
69
  *
@@ -56,8 +78,28 @@ declare const IconButton: import("react").ForwardRefExoticComponent<Omit<WithSty
56
78
  } & {
57
79
  children?: import("react").ReactNode | undefined;
58
80
  } & {
59
- /** URI for the SVG icon to display */
81
+ /** URI for the SVG icon to display (legacy vector icons) */
60
82
  uri?: string | SvgSource;
83
+ /**
84
+ * Glyph name from the project icon family. Set, the button renders as a
85
+ * themed icon button (`variant`, `size`, `tone`, toggle state, badge);
86
+ * unset, it renders the legacy `uri` vector exactly as before.
87
+ */
88
+ iconName?: string;
89
+ /** Themed appearance: `standard` (no fill), `filled`, `tonal` or `outlined`. */
90
+ variant?: IconButtonVariant;
91
+ /** Square size: `sm` 36, `md` 44, `lg` 52 points. */
92
+ size?: ControlSize;
93
+ /** Colour role. Defaults to `primary`. */
94
+ tone?: Tone;
95
+ /** Toggle state (controlled). Omit for an uncontrolled toggle, or leave both unset for a plain button. */
96
+ selected?: boolean;
97
+ /** Fires with the next toggle state after a press. */
98
+ onSelectedChange?: (selected: boolean) => void;
99
+ /** Glyph shown while selected (e.g. the filled heart). */
100
+ selectedIconName?: string;
101
+ /** Count pinned to the top-right corner; hidden at 0. */
102
+ badgeCount?: number;
61
103
  } & import("react").RefAttributes<View>>;
62
104
  export default IconButton;
63
105
  //# sourceMappingURL=IconButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/IconButton/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EAIL,UAAU,EACV,WAAW,EACX,QAAQ,EAER,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK/D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,iBAAiB,CACvC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,GAAG;IAChD,kEAAkE;IAClE,MAAM,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,2BAA2B;QAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KACjC,CAAC;CACH,CACF,GAAG;IACF,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,QAAA,MAAM,UAAU;IA3CZ,kEAAkE;aACzD,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,2BAA2B;QAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC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