@ornikar/kitt-universal 9.3.2 → 9.6.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 (68) hide show
  1. package/dist/definitions/Actions/Actions.d.ts +13 -0
  2. package/dist/definitions/Actions/Actions.d.ts.map +1 -0
  3. package/dist/definitions/Actions/ActionsButton.d.ts +9 -0
  4. package/dist/definitions/Actions/ActionsButton.d.ts.map +1 -0
  5. package/dist/definitions/Actions/ActionsItem.d.ts +12 -0
  6. package/dist/definitions/Actions/ActionsItem.d.ts.map +1 -0
  7. package/dist/definitions/Choices/ChoiceItem.d.ts +38 -0
  8. package/dist/definitions/Choices/ChoiceItem.d.ts.map +1 -0
  9. package/dist/definitions/Choices/ChoiceItemContainer.d.ts +10 -0
  10. package/dist/definitions/Choices/ChoiceItemContainer.d.ts.map +1 -0
  11. package/dist/definitions/Choices/Choices.d.ts +33 -0
  12. package/dist/definitions/Choices/Choices.d.ts.map +1 -0
  13. package/dist/definitions/Choices/hooks/useNativeAnimation.d.ts +14 -0
  14. package/dist/definitions/Choices/hooks/useNativeAnimation.d.ts.map +1 -0
  15. package/dist/definitions/Choices/hooks/useNativeAnimation.web.d.ts +7 -0
  16. package/dist/definitions/Choices/hooks/useNativeAnimation.web.d.ts.map +1 -0
  17. package/dist/definitions/IconButton/IconButton.d.ts +1 -1
  18. package/dist/definitions/IconButton/IconButton.d.ts.map +1 -1
  19. package/dist/definitions/IconButton/PressableAnimatedContainer.d.ts +1 -1
  20. package/dist/definitions/IconButton/PressableAnimatedContainer.d.ts.map +1 -1
  21. package/dist/definitions/forms/InputField/InputField.d.ts.map +1 -1
  22. package/dist/definitions/forms/InputText/InputTextContainer.web.d.ts +1 -1
  23. package/dist/definitions/index.d.ts +7 -0
  24. package/dist/definitions/index.d.ts.map +1 -1
  25. package/dist/definitions/native-base/KittNativeBaseProvider.d.ts +15 -15
  26. package/dist/definitions/story-components/StoryBlock.d.ts +1 -1
  27. package/dist/definitions/test-utils/TestWrapper.d.ts +7 -0
  28. package/dist/definitions/test-utils/TestWrapper.d.ts.map +1 -0
  29. package/dist/definitions/themes/default.d.ts +8 -1
  30. package/dist/definitions/themes/default.d.ts.map +1 -1
  31. package/dist/definitions/themes/late-ocean/choices.d.ts +35 -0
  32. package/dist/definitions/themes/late-ocean/choices.d.ts.map +1 -0
  33. package/dist/definitions/themes/late-ocean/forms.d.ts +7 -1
  34. package/dist/definitions/themes/late-ocean/forms.d.ts.map +1 -1
  35. package/dist/definitions/themes/late-ocean/inputField.d.ts +7 -1
  36. package/dist/definitions/themes/late-ocean/inputField.d.ts.map +1 -1
  37. package/dist/definitions/typography/Typography.d.ts +1 -0
  38. package/dist/definitions/typography/Typography.d.ts.map +1 -1
  39. package/dist/definitions/typography/TypographyLink.d.ts +1 -1
  40. package/dist/definitions/typography/TypographyLink.d.ts.map +1 -1
  41. package/dist/index-browser-all.es.android.js +917 -432
  42. package/dist/index-browser-all.es.android.js.map +1 -1
  43. package/dist/index-browser-all.es.ios.js +917 -432
  44. package/dist/index-browser-all.es.ios.js.map +1 -1
  45. package/dist/index-browser-all.es.js +917 -432
  46. package/dist/index-browser-all.es.js.map +1 -1
  47. package/dist/index-browser-all.es.web.js +995 -591
  48. package/dist/index-browser-all.es.web.js.map +1 -1
  49. package/dist/index-node-14.17.cjs.js +933 -477
  50. package/dist/index-node-14.17.cjs.js.map +1 -1
  51. package/dist/index-node-14.17.cjs.web.css +1 -1
  52. package/dist/index-node-14.17.cjs.web.js +824 -449
  53. package/dist/index-node-14.17.cjs.web.js.map +1 -1
  54. package/dist/linaria-themes-browser-all.es.android.js +41 -1
  55. package/dist/linaria-themes-browser-all.es.android.js.map +1 -1
  56. package/dist/linaria-themes-browser-all.es.ios.js +41 -1
  57. package/dist/linaria-themes-browser-all.es.ios.js.map +1 -1
  58. package/dist/linaria-themes-browser-all.es.js +41 -1
  59. package/dist/linaria-themes-browser-all.es.js.map +1 -1
  60. package/dist/linaria-themes-browser-all.es.web.js +41 -1
  61. package/dist/linaria-themes-browser-all.es.web.js.map +1 -1
  62. package/dist/linaria-themes-node-14.17.cjs.js +41 -1
  63. package/dist/linaria-themes-node-14.17.cjs.js.map +1 -1
  64. package/dist/linaria-themes-node-14.17.cjs.web.js +41 -1
  65. package/dist/linaria-themes-node-14.17.cjs.web.js.map +1 -1
  66. package/dist/styles.css +1 -1
  67. package/dist/tsbuildinfo +1 -1
  68. package/package.json +27 -2
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const kittIcons = require('@ornikar/kitt-icons');
5
+ const nativeBase = require('native-base');
6
+ const React = require('react');
6
7
  const reactNative = require('react-native');
8
+ const Animated = require('react-native-reanimated');
7
9
  const styled = require('styled-components/native');
8
- const React = require('react');
9
10
  const jsxRuntime = require('react/jsx-runtime');
10
- const nativeBase = require('native-base');
11
- const Animated = require('react-native-reanimated');
11
+ const kittIcons = require('@ornikar/kitt-icons');
12
12
  const twemojiParser = require('twemoji-parser');
13
13
  const WebBrowser = require('expo-web-browser');
14
14
  const DateTimePicker = require('@react-native-community/datetimepicker');
@@ -23,42 +23,183 @@ const addons = require('@storybook/addons');
23
23
 
24
24
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
25
25
 
26
- const styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
27
26
  const React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
27
  const Animated__default = /*#__PURE__*/_interopDefaultLegacy(Animated);
28
+ const styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
29
29
  const DateTimePicker__default = /*#__PURE__*/_interopDefaultLegacy(DateTimePicker);
30
30
  const Svg__default = /*#__PURE__*/_interopDefaultLegacy(Svg);
31
31
 
32
- const defaultIconSize = 20;
33
- const IconContainer$1 = /*#__PURE__*/styled__default.View.withConfig({
34
- displayName: "Icon__IconContainer",
35
- componentId: "kitt-universal__sc-usm0ol-0"
36
- })(["color:", ";width:", "px;height:", "px;align-self:", ";"], ({
37
- $color
38
- }) => $color, ({
39
- $size
40
- }) => $size, ({
41
- $size
42
- }) => $size, ({
43
- $align = 'auto'
44
- }) => $align);
45
- function Icon({
46
- icon,
47
- size = defaultIconSize,
48
- align,
49
- color
50
- }) {
51
- const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
52
- color
53
- });
54
- return /*#__PURE__*/jsxRuntime.jsx(IconContainer$1, {
55
- $align: align,
56
- $size: size,
57
- $color: color,
58
- children: clonedIcon
59
- });
32
+ const Stack = nativeBase.Stack;
33
+ const VStack = nativeBase.VStack;
34
+ const HStack = nativeBase.HStack;
35
+
36
+ function warn(message) {
37
+ if (process.env.NODE_ENV !== 'production') {
38
+ console.warn(message);
39
+ }
40
+ }
41
+ function deprecatedMessage(symbol, deprecation, replaceBy) {
42
+ const replaceMessage = replaceBy === undefined ? '' : `, please use ${replaceBy} instead`;
43
+ warn(`[Deprecation] in ${symbol}: ${deprecation} is deprecated${replaceMessage}.`);
44
+ }
45
+ function deprecatedInComponent(component, deprecation, replaceBy) {
46
+ deprecatedMessage(`<${component} />`, deprecation, replaceBy);
47
+ }
48
+
49
+ const hasVariant = (button, variant) => {
50
+ return variant in button;
51
+ };
52
+
53
+ function getVariantValuesIfExist(theme, type, variant) {
54
+ const button = theme.kitt.button[type];
55
+
56
+ if (hasVariant(button, variant)) {
57
+ return button[variant];
58
+ }
59
+
60
+ return theme.kitt.button[type].default;
60
61
  }
61
62
 
63
+ const StyledPressable = /*#__PURE__*/styled__default.Pressable.withConfig({
64
+ displayName: "AnimatedButtonPressable__StyledPressable",
65
+ componentId: "kitt-universal__sc-175vyve-0"
66
+ })(["", ""], ({
67
+ $isStretch
68
+ }) => {
69
+ if ($isStretch) return undefined;
70
+ return 'align-self: flex-start;';
71
+ });
72
+ const StyledAnimatedView = /*#__PURE__*/styled__default(Animated__default.View).withConfig({
73
+ displayName: "AnimatedButtonPressable__StyledAnimatedView",
74
+ componentId: "kitt-universal__sc-175vyve-1"
75
+ })(["border-radius:", "px;"], ({
76
+ theme
77
+ }) => theme.kitt.button.borderRadius);
78
+ const AnimatedButtonPressable = /*#__PURE__*/React.forwardRef(({
79
+ children,
80
+ disabled,
81
+ accessibilityRole,
82
+ $type,
83
+ $variant,
84
+ $isStretch,
85
+ href,
86
+ hrefAttrs,
87
+ testID,
88
+ onPress
89
+ }, ref) => {
90
+ const theme = /*#__PURE__*/styled.useTheme();
91
+ const pressed = Animated.useSharedValue(0);
92
+ const color = Animated.useSharedValue(0);
93
+ const {
94
+ backgroundColor,
95
+ pressedBackgroundColor
96
+ } = getVariantValuesIfExist(theme, $type, $variant);
97
+ const {
98
+ scale
99
+ } = theme.kitt.button;
100
+ const scaleStyles = Animated.useAnimatedStyle(function () {
101
+ const _f = function () {
102
+ return {
103
+ backgroundColor: Animated.interpolateColor(color.value, [0, 1], [backgroundColor, pressedBackgroundColor]),
104
+ transform: [{
105
+ scale: Animated.withSpring(pressed.value ? scale.base.active : scale.base.default)
106
+ }]
107
+ };
108
+ };
109
+
110
+ _f._closure = {
111
+ interpolateColor: Animated.interpolateColor,
112
+ color,
113
+ backgroundColor,
114
+ pressedBackgroundColor,
115
+ withSpring: Animated.withSpring,
116
+ pressed,
117
+ scale: {
118
+ base: {
119
+ active: scale.base.active,
120
+ default: scale.base.default
121
+ }
122
+ }
123
+ };
124
+ _f.asString = "function _f(){const{interpolateColor,color,backgroundColor,pressedBackgroundColor,withSpring,pressed,scale}=jsThis._closure;{return{backgroundColor:interpolateColor(color.value,[0,1],[backgroundColor,pressedBackgroundColor]),transform:[{scale:withSpring(pressed.value?scale.base.active:scale.base.default)}]};}}";
125
+ _f.__workletHash = 5368461229978;
126
+ _f.__location = "/home/circleci/repo/@ornikar/kitt-universal/src/Button/AnimatedButtonPressable.tsx (56:41)";
127
+ _f.__optimalization = 2;
128
+ return _f;
129
+ }());
130
+
131
+ const handlePressInOut = pressIn => {
132
+ color.value = Animated.withSpring(pressIn ? 1 : 0);
133
+ pressed.value = pressIn ? 1 : 0;
134
+ };
135
+
136
+ return /*#__PURE__*/jsxRuntime.jsx(StyledPressable, {
137
+ ref: ref,
138
+ disabled: disabled,
139
+ accessibilityRole: accessibilityRole,
140
+ testID: testID,
141
+ href: href,
142
+ hrefAttrs: hrefAttrs,
143
+ $isStretch: $isStretch,
144
+ $type: $type,
145
+ onPress: onPress,
146
+ onPressIn: () => {
147
+ handlePressInOut(true);
148
+ },
149
+ onPressOut: () => {
150
+ handlePressInOut(false);
151
+ },
152
+ children: /*#__PURE__*/jsxRuntime.jsx(StyledAnimatedView, {
153
+ style: disabled ? [{
154
+ transform: [{
155
+ scale: 1
156
+ }]
157
+ }] : [scaleStyles],
158
+ children: children
159
+ })
160
+ });
161
+ });
162
+
163
+ const BaseStyledButtonPressable = /*#__PURE__*/styled__default.View.withConfig({
164
+ displayName: "BaseStyledButtonPressable",
165
+ componentId: "kitt-universal__sc-4k8lse-0"
166
+ })(["position:relative;min-width:", "px;max-width:", ";width:", ";min-height:", "px;border-radius:", "px;flex-direction:row;align-items:center;justify-content:center;align-self:flex-start;background-color:", ";padding:", ";"], ({
167
+ theme
168
+ }) => theme.kitt.button.minWidth, ({
169
+ theme,
170
+ $isStretch
171
+ }) => $isStretch ? '100%' : `${theme.kitt.button.maxWidth}px`, ({
172
+ $isStretch
173
+ }) => $isStretch ? '100%' : 'auto', ({
174
+ theme
175
+ }) => theme.kitt.button.minHeight, ({
176
+ theme
177
+ }) => theme.kitt.button.borderRadius, ({
178
+ theme,
179
+ $isDisabled,
180
+ $type,
181
+ $variant
182
+ }) => {
183
+ if ($isDisabled) return theme.kitt.button.disabled.default.backgroundColor;
184
+ if (reactNative.Platform.OS !== 'web') return 'transparent';
185
+ return getVariantValuesIfExist(theme, $type, $variant).backgroundColor;
186
+ }, ({
187
+ theme,
188
+ $size,
189
+ $isDisabled
190
+ }) => {
191
+ const {
192
+ large,
193
+ default: defaultPadding,
194
+ disabled: disabledPadding,
195
+ xLarge
196
+ } = theme.kitt.button.contentPadding;
197
+ if ($size === 'large') return large;
198
+ if ($size === 'xlarge') return xLarge;
199
+ if ($isDisabled) return disabledPadding;
200
+ return defaultPadding;
201
+ });
202
+
62
203
  const KittBreakpoints = {
63
204
  /**
64
205
  * min-width: 0
@@ -121,8 +262,14 @@ const TypographyColorContext = /*#__PURE__*/React.createContext('black');
121
262
  function useTypographyColor() {
122
263
  return React.useContext(TypographyColorContext);
123
264
  }
265
+ const TypographyDefaultColorContext = /*#__PURE__*/React.createContext(undefined);
266
+
267
+ function useTypographyDefaultColor() {
268
+ return React.useContext(TypographyDefaultColorContext);
269
+ }
124
270
  /** @deprecated use native-base instead for SSR compatibility */
125
271
 
272
+
126
273
  const getTypographyTypeConfigKey = theme => {
127
274
  const isMediumOrAbove = theme.responsive.matchWindowSize({
128
275
  minWidth: KittBreakpoints.MEDIUM
@@ -154,6 +301,11 @@ function createNativeBaseFontSize(type) {
154
301
  });
155
302
  return fontSizeForNativeBase;
156
303
  }
304
+
305
+ function getNBThemeColorFromColorProps(colorName) {
306
+ return colorName ? `kitt.typography.${colorName}` : undefined;
307
+ }
308
+
157
309
  function Typography({
158
310
  accessibilityRole,
159
311
  base: legacyBase,
@@ -173,6 +325,7 @@ function Typography({
173
325
  ...otherProps
174
326
  }) {
175
327
  const isHeaderTypographyInContext = React.useContext(IsHeaderTypographyContext);
328
+ const defaultColor = useTypographyDefaultColor();
176
329
  const hasTypographyAncestor = isHeaderTypographyInContext !== undefined;
177
330
  const baseOrDefaultToBody = hasTypographyAncestor ? type.base : type.base ?? 'body';
178
331
  const isHeader = isTypographyHeader(baseOrDefaultToBody, isHeaderTypographyInContext);
@@ -189,14 +342,16 @@ function Typography({
189
342
  });
190
343
  }
191
344
 
345
+ const currentColor = !color && !hasTypographyAncestor ? defaultColor : color;
346
+
192
347
  const text = /*#__PURE__*/jsxRuntime.jsx(nativeBase.Text, {
193
348
  accessibilityRole: accessibilityRole || undefined,
194
349
  fontSize: fontSizeForNativeBase,
195
350
  lineHeight: hasTypographyAncestor ? undefined : fontSizeForNativeBase,
196
351
  fontWeight: isHeader ? `headers.${nonNullableVariant}` : `bodies.${nonNullableVariant}`,
197
352
  fontFamily: isHeader ? `headers.${nonNullableVariant}` : `bodies.${nonNullableVariant}`,
198
- color: color ? `kitt.typography.${color}` : undefined,
199
- textDecorationColor: color ? `kitt.typography.${color}` : undefined,
353
+ color: getNBThemeColorFromColorProps(currentColor),
354
+ textDecorationColor: getNBThemeColorFromColorProps(currentColor),
200
355
  ...otherProps
201
356
  });
202
357
 
@@ -240,6 +395,7 @@ const createHeading = (level, defaultBase) => {
240
395
  return TypographyHeading;
241
396
  };
242
397
 
398
+ Typography.SetDefaultColor = TypographyDefaultColorContext.Provider;
243
399
  Typography.Text = TypographyText;
244
400
  Typography.Paragraph = TypographyParagraph;
245
401
  Typography.Header1 = createHeading(1);
@@ -264,254 +420,36 @@ Typography.h4 = createHeading(4, 'header4');
264
420
 
265
421
  Typography.h5 = createHeading(5, 'header5');
266
422
 
267
- const getInitials = (firstname, lastname) => `${firstname[0]}${lastname[0]}`.toUpperCase();
268
-
269
- const StyledAvatarView = /*#__PURE__*/styled__default.View.withConfig({
270
- displayName: "Avatar__StyledAvatarView",
271
- componentId: "kitt-universal__sc-9miubv-0"
272
- })(["border-radius:", ";background-color:", ";height:", "px;width:", "px;overflow:hidden;align-items:center;justify-content:center;"], ({
273
- theme,
274
- $isRound,
275
- $size,
276
- $sizeVariant
277
- }) => {
278
- if ($isRound) return `${$size / 2}px`;
279
- return `${$sizeVariant === 'large' ? theme.kitt.avatar.large.borderRadius : theme.kitt.avatar.borderRadius}px`;
280
- }, ({
281
- theme,
282
- $isLight
283
- }) => $isLight ? theme.kitt.avatar.light.backgroundColor : theme.kitt.avatar.default.backgroundColor, ({
423
+ const defaultIconSize = 20;
424
+ const IconContainer$1 = /*#__PURE__*/styled__default.View.withConfig({
425
+ displayName: "Icon__IconContainer",
426
+ componentId: "kitt-universal__sc-usm0ol-0"
427
+ })(["color:", ";width:", "px;height:", "px;align-self:", ";"], ({
428
+ $color
429
+ }) => $color, ({
284
430
  $size
285
431
  }) => $size, ({
286
432
  $size
287
- }) => $size);
288
-
289
- function AvatarContent({
290
- size,
291
- src,
292
- firstname,
293
- lastname,
294
- alt,
295
- isLight,
296
- sizeVariant
433
+ }) => $size, ({
434
+ $align = 'auto'
435
+ }) => $align);
436
+ function Icon({
437
+ icon,
438
+ size = defaultIconSize,
439
+ align,
440
+ color
297
441
  }) {
298
- if (src) {
299
- return /*#__PURE__*/jsxRuntime.jsx(reactNative.Image, {
300
- source: {
301
- uri: src
302
- },
303
- style: {
304
- width: size,
305
- height: size
306
- },
307
- accessibilityLabel: alt
308
- });
309
- }
310
-
311
- if (firstname && lastname) {
312
- return /*#__PURE__*/jsxRuntime.jsx(Typography.Text, {
313
- base: sizeVariant === 'large' ? 'body-large' : 'body-small',
314
- variant: sizeVariant === 'large' ? 'bold' : 'regular',
315
- color: isLight ? 'black' : 'white',
316
- children: getInitials(firstname, lastname)
317
- });
318
- }
319
-
320
- return /*#__PURE__*/jsxRuntime.jsx(Icon, {
321
- icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.UserIcon, {}),
322
- color: isLight ? 'black' : 'white',
323
- size: size / 2
442
+ const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
443
+ color
324
444
  });
325
- }
326
-
327
- function Avatar({
328
- size = 40,
329
- round,
330
- light,
331
- sizeVariant,
332
- ...props
333
- }) {
334
- return /*#__PURE__*/jsxRuntime.jsx(StyledAvatarView, {
445
+ return /*#__PURE__*/jsxRuntime.jsx(IconContainer$1, {
446
+ $align: align,
335
447
  $size: size,
336
- $isRound: round,
337
- $isLight: light,
338
- $sizeVariant: sizeVariant,
339
- children: /*#__PURE__*/jsxRuntime.jsx(AvatarContent, {
340
- size: size,
341
- isLight: light,
342
- sizeVariant: sizeVariant,
343
- ...props
344
- })
448
+ $color: color,
449
+ children: clonedIcon
345
450
  });
346
451
  }
347
452
 
348
- function warn(message) {
349
- if (process.env.NODE_ENV !== 'production') {
350
- console.warn(message);
351
- }
352
- }
353
- function deprecatedMessage(symbol, deprecation, replaceBy) {
354
- const replaceMessage = replaceBy === undefined ? '' : `, please use ${replaceBy} instead`;
355
- warn(`[Deprecation] in ${symbol}: ${deprecation} is deprecated${replaceMessage}.`);
356
- }
357
- function deprecatedInComponent(component, deprecation, replaceBy) {
358
- deprecatedMessage(`<${component} />`, deprecation, replaceBy);
359
- }
360
-
361
- const hasVariant = (button, variant) => {
362
- return variant in button;
363
- };
364
-
365
- function getVariantValuesIfExist(theme, type, variant) {
366
- const button = theme.kitt.button[type];
367
-
368
- if (hasVariant(button, variant)) {
369
- return button[variant];
370
- }
371
-
372
- return theme.kitt.button[type].default;
373
- }
374
-
375
- const StyledPressable = /*#__PURE__*/styled__default.Pressable.withConfig({
376
- displayName: "AnimatedButtonPressable__StyledPressable",
377
- componentId: "kitt-universal__sc-175vyve-0"
378
- })(["", ""], ({
379
- $isStretch
380
- }) => {
381
- if ($isStretch) return undefined;
382
- return 'align-self: flex-start;';
383
- });
384
- const StyledAnimatedView = /*#__PURE__*/styled__default(Animated__default.View).withConfig({
385
- displayName: "AnimatedButtonPressable__StyledAnimatedView",
386
- componentId: "kitt-universal__sc-175vyve-1"
387
- })(["border-radius:", "px;"], ({
388
- theme
389
- }) => theme.kitt.button.borderRadius);
390
- const AnimatedButtonPressable = /*#__PURE__*/React.forwardRef(({
391
- children,
392
- disabled,
393
- accessibilityRole,
394
- $type,
395
- $variant,
396
- $isStretch,
397
- href,
398
- hrefAttrs,
399
- testID,
400
- onPress
401
- }, ref) => {
402
- const theme = /*#__PURE__*/styled.useTheme();
403
- const pressed = Animated.useSharedValue(0);
404
- const color = Animated.useSharedValue(0);
405
- const {
406
- backgroundColor,
407
- pressedBackgroundColor
408
- } = getVariantValuesIfExist(theme, $type, $variant);
409
- const {
410
- scale
411
- } = theme.kitt.button;
412
- const scaleStyles = Animated.useAnimatedStyle(function () {
413
- const _f = function () {
414
- return {
415
- backgroundColor: Animated.interpolateColor(color.value, [0, 1], [backgroundColor, pressedBackgroundColor]),
416
- transform: [{
417
- scale: Animated.withSpring(pressed.value ? scale.base.active : scale.base.default)
418
- }]
419
- };
420
- };
421
-
422
- _f._closure = {
423
- interpolateColor: Animated.interpolateColor,
424
- color,
425
- backgroundColor,
426
- pressedBackgroundColor,
427
- withSpring: Animated.withSpring,
428
- pressed,
429
- scale: {
430
- base: {
431
- active: scale.base.active,
432
- default: scale.base.default
433
- }
434
- }
435
- };
436
- _f.asString = "function _f(){const{interpolateColor,color,backgroundColor,pressedBackgroundColor,withSpring,pressed,scale}=jsThis._closure;{return{backgroundColor:interpolateColor(color.value,[0,1],[backgroundColor,pressedBackgroundColor]),transform:[{scale:withSpring(pressed.value?scale.base.active:scale.base.default)}]};}}";
437
- _f.__workletHash = 5368461229978;
438
- _f.__location = "/home/circleci/repo/@ornikar/kitt-universal/src/Button/AnimatedButtonPressable.tsx (56:41)";
439
- _f.__optimalization = 2;
440
- return _f;
441
- }());
442
-
443
- const handlePressInOut = pressIn => {
444
- color.value = Animated.withSpring(pressIn ? 1 : 0);
445
- pressed.value = pressIn ? 1 : 0;
446
- };
447
-
448
- return /*#__PURE__*/jsxRuntime.jsx(StyledPressable, {
449
- ref: ref,
450
- disabled: disabled,
451
- accessibilityRole: accessibilityRole,
452
- testID: testID,
453
- href: href,
454
- hrefAttrs: hrefAttrs,
455
- $isStretch: $isStretch,
456
- $type: $type,
457
- onPress: onPress,
458
- onPressIn: () => {
459
- handlePressInOut(true);
460
- },
461
- onPressOut: () => {
462
- handlePressInOut(false);
463
- },
464
- children: /*#__PURE__*/jsxRuntime.jsx(StyledAnimatedView, {
465
- style: disabled ? [{
466
- transform: [{
467
- scale: 1
468
- }]
469
- }] : [scaleStyles],
470
- children: children
471
- })
472
- });
473
- });
474
-
475
- const BaseStyledButtonPressable = /*#__PURE__*/styled__default.View.withConfig({
476
- displayName: "BaseStyledButtonPressable",
477
- componentId: "kitt-universal__sc-4k8lse-0"
478
- })(["position:relative;min-width:", "px;max-width:", ";width:", ";min-height:", "px;border-radius:", "px;flex-direction:row;align-items:center;justify-content:center;align-self:flex-start;background-color:", ";padding:", ";"], ({
479
- theme
480
- }) => theme.kitt.button.minWidth, ({
481
- theme,
482
- $isStretch
483
- }) => $isStretch ? '100%' : `${theme.kitt.button.maxWidth}px`, ({
484
- $isStretch
485
- }) => $isStretch ? '100%' : 'auto', ({
486
- theme
487
- }) => theme.kitt.button.minHeight, ({
488
- theme
489
- }) => theme.kitt.button.borderRadius, ({
490
- theme,
491
- $isDisabled,
492
- $type,
493
- $variant
494
- }) => {
495
- if ($isDisabled) return theme.kitt.button.disabled.default.backgroundColor;
496
- if (reactNative.Platform.OS !== 'web') return 'transparent';
497
- return getVariantValuesIfExist(theme, $type, $variant).backgroundColor;
498
- }, ({
499
- theme,
500
- $size,
501
- $isDisabled
502
- }) => {
503
- const {
504
- large,
505
- default: defaultPadding,
506
- disabled: disabledPadding,
507
- xLarge
508
- } = theme.kitt.button.contentPadding;
509
- if ($size === 'large') return large;
510
- if ($size === 'xlarge') return xLarge;
511
- if ($isDisabled) return disabledPadding;
512
- return defaultPadding;
513
- });
514
-
515
453
  function TypographyIconSpecifiedColor({
516
454
  color,
517
455
  ...props
@@ -659,7 +597,7 @@ function ButtonContentChildren({
659
597
  };
660
598
  return /*#__PURE__*/jsxRuntime.jsxs(StyledChildrenWithIcon, {
661
599
  children: [icon && iconPosition === 'left' ? /*#__PURE__*/jsxRuntime.jsx(ButtonIcon, { ...buttonIconSharedProps,
662
- testID: "button-left-icon",
600
+ testID: "button.ButtonContent.leftButtonIcon",
663
601
  icon: icon
664
602
  }) : null, /*#__PURE__*/jsxRuntime.jsx(StyledButtonText, {
665
603
  base: "body",
@@ -726,113 +664,686 @@ const StyledDisabled = /*#__PURE__*/styled__default.View.withConfig({
726
664
  theme
727
665
  }) => {
728
666
  const {
729
- borderWidth,
730
- disabled
731
- } = theme.kitt.button;
732
- return `${borderWidth.disabled}px solid ${disabled.default.borderColor}`;
667
+ borderWidth,
668
+ disabled
669
+ } = theme.kitt.button;
670
+ return `${borderWidth.disabled}px solid ${disabled.default.borderColor}`;
671
+ }, ({
672
+ theme
673
+ }) => theme.kitt.button.borderRadius);
674
+
675
+ const allowedGhostTypes = ['primary', 'default'];
676
+
677
+ const getButtonSize = ({
678
+ large,
679
+ xLarge,
680
+ size
681
+ }) => {
682
+ if (large) return 'large';
683
+ if (xLarge) return 'xlarge';
684
+ return size;
685
+ };
686
+
687
+ const Button = /*#__PURE__*/React.forwardRef(({
688
+ children,
689
+ type = 'default',
690
+ variant = 'default',
691
+ disabled,
692
+ stretch,
693
+ large,
694
+ xLarge,
695
+ icon,
696
+ size: sizeProp,
697
+ iconPosition = 'left',
698
+ testID,
699
+ href,
700
+ hrefAttrs,
701
+ accessibilityRole = 'button',
702
+ onPress
703
+ }, ref) => {
704
+ if ((process.env.NODE_ENV !== "production") && variant === 'ghost' && !allowedGhostTypes.includes(type)) {
705
+ throw new Error('variant=ghost is only allowed with type=primary or default');
706
+ }
707
+
708
+ if (large || xLarge) {
709
+ const deprecatedProp = large ? 'large' : 'xLarge';
710
+ deprecatedInComponent('Button', `${deprecatedProp} prop`, 'size');
711
+ }
712
+
713
+ const size = getButtonSize({
714
+ large,
715
+ xLarge,
716
+ size: sizeProp
717
+ });
718
+ return /*#__PURE__*/jsxRuntime.jsx(AnimatedButtonPressable, {
719
+ ref: ref,
720
+ accessibilityRole: accessibilityRole,
721
+ testID: testID,
722
+ href: href,
723
+ hrefAttrs: hrefAttrs,
724
+ disabled: disabled,
725
+ $isStretch: stretch,
726
+ $type: type,
727
+ $variant: variant,
728
+ onPress: onPress,
729
+ children: /*#__PURE__*/jsxRuntime.jsxs(BaseStyledButtonPressable, {
730
+ $type: type,
731
+ $variant: variant,
732
+ $isStretch: stretch,
733
+ $size: size,
734
+ $isDisabled: disabled,
735
+ children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
736
+ type: type,
737
+ variant: variant,
738
+ $isStretch: stretch,
739
+ isDisabled: disabled,
740
+ icon: icon,
741
+ iconPosition: iconPosition,
742
+ children: children
743
+ }), reactNative.Platform.OS !== 'web' && disabled ? /*#__PURE__*/jsxRuntime.jsx(StyledDisabled, {}) : null]
744
+ })
745
+ });
746
+ });
747
+
748
+ function SpinningIcon({
749
+ icon,
750
+ color
751
+ }) {
752
+ if (process.env.NODE_ENV !== 'production' && !color) {
753
+ throw new Error(`Invalid color passed to SpinningIcon: ${String(color)}`);
754
+ }
755
+
756
+ const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
757
+ color
758
+ });
759
+ const animationRef = React.useRef(new reactNative.Animated.Value(0));
760
+ const rotation = animationRef.current.interpolate({
761
+ inputRange: [0, 1],
762
+ outputRange: ['0deg', '360deg']
763
+ });
764
+ React.useEffect(() => {
765
+ if (process.env.NODE_ENV === 'test') return undefined;
766
+ const animation = reactNative.Animated.loop(reactNative.Animated.timing(animationRef.current, {
767
+ toValue: 1,
768
+ duration: 1100,
769
+ easing: reactNative.Easing.linear,
770
+ useNativeDriver: true
771
+ }));
772
+ animation.start();
773
+ return () => {
774
+ if (process.env.NODE_ENV === 'test') return undefined;
775
+ animation.stop();
776
+ return undefined;
777
+ };
778
+ }, []);
779
+ return /*#__PURE__*/jsxRuntime.jsx(reactNative.Animated.View, {
780
+ style: {
781
+ transform: [{
782
+ rotate: rotation
783
+ }]
784
+ },
785
+ children: clonedIcon
786
+ });
787
+ }
788
+
789
+ function LoaderIcon({
790
+ color
791
+ }) {
792
+ return /*#__PURE__*/jsxRuntime.jsx(SpinningIcon, {
793
+ color: color,
794
+ icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.ArcIcon, {})
795
+ });
796
+ }
797
+
798
+ const View = nativeBase.View;
799
+ const ScrollView = nativeBase.ScrollView;
800
+ const Pressable = nativeBase.Pressable;
801
+
802
+ function matchWindowSize({
803
+ width,
804
+ height
805
+ }, {
806
+ minWidth,
807
+ maxWidth,
808
+ minHeight,
809
+ maxHeight
810
+ }) {
811
+ const hasWidthMatched = width ? (!minWidth || width >= minWidth) && (!maxWidth || width <= maxWidth) : true;
812
+ const hasHeightMatched = height ? (!minHeight || height >= minHeight) && (!maxHeight || height <= maxHeight) : true;
813
+ return hasWidthMatched && hasHeightMatched;
814
+ }
815
+ function useMatchWindowSize(options) {
816
+ const {
817
+ width,
818
+ height
819
+ } = reactNative.useWindowDimensions();
820
+ return matchWindowSize({
821
+ width,
822
+ height
823
+ }, options);
824
+ }
825
+
826
+ function ActionsItem({
827
+ as,
828
+ onPress,
829
+ disabled,
830
+ icon,
831
+ ...props
832
+ }) {
833
+ const isMedium = useMatchWindowSize({
834
+ minWidth: KittBreakpoints.MEDIUM
835
+ });
836
+ const [isLoading, setIsLoading] = React.useState(false);
837
+ const mountedRef = React.useRef(false); // effect just for tracking mounted state, as onPress can unmount the ActionButton
838
+
839
+ React.useEffect(() => {
840
+ mountedRef.current = true;
841
+ return () => {
842
+ mountedRef.current = false;
843
+ };
844
+ }, []);
845
+ return /*#__PURE__*/jsxRuntime.jsx(View, {
846
+ children: /*#__PURE__*/jsxRuntime.jsx(as, { ...props,
847
+ stretch: !isMedium ? true : undefined,
848
+ disabled: isLoading ? true : disabled,
849
+ icon: isLoading ? /*#__PURE__*/jsxRuntime.jsx(LoaderIcon, {}) : icon,
850
+ onPress: e => {
851
+ (async () => {
852
+ if (!onPress) return;
853
+ setIsLoading(true);
854
+
855
+ try {
856
+ await onPress(e);
857
+
858
+ if (mountedRef.current) {
859
+ setIsLoading(false);
860
+ }
861
+ } catch (err) {
862
+ if (mountedRef.current) {
863
+ setIsLoading(false);
864
+ }
865
+
866
+ throw err;
867
+ }
868
+ })();
869
+ }
870
+ })
871
+ });
872
+ }
873
+
874
+ function ActionsButton({ ...props
875
+ }) {
876
+ return /*#__PURE__*/jsxRuntime.jsx(ActionsItem, {
877
+ as: Button,
878
+ ...props
879
+ });
880
+ }
881
+
882
+ function Actions({
883
+ children,
884
+ ...props
885
+ }) {
886
+ return /*#__PURE__*/jsxRuntime.jsx(Stack, {
887
+ alignItems: {
888
+ base: 'stretch',
889
+ medium: 'center'
890
+ },
891
+ direction: {
892
+ base: 'column',
893
+ medium: 'row'
894
+ },
895
+ flex: 1,
896
+ ...props,
897
+ space: "kitt.3",
898
+ children: children
899
+ });
900
+ }
901
+ Actions.Button = ActionsButton;
902
+ Actions.Item = ActionsItem;
903
+
904
+ const getInitials = (firstname, lastname) => `${firstname[0]}${lastname[0]}`.toUpperCase();
905
+
906
+ const StyledAvatarView = /*#__PURE__*/styled__default.View.withConfig({
907
+ displayName: "Avatar__StyledAvatarView",
908
+ componentId: "kitt-universal__sc-9miubv-0"
909
+ })(["border-radius:", ";background-color:", ";height:", "px;width:", "px;overflow:hidden;align-items:center;justify-content:center;"], ({
910
+ theme,
911
+ $isRound,
912
+ $size,
913
+ $sizeVariant
914
+ }) => {
915
+ if ($isRound) return `${$size / 2}px`;
916
+ return `${$sizeVariant === 'large' ? theme.kitt.avatar.large.borderRadius : theme.kitt.avatar.borderRadius}px`;
917
+ }, ({
918
+ theme,
919
+ $isLight
920
+ }) => $isLight ? theme.kitt.avatar.light.backgroundColor : theme.kitt.avatar.default.backgroundColor, ({
921
+ $size
922
+ }) => $size, ({
923
+ $size
924
+ }) => $size);
925
+
926
+ function AvatarContent({
927
+ size,
928
+ src,
929
+ firstname,
930
+ lastname,
931
+ alt,
932
+ isLight,
933
+ sizeVariant
934
+ }) {
935
+ if (src) {
936
+ return /*#__PURE__*/jsxRuntime.jsx(reactNative.Image, {
937
+ source: {
938
+ uri: src
939
+ },
940
+ style: {
941
+ width: size,
942
+ height: size
943
+ },
944
+ accessibilityLabel: alt
945
+ });
946
+ }
947
+
948
+ if (firstname && lastname) {
949
+ return /*#__PURE__*/jsxRuntime.jsx(Typography.Text, {
950
+ base: sizeVariant === 'large' ? 'body-large' : 'body-small',
951
+ variant: sizeVariant === 'large' ? 'bold' : 'regular',
952
+ color: isLight ? 'black' : 'white',
953
+ children: getInitials(firstname, lastname)
954
+ });
955
+ }
956
+
957
+ return /*#__PURE__*/jsxRuntime.jsx(Icon, {
958
+ icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.UserIcon, {}),
959
+ color: isLight ? 'black' : 'white',
960
+ size: size / 2
961
+ });
962
+ }
963
+
964
+ function Avatar({
965
+ size = 40,
966
+ round,
967
+ light,
968
+ sizeVariant,
969
+ ...props
970
+ }) {
971
+ return /*#__PURE__*/jsxRuntime.jsx(StyledAvatarView, {
972
+ $size: size,
973
+ $isRound: round,
974
+ $isLight: light,
975
+ $sizeVariant: sizeVariant,
976
+ children: /*#__PURE__*/jsxRuntime.jsx(AvatarContent, {
977
+ size: size,
978
+ isLight: light,
979
+ sizeVariant: sizeVariant,
980
+ ...props
981
+ })
982
+ });
983
+ }
984
+
985
+ const Container$5 = /*#__PURE__*/styled__default.View.withConfig({
986
+ displayName: "Card__Container",
987
+ componentId: "kitt-universal__sc-1n9psug-0"
988
+ })(["background-color:", ";padding:", "px;border-radius:", "px;border-width:", "px;border-color:", ";"], ({
989
+ theme,
990
+ type
991
+ }) => theme.kitt.card[type].backgroundColor, ({
992
+ theme
993
+ }) => theme.kitt.spacing * 4, ({
994
+ theme
995
+ }) => theme.kitt.card.borderRadius, ({
996
+ theme
997
+ }) => theme.kitt.card.borderWidth, ({
998
+ theme,
999
+ type
1000
+ }) => theme.kitt.card[type].borderColor);
1001
+ function Card({
1002
+ children,
1003
+ type
1004
+ }) {
1005
+ return /*#__PURE__*/jsxRuntime.jsx(Container$5, {
1006
+ type: type,
1007
+ children: children
1008
+ });
1009
+ }
1010
+
1011
+ const useNativeAnimation = ({
1012
+ selected,
1013
+ disabled,
1014
+ isPressedInternal
1015
+ }) => {
1016
+ const theme = /*#__PURE__*/styled.useTheme();
1017
+ const pressed = Animated.useSharedValue(Boolean(isPressedInternal));
1018
+ const progress = Animated.useDerivedValue(function () {
1019
+ const _f = function () {
1020
+ return Animated.withTiming(pressed.value ? 1 : 0, {
1021
+ duration: theme.kitt.choices.item.transition.duration
1022
+ });
1023
+ };
1024
+
1025
+ _f._closure = {
1026
+ withTiming: Animated.withTiming,
1027
+ pressed,
1028
+ theme: {
1029
+ kitt: {
1030
+ choices: {
1031
+ item: {
1032
+ transition: {
1033
+ duration: theme.kitt.choices.item.transition.duration
1034
+ }
1035
+ }
1036
+ }
1037
+ }
1038
+ }
1039
+ };
1040
+ _f.asString = "function _f(){const{withTiming,pressed,theme}=jsThis._closure;{return withTiming(pressed.value?1:0,{duration:theme.kitt.choices.item.transition.duration});}}";
1041
+ _f.__workletHash = 1120030177160;
1042
+ _f.__location = "/home/circleci/repo/@ornikar/kitt-universal/src/Choices/hooks/useNativeAnimation.tsx (31:35)";
1043
+ return _f;
1044
+ }());
1045
+ const backgroundStyles = Animated.useAnimatedStyle(function () {
1046
+ const _f = function () {
1047
+ const {
1048
+ default: defaultBg,
1049
+ pressed: pressedBg,
1050
+ selected: selectedBg,
1051
+ disabled: disabledBg
1052
+ } = theme.kitt.choices.item.backgroundColor;
1053
+ if (disabled) return {
1054
+ backgroundColor: disabledBg
1055
+ };
1056
+ if (selected) return {
1057
+ backgroundColor: selectedBg
1058
+ };
1059
+ return {
1060
+ backgroundColor: Animated.interpolateColor(progress.value, [0, 1], [defaultBg, pressedBg])
1061
+ };
1062
+ };
1063
+
1064
+ _f._closure = {
1065
+ theme: {
1066
+ kitt: {
1067
+ choices: {
1068
+ item: {
1069
+ backgroundColor: theme.kitt.choices.item.backgroundColor
1070
+ }
1071
+ }
1072
+ }
1073
+ },
1074
+ disabled,
1075
+ selected,
1076
+ interpolateColor: Animated.interpolateColor,
1077
+ progress
1078
+ };
1079
+ _f.asString = "function _f(){const{theme,disabled,selected,interpolateColor,progress}=jsThis._closure;{const{default:defaultBg,pressed:pressedBg,selected:selectedBg,disabled:disabledBg}=theme.kitt.choices.item.backgroundColor;if(disabled)return{backgroundColor:disabledBg};if(selected)return{backgroundColor:selectedBg};return{backgroundColor:interpolateColor(progress.value,[0,1],[defaultBg,pressedBg])};}}";
1080
+ _f.__workletHash = 15506726129309;
1081
+ _f.__location = "/home/circleci/repo/@ornikar/kitt-universal/src/Choices/hooks/useNativeAnimation.tsx (35:44)";
1082
+ return _f;
1083
+ }());
1084
+ return {
1085
+ onPressIn: () => {
1086
+ pressed.value = true;
1087
+ },
1088
+ onPressOut: () => {
1089
+ pressed.value = false;
1090
+ },
1091
+ backgroundStyles
1092
+ };
1093
+ };
1094
+
1095
+ function getCurrentTextColor({
1096
+ isDisabled,
1097
+ isSelected,
1098
+ isPressed,
1099
+ isHovered
1100
+ }) {
1101
+ if (isDisabled) return 'black-light';
1102
+ if (isSelected && isHovered) return 'white';
1103
+ if (isSelected || isPressed) return 'white';
1104
+ return 'black';
1105
+ }
1106
+
1107
+ function getBorderRadius(defaultRadius, variant) {
1108
+ // The clean way to have the rounded effect would have been to know the children height since radius >= height * 0.5
1109
+ // We don't control over the height of the rendered children we just go with a arbitrary really high value
1110
+ if (variant === 'rounded') return 800;
1111
+ return defaultRadius;
1112
+ }
1113
+
1114
+ const DisabledBorder = /*#__PURE__*/styled__default(reactNative.View).withConfig({
1115
+ displayName: "ChoiceItem__DisabledBorder",
1116
+ componentId: "kitt-universal__sc-wuv3y6-0"
1117
+ })(["border-radius:", "px;", ";"], ({
1118
+ theme,
1119
+ $variant
1120
+ }) => getBorderRadius(theme.kitt.choices.item.borderRadius, $variant), ({
1121
+ theme
1122
+ }) => {
1123
+ const {
1124
+ width,
1125
+ color
1126
+ } = theme.kitt.choices.item.disabled.border;
1127
+ return styled.css(["border:", "px solid ", ";"], width, color);
1128
+ });
1129
+ const ChoiceItemView = /*#__PURE__*/styled__default(reactNative.Platform.OS === 'web' ? reactNative.View : Animated__default.View).withConfig({
1130
+ displayName: "ChoiceItem__ChoiceItemView",
1131
+ componentId: "kitt-universal__sc-wuv3y6-1"
1132
+ })(["position:relative;border-radius:", "px;background-color:", ";", ";", ""], ({
1133
+ theme,
1134
+ $variant
1135
+ }) => getBorderRadius(theme.kitt.choices.item.borderRadius, $variant), ({
1136
+ theme,
1137
+ $isHovered,
1138
+ $isPressed,
1139
+ $isDisabled,
1140
+ $isSelected
1141
+ }) => {
1142
+ const {
1143
+ hoverWhenSelected,
1144
+ hover,
1145
+ disabled,
1146
+ selected,
1147
+ pressed,
1148
+ default: defaultBackground
1149
+ } = theme.kitt.choices.item.backgroundColor;
1150
+ if ($isDisabled) return disabled;
1151
+ if ($isSelected && $isHovered) return hoverWhenSelected;
1152
+ if ($isPressed) return pressed;
1153
+ if ($isHovered) return hover;
1154
+ if ($isSelected) return selected;
1155
+ return defaultBackground;
1156
+ }, ({
1157
+ theme
1158
+ }) => {
1159
+ const {
1160
+ base,
1161
+ small
1162
+ } = theme.kitt.choices.item.padding;
1163
+ return theme.responsive.ifWindowSizeMatches({
1164
+ minWidth: KittBreakpoints.SMALL
1165
+ }, styled.css(["padding:", "px;"], small), styled.css(["padding:", "px;"], base));
733
1166
  }, ({
734
1167
  theme
735
- }) => theme.kitt.button.borderRadius);
736
-
737
- const allowedGhostTypes = ['primary', 'default'];
738
-
739
- const getButtonSize = ({
740
- large,
741
- xLarge,
742
- size
743
1168
  }) => {
744
- if (large) return 'large';
745
- if (xLarge) return 'xlarge';
746
- return size;
747
- };
748
-
749
- const Button = /*#__PURE__*/React.forwardRef(({
750
- children,
751
- type = 'default',
752
- variant = 'default',
1169
+ if (reactNative.Platform.OS !== 'web') return undefined;
1170
+ const {
1171
+ property,
1172
+ duration,
1173
+ timingFunction
1174
+ } = theme.kitt.choices.item.transition;
1175
+ return styled.css(["transition:", " ", "ms ", ";"], property, duration, timingFunction);
1176
+ });
1177
+ function ChoiceItem({
1178
+ type = 'button',
1179
+ value,
1180
+ selected,
753
1181
  disabled,
754
- stretch,
755
- large,
756
- xLarge,
757
- icon,
758
- size: sizeProp,
759
- iconPosition = 'left',
760
- testID,
761
- href,
762
- hrefAttrs,
763
- accessibilityRole = 'button',
764
- onPress
765
- }, ref) => {
766
- if ((process.env.NODE_ENV !== "production") && variant === 'ghost' && !allowedGhostTypes.includes(type)) {
767
- throw new Error('variant=ghost is only allowed with type=primary or default');
768
- }
1182
+ variant,
1183
+ children,
1184
+ isPressedInternal,
1185
+ isHoveredInternal,
1186
+ onPress,
1187
+ onChange,
1188
+ onBlur,
1189
+ onFocus
1190
+ }) {
1191
+ const {
1192
+ onPressIn,
1193
+ onPressOut,
1194
+ backgroundStyles
1195
+ } = useNativeAnimation({
1196
+ selected,
1197
+ disabled,
1198
+ isPressedInternal
1199
+ });
769
1200
 
770
- if (large || xLarge) {
771
- const deprecatedProp = large ? 'large' : 'xLarge';
772
- deprecatedInComponent('Button', `${deprecatedProp} prop`, 'size');
773
- }
1201
+ const handleChange = () => {
1202
+ if (!onChange) return; // Checkbox can be toggled
774
1203
 
775
- const size = getButtonSize({
776
- large,
777
- xLarge,
778
- size: sizeProp
779
- });
780
- return /*#__PURE__*/jsxRuntime.jsx(AnimatedButtonPressable, {
781
- ref: ref,
782
- accessibilityRole: accessibilityRole,
783
- testID: testID,
784
- href: href,
785
- hrefAttrs: hrefAttrs,
1204
+ if (type === 'checkbox') {
1205
+ onChange(selected ? undefined : value);
1206
+ return;
1207
+ }
1208
+
1209
+ onChange(value);
1210
+ };
1211
+
1212
+ return /*#__PURE__*/jsxRuntime.jsx(Pressable, {
786
1213
  disabled: disabled,
787
- $isStretch: stretch,
788
- $type: type,
789
- $variant: variant,
790
- onPress: onPress,
791
- children: /*#__PURE__*/jsxRuntime.jsxs(BaseStyledButtonPressable, {
792
- $type: type,
793
- $variant: variant,
794
- $isStretch: stretch,
795
- $size: size,
1214
+ accessibilityRole: type,
1215
+ accessibilityState: {
1216
+ checked: selected
1217
+ },
1218
+ onBlur: onBlur,
1219
+ onFocus: onFocus,
1220
+ onPress: e => {
1221
+ if (onFocus) onFocus(e);
1222
+ if (onPress) onPress();
1223
+ handleChange();
1224
+ if (onBlur) onBlur(e);
1225
+ },
1226
+ onPressIn: onPressIn,
1227
+ onPressOut: onPressOut,
1228
+ children: ({
1229
+ isHovered,
1230
+ isPressed
1231
+ }) => /*#__PURE__*/jsxRuntime.jsxs(ChoiceItemView, {
1232
+ style: reactNative.Platform.OS !== 'web' ? [backgroundStyles] : undefined,
1233
+ $isHovered: isHovered || isHoveredInternal,
796
1234
  $isDisabled: disabled,
797
- children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
798
- type: type,
799
- variant: variant,
800
- $isStretch: stretch,
801
- isDisabled: disabled,
802
- icon: icon,
803
- iconPosition: iconPosition,
1235
+ $isSelected: selected,
1236
+ $isPressed: isPressed || isPressedInternal,
1237
+ $variant: variant,
1238
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography.SetDefaultColor, {
1239
+ value: getCurrentTextColor({
1240
+ isDisabled: disabled,
1241
+ isSelected: selected || isPressedInternal,
1242
+ isPressed,
1243
+ isHovered: isHovered || isHoveredInternal
1244
+ }),
804
1245
  children: children
805
- }), reactNative.Platform.OS !== 'web' && disabled ? /*#__PURE__*/jsxRuntime.jsx(StyledDisabled, {}) : null]
1246
+ }), disabled ? /*#__PURE__*/jsxRuntime.jsx(DisabledBorder, {
1247
+ $variant: variant,
1248
+ style: reactNative.StyleSheet.absoluteFillObject
1249
+ }) : null]
806
1250
  })
807
1251
  });
808
- });
1252
+ }
809
1253
 
810
- const Container$5 = /*#__PURE__*/styled__default.View.withConfig({
811
- displayName: "Card__Container",
812
- componentId: "kitt-universal__sc-1n9psug-0"
813
- })(["background-color:", ";padding:", "px;border-radius:", "px;border-width:", "px;border-color:", ";"], ({
814
- theme,
815
- type
816
- }) => theme.kitt.card[type].backgroundColor, ({
817
- theme
818
- }) => theme.kitt.spacing * 4, ({
819
- theme
820
- }) => theme.kitt.card.borderRadius, ({
821
- theme
822
- }) => theme.kitt.card.borderWidth, ({
1254
+ const ChoiceItemContainer = /*#__PURE__*/styled__default(reactNative.View).withConfig({
1255
+ displayName: "ChoiceItemContainer",
1256
+ componentId: "kitt-universal__sc-17uuimx-0"
1257
+ })(["", ""], ({
823
1258
  theme,
824
- type
825
- }) => theme.kitt.card[type].borderColor);
826
- function Card({
1259
+ $isLast,
1260
+ $direction
1261
+ }) => {
1262
+ const {
1263
+ row,
1264
+ column
1265
+ } = theme.kitt.choices.spacing;
1266
+
1267
+ if ($direction === 'row') {
1268
+ return styled.css(["margin-right:", "px;"], $isLast ? 0 : row);
1269
+ }
1270
+
1271
+ return styled.css(["margin-bottom:", "px;"], $isLast ? 0 : column);
1272
+ });
1273
+
1274
+ function ChoicesContainer({
1275
+ direction,
1276
+ ...props
1277
+ }) {
1278
+ if (direction === 'row') {
1279
+ return /*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
1280
+ horizontal: true,
1281
+ ...props
1282
+ });
1283
+ }
1284
+
1285
+ return /*#__PURE__*/jsxRuntime.jsx(reactNative.View, { ...props
1286
+ });
1287
+ }
1288
+
1289
+ function Choices({
1290
+ id,
1291
+ testID,
1292
+ type,
1293
+ direction = 'column',
1294
+ disabled,
827
1295
  children,
828
- type
1296
+ value,
1297
+ variant,
1298
+ onPress,
1299
+ onChange,
1300
+ onFocus,
1301
+ onBlur
829
1302
  }) {
830
- return /*#__PURE__*/jsxRuntime.jsx(Container$5, {
831
- type: type,
832
- children: children
1303
+ const [currentValue, setCurrentValue] = React.useState(value);
1304
+ const isForm = type && ['radio', 'checkbox'].includes(type);
1305
+ const childrenArray = React.Children.toArray(children);
1306
+ const sharedProps = {
1307
+ type,
1308
+ disabled,
1309
+ variant,
1310
+ onPress: !isForm ? onPress : undefined,
1311
+ onChange: isForm ? newValue => {
1312
+ setCurrentValue(newValue);
1313
+ if (onChange) onChange(newValue);
1314
+ } : undefined,
1315
+ onFocus,
1316
+ onBlur
1317
+ };
1318
+ return /*#__PURE__*/jsxRuntime.jsx(ChoicesContainer, {
1319
+ direction: direction,
1320
+ testID: testID,
1321
+ nativeID: id,
1322
+ children: childrenArray.map((child, index) => {
1323
+ const element = /*#__PURE__*/React.cloneElement(child, {
1324
+ selected: isForm ? child.props.value === currentValue : undefined,
1325
+ ...sharedProps
1326
+ });
1327
+ return /*#__PURE__*/jsxRuntime.jsx(ChoiceItemContainer, {
1328
+ $direction: direction,
1329
+ $isLast: index === childrenArray.length - 1,
1330
+ children: element
1331
+ }, child.key);
1332
+ })
833
1333
  });
834
1334
  }
835
1335
 
1336
+ Choices.Item = ChoiceItem;
1337
+ function createChoicesComponent() {
1338
+ return Choices;
1339
+ }
1340
+ const ButtonChoices = createChoicesComponent();
1341
+ Choices.ButtonChoices = ButtonChoices;
1342
+ const ChoicesElements = {
1343
+ Item: ChoiceItem,
1344
+ ButtonChoices
1345
+ };
1346
+
836
1347
  function Emoji({
837
1348
  emoji,
838
1349
  size,
@@ -1159,6 +1670,39 @@ const card = {
1159
1670
  }
1160
1671
  };
1161
1672
 
1673
+ const choices = {
1674
+ spacing: {
1675
+ row: 12,
1676
+ column: 12
1677
+ },
1678
+ item: {
1679
+ borderRadius: 10,
1680
+ padding: {
1681
+ base: 16,
1682
+ small: 24
1683
+ },
1684
+ backgroundColor: {
1685
+ default: lateOceanColorPalette.black50,
1686
+ disabled: colors.disabled,
1687
+ selected: colors.primary,
1688
+ pressed: lateOceanColorPalette.lateOceanLight1,
1689
+ hover: lateOceanColorPalette.black100,
1690
+ hoverWhenSelected: lateOceanColorPalette.lateOceanLight1
1691
+ },
1692
+ disabled: {
1693
+ border: {
1694
+ width: 2,
1695
+ color: lateOceanColorPalette.black100
1696
+ }
1697
+ },
1698
+ transition: {
1699
+ property: 'all',
1700
+ duration: 300,
1701
+ timingFunction: 'cubic-bezier(0.645, 0.045, 0.355, 1)'
1702
+ }
1703
+ }
1704
+ };
1705
+
1162
1706
  const feedbackMessage = {
1163
1707
  danger: {
1164
1708
  backgroundColor: colors.danger
@@ -1330,8 +1874,14 @@ const input = {
1330
1874
  };
1331
1875
 
1332
1876
  const inputField = {
1877
+ containerPaddingTop: 5,
1878
+ containerPaddingBottom: 10,
1879
+ feedbackPaddingTop: {
1880
+ base: 5,
1881
+ small: 10
1882
+ },
1333
1883
  labelContainerPaddingBottom: 5,
1334
- iconMarginLeft: 6
1884
+ labelFeedbackMarginLeft: 6
1335
1885
  };
1336
1886
 
1337
1887
  const inputTag = {
@@ -1572,6 +2122,7 @@ const theme = {
1572
2122
  breakpoints,
1573
2123
  button,
1574
2124
  card,
2125
+ choices,
1575
2126
  feedbackMessage,
1576
2127
  forms,
1577
2128
  fullScreenModal,
@@ -1587,30 +2138,6 @@ const theme = {
1587
2138
  navigationModal
1588
2139
  };
1589
2140
 
1590
- function matchWindowSize({
1591
- width,
1592
- height
1593
- }, {
1594
- minWidth,
1595
- maxWidth,
1596
- minHeight,
1597
- maxHeight
1598
- }) {
1599
- const hasWidthMatched = width ? (!minWidth || width >= minWidth) && (!maxWidth || width <= maxWidth) : true;
1600
- const hasHeightMatched = height ? (!minHeight || height >= minHeight) && (!maxHeight || height <= maxHeight) : true;
1601
- return hasWidthMatched && hasHeightMatched;
1602
- }
1603
- function useMatchWindowSize(options) {
1604
- const {
1605
- width,
1606
- height
1607
- } = reactNative.useWindowDimensions();
1608
- return matchWindowSize({
1609
- width,
1610
- height
1611
- }, options);
1612
- }
1613
-
1614
2141
  // eslint-disable-next-line no-restricted-imports
1615
2142
  function createWindowSizeHelper(dimensions) {
1616
2143
  return {
@@ -2629,42 +3156,26 @@ function InputFeedback({
2629
3156
  });
2630
3157
  }
2631
3158
 
2632
- const FieldContainer = /*#__PURE__*/styled__default.View.withConfig({
2633
- displayName: "InputField__FieldContainer",
2634
- componentId: "kitt-universal__sc-13fkixs-0"
2635
- })(["padding:5px 0 10px;"]);
2636
- const FeedbackContainer = /*#__PURE__*/styled__default.View.withConfig({
2637
- displayName: "InputField__FeedbackContainer",
2638
- componentId: "kitt-universal__sc-13fkixs-1"
2639
- })(["", ";"], ({
2640
- theme
2641
- }) => theme.responsive.ifWindowSizeMatches({
2642
- minWidth: KittBreakpoints.SMALL
2643
- }, 'padding-top: 10px', 'padding-top: 5px'));
2644
- const FieldLabelContainer = /*#__PURE__*/styled__default.View.withConfig({
2645
- displayName: "InputField__FieldLabelContainer",
2646
- componentId: "kitt-universal__sc-13fkixs-2"
2647
- })(["flex-direction:row;align-items:center;padding-bottom:", "px;"], ({
2648
- theme
2649
- }) => theme.kitt.forms.inputField.labelContainerPaddingBottom);
2650
- const LabelContainer = /*#__PURE__*/styled__default.View.withConfig({
2651
- displayName: "InputField__LabelContainer",
2652
- componentId: "kitt-universal__sc-13fkixs-3"
2653
- })(["margin-right:", "px;"], ({
2654
- theme
2655
- }) => theme.kitt.forms.inputField.iconMarginLeft);
2656
3159
  function InputField({
2657
3160
  label,
2658
3161
  labelFeedback,
2659
3162
  input,
2660
3163
  feedback
2661
3164
  }) {
2662
- return /*#__PURE__*/jsxRuntime.jsxs(FieldContainer, {
2663
- children: [label ? /*#__PURE__*/jsxRuntime.jsxs(FieldLabelContainer, {
2664
- children: [/*#__PURE__*/jsxRuntime.jsx(LabelContainer, {
3165
+ const theme = /*#__PURE__*/styled.useTheme();
3166
+ return /*#__PURE__*/jsxRuntime.jsxs(View, {
3167
+ paddingTop: theme.kitt.forms.inputField.containerPaddingTop,
3168
+ paddingBottom: theme.kitt.forms.inputField.containerPaddingBottom,
3169
+ children: [label ? /*#__PURE__*/jsxRuntime.jsxs(View, {
3170
+ flexDirection: "row",
3171
+ alignItems: "center",
3172
+ paddingBottom: theme.kitt.forms.inputField.labelContainerPaddingBottom,
3173
+ children: [/*#__PURE__*/jsxRuntime.jsx(View, {
3174
+ marginRight: theme.kitt.forms.inputField.labelFeedbackMarginLeft,
2665
3175
  children: label
2666
3176
  }), labelFeedback]
2667
- }) : null, input, feedback ? /*#__PURE__*/jsxRuntime.jsx(FeedbackContainer, {
3177
+ }) : null, input, feedback ? /*#__PURE__*/jsxRuntime.jsx(View, {
3178
+ paddingTop: theme.kitt.forms.inputField.feedbackPaddingTop,
2668
3179
  children: feedback
2669
3180
  }) : null]
2670
3181
  });
@@ -3043,47 +3554,6 @@ function FullScreenModal({
3043
3554
  FullScreenModal.Header = FullScreenModalHeader;
3044
3555
  FullScreenModal.Body = FullScreenModalBody;
3045
3556
 
3046
- function SpinningIcon({
3047
- icon,
3048
- color
3049
- }) {
3050
- if (process.env.NODE_ENV !== 'production' && !color) {
3051
- throw new Error(`Invalid color passed to SpinningIcon: ${String(color)}`);
3052
- }
3053
-
3054
- const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
3055
- color
3056
- });
3057
- const animationRef = React.useRef(new reactNative.Animated.Value(0));
3058
- const rotation = animationRef.current.interpolate({
3059
- inputRange: [0, 1],
3060
- outputRange: ['0deg', '360deg']
3061
- });
3062
- React.useEffect(() => {
3063
- if (process.env.NODE_ENV === 'test') return undefined;
3064
- const animation = reactNative.Animated.loop(reactNative.Animated.timing(animationRef.current, {
3065
- toValue: 1,
3066
- duration: 1100,
3067
- easing: reactNative.Easing.linear,
3068
- useNativeDriver: true
3069
- }));
3070
- animation.start();
3071
- return () => {
3072
- if (process.env.NODE_ENV === 'test') return undefined;
3073
- animation.stop();
3074
- return undefined;
3075
- };
3076
- }, []);
3077
- return /*#__PURE__*/jsxRuntime.jsx(reactNative.Animated.View, {
3078
- style: {
3079
- transform: [{
3080
- rotate: rotation
3081
- }]
3082
- },
3083
- children: clonedIcon
3084
- });
3085
- }
3086
-
3087
3557
  const ContentView = /*#__PURE__*/styled__default.View.withConfig({
3088
3558
  displayName: "ListItemContent__ContentView",
3089
3559
  componentId: "kitt-universal__sc-57q0u9-0"
@@ -3206,15 +3676,6 @@ ListItem.Content = ListItemContent;
3206
3676
  ListItem.SideContent = ListItemSideContent;
3207
3677
  ListItem.SideContainer = ListItemSideContainer;
3208
3678
 
3209
- function LoaderIcon({
3210
- color
3211
- }) {
3212
- return /*#__PURE__*/jsxRuntime.jsx(SpinningIcon, {
3213
- color: color,
3214
- icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.ArcIcon, {})
3215
- });
3216
- }
3217
-
3218
3679
  function IconContent({
3219
3680
  type,
3220
3681
  color
@@ -3581,14 +4042,6 @@ function KittNativeBaseProvider({
3581
4042
  });
3582
4043
  }
3583
4044
 
3584
- const Stack = nativeBase.Stack;
3585
- const VStack = nativeBase.VStack;
3586
- const HStack = nativeBase.HStack;
3587
-
3588
- const View = nativeBase.View;
3589
- const ScrollView = nativeBase.ScrollView;
3590
- const Pressable = nativeBase.Pressable;
3591
-
3592
4045
  const ViewWithPadding = /*#__PURE__*/styled__default(reactNative.View).withConfig({
3593
4046
  displayName: "ContentPadding__ViewWithPadding",
3594
4047
  componentId: "kitt-universal__sc-1rprqcv-0"
@@ -4638,7 +5091,7 @@ function ModalDateTimePicker({
4638
5091
  }) : null, /*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
4639
5092
  children: /*#__PURE__*/jsxRuntime.jsx(DateTimePicker__default, {
4640
5093
  is24Hour: true,
4641
- testID: "date-picker-native-element",
5094
+ testID: "timePicker.ModalDateTimePicker.dateTimeNativePicker",
4642
5095
  value: currentValue,
4643
5096
  mode: "time",
4644
5097
  display: reactNative.Platform.OS === 'ios' ? 'spinner' : 'default',
@@ -4732,7 +5185,7 @@ function TimePicker({
4732
5185
  children: displayedValue
4733
5186
  }), reactNative.Platform.OS === 'android' && isTimePickerModalVisible ? /*#__PURE__*/jsxRuntime.jsx(DateTimePicker__default, {
4734
5187
  is24Hour: true,
4735
- testID: "date-picker-native-element",
5188
+ testID: "timePicker.TimePicker.dateTimeNativePicker",
4736
5189
  value: dateTimePickerValue,
4737
5190
  mode: "time",
4738
5191
  display: "default",
@@ -5099,10 +5552,12 @@ function MatchWindowSize({
5099
5552
  }
5100
5553
 
5101
5554
  exports.useWindowSize = reactNative.useWindowDimensions;
5555
+ exports.Actions = Actions;
5102
5556
  exports.Avatar = Avatar;
5103
5557
  exports.Button = Button;
5104
5558
  exports.Card = Card;
5105
5559
  exports.Checkbox = Checkbox;
5560
+ exports.ChoicesElements = ChoicesElements;
5106
5561
  exports.DatePicker = DatePicker;
5107
5562
  exports.Emoji = Emoji;
5108
5563
  exports.ExternalAppLink = ExternalAppLink;
@@ -5163,6 +5618,7 @@ exports.TypographyIcon = TypographyIcon;
5163
5618
  exports.TypographyLink = TypographyLink;
5164
5619
  exports.VStack = VStack;
5165
5620
  exports.View = View;
5621
+ exports.createChoicesComponent = createChoicesComponent;
5166
5622
  exports.createWindowSizeHelper = createWindowSizeHelper;
5167
5623
  exports.hex2rgba = hex2rgba;
5168
5624
  exports.matchWindowSize = matchWindowSize;