@mapples/ui 1.1.3 → 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 (81) 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 +61 -19
  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/BarCodeEncoder.d.ts.map +1 -1
  18. package/dist/components/media/BarCode/BarCodeEncoder.js +22 -3
  19. package/dist/components/media/BarCode/BarCodeEncoder.js.map +1 -1
  20. package/dist/components/media/Icon/Icon.d.ts +40 -21
  21. package/dist/components/media/Icon/Icon.d.ts.map +1 -1
  22. package/dist/components/media/Icon/Icon.js +31 -33
  23. package/dist/components/media/Icon/Icon.js.map +1 -1
  24. package/dist/components/media/Icon/families.d.ts +66 -0
  25. package/dist/components/media/Icon/families.d.ts.map +1 -0
  26. package/dist/components/media/Icon/families.js +316 -0
  27. package/dist/components/media/Icon/families.js.map +1 -0
  28. package/dist/components/media/Icon/index.d.ts +2 -0
  29. package/dist/components/media/Icon/index.d.ts.map +1 -1
  30. package/dist/components/media/Icon/index.js +2 -0
  31. package/dist/components/media/Icon/index.js.map +1 -1
  32. package/dist/components/media/QRCode/QRCode.d.ts.map +1 -1
  33. package/dist/components/media/QRCode/QRCode.js +19 -2
  34. package/dist/components/media/QRCode/QRCode.js.map +1 -1
  35. package/dist/components/media/Vector/MockIcon.d.ts.map +1 -0
  36. package/dist/components/media/Vector/MockIcon.js.map +1 -0
  37. package/dist/components/media/Vector/Vector.d.ts +56 -0
  38. package/dist/components/media/Vector/Vector.d.ts.map +1 -0
  39. package/dist/components/media/Vector/Vector.js +59 -0
  40. package/dist/components/media/Vector/Vector.js.map +1 -0
  41. package/dist/components/media/Vector/index.d.ts +5 -0
  42. package/dist/components/media/Vector/index.d.ts.map +1 -0
  43. package/dist/components/media/Vector/index.js +5 -0
  44. package/dist/components/media/Vector/index.js.map +1 -0
  45. package/dist/components/media/Vector/schematics.d.ts +11 -0
  46. package/dist/components/media/Vector/schematics.d.ts.map +1 -0
  47. package/dist/components/media/Vector/schematics.js +14 -0
  48. package/dist/components/media/Vector/schematics.js.map +1 -0
  49. package/dist/components/media/Video/Video.d.ts +1 -1
  50. package/dist/components/media/Video/Video.d.ts.map +1 -1
  51. package/dist/components/media/Video/Video.js +26 -3
  52. package/dist/components/media/Video/Video.js.map +1 -1
  53. package/dist/components/media/index.d.ts +2 -0
  54. package/dist/components/media/index.d.ts.map +1 -1
  55. package/dist/components/media/index.js +2 -0
  56. package/dist/components/media/index.js.map +1 -1
  57. package/dist/components/media/schematics.d.ts +3 -3
  58. package/dist/components/media/schematics.d.ts.map +1 -1
  59. package/dist/components/media/schematics.js +5 -3
  60. package/dist/components/media/schematics.js.map +1 -1
  61. package/dist/hooks/index.d.ts +3 -0
  62. package/dist/hooks/index.d.ts.map +1 -0
  63. package/dist/hooks/index.js +3 -0
  64. package/dist/hooks/index.js.map +1 -0
  65. package/dist/hooks/useTones.d.ts +54 -0
  66. package/dist/hooks/useTones.d.ts.map +1 -0
  67. package/dist/hooks/useTones.js +79 -0
  68. package/dist/hooks/useTones.js.map +1 -0
  69. package/dist/index.d.ts +2 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2 -0
  72. package/dist/index.js.map +1 -1
  73. package/dist/tokens.d.ts +111 -0
  74. package/dist/tokens.d.ts.map +1 -0
  75. package/dist/tokens.js +133 -0
  76. package/dist/tokens.js.map +1 -0
  77. package/package.json +76 -1
  78. package/dist/components/media/Icon/MockIcon.d.ts.map +0 -1
  79. package/dist/components/media/Icon/MockIcon.js.map +0 -1
  80. /package/dist/components/media/{Icon → Vector}/MockIcon.d.ts +0 -0
  81. /package/dist/components/media/{Icon → Vector}/MockIcon.js +0 -0
@@ -1,66 +1,213 @@
1
- import { forwardRef } from 'react';
2
- import { styled as makeStyled, styled, StyledPressable, Styler, } from '@mapples/style';
1
+ import { forwardRef, useCallback, useState, } from 'react';
2
+ import { styled as makeStyled, styled, StyledPressable, StyledView, Styler, Typography, } from '@mapples/style';
3
3
  import { SvgUri } from 'react-native-svg';
4
+ import useTones from '../../../hooks/useTones';
5
+ import { CONTROL_SIZES, DISABLED_OPACITY, } from '../../../tokens';
6
+ import Icon from '../../media/Icon';
4
7
  import MockIcon from './MockIcon';
5
8
  const StyledSvgUri = styled(SvgUri);
9
+ const BADGE_MAX = 99;
6
10
  /**
7
- * A customizable icon button component with SVG support.
11
+ * An icon-only button.
8
12
  *
9
- * The IconButton component displays an SVG icon that can be pressed.
10
- * It supports both remote SVG URIs and fallback mock icons, with
11
- * comprehensive styling support for both the button container and the icon.
13
+ * With `iconName` it is a themed control: a square of `size`, painted by
14
+ * `variant` and `tone`, optionally a toggle (`selected`) with its own glyph,
15
+ * and a count badge. With only `uri` it renders the legacy SVG vector.
16
+ * Icon-only controls need an `accessibilityLabel`.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * <IconButton
21
+ * iconName="heart-outline"
22
+ * selectedIconName="heart"
23
+ * variant="standard"
24
+ * selected={liked}
25
+ * onSelectedChange={setLiked}
26
+ * accessibilityLabel="Like"
27
+ * />
28
+ * ```
12
29
  *
13
30
  * @example
14
31
  * ```tsx
15
32
  * <IconButton
16
33
  * uri="https://example.com/icon.svg"
17
34
  * onPress={() => console.log('Icon pressed')}
18
- * styled={{
19
- * style: {
20
- * width: 48,
21
- * height: 48,
22
- * backgroundColor: 'lightblue',
23
- * borderRadius: 24,
24
- * },
25
- * styleSvg: {
26
- * width: 24,
27
- * height: 24,
28
- * color: 'blue',
29
- * },
30
- * }}
35
+ * styled={{ styleSvg: { width: 24, height: 24, color: 'blue' } }}
31
36
  * />
32
37
  * ```
33
38
  *
34
39
  * @public
35
40
  */
36
- const IconButton = forwardRef(({ styled, uri, ...props }, ref) => {
41
+ const IconButton = forwardRef(({ styled, uri, iconName, variant = 'standard', size = 'md', tone = 'primary', selected, onSelectedChange, selectedIconName, badgeCount, disabled = false, onPress, onPressIn, onPressOut, onHoverIn, onHoverOut, children, ...props }, ref) => {
37
42
  const { styleSvg, ...styledViewProps } = styled || {};
43
+ const tones = useTones();
44
+ const [pressed, setPressed] = useState(false);
45
+ const [hovered, setHovered] = useState(false);
46
+ const [internalSelected, setInternalSelected] = useState(false);
38
47
  const ejectStyle = Styler.flatten(styleSvg);
39
- const getUriComponent = (Uri) => {
40
- const StyledSvg = makeStyled(Uri.default);
41
- return (<StyledSvg styled={{
42
- width: ejectStyle?.width,
43
- height: ejectStyle?.height,
44
- color: ejectStyle?.color,
45
- style: styleSvg,
46
- }}/>);
47
- };
48
- return (<StyledPressable ref={ref} styled={styledViewProps} {...props}>
49
- {uri ? (<>
50
- {typeof uri === 'string' ? (<StyledSvgUri uri={uri} styled={{
48
+ const isToggle = selected !== undefined || !!onSelectedChange;
49
+ const isSelected = selected ?? internalSelected;
50
+ const handlePress = useCallback((event) => {
51
+ if (isToggle) {
52
+ const next = !isSelected;
53
+ if (selected === undefined)
54
+ setInternalSelected(next);
55
+ onSelectedChange?.(next);
56
+ }
57
+ onPress?.(event);
58
+ }, [isSelected, isToggle, onPress, onSelectedChange, selected]);
59
+ const handlePressIn = useCallback((event) => {
60
+ setPressed(true);
61
+ onPressIn?.(event);
62
+ }, [onPressIn]);
63
+ const handlePressOut = useCallback((event) => {
64
+ setPressed(false);
65
+ onPressOut?.(event);
66
+ }, [onPressOut]);
67
+ const handleHoverIn = useCallback((event) => {
68
+ setHovered(true);
69
+ onHoverIn?.(event);
70
+ }, [onHoverIn]);
71
+ const handleHoverOut = useCallback((event) => {
72
+ setHovered(false);
73
+ onHoverOut?.(event);
74
+ }, [onHoverOut]);
75
+ if (iconName === undefined) {
76
+ const getUriComponent = (Uri) => {
77
+ const StyledSvg = makeStyled(Uri.default);
78
+ return (<StyledSvg styled={{
51
79
  width: ejectStyle?.width,
52
80
  height: ejectStyle?.height,
53
81
  color: ejectStyle?.color,
54
82
  style: styleSvg,
55
- }}/>) : (getUriComponent(uri))}
56
- </>) : (<MockIcon styled={{
57
- width: ejectStyle?.width,
58
- height: ejectStyle?.height,
59
- color: ejectStyle?.color,
60
- style: styleSvg,
83
+ }}/>);
84
+ };
85
+ return (<StyledPressable ref={ref} styled={styledViewProps} disabled={disabled} onPress={onPress} onPressIn={onPressIn} onPressOut={onPressOut} onHoverIn={onHoverIn} onHoverOut={onHoverOut} {...props}>
86
+ {uri ? (<>
87
+ {typeof uri === 'string' ? (<StyledSvgUri uri={uri} styled={{
88
+ width: ejectStyle?.width,
89
+ height: ejectStyle?.height,
90
+ color: ejectStyle?.color,
91
+ style: styleSvg,
92
+ }}/>) : (getUriComponent(uri))}
93
+ </>) : (<MockIcon styled={{
94
+ width: ejectStyle?.width,
95
+ height: ejectStyle?.height,
96
+ color: ejectStyle?.color,
97
+ style: styleSvg,
98
+ }}/>)}
99
+ {children}
100
+ </StyledPressable>);
101
+ }
102
+ const spec = CONTROL_SIZES[size];
103
+ const palette = tones.tone(tone);
104
+ const text = tones.resolve('theme.text.primary');
105
+ const isDisabled = !!disabled;
106
+ let background = 'transparent';
107
+ let glyph = text;
108
+ let border;
109
+ switch (variant) {
110
+ case 'filled':
111
+ background = palette.main;
112
+ glyph = palette.contrast;
113
+ break;
114
+ case 'tonal':
115
+ background = palette.container;
116
+ glyph = isSelected ? palette.main : palette.onContainer;
117
+ break;
118
+ case 'outlined':
119
+ border = tones.outlineStrong;
120
+ background = isSelected ? palette.container : 'transparent';
121
+ glyph = isSelected ? palette.main : text;
122
+ break;
123
+ default:
124
+ background = isSelected ? palette.container : 'transparent';
125
+ glyph = isSelected ? palette.main : text;
126
+ }
127
+ const authoredGlyph = ejectStyle?.color;
128
+ const glyphColor = typeof authoredGlyph === 'string' ? tones.resolve(authoredGlyph) : glyph;
129
+ const glyphSize = ejectStyle?.width ?? spec.iconSize + 4;
130
+ const showLayer = !isDisabled && (pressed || hovered);
131
+ const badge = typeof badgeCount === 'number' && badgeCount > 0
132
+ ? badgeCount > BADGE_MAX
133
+ ? `${BADGE_MAX}+`
134
+ : String(badgeCount)
135
+ : null;
136
+ return (<StyledPressable ref={ref} accessibilityRole="button" accessibilityState={{
137
+ disabled: isDisabled,
138
+ selected: isToggle ? isSelected : undefined,
139
+ }} disabled={isDisabled} onPress={handlePress} onPressIn={handlePressIn} onPressOut={handlePressOut} onHoverIn={handleHoverIn} onHoverOut={handleHoverOut} styled={{
140
+ ...styledViewProps,
141
+ style: [
142
+ styler.root,
143
+ {
144
+ width: spec.height,
145
+ height: spec.height,
146
+ borderRadius: spec.height / 2,
147
+ backgroundColor: background,
148
+ borderWidth: border ? 1 : 0,
149
+ borderColor: border ?? 'transparent',
150
+ },
151
+ styledViewProps.style,
152
+ isDisabled && styler.disabled,
153
+ ],
154
+ }} {...props}>
155
+ {showLayer && (<StyledView pointerEvents="none" styled={{
156
+ style: [
157
+ styler.stateLayer,
158
+ {
159
+ backgroundColor: tones.stateLayer(glyphColor, pressed ? 'pressed' : 'hover'),
160
+ borderRadius: spec.height / 2,
161
+ },
162
+ ],
61
163
  }}/>)}
164
+ <Icon iconName={isSelected && selectedIconName ? selectedIconName : iconName} size={glyphSize} color={glyphColor} styled={{ styleSvg }}/>
165
+ {badge !== null && (<StyledView pointerEvents="none" styled={{
166
+ style: [
167
+ styler.badge,
168
+ { backgroundColor: tones.tone('error').main },
169
+ ],
170
+ }}>
171
+ <Typography variant="Caption" color={tones.tone('error').contrast} style={styler.badgeText}>
172
+ {badge}
173
+ </Typography>
174
+ </StyledView>)}
175
+ {children}
62
176
  </StyledPressable>);
63
177
  });
64
178
  IconButton.displayName = 'IconButton';
179
+ const styler = Styler.create({
180
+ root: {
181
+ alignItems: 'center',
182
+ justifyContent: 'center',
183
+ alignSelf: 'flex-start',
184
+ },
185
+ disabled: {
186
+ opacity: DISABLED_OPACITY,
187
+ },
188
+ stateLayer: {
189
+ position: 'absolute',
190
+ top: 0,
191
+ left: 0,
192
+ right: 0,
193
+ bottom: 0,
194
+ },
195
+ badge: {
196
+ position: 'absolute',
197
+ top: 0,
198
+ right: 0,
199
+ minWidth: 16,
200
+ height: 16,
201
+ borderRadius: 8,
202
+ paddingHorizontal: 4,
203
+ alignItems: 'center',
204
+ justifyContent: 'center',
205
+ },
206
+ badgeText: {
207
+ fontSize: 10,
208
+ lineHeight: 12,
209
+ fontWeight: '700',
210
+ },
211
+ });
65
212
  export default IconButton;
66
213
  //# sourceMappingURL=IconButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../../src/components/inputs/IconButton/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAqB,MAAM,OAAO,CAAC;AAErE,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,MAAM,EACN,eAAe,EAIf,MAAM,GAEP,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAY,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAoBlC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;gBACN,KAAK,EAAE,UAAU,EAAE,KAAwB;gBAC3C,MAAM,EAAE,UAAU,EAAE,MAAyB;gBAC7C,KAAK,EAAE,UAAU,EAAE,KAAK;gBACxB,KAAK,EAAE,QAAQ;aAChB,CAAC,EACF,CACH,CACH;MAAA,EAAE,eAAe,CAAC,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AACF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AAEtC,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../../../src/components/inputs/IconButton/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,WAAW,EACX,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,MAAM,EACN,eAAe,EAGf,UAAU,EAEV,MAAM,EACN,UAAU,GAEX,MAAM,gBAAgB,CAAC;AASxB,OAAO,EAAY,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EACL,aAAa,EAEb,gBAAgB,GAGjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAwClC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAEpC,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,GAAG,UAAU,CAC3B,CACE,EACE,MAAM,EACN,GAAG,EACH,QAAQ,EACR,OAAO,GAAG,UAAU,EACpB,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,SAAS,EAChB,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,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K,EAAE;QACL,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC;QACN,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC;QACf,iBAAiB,EAAE,CAAC;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,KAAK;KAClB;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
@@ -6,6 +6,11 @@ import { TextInputProps, TextInput as RNTextInput } from 'react-native';
6
6
  * capabilities through the @mapples/style system. It supports all standard
7
7
  * TextInput properties and behaviors.
8
8
  *
9
+ * The text is always passed to the native input as a string: while `value` is
10
+ * undefined the component keeps the typed text itself, so a data binding that
11
+ * resolves later (page variables register after the first render) does not
12
+ * flip the input from uncontrolled to controlled.
13
+ *
9
14
  * @example
10
15
  * ```tsx
11
16
  * <TextInput
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/TextInput/TextInput.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,SAAS;;+CAId,CAAC;AAGF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/components/inputs/TextInput/TextInput.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,QAAA,MAAM,SAAS;;+CAsBd,CAAC;AAGF,eAAe,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react';
1
+ import { forwardRef, useCallback, useState } from 'react';
2
2
  import { StyledTextInput } from '@mapples/style';
3
3
  /**
4
4
  * A customizable text input component with built-in styling support.
@@ -7,6 +7,11 @@ import { StyledTextInput } from '@mapples/style';
7
7
  * capabilities through the @mapples/style system. It supports all standard
8
8
  * TextInput properties and behaviors.
9
9
  *
10
+ * The text is always passed to the native input as a string: while `value` is
11
+ * undefined the component keeps the typed text itself, so a data binding that
12
+ * resolves later (page variables register after the first render) does not
13
+ * flip the input from uncontrolled to controlled.
14
+ *
10
15
  * @example
11
16
  * ```tsx
12
17
  * <TextInput
@@ -26,8 +31,15 @@ import { StyledTextInput } from '@mapples/style';
26
31
  *
27
32
  * @public
28
33
  */
29
- const TextInput = forwardRef(({ children, ...props }, ref) => {
30
- return <StyledTextInput ref={ref} {...props}/>;
34
+ const TextInput = forwardRef(({ children, value, defaultValue, onChangeText, ...props }, ref) => {
35
+ const [internal, setInternal] = useState(defaultValue ?? '');
36
+ const controlled = value !== undefined;
37
+ const handleChangeText = useCallback((next) => {
38
+ if (!controlled)
39
+ setInternal(next);
40
+ onChangeText?.(next);
41
+ }, [controlled, onChangeText]);
42
+ return (<StyledTextInput ref={ref} {...props} value={controlled ? value : internal} onChangeText={handleChangeText}/>);
31
43
  });
32
44
  TextInput.displayName = 'TextInput';
33
45
  export default TextInput;
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../../src/components/inputs/TextInput/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,SAAS,GAAG,UAAU,CAC1B,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC9B,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CA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@ -1 +1 @@
1
- {"version":3,"file":"BarCodeEncoder.d.ts","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,GACN,KAAK,GACL,OAAO,GACP,KAAK,GACL,YAAY,GACZ,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IACE,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd,GACD,qBAAqB,EAAE,CAAC;AA0D5B;;GAEG;AACH,cAAM,cAAc;IAClB;;;;;;;;OAQG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,oBAAyB,GACjC,cAAc;IA6DjB;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE;CAGhC;;AAED,wBAAoC"}
1
+ {"version":3,"file":"BarCodeEncoder.d.ts","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAuBA;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,GACN,KAAK,GACL,OAAO,GACP,KAAK,GACL,YAAY,GACZ,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IACE,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd,GACD,qBAAqB,EAAE,CAAC;AA0D5B;;GAEG;AACH,cAAM,cAAc;IAClB;;;;;;;;OAQG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE,oBAAyB,GACjC,cAAc;IAsEjB;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE;CAGhC;;AAED,wBAAoC"}
@@ -1,5 +1,23 @@
1
- // @ts-expect-error - jsbarcode/src/barcodes doesn't have type definitions
2
- import barcodes from 'jsbarcode/src/barcodes';
1
+ /**
2
+ * `jsbarcode` is an **optional peer dependency** of `@mapples/ui` (Project
3
+ * settings → Packages → "Barcode"): resolved lazily so apps without a barcode
4
+ * element don't have to install it. When absent, encoding throws.
5
+ */
6
+ let barcodes = null;
7
+ try {
8
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
9
+ barcodes = require('jsbarcode/src/barcodes').default;
10
+ }
11
+ catch {
12
+ barcodes = null;
13
+ }
14
+ const requireBarcodes = () => {
15
+ if (!barcodes) {
16
+ throw new Error('BarCode needs jsbarcode: enable the "Barcode" package in Project ' +
17
+ 'settings → Packages.');
18
+ }
19
+ return barcodes;
20
+ };
3
21
  /**
4
22
  * Maps format names to jsbarcode format names
5
23
  * Some formats might have different names in jsbarcode
@@ -61,6 +79,7 @@ class BarcodeEncoder {
61
79
  * @throws Error if text is invalid, format is not supported, or encoding fails
62
80
  */
63
81
  encode(text, format, options = {}) {
82
+ const barcodes = requireBarcodes();
64
83
  // Find the correct format name in jsbarcode
65
84
  const jsbarcodeFormat = findFormat(format, barcodes);
66
85
  if (!jsbarcodeFormat) {
@@ -105,7 +124,7 @@ class BarcodeEncoder {
105
124
  * Gets list of available barcode formats
106
125
  */
107
126
  getAvailableFormats() {
108
- return Object.keys(barcodes);
127
+ return Object.keys(requireBarcodes());
109
128
  }
110
129
  }
111
130
  export default new BarcodeEncoder();
@@ -1 +1 @@
1
- {"version":3,"file":"BarCodeEncoder.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAmD9C;;;GAGG;AACH,MAAM,UAAU,GAAkC;IAChD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK,EAAE,mCAAmC;IAC/C,KAAK,EAAE,OAAO,EAAE,mCAAmC;IACnD,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,MAAqB,EACrB,QAAiC,EAClB,EAAE;IACjB,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACzC,KAAK,MAAM,GAAG,IAAI,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 {"version":3,"file":"BarCodeEncoder.js","sourceRoot":"","sources":["../../../../src/components/media/BarCode/BarCodeEncoder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,IAAI,QAAQ,GAAmC,IAAI,CAAC;AACpD,IAAI,CAAC;IACH,iEAAiE;IACjE,QAAQ,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC;AACvD,CAAC;AAAC,MAAM,CAAC;IACP,QAAQ,GAAG,IAAI,CAAC;AAClB,CAAC;AAED,MAAM,eAAe,GAAG,GAA4B,EAAE;IACpD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,mEAAmE;YACjE,sBAAsB,CACzB,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAmDF;;;GAGG;AACH,MAAM,UAAU,GAAkC;IAChD,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK,EAAE,mCAAmC;IAC/C,KAAK,EAAE,OAAO,EAAE,mCAAmC;IACnD,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,MAAqB,EACrB,QAAiC,EAClB,EAAE;IACjB,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACzC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC;YACtC,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,qB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mapples/style';
3
- import { SvgSource } from '@mapples/types';
4
- import { View, ViewProps } from 'react-native';
3
+ import { ColorValue, View, ViewProps } from 'react-native';
4
+ import { IconFamilyKey } from './families';
5
5
  /**
6
6
  * Props for the Icon component.
7
7
  *
8
8
  * @public
9
9
  */
10
10
  export type IconProps = PropsWithChildren<Omit<WithStyledProps<ViewProps>, 'styled'> & {
11
- /** Styling configuration for the icon container and SVG */
11
+ /** Styling configuration for the icon container and glyph */
12
12
  styled?: StyledProps<ViewProps> & {
13
- /** SVG-specific styling (width, height, color) */
13
+ /** Glyph-specific styling (width, height, color) */
14
14
  styleSvg?: StyledProp<SvgStyle>;
15
15
  };
16
16
  }> & {
17
- /** URI of the SVG icon — either a remote URL string or a local `SvgSource` module reference */
18
- uri?: string | SvgSource;
17
+ /**
18
+ * Icon family override for direct (chrome/chat) use. Canvas elements leave
19
+ * this unset — the family then comes from the project style config
20
+ * (`themeConfig.icons.family`), set in the styles modal.
21
+ */
22
+ iconStyle?: IconFamilyKey;
23
+ /** Glyph name within the selected family */
24
+ iconName?: string;
25
+ /** Glyph font size — overrides the `styleSvg` width for direct use */
26
+ size?: number;
27
+ /** Glyph color — theme tokens allowed, overrides the `styleSvg` color */
28
+ color?: ColorValue;
19
29
  };
20
30
  /**
21
- * Renders an SVG icon from a URI or falls back to a placeholder `MockIcon`.
22
- *
23
- * Accepts either a remote URL string or a local `SvgSource` module reference
24
- * via the `uri` prop. When no `uri` is provided the `MockIcon` placeholder is
25
- * shown instead, which is useful during development or when the icon asset is
26
- * optional.
31
+ * Renders a font glyph from one of the bundled `@react-native-vector-icons`
32
+ * families. The family comes from the project style config
33
+ * (`themeConfig.icons.family`) unless overridden per instance via `iconStyle`;
34
+ * the glyph is selected by `iconName`. Without a family or a name the
35
+ * `MockIcon` placeholder is shown; a family whose package is not installed
36
+ * (every pack is an optional peer) throws.
27
37
  *
28
38
  * @example
29
39
  * ```tsx
30
- * // Remote URL
40
+ * // Canvas usage — family from the project style config
31
41
  * <Icon
32
- * uri="https://example.com/icon.svg"
42
+ * iconName="star"
33
43
  * styled={{ styleSvg: { width: 24, height: 24, color: '#333' } }}
34
44
  * />
35
45
  *
36
- * // Local SVG module
37
- * import MyIcon from './my-icon.svg';
38
- * <Icon uri={MyIcon} styled={{ styleSvg: { width: 24, height: 24 } }} />
46
+ * // Direct usage — chrome/chat surfaces pin the family
47
+ * <Icon iconStyle="ionicons" iconName="close" size={14} color="theme.text.tertiary" />
39
48
  * ```
40
49
  *
41
50
  * @public
42
51
  */
43
52
  declare const Icon: import("react").ForwardRefExoticComponent<Omit<WithStyledProps<ViewProps>, "styled"> & {
44
- /** Styling configuration for the icon container and SVG */
53
+ /** Styling configuration for the icon container and glyph */
45
54
  styled?: StyledProps<ViewProps> & {
46
- /** SVG-specific styling (width, height, color) */
55
+ /** Glyph-specific styling (width, height, color) */
47
56
  styleSvg?: StyledProp<SvgStyle>;
48
57
  };
49
58
  } & {
50
59
  children?: import("react").ReactNode | undefined;
51
60
  } & {
52
- /** URI of the SVG icon — either a remote URL string or a local `SvgSource` module reference */
53
- uri?: string | SvgSource;
61
+ /**
62
+ * Icon family override for direct (chrome/chat) use. Canvas elements leave
63
+ * this unset — the family then comes from the project style config
64
+ * (`themeConfig.icons.family`), set in the styles modal.
65
+ */
66
+ iconStyle?: IconFamilyKey;
67
+ /** Glyph name within the selected family */
68
+ iconName?: string;
69
+ /** Glyph font size — overrides the `styleSvg` width for direct use */
70
+ size?: number;
71
+ /** Glyph color — theme tokens allowed, overrides the `styleSvg` color */
72
+ color?: ColorValue;
54
73
  } & import("react").RefAttributes<View>>;
55
74
  export default Icon;
56
75
  //# sourceMappingURL=Icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.d.ts","sourceRoot":"","sources":["../../../../src/components/media/Icon/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAErE,OAAO,EAEL,UAAU,EACV,WAAW,EACX,QAAQ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E,QAAQ,CAAC,GAAG;IAC3C,6DAA6D;IAC7D,MAAM,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,oDAAoD;QACpD,QAAQ,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KACjC,CAAC;CACH,CACF,GAAG;IACF;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,IAAI;IA3CN,6DAA6D;aACpD,WAAW,CAAC,SAAS,CAAC,GAAG;QAChC,oDAAoD;QACpD,QAAQ,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KACjC;;;;IAGH;;;;OAIG;gBACS,aAAa;IACzB,4CAA4C;eACjC,MAAM;IACjB,sEAAsE;WAC/D,MAAM;IACb,yEAAyE;YACjE,UAAU;wCAqEnB,CAAC;AAGF,eAAe,IAAI,CAAC"}
@@ -1,52 +1,50 @@
1
1
  import { forwardRef } from 'react';
2
- import { styled as makeStyled, StyledView, Styler, } from '@mapples/style';
3
- import { SvgUri } from 'react-native-svg';
4
- import MockIcon from './MockIcon';
5
- const StyledSvgUri = makeStyled(SvgUri);
2
+ import { StyledView, Styler, useStyle, } from '@mapples/style';
3
+ import MockIcon from '../Vector/MockIcon';
4
+ import { IconFamilies } from './families';
6
5
  /**
7
- * Renders an SVG icon from a URI or falls back to a placeholder `MockIcon`.
8
- *
9
- * Accepts either a remote URL string or a local `SvgSource` module reference
10
- * via the `uri` prop. When no `uri` is provided the `MockIcon` placeholder is
11
- * shown instead, which is useful during development or when the icon asset is
12
- * optional.
6
+ * Renders a font glyph from one of the bundled `@react-native-vector-icons`
7
+ * families. The family comes from the project style config
8
+ * (`themeConfig.icons.family`) unless overridden per instance via `iconStyle`;
9
+ * the glyph is selected by `iconName`. Without a family or a name the
10
+ * `MockIcon` placeholder is shown; a family whose package is not installed
11
+ * (every pack is an optional peer) throws.
13
12
  *
14
13
  * @example
15
14
  * ```tsx
16
- * // Remote URL
15
+ * // Canvas usage — family from the project style config
17
16
  * <Icon
18
- * uri="https://example.com/icon.svg"
17
+ * iconName="star"
19
18
  * styled={{ styleSvg: { width: 24, height: 24, color: '#333' } }}
20
19
  * />
21
20
  *
22
- * // Local SVG module
23
- * import MyIcon from './my-icon.svg';
24
- * <Icon uri={MyIcon} styled={{ styleSvg: { width: 24, height: 24 } }} />
21
+ * // Direct usage — chrome/chat surfaces pin the family
22
+ * <Icon iconStyle="ionicons" iconName="close" size={14} color="theme.text.tertiary" />
25
23
  * ```
26
24
  *
27
25
  * @public
28
26
  */
29
- const Icon = forwardRef(({ styled, uri, ...props }, ref) => {
27
+ const Icon = forwardRef(({ styled, iconStyle, iconName, size, color, ...props }, ref) => {
28
+ const { themeConfig } = useStyle();
30
29
  const { styleSvg, ...styledViewProps } = styled || {};
31
30
  const ejectStyle = Styler.flatten(styleSvg);
32
- const getUriComponent = (Uri) => {
33
- const StyledSvg = makeStyled(Uri.default);
34
- return (<StyledSvg styled={{
35
- width: ejectStyle?.width,
36
- height: ejectStyle?.height,
37
- color: ejectStyle?.color,
38
- style: styleSvg,
39
- }}/>);
40
- };
31
+ const familyKey = iconStyle ?? themeConfig.icons?.family;
32
+ const family = familyKey
33
+ ? IconFamilies[familyKey]
34
+ : undefined;
35
+ if (family && !family.installed) {
36
+ // The project selected a family whose package isn't installed — a
37
+ // configuration error, not a missing glyph: surface it instead of
38
+ // drawing the placeholder.
39
+ throw new Error(`Icon family "${family.key}" is not installed: add ${family.npm} to ` +
40
+ 'the project (Project settings → Packages) to render it.');
41
+ }
41
42
  return (<StyledView ref={ref} styled={styledViewProps} {...props}>
42
- {uri ? (<>
43
- {typeof uri === 'string' ? (<StyledSvgUri uri={uri} styled={{
44
- width: ejectStyle?.width,
45
- height: ejectStyle?.height,
46
- color: ejectStyle?.color,
47
- style: styleSvg,
48
- }}/>) : (getUriComponent(uri))}
49
- </>) : (<MockIcon styled={{
43
+ {family && iconName ? (<family.Component name={iconName} styled={{
44
+ size: size ?? ejectStyle?.width,
45
+ color: color ?? ejectStyle?.color,
46
+ style: styleSvg,
47
+ }}/>) : (<MockIcon styled={{
50
48
  width: ejectStyle?.width,
51
49
  height: ejectStyle?.height,
52
50
  color: ejectStyle?.color,
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../../src/components/media/Icon/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAqB,MAAM,OAAO,CAAC;AAErE,OAAO,EACL,MAAM,IAAI,UAAU,EAIpB,UAAU,EACV,MAAM,GAEP,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAoBlC,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,IAAI,GAAG,UAAU,CACrB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACjC,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAEtD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,eAAe,GAAG,CAAC,GAAyC,EAAE,EAAE;QACpE,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE1C,OAAO,CACL,CAAC,SAAS,CACR,MAAM,CAAC,CAAC;gBACN,KAAK,EAAE,UAAU,EAAE,KAAwB;gBAC3C,MAA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