@impulse-ui-native/primitives 2.0.1 → 2.1.1

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 (113) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/atoms/button.d.mts +10 -0
  3. package/dist/components/atoms/button.js +60 -0
  4. package/dist/components/atoms/button.js.map +1 -0
  5. package/dist/components/atoms/icon-button.d.mts +12 -0
  6. package/dist/components/atoms/icon-button.js +51 -0
  7. package/dist/components/atoms/icon-button.js.map +1 -0
  8. package/dist/components/atoms/index.d.mts +18 -0
  9. package/dist/components/atoms/index.js +17 -0
  10. package/dist/components/atoms/index.js.map +1 -0
  11. package/dist/components/atoms/pressable.d.mts +9 -0
  12. package/dist/components/atoms/pressable.js +52 -0
  13. package/dist/components/atoms/pressable.js.map +1 -0
  14. package/dist/components/atoms/safe-area-view.d.mts +8 -0
  15. package/dist/components/atoms/safe-area-view.js +103 -0
  16. package/dist/components/atoms/safe-area-view.js.map +1 -0
  17. package/dist/components/atoms/tag.d.mts +9 -0
  18. package/dist/components/atoms/tag.js +82 -0
  19. package/dist/components/atoms/tag.js.map +1 -0
  20. package/dist/components/atoms/typography.d.mts +99 -0
  21. package/dist/components/atoms/typography.js +184 -0
  22. package/dist/components/atoms/typography.js.map +1 -0
  23. package/dist/components/atoms/view.d.mts +8 -0
  24. package/dist/components/atoms/view.js +27 -0
  25. package/dist/components/atoms/view.js.map +1 -0
  26. package/dist/components/controls/addon.d.mts +11 -0
  27. package/dist/components/controls/addon.js +72 -0
  28. package/dist/components/controls/addon.js.map +1 -0
  29. package/dist/components/controls/container.d.mts +11 -0
  30. package/dist/components/controls/container.js +54 -0
  31. package/dist/components/controls/container.js.map +1 -0
  32. package/dist/components/controls/control.d.mts +23 -0
  33. package/dist/components/controls/control.js +26 -0
  34. package/dist/components/controls/control.js.map +1 -0
  35. package/dist/components/controls/error.d.mts +11 -0
  36. package/dist/components/controls/error.js +33 -0
  37. package/dist/components/controls/error.js.map +1 -0
  38. package/dist/components/controls/index.d.mts +10 -0
  39. package/dist/components/controls/index.js +7 -0
  40. package/dist/components/controls/index.js.map +1 -0
  41. package/dist/components/controls/input.d.mts +11 -0
  42. package/dist/components/controls/input.js +63 -0
  43. package/dist/components/controls/input.js.map +1 -0
  44. package/dist/components/controls/label.d.mts +11 -0
  45. package/dist/components/controls/label.js +42 -0
  46. package/dist/components/controls/label.js.map +1 -0
  47. package/dist/components/controls/loader.d.mts +6 -0
  48. package/dist/components/controls/loader.js +10 -0
  49. package/dist/components/controls/loader.js.map +1 -0
  50. package/dist/components/controls/placeholder.d.mts +11 -0
  51. package/dist/components/controls/placeholder.js +51 -0
  52. package/dist/components/controls/placeholder.js.map +1 -0
  53. package/dist/components/controls/provider.d.mts +13 -0
  54. package/dist/components/controls/provider.js +19 -0
  55. package/dist/components/controls/provider.js.map +1 -0
  56. package/dist/components/controls/root.d.mts +9 -0
  57. package/dist/components/controls/root.js +18 -0
  58. package/dist/components/controls/root.js.map +1 -0
  59. package/dist/components/controls/value.d.mts +11 -0
  60. package/dist/components/controls/value.js +36 -0
  61. package/dist/components/controls/value.js.map +1 -0
  62. package/dist/components/index.d.mts +22 -0
  63. package/dist/components/index.js +3 -0
  64. package/dist/components/index.js.map +1 -0
  65. package/dist/constants/control-container.constants.d.mts +6 -0
  66. package/dist/constants/control-container.constants.js +15 -0
  67. package/dist/constants/control-container.constants.js.map +1 -0
  68. package/dist/constants/index.d.mts +3 -0
  69. package/dist/constants/index.js +3 -0
  70. package/dist/constants/index.js.map +1 -0
  71. package/dist/constants/safe-area-view.constants.d.mts +14 -0
  72. package/dist/constants/safe-area-view.constants.js +17 -0
  73. package/dist/constants/safe-area-view.constants.js.map +1 -0
  74. package/dist/hocs/create-preset.hoc.d.mts +12 -0
  75. package/dist/hocs/create-preset.hoc.js +38 -0
  76. package/dist/hocs/create-preset.hoc.js.map +1 -0
  77. package/dist/hocs/index.d.mts +6 -0
  78. package/dist/hocs/index.js +5 -0
  79. package/dist/hocs/index.js.map +1 -0
  80. package/dist/index.d.mts +25 -242
  81. package/dist/index.js +4 -997
  82. package/dist/index.js.map +1 -1
  83. package/dist/types/button.types.d.mts +21 -0
  84. package/dist/types/button.types.js +1 -0
  85. package/dist/types/button.types.js.map +1 -0
  86. package/dist/types/control-components.types.d.mts +45 -0
  87. package/dist/types/control-components.types.js +1 -0
  88. package/dist/types/control-components.types.js.map +1 -0
  89. package/dist/types/icon-button.types.d.mts +15 -0
  90. package/dist/types/icon-button.types.js +1 -0
  91. package/dist/types/icon-button.types.js.map +1 -0
  92. package/dist/types/index.d.mts +12 -0
  93. package/dist/types/index.js +9 -0
  94. package/dist/types/index.js.map +1 -0
  95. package/dist/types/safe-area-view.types.d.mts +5 -0
  96. package/dist/types/safe-area-view.types.js +1 -0
  97. package/dist/types/safe-area-view.types.js.map +1 -0
  98. package/dist/types/tag.types.d.mts +22 -0
  99. package/dist/types/tag.types.js +1 -0
  100. package/dist/types/tag.types.js.map +1 -0
  101. package/dist/types/typography.types.d.mts +8 -0
  102. package/dist/types/typography.types.js +1 -0
  103. package/dist/types/typography.types.js.map +1 -0
  104. package/dist/types/view.types.d.mts +6 -0
  105. package/dist/types/view.types.js +1 -0
  106. package/dist/types/view.types.js.map +1 -0
  107. package/dist/utils/controls.utils.d.mts +13 -0
  108. package/dist/utils/controls.utils.js +18 -0
  109. package/dist/utils/controls.utils.js.map +1 -0
  110. package/dist/utils/index.d.mts +2 -0
  111. package/dist/utils/index.js +2 -0
  112. package/dist/utils/index.js.map +1 -0
  113. package/package.json +11 -10
package/dist/index.js CHANGED
@@ -1,998 +1,5 @@
1
- // src/components/atoms/view.tsx
2
- import { forwardRef, memo, useMemo } from "react";
3
- import { View as NativeView, StyleSheet } from "react-native";
4
- import {
5
- getShadowStyle,
6
- useColors,
7
- useStyleProps
8
- } from "@impulse-ui-native/theme";
9
- import { jsx } from "react/jsx-runtime";
10
- var View = memo(
11
- forwardRef(function View2(props, ref) {
12
- const { style, shadow, shadowPosition, ...rest } = props;
13
- const colors = useColors();
14
- const extractedStyleProps = useStyleProps(props);
15
- const viewStyle = useMemo(() => {
16
- return StyleSheet.flatten([
17
- getShadowStyle(shadow, shadowPosition, colors),
18
- extractedStyleProps,
19
- style
20
- ]);
21
- }, [extractedStyleProps, style, shadow, shadowPosition, colors]);
22
- return /* @__PURE__ */ jsx(NativeView, { ...rest, style: viewStyle, ref });
23
- })
24
- );
25
-
26
- // src/components/atoms/safe-area-view.tsx
27
- import { memo as memo2, useCallback, useMemo as useMemo2 } from "react";
28
- import { StyleSheet as StyleSheet2 } from "react-native";
29
- import {
30
- useSafeAreaInsets
31
- } from "react-native-safe-area-context";
32
-
33
- // src/constants/safe-area-view.constants.ts
34
- var EdgeToSpacingKeyMap = {
35
- top: "Top",
36
- bottom: "Bottom",
37
- left: "Left",
38
- right: "Right"
39
- };
40
- var EdgeToShorthandKeyMap = {
41
- top: "Vertical",
42
- bottom: "Vertical",
43
- left: "Horizontal",
44
- right: "Horizontal"
45
- };
46
-
47
- // src/constants/control-container.constants.ts
48
- var ControlContainerHeight = {
49
- small: 36,
50
- medium: 44,
51
- large: 52
52
- };
53
- var ControlFontSize = {
54
- small: 14,
55
- medium: 16,
56
- large: 18
57
- };
58
-
59
- // src/components/atoms/safe-area-view.tsx
60
- import { jsx as jsx2 } from "react/jsx-runtime";
61
- var SafeAreaView = memo2(function SafeAreaView2(props) {
62
- const { edges, mode = "padding", style, ...rest } = props;
63
- const insets = useSafeAreaInsets();
64
- const flatenedStyle = useMemo2(() => {
65
- return StyleSheet2.flatten(style);
66
- }, [style]);
67
- const nativeEdges = useMemo2(() => {
68
- if (!edges) {
69
- return {
70
- top: "additive",
71
- bottom: "additive",
72
- left: "additive",
73
- right: "additive"
74
- };
75
- }
76
- let computedEdges;
77
- if (Array.isArray(edges)) {
78
- computedEdges = edges.reduce((acc, current) => {
79
- acc[current] = "additive";
80
- return acc;
81
- }, {});
82
- } else {
83
- computedEdges = edges;
84
- }
85
- return {
86
- top: computedEdges.top ?? "off",
87
- bottom: computedEdges.bottom ?? "off",
88
- left: computedEdges.left ?? "off",
89
- right: computedEdges.right ?? "off"
90
- };
91
- }, [edges]);
92
- const getSpacingKey = useCallback(
93
- (edge) => `${mode}${EdgeToSpacingKeyMap[edge]}`,
94
- [mode]
95
- );
96
- const getSpacingForEdge = useCallback(
97
- (edge) => {
98
- const shorthand = `${mode}${EdgeToShorthandKeyMap[edge]}`;
99
- const spacing = getSpacingKey(edge);
100
- return Number(
101
- flatenedStyle?.[spacing] ?? flatenedStyle?.[shorthand] ?? flatenedStyle?.[mode] ?? 0
102
- );
103
- },
104
- [flatenedStyle, getSpacingKey, mode]
105
- );
106
- const resolveEdge = useCallback(
107
- (inset, current, edgeMode) => {
108
- if (edgeMode === "off") {
109
- return current;
110
- }
111
- if (edgeMode === "maximum") {
112
- return Math.max(inset, current);
113
- }
114
- return inset + current;
115
- },
116
- []
117
- );
118
- const computedStyle = useMemo2(() => {
119
- const insetsStyle = {
120
- [getSpacingKey("top")]: resolveEdge(
121
- insets.top,
122
- getSpacingForEdge("top"),
123
- nativeEdges.top
124
- ),
125
- [getSpacingKey("bottom")]: resolveEdge(
126
- insets.bottom,
127
- getSpacingForEdge("bottom"),
128
- nativeEdges.bottom
129
- ),
130
- [getSpacingKey("left")]: resolveEdge(
131
- insets.left,
132
- getSpacingForEdge("left"),
133
- nativeEdges.left
134
- ),
135
- [getSpacingKey("right")]: resolveEdge(
136
- insets.right,
137
- getSpacingForEdge("right"),
138
- nativeEdges.right
139
- )
140
- };
141
- return StyleSheet2.flatten([style, insetsStyle]);
142
- }, [
143
- insets,
144
- nativeEdges,
145
- style,
146
- resolveEdge,
147
- getSpacingKey,
148
- getSpacingForEdge
149
- ]);
150
- return /* @__PURE__ */ jsx2(View, { style: computedStyle, ...rest });
151
- });
152
-
153
- // src/hocs/create-preset.hoc.tsx
154
- import { memo as memo3, useMemo as useMemo3 } from "react";
155
- import { StyleSheet as StyleSheet3, Text } from "react-native";
156
- import {
157
- useStyleProps as useStyleProps2,
158
- useTheme
159
- } from "@impulse-ui-native/theme";
160
- import { jsx as jsx3 } from "react/jsx-runtime";
161
- var numericFontVariant = ["tabular-nums"];
162
- var defaultFontVariant = [];
163
- function createPreset(config, key) {
164
- const Component = (props) => {
165
- const { style, numeric, fontStyle, fontWeight, ...rest } = props;
166
- const theme = useTheme();
167
- const extractedStyleProps = useStyleProps2(props);
168
- const typographyStyle = useMemo3(() => {
169
- const themedConfig = config(theme);
170
- const resolvedFontStyle = fontStyle ?? themedConfig.fontStyle ?? "normal";
171
- const resolvedFontWeight = fontWeight ?? themedConfig.fontWeight ?? 400;
172
- const fontFamily = theme.fontFamily[resolvedFontStyle][resolvedFontWeight];
173
- return StyleSheet3.flatten([
174
- themedConfig,
175
- extractedStyleProps,
176
- {
177
- fontFamily,
178
- fontVariant: numeric ? numericFontVariant : defaultFontVariant
179
- },
180
- style
181
- ]);
182
- }, [theme, extractedStyleProps, style, numeric, fontStyle, fontWeight]);
183
- return /* @__PURE__ */ jsx3(Text, { ...rest, style: typographyStyle });
184
- };
185
- Component.displayName = `Typography.${key}`;
186
- return memo3(Component);
187
- }
188
-
189
- // src/components/atoms/typography.tsx
190
- var Typography = {
191
- Master: createPreset(
192
- (theme) => ({ fontWeight: theme.fontWeight.regular }),
193
- "Master"
194
- ),
195
- DisplayLarge: createPreset(
196
- (theme) => ({
197
- fontWeight: theme.fontWeight.bold,
198
- fontSize: theme.fontSize.colossal,
199
- lineHeight: theme.lineHeight.colossal
200
- }),
201
- "DisplayLarge"
202
- ),
203
- DisplayMedium: createPreset(
204
- (theme) => ({
205
- fontWeight: theme.fontWeight.bold,
206
- fontSize: theme.fontSize.giant,
207
- lineHeight: theme.lineHeight.giant
208
- }),
209
- "DisplayMedium"
210
- ),
211
- DisplaySmall: createPreset(
212
- (theme) => ({
213
- fontWeight: theme.fontWeight.semiBold,
214
- fontSize: theme.fontSize.huge,
215
- lineHeight: theme.lineHeight.huge
216
- }),
217
- "DisplaySmall"
218
- ),
219
- Title1: createPreset(
220
- (theme) => ({
221
- fontWeight: theme.fontWeight.bold,
222
- fontSize: theme.fontSize.xxxl,
223
- lineHeight: theme.lineHeight.xxxl
224
- }),
225
- "Title1"
226
- ),
227
- Title2: createPreset(
228
- (theme) => ({
229
- fontWeight: theme.fontWeight.bold,
230
- fontSize: theme.fontSize.xxl,
231
- lineHeight: theme.lineHeight.xxl
232
- }),
233
- "Title2"
234
- ),
235
- Title3: createPreset(
236
- (theme) => ({
237
- fontWeight: theme.fontWeight.semiBold,
238
- fontSize: theme.fontSize.xl,
239
- lineHeight: theme.lineHeight.xl
240
- }),
241
- "Title3"
242
- ),
243
- Title4: createPreset(
244
- (theme) => ({
245
- fontWeight: theme.fontWeight.semiBold,
246
- fontSize: theme.fontSize.lg,
247
- lineHeight: theme.lineHeight.lg
248
- }),
249
- "Title4"
250
- ),
251
- Title5: createPreset(
252
- (theme) => ({
253
- fontWeight: theme.fontWeight.semiBold,
254
- fontSize: theme.fontSize.md,
255
- lineHeight: theme.lineHeight.md
256
- }),
257
- "Title5"
258
- ),
259
- Title6: createPreset(
260
- (theme) => ({
261
- fontWeight: theme.fontWeight.semiBold,
262
- fontSize: theme.fontSize.sm,
263
- lineHeight: theme.lineHeight.sm
264
- }),
265
- "Title6"
266
- ),
267
- Subtitle1: createPreset(
268
- (theme) => ({
269
- fontWeight: theme.fontWeight.medium,
270
- fontSize: theme.fontSize.md,
271
- lineHeight: theme.lineHeight.lg
272
- }),
273
- "Subtitle1"
274
- ),
275
- Subtitle2: createPreset(
276
- (theme) => ({
277
- fontWeight: theme.fontWeight.regular,
278
- fontSize: theme.fontSize.sm,
279
- lineHeight: theme.lineHeight.sm
280
- }),
281
- "Subtitle2"
282
- ),
283
- BodyLarge: createPreset(
284
- (theme) => ({
285
- fontWeight: theme.fontWeight.regular,
286
- fontSize: theme.fontSize.md,
287
- lineHeight: theme.lineHeight.lg
288
- }),
289
- "BodyLarge"
290
- ),
291
- Body: createPreset(
292
- (theme) => ({
293
- fontWeight: theme.fontWeight.regular,
294
- fontSize: theme.fontSize.sm,
295
- lineHeight: theme.lineHeight.sm
296
- }),
297
- "Body"
298
- ),
299
- BodySmall: createPreset(
300
- (theme) => ({
301
- fontWeight: theme.fontWeight.regular,
302
- fontSize: theme.fontSize.xsm,
303
- lineHeight: theme.lineHeight.xsm
304
- }),
305
- "BodySmall"
306
- ),
307
- Caption: createPreset(
308
- (theme) => ({
309
- fontWeight: theme.fontWeight.regular,
310
- fontSize: theme.fontSize.xs,
311
- lineHeight: theme.lineHeight.xs
312
- }),
313
- "Caption"
314
- ),
315
- Label: createPreset(
316
- (theme) => ({
317
- fontWeight: theme.fontWeight.medium,
318
- fontSize: theme.fontSize.xsm,
319
- lineHeight: theme.lineHeight.xsm
320
- }),
321
- "Label"
322
- ),
323
- Overline: createPreset(
324
- (theme) => ({
325
- fontWeight: theme.fontWeight.semiBold,
326
- fontSize: theme.fontSize.xs,
327
- lineHeight: theme.lineHeight.xs,
328
- textTransform: "uppercase",
329
- letterSpacing: 1
330
- }),
331
- "Overline"
332
- ),
333
- Helper: createPreset(
334
- (theme) => ({
335
- fontWeight: theme.fontWeight.regular,
336
- fontSize: theme.fontSize.xsm,
337
- lineHeight: theme.lineHeight.xsm
338
- }),
339
- "Helper"
340
- ),
341
- Code: createPreset(
342
- (theme) => ({
343
- fontFamily: "monospace",
344
- fontSize: theme.fontSize.xsm,
345
- lineHeight: theme.lineHeight.xsm
346
- }),
347
- "Code"
348
- ),
349
- Quote: createPreset(
350
- (theme) => ({
351
- fontWeight: theme.fontWeight.regular,
352
- fontSize: theme.fontSize.md,
353
- lineHeight: theme.lineHeight.lg,
354
- fontStyle: "italic"
355
- }),
356
- "Quote"
357
- ),
358
- Eyebrow: createPreset(
359
- (theme) => ({
360
- fontWeight: theme.fontWeight.medium,
361
- fontSize: theme.fontSize.xs,
362
- lineHeight: theme.lineHeight.xs,
363
- textTransform: "uppercase",
364
- letterSpacing: 1
365
- }),
366
- "Eyebrow"
367
- )
368
- };
369
-
370
- // src/components/atoms/button.tsx
371
- import { memo as memo4, useMemo as useMemo4 } from "react";
372
- import { ActivityIndicator, StyleSheet as StyleSheet5 } from "react-native";
373
- import { useThemedStyles } from "@impulse-ui-native/theme";
374
-
375
- // src/components/atoms/pressable.tsx
376
- import { useCallback as useCallback2 } from "react";
377
- import {
378
- Pressable as RNPressable,
379
- StyleSheet as StyleSheet4
380
- } from "react-native";
381
- import {
382
- getShadowStyle as getShadowStyle2,
383
- useColors as useColors2,
384
- useStyleProps as useStyleProps3
385
- } from "@impulse-ui-native/theme";
386
- import { jsx as jsx4 } from "react/jsx-runtime";
387
- var Pressable = function PressableCore({
388
- children,
389
- disabled,
390
- pressedStyle,
391
- style,
392
- ...props
393
- }) {
394
- const colors = useColors2();
395
- const extractedStyleProps = useStyleProps3(props);
396
- const pressableStyles = useCallback2(
397
- (state) => {
398
- let overrideStyle;
399
- if (typeof style === "function") {
400
- overrideStyle = style(state);
401
- } else {
402
- overrideStyle = style;
403
- }
404
- return StyleSheet4.flatten([
405
- { opacity: disabled || state.pressed ? 0.6 : 1 },
406
- getShadowStyle2(props.shadow, props.shadowPosition, colors),
407
- extractedStyleProps,
408
- overrideStyle,
409
- state.pressed ? pressedStyle : void 0
410
- ]);
411
- },
412
- [
413
- style,
414
- pressedStyle,
415
- disabled,
416
- extractedStyleProps,
417
- props.shadow,
418
- props.shadowPosition,
419
- colors
420
- ]
421
- );
422
- return /* @__PURE__ */ jsx4(RNPressable, { ...props, style: pressableStyles, disabled, children });
423
- };
424
-
425
- // src/components/atoms/button.tsx
426
- import { jsx as jsx5 } from "react/jsx-runtime";
427
- var Button = memo4(function Button2({
428
- size = "medium",
429
- variant = "filled",
430
- disabled,
431
- children,
432
- style,
433
- ...props
434
- }) {
435
- const styles2 = useThemedStyles(themedStyles, { size, variant, disabled }, [
436
- size,
437
- variant,
438
- disabled
439
- ]);
440
- const buttonStyles = useMemo4(
441
- () => [styles2.button, style],
442
- [styles2.button, style]
443
- );
444
- const content = useMemo4(() => {
445
- if (props.loading) {
446
- return /* @__PURE__ */ jsx5(ActivityIndicator, { color: styles2.text.color });
447
- }
448
- return typeof children === "string" ? /* @__PURE__ */ jsx5(Typography.Master, { style: styles2.text, children }) : children;
449
- }, [children, props.loading, styles2.text]);
450
- return /* @__PURE__ */ jsx5(Pressable, { style: buttonStyles, disabled, ...props, children: content });
451
- });
452
- function themedStyles(theme, props) {
453
- const { size, variant, disabled } = props;
454
- const buttonTokens = theme.components.button;
455
- const sizeTokens = buttonTokens.sizes[size];
456
- const variantTokens = buttonTokens.variants[variant];
457
- return StyleSheet5.create({
458
- button: {
459
- alignItems: "center",
460
- justifyContent: "center",
461
- height: sizeTokens.height,
462
- paddingVertical: sizeTokens.paddingVertical,
463
- paddingHorizontal: sizeTokens.paddingHorizontal,
464
- borderWidth: buttonTokens.borderWidth,
465
- borderRadius: buttonTokens.borderRadius,
466
- borderColor: disabled ? variantTokens.disabledBorderColor : variantTokens.borderColor,
467
- backgroundColor: disabled ? variantTokens.disabledBackgroundColor : variantTokens.backgroundColor
468
- },
469
- text: {
470
- width: "100%",
471
- textAlign: "center",
472
- fontSize: sizeTokens.fontSize,
473
- color: disabled ? variantTokens.disabledColor : variantTokens.color
474
- }
475
- });
476
- }
477
-
478
- // src/components/atoms/icon-button.tsx
479
- import { memo as memo5, useMemo as useMemo5 } from "react";
480
- import { StyleSheet as StyleSheet6 } from "react-native";
481
- import { Icon } from "@impulse-ui-native/icon";
482
- import { useThemedStyles as useThemedStyles2 } from "@impulse-ui-native/theme";
483
- import { jsx as jsx6 } from "react/jsx-runtime";
484
- var IconButton = memo5(function IconButton2({
485
- size = "medium",
486
- variant = "filled",
487
- disabled,
488
- style,
489
- icon,
490
- ...props
491
- }) {
492
- const styles2 = useThemedStyles2(themedStyles2, { size, variant, disabled }, [
493
- size,
494
- variant,
495
- disabled
496
- ]);
497
- const iconButtonStyles = useMemo5(
498
- () => [styles2.button, style],
499
- [styles2.button, style]
500
- );
501
- return /* @__PURE__ */ jsx6(Pressable, { style: iconButtonStyles, disabled, ...props, children: /* @__PURE__ */ jsx6(Icon, { size, icon, color: styles2.icon.color }) });
502
- });
503
- function themedStyles2(theme, props) {
504
- const { size, variant, disabled } = props;
505
- const iconButtonTokens = theme.components.iconButton;
506
- const sizeTokens = iconButtonTokens.sizes[size];
507
- const variantTokens = iconButtonTokens.variants[variant];
508
- return StyleSheet6.create({
509
- button: {
510
- alignItems: "center",
511
- justifyContent: "center",
512
- height: sizeTokens.size,
513
- width: sizeTokens.size,
514
- padding: sizeTokens.padding,
515
- borderWidth: iconButtonTokens.borderWidth,
516
- borderRadius: iconButtonTokens.borderRadius,
517
- borderColor: disabled ? variantTokens.disabledBorderColor : variantTokens.borderColor,
518
- backgroundColor: disabled ? variantTokens.disabledBackgroundColor : variantTokens.backgroundColor
519
- },
520
- icon: {
521
- color: disabled ? variantTokens.disabledColor : variantTokens.color
522
- }
523
- });
524
- }
525
-
526
- // src/components/atoms/tag.tsx
527
- import { memo as memo6, useMemo as useMemo6 } from "react";
528
- import { StyleSheet as StyleSheet7, View as View3 } from "react-native";
529
- import { Icon as Icon2, XCircleIcon } from "@impulse-ui-native/icon";
530
- import { useThemedStyles as useThemedStyles3 } from "@impulse-ui-native/theme";
531
- import { jsx as jsx7, jsxs } from "react/jsx-runtime";
532
- var Tag = memo6(function Tag2({
533
- label,
534
- size = "medium",
535
- variant = "filled",
536
- color = "primary",
537
- closable,
538
- disabled,
539
- onClose,
540
- onPress
541
- }) {
542
- const styles2 = useThemedStyles3(
543
- themedStyles3,
544
- {
545
- size,
546
- variant,
547
- disabled,
548
- color
549
- },
550
- [size, variant, disabled, color]
551
- );
552
- const Container = useMemo6(() => {
553
- if (onPress) {
554
- return Pressable;
555
- }
556
- return View3;
557
- }, [onPress]);
558
- const showClose = (closable || size === "medium" || size === "large") && !disabled && onClose;
559
- return /* @__PURE__ */ jsxs(Container, { onPress, disabled, style: styles2.container, children: [
560
- /* @__PURE__ */ jsx7(Typography.Caption, { style: styles2.label, children: label }),
561
- showClose ? /* @__PURE__ */ jsx7(Pressable, { onPress: onClose, hitSlop: 10, children: /* @__PURE__ */ jsx7(
562
- Icon2,
563
- {
564
- icon: XCircleIcon,
565
- size: "small",
566
- color: styles2.icon.color,
567
- style: styles2.icon
568
- }
569
- ) }) : null
570
- ] });
571
- });
572
- function themedStyles3(theme, props) {
573
- const { size, variant, color, disabled } = props;
574
- const tagTokens = theme.components.tag;
575
- const sizeTokens = tagTokens.sizes[size];
576
- const variantTokens = tagTokens.colors[color][variant];
577
- return StyleSheet7.create({
578
- container: {
579
- flexDirection: "row",
580
- alignItems: "center",
581
- justifyContent: "center",
582
- alignSelf: "flex-start",
583
- height: sizeTokens.height,
584
- paddingHorizontal: sizeTokens.paddingHorizontal,
585
- minWidth: sizeTokens.minWidth,
586
- borderRadius: tagTokens.borderRadius,
587
- gap: tagTokens.gap,
588
- borderWidth: tagTokens.borderWidth,
589
- borderColor: disabled ? variantTokens.disabledBorderColor : variantTokens.borderColor,
590
- backgroundColor: disabled ? variantTokens.disabledBackgroundColor : variantTokens.backgroundColor
591
- },
592
- label: {
593
- fontSize: sizeTokens.fontSize,
594
- color: disabled ? variantTokens.disabledColor : variantTokens.color
595
- },
596
- icon: {
597
- marginLeft: tagTokens.iconMarginLeft,
598
- color: disabled ? variantTokens.disabledColor : variantTokens.color
599
- }
600
- });
601
- }
602
-
603
- // src/components/controls/addon.tsx
604
- import { memo as memo8, useMemo as useMemo7 } from "react";
605
- import { StyleSheet as StyleSheet8 } from "react-native";
606
- import { Icon as Icon3 } from "@impulse-ui-native/icon";
607
- import {
608
- useComponentsTokens,
609
- useThemedStyles as useThemedStyles4
610
- } from "@impulse-ui-native/theme";
611
-
612
- // src/components/controls/provider.tsx
613
- import { createContext, memo as memo7, useContext } from "react";
614
- import { jsx as jsx8 } from "react/jsx-runtime";
615
- var ControlContext = createContext(void 0);
616
- var ControlProvider = memo7(function ControlProvider2(props) {
617
- const { children, ...context } = props;
618
- return /* @__PURE__ */ jsx8(ControlContext.Provider, { value: context, children });
619
- });
620
- function useControlContext() {
621
- const context = useContext(ControlContext);
622
- if (!context) {
623
- throw new Error("useControlContext must be used within ControlProvider");
624
- }
625
- return context;
626
- }
627
-
628
- // src/components/controls/addon.tsx
629
- import { jsx as jsx9 } from "react/jsx-runtime";
630
- var ControlAddon = memo8(function ControlAddon2(props) {
631
- const { icon: AddonIcon, onPress, Content, style, ...rest } = props;
632
- const { disabled, error } = useControlContext();
633
- const tokens = useComponentsTokens();
634
- const styles2 = useThemedStyles4(
635
- themedStyles4,
636
- {
637
- disabled,
638
- error
639
- },
640
- [disabled, error]
641
- );
642
- const Container = useMemo7(() => {
643
- if (onPress) {
644
- return Pressable;
645
- }
646
- return View;
647
- }, [onPress]);
648
- const children = useMemo7(() => {
649
- if (Content) {
650
- return /* @__PURE__ */ jsx9(Content, {});
651
- }
652
- if (AddonIcon) {
653
- return /* @__PURE__ */ jsx9(Icon3, { color: styles2.icon.color, icon: AddonIcon });
654
- }
655
- return null;
656
- }, [AddonIcon, Content, styles2.icon.color]);
657
- const containerStyle = useMemo7(
658
- () => [styles2.container, style],
659
- [styles2.container, style]
660
- );
661
- if (!children) {
662
- return null;
663
- }
664
- return /* @__PURE__ */ jsx9(
665
- Container,
666
- {
667
- ...rest,
668
- style: containerStyle,
669
- hitSlop: tokens.controlAddon.hitSlop,
670
- onPress,
671
- disabled,
672
- children
673
- }
674
- );
675
- });
676
- function themedStyles4(theme, props) {
677
- const { disabled, error } = props;
678
- const controlAddonTokens = theme.components.controlAddon;
679
- return StyleSheet8.create({
680
- container: {
681
- marginHorizontal: controlAddonTokens.marginHorizontal
682
- },
683
- icon: {
684
- color: disabled ? controlAddonTokens.disabledIconColor : error ? controlAddonTokens.errorIconColor : controlAddonTokens.iconColor
685
- }
686
- });
687
- }
688
-
689
- // src/components/controls/container.tsx
690
- import { memo as memo9, useMemo as useMemo8 } from "react";
691
- import { StyleSheet as StyleSheet9 } from "react-native";
692
- import {
693
- useThemedStyles as useThemedStyles5
694
- } from "@impulse-ui-native/theme";
695
- import { jsx as jsx10 } from "react/jsx-runtime";
696
- var ControlContainer = memo9(function ControlContainer2(props) {
697
- const { style, ...rest } = props;
698
- const { size, variant, disabled, error } = useControlContext();
699
- const styles2 = useThemedStyles5(
700
- themedStyles5,
701
- {
702
- size,
703
- variant,
704
- disabled,
705
- error
706
- },
707
- [size, variant, disabled, error]
708
- );
709
- const containerStyle = useMemo8(
710
- () => [styles2.inputContainer, style],
711
- [styles2.inputContainer, style]
712
- );
713
- return /* @__PURE__ */ jsx10(View, { style: containerStyle, ...rest });
714
- });
715
- function themedStyles5(theme, {
716
- size,
717
- variant,
718
- disabled,
719
- error
720
- }) {
721
- const controlContainerTokens = theme.components.controlContainer;
722
- const sizeTokens = controlContainerTokens.sizes[size];
723
- const variantTokens = controlContainerTokens.variants[variant];
724
- return StyleSheet9.create({
725
- inputContainer: {
726
- flexDirection: "row",
727
- alignItems: "center",
728
- height: sizeTokens.height,
729
- paddingHorizontal: sizeTokens.paddingHorizontal,
730
- borderRadius: controlContainerTokens.borderRadius,
731
- borderWidth: controlContainerTokens.borderWidth,
732
- opacity: disabled ? controlContainerTokens.disabledOpacity : 1,
733
- backgroundColor: disabled ? variantTokens.disabledBackgroundColor : variantTokens.backgroundColor,
734
- borderColor: error ? variantTokens.errorBorderColor : disabled ? variantTokens.disabledBorderColor : variantTokens.borderColor,
735
- borderBottomColor: error ? variantTokens.errorBorderBottomColor : disabled ? variantTokens.disabledBorderBottomColor : variantTokens.borderBottomColor
736
- }
737
- });
738
- }
739
-
740
- // src/components/controls/error.tsx
741
- import { memo as memo10, useMemo as useMemo9 } from "react";
742
- import { StyleSheet as StyleSheet10 } from "react-native";
743
- import { useThemedStyles as useThemedStyles6 } from "@impulse-ui-native/theme";
744
- import { jsx as jsx11 } from "react/jsx-runtime";
745
- var ControlError = memo10(function ControlError2(props) {
746
- const { style, ...rest } = props;
747
- const { error } = useControlContext();
748
- const styles2 = useThemedStyles6(themedStyles6);
749
- const errorStyle = useMemo9(
750
- () => [styles2.error, style],
751
- [styles2.error, style]
752
- );
753
- if (!Boolean(error)) {
754
- return null;
755
- }
756
- return /* @__PURE__ */ jsx11(Typography.Caption, { ...rest, style: errorStyle, children: error });
757
- });
758
- function themedStyles6(theme) {
759
- const controlErrorTokens = theme.components.controlError;
760
- return StyleSheet10.create({
761
- error: {
762
- marginTop: controlErrorTokens.marginTop,
763
- color: controlErrorTokens.color,
764
- fontSize: controlErrorTokens.fontSize
765
- }
766
- });
767
- }
768
-
769
- // src/components/controls/input.tsx
770
- import { memo as memo11, useMemo as useMemo10 } from "react";
771
- import { StyleSheet as StyleSheet11, TextInput } from "react-native";
772
- import {
773
- useThemedStyles as useThemedStyles7
774
- } from "@impulse-ui-native/theme";
775
- import { jsx as jsx12 } from "react/jsx-runtime";
776
- var ControlInput = memo11(function ControlInput2(props) {
777
- const { onPress, style, ...rest } = props;
778
- const { size, variant, disabled, error } = useControlContext();
779
- const styles2 = useThemedStyles7(
780
- themedStyles7,
781
- {
782
- size,
783
- variant,
784
- disabled,
785
- error
786
- },
787
- [size, variant, disabled, error]
788
- );
789
- const inputStyles = useMemo10(
790
- () => [styles2.input, style],
791
- [styles2.input, style]
792
- );
793
- return /* @__PURE__ */ jsx12(
794
- TextInput,
795
- {
796
- ...rest,
797
- style: inputStyles,
798
- placeholderTextColor: styles2.placeholder.color,
799
- editable: !disabled
800
- }
801
- );
802
- });
803
- function themedStyles7(theme, {
804
- size,
805
- variant,
806
- disabled,
807
- error
808
- }) {
809
- const controlInputTokens = theme.components.controlInput;
810
- const sizeTokens = controlInputTokens.sizes[size];
811
- const variantTokens = controlInputTokens.variants[variant];
812
- const color = disabled ? variantTokens.disabledColor : error ? variantTokens.errorColor : variantTokens.color;
813
- const placeholderColor = disabled ? variantTokens.disabledPlaceholderColor : error ? variantTokens.errorPlaceholderColor : variantTokens.placeholderColor;
814
- return StyleSheet11.create({
815
- input: {
816
- flex: controlInputTokens.flex,
817
- color,
818
- fontSize: sizeTokens.fontSize,
819
- fontFamily: controlInputTokens.fontFamily,
820
- paddingHorizontal: controlInputTokens.paddingHorizontal,
821
- height: "100%"
822
- },
823
- placeholder: {
824
- color: placeholderColor
825
- }
826
- });
827
- }
828
-
829
- // src/components/controls/label.tsx
830
- import { memo as memo12, useMemo as useMemo11 } from "react";
831
- import { StyleSheet as StyleSheet12 } from "react-native";
832
- import { useThemedStyles as useThemedStyles8 } from "@impulse-ui-native/theme";
833
- import { jsx as jsx13 } from "react/jsx-runtime";
834
- var ControlLabel = memo12(function ControlLabel2(props) {
835
- const { children, disabled, style, ...rest } = props;
836
- const { error } = useControlContext();
837
- const styles2 = useThemedStyles8(
838
- themedStyles8,
839
- {
840
- disabled,
841
- error
842
- },
843
- [disabled, error]
844
- );
845
- const labelStyle = useMemo11(
846
- () => [styles2.label, style],
847
- [styles2.label, style]
848
- );
849
- if (!children) {
850
- return null;
851
- }
852
- return /* @__PURE__ */ jsx13(Typography.Label, { ...rest, style: labelStyle, children });
853
- });
854
- function themedStyles8(theme, props) {
855
- const { disabled, error } = props;
856
- const controlLabelTokens = theme.components.controlLabel;
857
- const color = disabled ? controlLabelTokens.disabledColor : error ? controlLabelTokens.errorColor : controlLabelTokens.color;
858
- return StyleSheet12.create({
859
- label: {
860
- marginBottom: controlLabelTokens.marginBottom,
861
- fontSize: controlLabelTokens.fontSize,
862
- color
863
- }
864
- });
865
- }
866
-
867
- // src/components/controls/loader.tsx
868
- import { memo as memo13 } from "react";
869
- import { ActivityIndicator as ActivityIndicator2 } from "react-native";
870
- import { jsx as jsx14 } from "react/jsx-runtime";
871
- var ControlLoader = memo13(function ControlLoader2() {
872
- return /* @__PURE__ */ jsx14(ActivityIndicator2, {});
873
- });
874
-
875
- // src/components/controls/placeholder.tsx
876
- import { memo as memo14, useMemo as useMemo12 } from "react";
877
- import { StyleSheet as StyleSheet13 } from "react-native";
878
- import {
879
- useThemedStyles as useThemedStyles9
880
- } from "@impulse-ui-native/theme";
881
- import { jsx as jsx15 } from "react/jsx-runtime";
882
- var ControlPlaceholder = memo14(function ControlPlaceholder2(props) {
883
- const { style, ...rest } = props;
884
- const { size, variant, disabled, error } = useControlContext();
885
- const styles2 = useThemedStyles9(
886
- themedStyles9,
887
- {
888
- size,
889
- variant,
890
- disabled,
891
- error
892
- },
893
- [size, variant, disabled, error]
894
- );
895
- const placeholderStyle = useMemo12(
896
- () => [styles2.placeholder, style],
897
- [styles2.placeholder, style]
898
- );
899
- return /* @__PURE__ */ jsx15(Typography.Master, { numberOfLines: 1, ...rest, style: placeholderStyle });
900
- });
901
- function themedStyles9(theme, {
902
- size,
903
- variant,
904
- disabled,
905
- error
906
- }) {
907
- const controlInputTokens = theme.components.controlInput;
908
- const sizeTokens = controlInputTokens.sizes[size];
909
- const variantTokens = controlInputTokens.variants[variant];
910
- const color = disabled ? variantTokens.disabledPlaceholderColor : error ? variantTokens.errorPlaceholderColor : variantTokens.placeholderColor;
911
- return StyleSheet13.create({
912
- placeholder: {
913
- flex: controlInputTokens.flex,
914
- color,
915
- fontFamily: controlInputTokens.fontFamily,
916
- fontSize: sizeTokens.fontSize,
917
- paddingHorizontal: controlInputTokens.paddingHorizontal
918
- }
919
- });
920
- }
921
-
922
- // src/components/controls/root.tsx
923
- import { memo as memo15, useMemo as useMemo13 } from "react";
924
- import { StyleSheet as StyleSheet14 } from "react-native";
925
- import { jsx as jsx16 } from "react/jsx-runtime";
926
- var ControlRoot = memo15(function ControlRoot2(props) {
927
- const { style, ...rest } = props;
928
- const containerStyle = useMemo13(() => [styles.container, style], [style]);
929
- return /* @__PURE__ */ jsx16(View, { ...rest, style: containerStyle });
930
- });
931
- var styles = StyleSheet14.create({
932
- container: {
933
- width: "100%"
934
- }
935
- });
936
-
937
- // src/components/controls/value.tsx
938
- import { memo as memo16, useMemo as useMemo14 } from "react";
939
- import { StyleSheet as StyleSheet15 } from "react-native";
940
- import {
941
- useThemedStyles as useThemedStyles10
942
- } from "@impulse-ui-native/theme";
943
- import { jsx as jsx17 } from "react/jsx-runtime";
944
- var ControlValue = memo16(function ControlValue2(props) {
945
- const { style, ...rest } = props;
946
- const { size } = useControlContext();
947
- const styles2 = useThemedStyles10(themedStyles10, { size }, [size]);
948
- const valueStyle = useMemo14(
949
- () => [styles2.value, style],
950
- [styles2.value, style]
951
- );
952
- return /* @__PURE__ */ jsx17(Typography.Master, { numberOfLines: 1, ...rest, style: valueStyle });
953
- });
954
- function themedStyles10(theme, {
955
- size
956
- }) {
957
- const controlInputTokens = theme.components.controlInput;
958
- const sizeTokens = controlInputTokens.sizes[size];
959
- return StyleSheet15.create({
960
- value: {
961
- flex: controlInputTokens.flex,
962
- fontFamily: controlInputTokens.fontFamily,
963
- fontSize: sizeTokens.fontSize,
964
- paddingHorizontal: controlInputTokens.paddingHorizontal
965
- }
966
- });
967
- }
968
-
969
- // src/components/controls/control.tsx
970
- var Control = {
971
- Container: ControlContainer,
972
- Provider: ControlProvider,
973
- Root: ControlRoot,
974
- Label: ControlLabel,
975
- Error: ControlError,
976
- Addon: ControlAddon,
977
- Input: ControlInput,
978
- Placeholder: ControlPlaceholder,
979
- Value: ControlValue,
980
- Loader: ControlLoader
981
- };
982
- export {
983
- Button,
984
- Control,
985
- ControlContainerHeight,
986
- ControlFontSize,
987
- EdgeToShorthandKeyMap,
988
- EdgeToSpacingKeyMap,
989
- IconButton,
990
- Pressable,
991
- SafeAreaView,
992
- Tag,
993
- Typography,
994
- View,
995
- createPreset,
996
- useControlContext
997
- };
1
+ export * from "./components";
2
+ export * from "./hocs";
3
+ export * from "./constants";
4
+ export * from "./types";
998
5
  //# sourceMappingURL=index.js.map