@televet/kibble-ui 1.1.0 → 1.2.0-beta.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.
@@ -0,0 +1,2 @@
1
+ import { ButtonStyleConfig } from './button.types';
2
+ export declare const ButtonConfig: ButtonStyleConfig;
@@ -0,0 +1,13 @@
1
+ export declare const DrawerConfig: {
2
+ variants: {
3
+ alwaysOpen: {
4
+ parts: string[];
5
+ dialog: {
6
+ pointerEvents: string;
7
+ };
8
+ dialogContainer: {
9
+ pointerEvents: string;
10
+ };
11
+ };
12
+ };
13
+ };
@@ -0,0 +1,3 @@
1
+ export * from './tooltip.component';
2
+ export * from './tooltip.model';
3
+ export * from './tooltip.config';
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { TooltipProps as ChakraTooltipProps } from '@chakra-ui/react';
3
+ export interface TooltipProps extends ChakraTooltipProps {
4
+ label: string;
5
+ }
6
+ export declare const Tooltip: ({ children, label, openDelay, ...rest }: TooltipProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { TooltipStyleConfig } from './tooltip.model';
2
+ export declare const TooltipGlobalStyle: {
3
+ '[id^=tooltip]': {
4
+ padding: string;
5
+ borderRadius: string;
6
+ };
7
+ };
8
+ export declare const TooltipConfig: TooltipStyleConfig;
@@ -0,0 +1,4 @@
1
+ import { AdaptiveColor } from '../../theme/tokens';
2
+ export interface TooltipStyleConfig {
3
+ color: AdaptiveColor;
4
+ }
@@ -0,0 +1,9 @@
1
+ import { TooltipStyleConfig } from './tooltip.model';
2
+ export declare const TooltipGlobalStyle: {
3
+ '[id^=tooltip]': {
4
+ padding: string;
5
+ borderRadius: string;
6
+ textTransform: string;
7
+ };
8
+ };
9
+ export declare const TooltipConfig: TooltipStyleConfig;
@@ -0,0 +1,2 @@
1
+ import { HeadingStyleConfig } from './heading.types';
2
+ export declare const HeadingConfig: HeadingStyleConfig;
@@ -0,0 +1,2 @@
1
+ import { ComponentStyleConfig } from '@chakra-ui/theme';
2
+ export declare const TextConfig: ComponentStyleConfig;
@@ -4,3 +4,4 @@ export * from './Logo';
4
4
  export * from './Typography';
5
5
  export * from './Textarea';
6
6
  export * from './Button';
7
+ export * from './Tooltip';
package/build/index.js CHANGED
@@ -2741,6 +2741,39 @@ var TextareaConfig = {
2741
2741
 
2742
2742
  var camelCaseToLabel = function (s) {
2743
2743
  return s.replace(/([A-Z])/g, ' $1').replace(/^\w/, function (c) { return c.toUpperCase(); });
2744
+ };
2745
+ var toTitleCase = function (s) {
2746
+ var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
2747
+ var alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
2748
+ var wordSeparators = /([ :–—-])/;
2749
+ return s
2750
+ .split(wordSeparators)
2751
+ .map(function (current, index, array) {
2752
+ if (
2753
+ /* Check for small words */
2754
+ current.search(smallWords) > -1 &&
2755
+ /* Skip first and last word */
2756
+ index !== 0 &&
2757
+ index !== array.length - 1 &&
2758
+ /* Ignore title end and subtitle start */
2759
+ array[index - 3] !== ':' &&
2760
+ array[index + 1] !== ':' &&
2761
+ /* Ignore small words that start a hyphenated phrase */
2762
+ (array[index + 1] !== '-' || (array[index - 1] === '-' && array[index + 1] === '-'))) {
2763
+ return current.toLowerCase();
2764
+ }
2765
+ /* Ignore intentional capitalization */
2766
+ if (current.substring(1).search(/[A-Z]|\../) > -1) {
2767
+ return current;
2768
+ }
2769
+ /* Ignore URLs */
2770
+ if (array[index + 1] === ':' && array[index + 2] !== '') {
2771
+ return current;
2772
+ }
2773
+ /* Capitalize the first letter */
2774
+ return current.replace(alphanumericPattern, function (match) { return match.toUpperCase(); });
2775
+ })
2776
+ .join('');
2744
2777
  };
2745
2778
 
2746
2779
  var Button = React.forwardRef(function (props, ref) {
@@ -2962,8 +2995,31 @@ var ButtonConfig = {
2962
2995
  },
2963
2996
  };
2964
2997
 
2998
+ var useAdaptiveColor = function (color) { return react.useColorModeValue(color.light, color.dark); };
2999
+
3000
+ var Tooltip = function (_a) {
3001
+ var children = _a.children, label = _a.label, _b = _a.openDelay, openDelay = _b === void 0 ? 350 : _b, rest = __rest(_a, ["children", "label", "openDelay"]);
3002
+ var components = useTheme().components;
3003
+ var bg = useAdaptiveColor(components.Tooltip.color);
3004
+ var l = toTitleCase(label.toLowerCase());
3005
+ return (React__default["default"].createElement(react.Tooltip, __assign({ hasArrow: true, arrowSize: 10, label: l, bg: bg, openDelay: openDelay }, rest), children));
3006
+ };
3007
+
3008
+ var TooltipGlobalStyle = {
3009
+ '[id^=tooltip]': {
3010
+ padding: '4px 8px 4px 8px !important',
3011
+ borderRadius: '4px !important',
3012
+ },
3013
+ };
3014
+ var TooltipConfig = {
3015
+ color: { light: semanticTokens.background.dark, dark: semanticTokens.background.light },
3016
+ };
3017
+
2965
3018
  // @ts-ignore
2966
3019
  var theme = react.extendTheme({
3020
+ styles: {
3021
+ global: __assign({}, TooltipGlobalStyle),
3022
+ },
2967
3023
  blur: blur,
2968
3024
  borders: borders,
2969
3025
  colors: colors,
@@ -2988,6 +3044,7 @@ var theme = react.extendTheme({
2988
3044
  Textarea: TextareaConfig,
2989
3045
  Drawer: DrawerConfig,
2990
3046
  Button: ButtonConfig,
3047
+ Tooltip: TooltipConfig,
2991
3048
  },
2992
3049
  });
2993
3050
 
@@ -3009,6 +3066,9 @@ exports.Text = Text;
3009
3066
  exports.TextConfig = TextConfig;
3010
3067
  exports.Textarea = Textarea;
3011
3068
  exports.TextareaConfig = TextareaConfig;
3069
+ exports.Tooltip = Tooltip;
3070
+ exports.TooltipConfig = TooltipConfig;
3071
+ exports.TooltipGlobalStyle = TooltipGlobalStyle;
3012
3072
  exports.theme = theme;
3013
3073
  exports.useTheme = useTheme;
3014
3074
  //# sourceMappingURL=index.js.map