@mapples/ui 1.1.2 → 1.4.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 (84) 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 +151 -10
  8. package/dist/components/inputs/Button/Button.js.map +1 -1
  9. package/dist/components/inputs/IconButton/IconButton.d.ts +65 -23
  10. package/dist/components/inputs/IconButton/IconButton.d.ts.map +1 -1
  11. package/dist/components/inputs/IconButton/IconButton.js +185 -38
  12. package/dist/components/inputs/IconButton/IconButton.js.map +1 -1
  13. package/dist/components/inputs/TextInput/TextInput.d.ts +5 -0
  14. package/dist/components/inputs/TextInput/TextInput.d.ts.map +1 -1
  15. package/dist/components/inputs/TextInput/TextInput.js +15 -3
  16. package/dist/components/inputs/TextInput/TextInput.js.map +1 -1
  17. package/dist/components/media/BarCode/BarCode.d.ts.map +1 -1
  18. package/dist/components/media/BarCode/BarCode.js +32 -38
  19. package/dist/components/media/BarCode/BarCode.js.map +1 -1
  20. package/dist/components/media/BarCode/BarCodeEncoder.d.ts.map +1 -1
  21. package/dist/components/media/BarCode/BarCodeEncoder.js +22 -3
  22. package/dist/components/media/BarCode/BarCodeEncoder.js.map +1 -1
  23. package/dist/components/media/Icon/Icon.d.ts +43 -24
  24. package/dist/components/media/Icon/Icon.d.ts.map +1 -1
  25. package/dist/components/media/Icon/Icon.js +31 -33
  26. package/dist/components/media/Icon/Icon.js.map +1 -1
  27. package/dist/components/media/Icon/families.d.ts +66 -0
  28. package/dist/components/media/Icon/families.d.ts.map +1 -0
  29. package/dist/components/media/Icon/families.js +316 -0
  30. package/dist/components/media/Icon/families.js.map +1 -0
  31. package/dist/components/media/Icon/index.d.ts +2 -0
  32. package/dist/components/media/Icon/index.d.ts.map +1 -1
  33. package/dist/components/media/Icon/index.js +2 -0
  34. package/dist/components/media/Icon/index.js.map +1 -1
  35. package/dist/components/media/QRCode/QRCode.d.ts.map +1 -1
  36. package/dist/components/media/QRCode/QRCode.js +19 -2
  37. package/dist/components/media/QRCode/QRCode.js.map +1 -1
  38. package/dist/components/media/Vector/MockIcon.d.ts.map +1 -0
  39. package/dist/components/media/Vector/MockIcon.js.map +1 -0
  40. package/dist/components/media/Vector/Vector.d.ts +56 -0
  41. package/dist/components/media/Vector/Vector.d.ts.map +1 -0
  42. package/dist/components/media/Vector/Vector.js +59 -0
  43. package/dist/components/media/Vector/Vector.js.map +1 -0
  44. package/dist/components/media/Vector/index.d.ts +5 -0
  45. package/dist/components/media/Vector/index.d.ts.map +1 -0
  46. package/dist/components/media/Vector/index.js +5 -0
  47. package/dist/components/media/Vector/index.js.map +1 -0
  48. package/dist/components/media/Vector/schematics.d.ts +11 -0
  49. package/dist/components/media/Vector/schematics.d.ts.map +1 -0
  50. package/dist/components/media/Vector/schematics.js +14 -0
  51. package/dist/components/media/Vector/schematics.js.map +1 -0
  52. package/dist/components/media/Video/Video.d.ts +1 -1
  53. package/dist/components/media/Video/Video.d.ts.map +1 -1
  54. package/dist/components/media/Video/Video.js +26 -3
  55. package/dist/components/media/Video/Video.js.map +1 -1
  56. package/dist/components/media/index.d.ts +2 -0
  57. package/dist/components/media/index.d.ts.map +1 -1
  58. package/dist/components/media/index.js +2 -0
  59. package/dist/components/media/index.js.map +1 -1
  60. package/dist/components/media/schematics.d.ts +3 -3
  61. package/dist/components/media/schematics.d.ts.map +1 -1
  62. package/dist/components/media/schematics.js +5 -3
  63. package/dist/components/media/schematics.js.map +1 -1
  64. package/dist/hooks/index.d.ts +3 -0
  65. package/dist/hooks/index.d.ts.map +1 -0
  66. package/dist/hooks/index.js +3 -0
  67. package/dist/hooks/index.js.map +1 -0
  68. package/dist/hooks/useTones.d.ts +54 -0
  69. package/dist/hooks/useTones.d.ts.map +1 -0
  70. package/dist/hooks/useTones.js +79 -0
  71. package/dist/hooks/useTones.js.map +1 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +2 -0
  75. package/dist/index.js.map +1 -1
  76. package/dist/tokens.d.ts +111 -0
  77. package/dist/tokens.d.ts.map +1 -0
  78. package/dist/tokens.js +133 -0
  79. package/dist/tokens.js.map +1 -0
  80. package/package.json +76 -1
  81. package/dist/components/media/Icon/MockIcon.d.ts.map +0 -1
  82. package/dist/components/media/Icon/MockIcon.js.map +0 -1
  83. /package/dist/components/media/{Icon → Vector}/MockIcon.d.ts +0 -0
  84. /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;;;;G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ACZ,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;AAsCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,QAAA,MAAM,MAAM;;wCA8KX,CAAC;AA8BF,eAAe,MAAM,CAAC"}
@@ -1,17 +1,59 @@
1
- import { forwardRef } from 'react';
2
- import { StyledPressable, Typography, } from '@mapples/style';
1
+ import { forwardRef, useCallback, 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
+ const variantColors = (variant, palette, tones) => {
8
+ switch (variant) {
9
+ case 'filled':
10
+ return { background: palette.main, label: palette.contrast };
11
+ case 'tonal':
12
+ return { background: palette.container, label: palette.onContainer };
13
+ case 'outlined':
14
+ return {
15
+ background: 'transparent',
16
+ label: palette.main,
17
+ border: tones.outlineStrong,
18
+ };
19
+ case 'text':
20
+ return { background: 'transparent', label: palette.main };
21
+ case 'elevated':
22
+ return {
23
+ background: tones.resolve(Tokens.color.surface),
24
+ label: palette.main,
25
+ // Shadows vanish on dark surfaces — a hairline keeps the edge.
26
+ border: tones.isDark ? tones.outline : undefined,
27
+ elevated: true,
28
+ };
29
+ }
30
+ };
3
31
  /**
4
32
  * A customizable button component with built-in styling support.
5
33
  *
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.
34
+ * Without `variant` the Button is React Native's Pressable plus a label —
35
+ * every colour comes from `styled`. With `variant` it is a themed control:
36
+ * the fill, label colour, outline and elevation follow the project theme and
37
+ * the chosen `tone`, `size` sets the height and label scale, and glyphs,
38
+ * loading and disabled states are built in. Author styles in `styled` still
39
+ * override every part.
9
40
  *
10
41
  * @example
11
42
  * ```tsx
12
43
  * <Button
13
- * label="Click me"
44
+ * label="Continue"
45
+ * variant="filled"
46
+ * size="lg"
47
+ * trailingIconName="arrow-forward"
14
48
  * onPress={() => console.log('Button pressed')}
49
+ * />
50
+ * ```
51
+ *
52
+ * @example
53
+ * ```tsx
54
+ * // Bare pressable — the legacy render
55
+ * <Button
56
+ * label="Click me"
15
57
  * styled={{
16
58
  * style: { backgroundColor: 'blue', padding: 16 },
17
59
  * styleTypography: { color: 'white', fontSize: 16 }
@@ -21,14 +63,113 @@ import { StyledPressable, Typography, } from '@mapples/style';
21
63
  *
22
64
  * @public
23
65
  */
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}>
66
+ 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) => {
67
+ const { styleTypography, styleIcon, ...styledPressableProps } = styled;
68
+ const tones = useTones();
69
+ const [pressed, setPressed] = useState(false);
70
+ const [hovered, setHovered] = useState(false);
71
+ const handlePressIn = useCallback((event) => {
72
+ setPressed(true);
73
+ onPressIn?.(event);
74
+ }, [onPressIn]);
75
+ const handlePressOut = useCallback((event) => {
76
+ setPressed(false);
77
+ onPressOut?.(event);
78
+ }, [onPressOut]);
79
+ const handleHoverIn = useCallback((event) => {
80
+ setHovered(true);
81
+ onHoverIn?.(event);
82
+ }, [onHoverIn]);
83
+ const handleHoverOut = useCallback((event) => {
84
+ setHovered(false);
85
+ onHoverOut?.(event);
86
+ }, [onHoverOut]);
87
+ if (variant === undefined) {
88
+ return (<StyledPressable ref={ref} styled={styledPressableProps} disabled={disabled} onPressIn={onPressIn} onPressOut={onPressOut} onHoverIn={onHoverIn} onHoverOut={onHoverOut} {...props}>
89
+ {label && (<Typography style={styleTypography} variant={typographyVariant}>
90
+ {label}
91
+ </Typography>)}
92
+ {children}
93
+ </StyledPressable>);
94
+ }
95
+ const spec = CONTROL_SIZES[size];
96
+ const colors = variantColors(variant, tones.tone(tone), tones);
97
+ const isDisabled = !!disabled;
98
+ const inactive = isDisabled || loading;
99
+ const iconOnly = !label && (!!leadingIconName || !!trailingIconName || loading);
100
+ // An author colour on the label slot also tints the glyphs and the state layer.
101
+ const authoredLabelColor = Styler.flatten(styleTypography)?.color;
102
+ const labelColor = typeof authoredLabelColor === 'string'
103
+ ? tones.resolve(authoredLabelColor)
104
+ : colors.label;
105
+ const showLayer = !inactive && (pressed || hovered);
106
+ const renderGlyph = (iconName) => iconName ? (<Icon iconName={iconName} size={spec.iconSize} color={labelColor} styled={{ styleSvg: styleIcon }}/>) : null;
107
+ return (<StyledPressable ref={ref} accessibilityRole="button" accessibilityState={{ disabled: inactive, busy: loading }} disabled={inactive} onPressIn={handlePressIn} onPressOut={handlePressOut} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut} styled={{
108
+ ...styledPressableProps,
109
+ style: [
110
+ styler.root,
111
+ {
112
+ height: spec.height,
113
+ minWidth: iconOnly ? spec.height : undefined,
114
+ paddingHorizontal: iconOnly
115
+ ? 0
116
+ : variant === 'text'
117
+ ? spec.paddingX - 4
118
+ : spec.paddingX,
119
+ borderRadius: spec.radius,
120
+ backgroundColor: colors.background,
121
+ borderWidth: colors.border ? 1 : 0,
122
+ borderColor: colors.border ?? 'transparent',
123
+ },
124
+ colors.elevated && styler.elevated,
125
+ fullWidth && styler.fullWidth,
126
+ styledPressableProps.style,
127
+ isDisabled && styler.disabled,
128
+ ],
129
+ }} {...props}>
130
+ {showLayer && (<StyledView pointerEvents="none" styled={{
131
+ style: [
132
+ styler.stateLayer,
133
+ {
134
+ backgroundColor: tones.stateLayer(labelColor, pressed ? 'pressed' : 'hover'),
135
+ borderRadius: spec.radius,
136
+ },
137
+ ],
138
+ }}/>)}
139
+ {loading ? (<ActivityIndicator size="small" color={labelColor}/>) : (renderGlyph(leadingIconName))}
140
+ {!!label && (<Typography variant={typographyVariant ?? spec.labelVariant} numberOfLines={1} style={[{ color: colors.label }, styleTypography]}>
28
141
  {label}
29
142
  </Typography>)}
143
+ {renderGlyph(trailingIconName)}
144
+ {children}
30
145
  </StyledPressable>);
31
146
  });
32
147
  Button.displayName = 'Button';
148
+ const styler = Styler.create({
149
+ root: {
150
+ flexDirection: 'row',
151
+ alignItems: 'center',
152
+ justifyContent: 'center',
153
+ alignSelf: 'flex-start',
154
+ gap: 8,
155
+ overflow: 'hidden',
156
+ },
157
+ elevated: {
158
+ boxShadow: ELEVATION,
159
+ },
160
+ fullWidth: {
161
+ alignSelf: 'stretch',
162
+ },
163
+ disabled: {
164
+ opacity: DISABLED_OPACITY,
165
+ },
166
+ stateLayer: {
167
+ position: 'absolute',
168
+ top: 0,
169
+ left: 0,
170
+ right: 0,
171
+ bottom: 0,
172
+ },
173
+ });
33
174
  export default Button;
34
175
  //# 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,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rB;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"}
@@ -1,7 +1,8 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import { StyledProp, StyledProps, WithStyledProps } from '@mapples/style';
2
+ import { StyledProp, StyledProps, SvgStyle, WithStyledProps } from '@mapples/style';
3
3
  import { SvgSource } from '@mapples/types';
4
- import { PressableProps, TextStyle, View, ViewProps } from 'react-native';
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
  *
@@ -11,37 +12,58 @@ export type IconProps = PropsWithChildren<Omit<WithStyledProps<PressableProps>,
11
12
  /** Styling configuration for the button container and SVG icon */
12
13
  styled?: StyledProps<ViewProps> & {
13
14
  /** SVG-specific styling */
14
- styleSvg?: StyledProp<TextStyle>;
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
  *
@@ -51,13 +73,33 @@ declare const IconButton: import("react").ForwardRefExoticComponent<Omit<WithSty
51
73
  /** Styling configuration for the button container and SVG icon */
52
74
  styled?: StyledProps<ViewProps> & {
53
75
  /** SVG-specific styling */
54
- styleSvg?: StyledProp<TextStyle>;
76
+ styleSvg?: StyledProp<SvgStyle>;
55
77
  };
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,EAEX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK1E;;;;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,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