@ornikar/kitt-universal 9.4.0 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) 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.map +1 -1
  8. package/dist/definitions/IconButton/IconButton.d.ts +1 -1
  9. package/dist/definitions/IconButton/IconButton.d.ts.map +1 -1
  10. package/dist/definitions/IconButton/PressableAnimatedContainer.d.ts +1 -1
  11. package/dist/definitions/IconButton/PressableAnimatedContainer.d.ts.map +1 -1
  12. package/dist/definitions/forms/InputText/InputTextContainer.web.d.ts +1 -1
  13. package/dist/definitions/index.d.ts +4 -0
  14. package/dist/definitions/index.d.ts.map +1 -1
  15. package/dist/definitions/native-base/KittNativeBaseProvider.d.ts +15 -15
  16. package/dist/definitions/story-components/StoryBlock.d.ts +1 -1
  17. package/dist/definitions/typography/TypographyLink.d.ts +1 -1
  18. package/dist/definitions/typography/TypographyLink.d.ts.map +1 -1
  19. package/dist/index-browser-all.es.android.js +598 -480
  20. package/dist/index-browser-all.es.android.js.map +1 -1
  21. package/dist/index-browser-all.es.ios.js +598 -480
  22. package/dist/index-browser-all.es.ios.js.map +1 -1
  23. package/dist/index-browser-all.es.js +598 -480
  24. package/dist/index-browser-all.es.js.map +1 -1
  25. package/dist/index-browser-all.es.web.js +627 -509
  26. package/dist/index-browser-all.es.web.js.map +1 -1
  27. package/dist/index-node-14.17.cjs.js +535 -456
  28. package/dist/index-node-14.17.cjs.js.map +1 -1
  29. package/dist/index-node-14.17.cjs.web.css +1 -1
  30. package/dist/index-node-14.17.cjs.web.js +464 -385
  31. package/dist/index-node-14.17.cjs.web.js.map +1 -1
  32. package/dist/styles.css +1 -1
  33. package/dist/tsbuildinfo +1 -1
  34. package/package.json +2 -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
@@ -279,254 +420,36 @@ Typography.h4 = createHeading(4, 'header4');
279
420
 
280
421
  Typography.h5 = createHeading(5, 'header5');
281
422
 
282
- const getInitials = (firstname, lastname) => `${firstname[0]}${lastname[0]}`.toUpperCase();
283
-
284
- const StyledAvatarView = /*#__PURE__*/styled__default.View.withConfig({
285
- displayName: "Avatar__StyledAvatarView",
286
- componentId: "kitt-universal__sc-9miubv-0"
287
- })(["border-radius:", ";background-color:", ";height:", "px;width:", "px;overflow:hidden;align-items:center;justify-content:center;"], ({
288
- theme,
289
- $isRound,
290
- $size,
291
- $sizeVariant
292
- }) => {
293
- if ($isRound) return `${$size / 2}px`;
294
- return `${$sizeVariant === 'large' ? theme.kitt.avatar.large.borderRadius : theme.kitt.avatar.borderRadius}px`;
295
- }, ({
296
- theme,
297
- $isLight
298
- }) => $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, ({
299
430
  $size
300
431
  }) => $size, ({
301
432
  $size
302
- }) => $size);
303
-
304
- function AvatarContent({
305
- size,
306
- src,
307
- firstname,
308
- lastname,
309
- alt,
310
- isLight,
311
- sizeVariant
433
+ }) => $size, ({
434
+ $align = 'auto'
435
+ }) => $align);
436
+ function Icon({
437
+ icon,
438
+ size = defaultIconSize,
439
+ align,
440
+ color
312
441
  }) {
313
- if (src) {
314
- return /*#__PURE__*/jsxRuntime.jsx(reactNative.Image, {
315
- source: {
316
- uri: src
317
- },
318
- style: {
319
- width: size,
320
- height: size
321
- },
322
- accessibilityLabel: alt
323
- });
324
- }
325
-
326
- if (firstname && lastname) {
327
- return /*#__PURE__*/jsxRuntime.jsx(Typography.Text, {
328
- base: sizeVariant === 'large' ? 'body-large' : 'body-small',
329
- variant: sizeVariant === 'large' ? 'bold' : 'regular',
330
- color: isLight ? 'black' : 'white',
331
- children: getInitials(firstname, lastname)
332
- });
333
- }
334
-
335
- return /*#__PURE__*/jsxRuntime.jsx(Icon, {
336
- icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.UserIcon, {}),
337
- color: isLight ? 'black' : 'white',
338
- size: size / 2
442
+ const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
443
+ color
339
444
  });
340
- }
341
-
342
- function Avatar({
343
- size = 40,
344
- round,
345
- light,
346
- sizeVariant,
347
- ...props
348
- }) {
349
- return /*#__PURE__*/jsxRuntime.jsx(StyledAvatarView, {
445
+ return /*#__PURE__*/jsxRuntime.jsx(IconContainer$1, {
446
+ $align: align,
350
447
  $size: size,
351
- $isRound: round,
352
- $isLight: light,
353
- $sizeVariant: sizeVariant,
354
- children: /*#__PURE__*/jsxRuntime.jsx(AvatarContent, {
355
- size: size,
356
- isLight: light,
357
- sizeVariant: sizeVariant,
358
- ...props
359
- })
448
+ $color: color,
449
+ children: clonedIcon
360
450
  });
361
451
  }
362
452
 
363
- function warn(message) {
364
- if (process.env.NODE_ENV !== 'production') {
365
- console.warn(message);
366
- }
367
- }
368
- function deprecatedMessage(symbol, deprecation, replaceBy) {
369
- const replaceMessage = replaceBy === undefined ? '' : `, please use ${replaceBy} instead`;
370
- warn(`[Deprecation] in ${symbol}: ${deprecation} is deprecated${replaceMessage}.`);
371
- }
372
- function deprecatedInComponent(component, deprecation, replaceBy) {
373
- deprecatedMessage(`<${component} />`, deprecation, replaceBy);
374
- }
375
-
376
- const hasVariant = (button, variant) => {
377
- return variant in button;
378
- };
379
-
380
- function getVariantValuesIfExist(theme, type, variant) {
381
- const button = theme.kitt.button[type];
382
-
383
- if (hasVariant(button, variant)) {
384
- return button[variant];
385
- }
386
-
387
- return theme.kitt.button[type].default;
388
- }
389
-
390
- const StyledPressable = /*#__PURE__*/styled__default.Pressable.withConfig({
391
- displayName: "AnimatedButtonPressable__StyledPressable",
392
- componentId: "kitt-universal__sc-175vyve-0"
393
- })(["", ""], ({
394
- $isStretch
395
- }) => {
396
- if ($isStretch) return undefined;
397
- return 'align-self: flex-start;';
398
- });
399
- const StyledAnimatedView = /*#__PURE__*/styled__default(Animated__default.View).withConfig({
400
- displayName: "AnimatedButtonPressable__StyledAnimatedView",
401
- componentId: "kitt-universal__sc-175vyve-1"
402
- })(["border-radius:", "px;"], ({
403
- theme
404
- }) => theme.kitt.button.borderRadius);
405
- const AnimatedButtonPressable = /*#__PURE__*/React.forwardRef(({
406
- children,
407
- disabled,
408
- accessibilityRole,
409
- $type,
410
- $variant,
411
- $isStretch,
412
- href,
413
- hrefAttrs,
414
- testID,
415
- onPress
416
- }, ref) => {
417
- const theme = /*#__PURE__*/styled.useTheme();
418
- const pressed = Animated.useSharedValue(0);
419
- const color = Animated.useSharedValue(0);
420
- const {
421
- backgroundColor,
422
- pressedBackgroundColor
423
- } = getVariantValuesIfExist(theme, $type, $variant);
424
- const {
425
- scale
426
- } = theme.kitt.button;
427
- const scaleStyles = Animated.useAnimatedStyle(function () {
428
- const _f = function () {
429
- return {
430
- backgroundColor: Animated.interpolateColor(color.value, [0, 1], [backgroundColor, pressedBackgroundColor]),
431
- transform: [{
432
- scale: Animated.withSpring(pressed.value ? scale.base.active : scale.base.default)
433
- }]
434
- };
435
- };
436
-
437
- _f._closure = {
438
- interpolateColor: Animated.interpolateColor,
439
- color,
440
- backgroundColor,
441
- pressedBackgroundColor,
442
- withSpring: Animated.withSpring,
443
- pressed,
444
- scale: {
445
- base: {
446
- active: scale.base.active,
447
- default: scale.base.default
448
- }
449
- }
450
- };
451
- _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)}]};}}";
452
- _f.__workletHash = 5368461229978;
453
- _f.__location = "/home/circleci/repo/@ornikar/kitt-universal/src/Button/AnimatedButtonPressable.tsx (56:41)";
454
- _f.__optimalization = 2;
455
- return _f;
456
- }());
457
-
458
- const handlePressInOut = pressIn => {
459
- color.value = Animated.withSpring(pressIn ? 1 : 0);
460
- pressed.value = pressIn ? 1 : 0;
461
- };
462
-
463
- return /*#__PURE__*/jsxRuntime.jsx(StyledPressable, {
464
- ref: ref,
465
- disabled: disabled,
466
- accessibilityRole: accessibilityRole,
467
- testID: testID,
468
- href: href,
469
- hrefAttrs: hrefAttrs,
470
- $isStretch: $isStretch,
471
- $type: $type,
472
- onPress: onPress,
473
- onPressIn: () => {
474
- handlePressInOut(true);
475
- },
476
- onPressOut: () => {
477
- handlePressInOut(false);
478
- },
479
- children: /*#__PURE__*/jsxRuntime.jsx(StyledAnimatedView, {
480
- style: disabled ? [{
481
- transform: [{
482
- scale: 1
483
- }]
484
- }] : [scaleStyles],
485
- children: children
486
- })
487
- });
488
- });
489
-
490
- const BaseStyledButtonPressable = /*#__PURE__*/styled__default.View.withConfig({
491
- displayName: "BaseStyledButtonPressable",
492
- componentId: "kitt-universal__sc-4k8lse-0"
493
- })(["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:", ";"], ({
494
- theme
495
- }) => theme.kitt.button.minWidth, ({
496
- theme,
497
- $isStretch
498
- }) => $isStretch ? '100%' : `${theme.kitt.button.maxWidth}px`, ({
499
- $isStretch
500
- }) => $isStretch ? '100%' : 'auto', ({
501
- theme
502
- }) => theme.kitt.button.minHeight, ({
503
- theme
504
- }) => theme.kitt.button.borderRadius, ({
505
- theme,
506
- $isDisabled,
507
- $type,
508
- $variant
509
- }) => {
510
- if ($isDisabled) return theme.kitt.button.disabled.default.backgroundColor;
511
- if (reactNative.Platform.OS !== 'web') return 'transparent';
512
- return getVariantValuesIfExist(theme, $type, $variant).backgroundColor;
513
- }, ({
514
- theme,
515
- $size,
516
- $isDisabled
517
- }) => {
518
- const {
519
- large,
520
- default: defaultPadding,
521
- disabled: disabledPadding,
522
- xLarge
523
- } = theme.kitt.button.contentPadding;
524
- if ($size === 'large') return large;
525
- if ($size === 'xlarge') return xLarge;
526
- if ($isDisabled) return disabledPadding;
527
- return defaultPadding;
528
- });
529
-
530
453
  function TypographyIconSpecifiedColor({
531
454
  color,
532
455
  ...props
@@ -674,7 +597,7 @@ function ButtonContentChildren({
674
597
  };
675
598
  return /*#__PURE__*/jsxRuntime.jsxs(StyledChildrenWithIcon, {
676
599
  children: [icon && iconPosition === 'left' ? /*#__PURE__*/jsxRuntime.jsx(ButtonIcon, { ...buttonIconSharedProps,
677
- testID: "button-left-icon",
600
+ testID: "button.ButtonContent.leftButtonIcon",
678
601
  icon: icon
679
602
  }) : null, /*#__PURE__*/jsxRuntime.jsx(StyledButtonText, {
680
603
  base: "body",
@@ -707,120 +630,357 @@ const ButtonContentContainer = /*#__PURE__*/styled__default.View.withConfig({
707
630
  }) => {
708
631
  if (reactNative.Platform.OS !== 'web' || !$isSubtle) return undefined; // Needed for subtle type
709
632
 
710
- return 'color: inherit';
711
- });
712
- function ButtonContent({
713
- type,
714
- variant,
715
- isDisabled,
716
- $isStretch,
717
- icon,
633
+ return 'color: inherit';
634
+ });
635
+ function ButtonContent({
636
+ type,
637
+ variant,
638
+ isDisabled,
639
+ $isStretch,
640
+ icon,
641
+ children,
642
+ ...props
643
+ }) {
644
+ const color = isDisabled ? 'black-light' : getTextColorByType(type, variant);
645
+ return /*#__PURE__*/jsxRuntime.jsx(ButtonContentContainer, {
646
+ $isSubtle: isSubtle(type),
647
+ $isStretch: $isStretch,
648
+ $isIconOnly: Boolean(!children && icon),
649
+ children: /*#__PURE__*/jsxRuntime.jsx(ButtonContentChildren, {
650
+ icon: icon,
651
+ type: type,
652
+ isDisabled: isDisabled,
653
+ color: color,
654
+ ...props,
655
+ children: children
656
+ })
657
+ });
658
+ }
659
+
660
+ const StyledDisabled = /*#__PURE__*/styled__default.View.withConfig({
661
+ displayName: "StyledDisabled",
662
+ componentId: "kitt-universal__sc-16irf7q-0"
663
+ })(["position:absolute;top:0;left:0;right:0;bottom:0;border:", ";border-radius:", "px;"], ({
664
+ theme
665
+ }) => {
666
+ const {
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({
718
883
  children,
719
884
  ...props
720
885
  }) {
721
- const color = isDisabled ? 'black-light' : getTextColorByType(type, variant);
722
- return /*#__PURE__*/jsxRuntime.jsx(ButtonContentContainer, {
723
- $isSubtle: isSubtle(type),
724
- $isStretch: $isStretch,
725
- $isIconOnly: Boolean(!children && icon),
726
- children: /*#__PURE__*/jsxRuntime.jsx(ButtonContentChildren, {
727
- icon: icon,
728
- type: type,
729
- isDisabled: isDisabled,
730
- color: color,
731
- ...props,
732
- children: children
733
- })
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
734
899
  });
735
900
  }
901
+ Actions.Button = ActionsButton;
902
+ Actions.Item = ActionsItem;
736
903
 
737
- const StyledDisabled = /*#__PURE__*/styled__default.View.withConfig({
738
- displayName: "StyledDisabled",
739
- componentId: "kitt-universal__sc-16irf7q-0"
740
- })(["position:absolute;top:0;left:0;right:0;bottom:0;border:", ";border-radius:", "px;"], ({
741
- theme
742
- }) => {
743
- const {
744
- borderWidth,
745
- disabled
746
- } = theme.kitt.button;
747
- return `${borderWidth.disabled}px solid ${disabled.default.borderColor}`;
748
- }, ({
749
- theme
750
- }) => theme.kitt.button.borderRadius);
751
-
752
- const allowedGhostTypes = ['primary', 'default'];
904
+ const getInitials = (firstname, lastname) => `${firstname[0]}${lastname[0]}`.toUpperCase();
753
905
 
754
- const getButtonSize = ({
755
- large,
756
- xLarge,
757
- size
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
758
914
  }) => {
759
- if (large) return 'large';
760
- if (xLarge) return 'xlarge';
761
- return size;
762
- };
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);
763
925
 
764
- const Button = /*#__PURE__*/React.forwardRef(({
765
- children,
766
- type = 'default',
767
- variant = 'default',
768
- disabled,
769
- stretch,
770
- large,
771
- xLarge,
772
- icon,
773
- size: sizeProp,
774
- iconPosition = 'left',
775
- testID,
776
- href,
777
- hrefAttrs,
778
- accessibilityRole = 'button',
779
- onPress
780
- }, ref) => {
781
- if ((process.env.NODE_ENV !== "production") && variant === 'ghost' && !allowedGhostTypes.includes(type)) {
782
- throw new Error('variant=ghost is only allowed with type=primary or default');
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
+ });
783
946
  }
784
947
 
785
- if (large || xLarge) {
786
- const deprecatedProp = large ? 'large' : 'xLarge';
787
- deprecatedInComponent('Button', `${deprecatedProp} prop`, 'size');
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
+ });
788
955
  }
789
956
 
790
- const size = getButtonSize({
791
- large,
792
- xLarge,
793
- size: sizeProp
957
+ return /*#__PURE__*/jsxRuntime.jsx(Icon, {
958
+ icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.UserIcon, {}),
959
+ color: isLight ? 'black' : 'white',
960
+ size: size / 2
794
961
  });
795
- return /*#__PURE__*/jsxRuntime.jsx(AnimatedButtonPressable, {
796
- ref: ref,
797
- accessibilityRole: accessibilityRole,
798
- testID: testID,
799
- href: href,
800
- hrefAttrs: hrefAttrs,
801
- disabled: disabled,
802
- $isStretch: stretch,
803
- $type: type,
804
- $variant: variant,
805
- onPress: onPress,
806
- children: /*#__PURE__*/jsxRuntime.jsxs(BaseStyledButtonPressable, {
807
- $type: type,
808
- $variant: variant,
809
- $isStretch: stretch,
810
- $size: size,
811
- $isDisabled: disabled,
812
- children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
813
- type: type,
814
- variant: variant,
815
- $isStretch: stretch,
816
- isDisabled: disabled,
817
- icon: icon,
818
- iconPosition: iconPosition,
819
- children: children
820
- }), reactNative.Platform.OS !== 'web' && disabled ? /*#__PURE__*/jsxRuntime.jsx(StyledDisabled, {}) : null]
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
821
981
  })
822
982
  });
823
- });
983
+ }
824
984
 
825
985
  const Container$5 = /*#__PURE__*/styled__default.View.withConfig({
826
986
  displayName: "Card__Container",
@@ -1024,7 +1184,7 @@ function ChoiceItem({
1024
1184
  onChange(value);
1025
1185
  };
1026
1186
 
1027
- return /*#__PURE__*/jsxRuntime.jsx(nativeBase.Pressable, {
1187
+ return /*#__PURE__*/jsxRuntime.jsx(Pressable, {
1028
1188
  disabled: disabled,
1029
1189
  accessibilityRole: type,
1030
1190
  accessibilityState: {
@@ -1951,30 +2111,6 @@ const theme = {
1951
2111
  navigationModal
1952
2112
  };
1953
2113
 
1954
- function matchWindowSize({
1955
- width,
1956
- height
1957
- }, {
1958
- minWidth,
1959
- maxWidth,
1960
- minHeight,
1961
- maxHeight
1962
- }) {
1963
- const hasWidthMatched = width ? (!minWidth || width >= minWidth) && (!maxWidth || width <= maxWidth) : true;
1964
- const hasHeightMatched = height ? (!minHeight || height >= minHeight) && (!maxHeight || height <= maxHeight) : true;
1965
- return hasWidthMatched && hasHeightMatched;
1966
- }
1967
- function useMatchWindowSize(options) {
1968
- const {
1969
- width,
1970
- height
1971
- } = reactNative.useWindowDimensions();
1972
- return matchWindowSize({
1973
- width,
1974
- height
1975
- }, options);
1976
- }
1977
-
1978
2114
  // eslint-disable-next-line no-restricted-imports
1979
2115
  function createWindowSizeHelper(dimensions) {
1980
2116
  return {
@@ -3407,47 +3543,6 @@ function FullScreenModal({
3407
3543
  FullScreenModal.Header = FullScreenModalHeader;
3408
3544
  FullScreenModal.Body = FullScreenModalBody;
3409
3545
 
3410
- function SpinningIcon({
3411
- icon,
3412
- color
3413
- }) {
3414
- if (process.env.NODE_ENV !== 'production' && !color) {
3415
- throw new Error(`Invalid color passed to SpinningIcon: ${String(color)}`);
3416
- }
3417
-
3418
- const clonedIcon = /*#__PURE__*/React.cloneElement(icon, {
3419
- color
3420
- });
3421
- const animationRef = React.useRef(new reactNative.Animated.Value(0));
3422
- const rotation = animationRef.current.interpolate({
3423
- inputRange: [0, 1],
3424
- outputRange: ['0deg', '360deg']
3425
- });
3426
- React.useEffect(() => {
3427
- if (process.env.NODE_ENV === 'test') return undefined;
3428
- const animation = reactNative.Animated.loop(reactNative.Animated.timing(animationRef.current, {
3429
- toValue: 1,
3430
- duration: 1100,
3431
- easing: reactNative.Easing.linear,
3432
- useNativeDriver: true
3433
- }));
3434
- animation.start();
3435
- return () => {
3436
- if (process.env.NODE_ENV === 'test') return undefined;
3437
- animation.stop();
3438
- return undefined;
3439
- };
3440
- }, []);
3441
- return /*#__PURE__*/jsxRuntime.jsx(reactNative.Animated.View, {
3442
- style: {
3443
- transform: [{
3444
- rotate: rotation
3445
- }]
3446
- },
3447
- children: clonedIcon
3448
- });
3449
- }
3450
-
3451
3546
  const ContentView = /*#__PURE__*/styled__default.View.withConfig({
3452
3547
  displayName: "ListItemContent__ContentView",
3453
3548
  componentId: "kitt-universal__sc-57q0u9-0"
@@ -3570,15 +3665,6 @@ ListItem.Content = ListItemContent;
3570
3665
  ListItem.SideContent = ListItemSideContent;
3571
3666
  ListItem.SideContainer = ListItemSideContainer;
3572
3667
 
3573
- function LoaderIcon({
3574
- color
3575
- }) {
3576
- return /*#__PURE__*/jsxRuntime.jsx(SpinningIcon, {
3577
- color: color,
3578
- icon: /*#__PURE__*/jsxRuntime.jsx(kittIcons.ArcIcon, {})
3579
- });
3580
- }
3581
-
3582
3668
  function IconContent({
3583
3669
  type,
3584
3670
  color
@@ -3945,14 +4031,6 @@ function KittNativeBaseProvider({
3945
4031
  });
3946
4032
  }
3947
4033
 
3948
- const Stack = nativeBase.Stack;
3949
- const VStack = nativeBase.VStack;
3950
- const HStack = nativeBase.HStack;
3951
-
3952
- const View = nativeBase.View;
3953
- const ScrollView = nativeBase.ScrollView;
3954
- const Pressable = nativeBase.Pressable;
3955
-
3956
4034
  const ViewWithPadding = /*#__PURE__*/styled__default(reactNative.View).withConfig({
3957
4035
  displayName: "ContentPadding__ViewWithPadding",
3958
4036
  componentId: "kitt-universal__sc-1rprqcv-0"
@@ -5002,7 +5080,7 @@ function ModalDateTimePicker({
5002
5080
  }) : null, /*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
5003
5081
  children: /*#__PURE__*/jsxRuntime.jsx(DateTimePicker__default, {
5004
5082
  is24Hour: true,
5005
- testID: "date-picker-native-element",
5083
+ testID: "timePicker.ModalDateTimePicker.dateTimeNativePicker",
5006
5084
  value: currentValue,
5007
5085
  mode: "time",
5008
5086
  display: reactNative.Platform.OS === 'ios' ? 'spinner' : 'default',
@@ -5096,7 +5174,7 @@ function TimePicker({
5096
5174
  children: displayedValue
5097
5175
  }), reactNative.Platform.OS === 'android' && isTimePickerModalVisible ? /*#__PURE__*/jsxRuntime.jsx(DateTimePicker__default, {
5098
5176
  is24Hour: true,
5099
- testID: "date-picker-native-element",
5177
+ testID: "timePicker.TimePicker.dateTimeNativePicker",
5100
5178
  value: dateTimePickerValue,
5101
5179
  mode: "time",
5102
5180
  display: "default",
@@ -5463,6 +5541,7 @@ function MatchWindowSize({
5463
5541
  }
5464
5542
 
5465
5543
  exports.useWindowSize = reactNative.useWindowDimensions;
5544
+ exports.Actions = Actions;
5466
5545
  exports.Avatar = Avatar;
5467
5546
  exports.Button = Button;
5468
5547
  exports.Card = Card;