@channel.io/bezier-react 1.10.2 → 1.11.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.
@@ -18,9 +18,10 @@ const ItemContainer = /*#__PURE__*/FoundationStyledComponent.styled(AlphaStack.A
18
18
  }).withConfig({
19
19
  displayName: "SegmentedControlstyled__ItemContainer",
20
20
  componentId: "sc-15mhli4-0"
21
- })(["z-index:", ";"], ZIndex.ZIndex.Float);
21
+ })(["z-index:", ";overflow:hidden;"], ZIndex.ZIndex.Float);
22
22
  const ItemLabel = /*#__PURE__*/FoundationStyledComponent.styled(Text.default).attrs({
23
- bold: true
23
+ bold: true,
24
+ truncated: true
24
25
  }).withConfig({
25
26
  displayName: "SegmentedControlstyled__ItemLabel",
26
27
  componentId: "sc-15mhli4-1"
@@ -28,7 +29,7 @@ const ItemLabel = /*#__PURE__*/FoundationStyledComponent.styled(Text.default).at
28
29
  const Item = /*#__PURE__*/FoundationStyledComponent.styled.button.withConfig({
29
30
  displayName: "SegmentedControlstyled__Item",
30
31
  componentId: "sc-15mhli4-2"
31
- })(["all:unset;position:relative;display:flex;flex:1;align-items:center;justify-content:center;", " &[data-checked]{color:var(--txt-black-darkest);cursor:default;}&:not([data-checked]){color:var(--txt-black-dark);cursor:pointer;}&:disabled{cursor:not-allowed;}&::after{position:absolute;top:0;left:0;z-index:", ";display:block;width:100%;height:100%;content:'';border-radius:inherit;", "}&:focus-visible{&::after{", "}}&:not([data-checked]):not(&:disabled):hover{background-color:var(--bg-black-light);}"], ({
32
+ })(["all:unset;position:relative;display:flex;flex:1;align-items:center;justify-content:center;min-width:0;", " &[data-checked]{color:var(--txt-black-darkest);cursor:default;}&:not([data-checked]){color:var(--txt-black-dark);cursor:pointer;}&:disabled{cursor:not-allowed;}&::after{position:absolute;top:0;left:0;z-index:", ";display:block;width:100%;height:100%;content:'';border-radius:inherit;", "}&:focus-visible{&::after{", "}}&:not([data-checked]):not(&:disabled):hover{background-color:var(--bg-black-light);}"], ({
32
33
  foundation
33
34
  }) => foundation?.transition?.getTransitionsCSS('background-color'), ZIndex.ZIndex.Float, ({
34
35
  foundation
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.styled.js","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"sourcesContent":["/* stylelint-disable declaration-block-semicolon-newline-after, rule-empty-line-before */\nimport {\n Transition,\n Typography,\n styled,\n} from '~/src/foundation'\n\nimport DisabledOpacity from '~/src/constants/DisabledOpacity'\nimport { ZIndex } from '~/src/constants/ZIndex'\n\nimport { AlphaStack } from '~/src/components/AlphaStack'\nimport { focusedInputWrapperStyle } from '~/src/components/Forms/Inputs/mixins'\nimport { Text } from '~/src/components/Text'\n\nimport { SegmentedControlSize } from './SegmentedControl.types'\n\nexport const ItemContainer = styled(AlphaStack).attrs({\n direction: 'horizontal',\n align: 'center',\n spacing: 2,\n})`\n z-index: ${ZIndex.Float};\n`\n\nexport const ItemLabel = styled(Text).attrs({ bold: true })`\n padding: 1px 4px;\n`\n\nexport const Item = styled.button`\n all: unset;\n\n position: relative;\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('background-color')}\n\n &[data-checked] {\n color: var(--txt-black-darkest);\n cursor: default;\n }\n\n &:not([data-checked]) {\n color: var(--txt-black-dark);\n cursor: pointer;\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* NOTE: (@ed) focus indicator */\n &::after {\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n display: block;\n width: 100%;\n height: 100%;\n content: '';\n border-radius: inherit;\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS(['box-shadow'])}\n }\n\n &:focus-visible {\n &::after {\n ${focusedInputWrapperStyle}\n }\n }\n\n &:not([data-checked]):not(&:disabled):hover {\n background-color: var(--bg-black-light);\n }\n`\n\nexport const indicatorTransitionMeta = {\n duration: Transition.TransitionDuration.M,\n}\n\nexport const Indicator = styled.div`\n --bezier-react-segmented-control-indicator-transform: none;\n --bezier-react-segmented-control-indicator-width: auto;\n --bezier-react-segmented-control-indicator-height: auto;\n\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n\n width: var(--bezier-react-segmented-control-indicator-width);\n height: var(--bezier-react-segmented-control-indicator-height);\n\n ${({ foundation }) => foundation?.elevation.ev1()}\n /* NOTE: (@ed) Overrides the elevation mixin. Do not change the order! */\n background-color: var(--bg-white-high);\n\n transform: var(--bezier-react-segmented-control-indicator-transform);\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('transform', indicatorTransitionMeta.duration)}\n`\n\nexport const Container = styled(AlphaStack).attrs({ direction: 'horizontal' })`\n --bezier-react-segmented-control-width: auto;\n\n position: relative;\n z-index: ${ZIndex.Base};\n box-sizing: border-box;\n width: var(--bezier-react-segmented-control-width);\n background-color: var(--bg-black-lighter);\n\n &.${SegmentedControlSize.XS} {\n height: 24px;\n padding: 1px;\n border-radius: 6px;\n ${Typography.Size13}\n\n ${Item},\n ${Indicator} {\n border-radius: 5px;\n }\n\n ${Item} {\n padding: 1px 0;\n }\n }\n\n &.${SegmentedControlSize.S} {\n height: 28px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 2px 0;\n }\n }\n\n &.${SegmentedControlSize.M} {\n height: 36px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 6px 0;\n }\n }\n\n &.${SegmentedControlSize.L} {\n height: 44px;\n padding: 4px;\n border-radius: 12px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 8px;\n }\n\n ${Item} {\n padding: 8px 0;\n }\n }\n\n &[data-disabled] {\n opacity: ${DisabledOpacity};\n\n ${Item},\n ${Indicator} {\n cursor: not-allowed;\n }\n }\n`\n"],"names":["ItemContainer","styled","AlphaStack","attrs","direction","align","spacing","withConfig","displayName","componentId","ZIndex","Float","ItemLabel","Text","bold","Item","button","foundation","transition","getTransitionsCSS","focusedInputWrapperStyle","indicatorTransitionMeta","duration","Transition","TransitionDuration","M","Indicator","div","elevation","ev1","Container","Base","SegmentedControlSize","XS","Typography","Size13","S","Size14","L","DisabledOpacity"],"mappings":";;;;;;;;;;;;AAAA;AAgBO,MAAMA,aAAa,gBAAGC,gCAAM,CAACC,qBAAU,CAAC,CAACC,KAAK,CAAC;AACpDC,EAAAA,SAAS,EAAE,YAAY;AACvBC,EAAAA,KAAK,EAAE,QAAQ;AACfC,EAAAA,OAAO,EAAE,CAAA;AACX,CAAC,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CACWC,CAAAA,CAAAA,CAAAA,UAAAA,EAAAA,GAAAA,CAAAA,EAAAA,aAAM,CAACC,KAAK,EACxB;AAEM,MAAMC,SAAS,gBAAGX,gCAAM,CAACY,YAAI,CAAC,CAACV,KAAK,CAAC;AAAEW,EAAAA,IAAI,EAAE,IAAA;AAAK,CAAC,CAAC,CAAAP,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAE1D,CAAA,CAAA,CAAA,kBAAA,CAAA,EAAA;MAEYM,IAAI,gBAAGd,gCAAM,CAACe,MAAM,CAAAT,UAAA,CAAA;EAAAC,WAAA,EAAA,8BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAA,CAAA,4FAAA,EAAA,mNAAA,EAAA,yEAAA,EAAA,4BAAA,EAAA,wFAAA,CAAA,EAS7B,CAAC;AAAEQ,EAAAA,UAAAA;AAAW,CAAC,KAAKA,UAAU,EAAEC,UAAU,EAAEC,iBAAiB,CAAC,kBAAkB,CAAC,EAqBtET,aAAM,CAACC,KAAK,EAMrB,CAAC;AAAEM,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EAIjEC,aAAM,CAACqB,IAAI,EAKlBC,2CAAoB,CAACC,EAAE,EAIvBC,qBAAU,CAACC,MAAM,EAEjBpB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACI,CAAC,EAItBF,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACP,CAAC,EAItBS,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACM,CAAC,EAItBJ,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAMKwB,uBAAe,EAExBxB,IAAI,EACJW,SAAS;;;;;;;;;"}
1
+ {"version":3,"file":"SegmentedControl.styled.js","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"sourcesContent":["/* stylelint-disable declaration-block-semicolon-newline-after, rule-empty-line-before */\nimport {\n Transition,\n Typography,\n styled,\n} from '~/src/foundation'\n\nimport DisabledOpacity from '~/src/constants/DisabledOpacity'\nimport { ZIndex } from '~/src/constants/ZIndex'\n\nimport { AlphaStack } from '~/src/components/AlphaStack'\nimport { focusedInputWrapperStyle } from '~/src/components/Forms/Inputs/mixins'\nimport { Text } from '~/src/components/Text'\n\nimport { SegmentedControlSize } from './SegmentedControl.types'\n\nexport const ItemContainer = styled(AlphaStack).attrs({\n direction: 'horizontal',\n align: 'center',\n spacing: 2,\n})`\n z-index: ${ZIndex.Float};\n overflow: hidden;\n`\n\nexport const ItemLabel = styled(Text).attrs({\n bold: true,\n truncated: true,\n})`\n padding: 1px 4px;\n`\n\nexport const Item = styled.button`\n all: unset;\n\n position: relative;\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-width: 0;\n\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('background-color')}\n\n &[data-checked] {\n color: var(--txt-black-darkest);\n cursor: default;\n }\n\n &:not([data-checked]) {\n color: var(--txt-black-dark);\n cursor: pointer;\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* NOTE: (@ed) focus indicator */\n &::after {\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n display: block;\n width: 100%;\n height: 100%;\n content: '';\n border-radius: inherit;\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS(['box-shadow'])}\n }\n\n &:focus-visible {\n &::after {\n ${focusedInputWrapperStyle}\n }\n }\n\n &:not([data-checked]):not(&:disabled):hover {\n background-color: var(--bg-black-light);\n }\n`\n\nexport const indicatorTransitionMeta = {\n duration: Transition.TransitionDuration.M,\n}\n\nexport const Indicator = styled.div`\n --bezier-react-segmented-control-indicator-transform: none;\n --bezier-react-segmented-control-indicator-width: auto;\n --bezier-react-segmented-control-indicator-height: auto;\n\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n\n width: var(--bezier-react-segmented-control-indicator-width);\n height: var(--bezier-react-segmented-control-indicator-height);\n\n ${({ foundation }) => foundation?.elevation.ev1()}\n /* NOTE: (@ed) Overrides the elevation mixin. Do not change the order! */\n background-color: var(--bg-white-high);\n\n transform: var(--bezier-react-segmented-control-indicator-transform);\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('transform', indicatorTransitionMeta.duration)}\n`\n\nexport const Container = styled(AlphaStack).attrs({ direction: 'horizontal' })`\n --bezier-react-segmented-control-width: auto;\n\n position: relative;\n z-index: ${ZIndex.Base};\n box-sizing: border-box;\n width: var(--bezier-react-segmented-control-width);\n background-color: var(--bg-black-lighter);\n\n &.${SegmentedControlSize.XS} {\n height: 24px;\n padding: 1px;\n border-radius: 6px;\n ${Typography.Size13}\n\n ${Item},\n ${Indicator} {\n border-radius: 5px;\n }\n\n ${Item} {\n padding: 1px 0;\n }\n }\n\n &.${SegmentedControlSize.S} {\n height: 28px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 2px 0;\n }\n }\n\n &.${SegmentedControlSize.M} {\n height: 36px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 6px 0;\n }\n }\n\n &.${SegmentedControlSize.L} {\n height: 44px;\n padding: 4px;\n border-radius: 12px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 8px;\n }\n\n ${Item} {\n padding: 8px 0;\n }\n }\n\n &[data-disabled] {\n opacity: ${DisabledOpacity};\n\n ${Item},\n ${Indicator} {\n cursor: not-allowed;\n }\n }\n`\n"],"names":["ItemContainer","styled","AlphaStack","attrs","direction","align","spacing","withConfig","displayName","componentId","ZIndex","Float","ItemLabel","Text","bold","truncated","Item","button","foundation","transition","getTransitionsCSS","focusedInputWrapperStyle","indicatorTransitionMeta","duration","Transition","TransitionDuration","M","Indicator","div","elevation","ev1","Container","Base","SegmentedControlSize","XS","Typography","Size13","S","Size14","L","DisabledOpacity"],"mappings":";;;;;;;;;;;;AAAA;AAgBO,MAAMA,aAAa,gBAAGC,gCAAM,CAACC,qBAAU,CAAC,CAACC,KAAK,CAAC;AACpDC,EAAAA,SAAS,EAAE,YAAY;AACvBC,EAAAA,KAAK,EAAE,QAAQ;AACfC,EAAAA,OAAO,EAAE,CAAA;AACX,CAAC,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CACWC,CAAAA,CAAAA,CAAAA,UAAAA,EAAAA,mBAAAA,CAAAA,EAAAA,aAAM,CAACC,KAAK,EAExB;AAEM,MAAMC,SAAS,gBAAGX,gCAAM,CAACY,YAAI,CAAC,CAACV,KAAK,CAAC;AAC1CW,EAAAA,IAAI,EAAE,IAAI;AACVC,EAAAA,SAAS,EAAE,IAAA;AACb,CAAC,CAAC,CAAAR,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,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CAAC,CAAAG,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAA,CAAA,wEAAA,EAAA,sHAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,8CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,4CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,wBAAA,CAAA,EAIjEC,aAAM,CAACsB,IAAI,EAKlBC,2CAAoB,CAACC,EAAE,EAIvBC,qBAAU,CAACC,MAAM,EAEjBpB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACI,CAAC,EAItBF,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACP,CAAC,EAItBS,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,2CAAoB,CAACM,CAAC,EAItBJ,qBAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAMKwB,uBAAe,EAExBxB,IAAI,EACJW,SAAS;;;;;;;;;"}
@@ -113,31 +113,12 @@ function TooltipProvider({
113
113
  value: contextValue
114
114
  }, children));
115
115
  }
116
-
117
- /**
118
- * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
119
- *
120
- * @example
121
- *
122
- * ```tsx
123
- * // Anatomy of the Tooltip
124
- * <TooltipProvider>
125
- * <Tooltip />
126
- * </TooltipProvider>
127
- *
128
- * // Example of a Tooltip with a button
129
- * <Tooltip content="Ta-da!">
130
- * <button>Hover me</button>
131
- * </Tooltip>
132
- * ```
133
- */
134
- const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
116
+ const TooltipImpl = /*#__PURE__*/React.forwardRef(function TooltipImpl({
135
117
  as,
136
118
  children,
137
119
  defaultShow,
138
120
  onShow: onShowProp,
139
121
  onHide: onHideProp,
140
- disabled,
141
122
  content,
142
123
  description,
143
124
  icon,
@@ -174,9 +155,6 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
174
155
  onHideProp?.();
175
156
  }, [onHideProp]);
176
157
  const onOpenChange = React.useCallback(open => {
177
- if (disabled) {
178
- return;
179
- }
180
158
  if (open) {
181
159
  onShow();
182
160
  return;
@@ -192,7 +170,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
192
170
  return;
193
171
  }
194
172
  onHide();
195
- }, [disabled, delayHide, onShow, onHide]);
173
+ }, [delayHide, onShow, onHide]);
196
174
  return /*#__PURE__*/React.createElement(index.Root, {
197
175
  open: show,
198
176
  defaultOpen: defaultShow,
@@ -217,6 +195,38 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
217
195
  })))));
218
196
  });
219
197
 
198
+ /**
199
+ * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
200
+ *
201
+ * @example
202
+ *
203
+ * ```tsx
204
+ * // Anatomy of the Tooltip
205
+ * <TooltipProvider>
206
+ * <Tooltip />
207
+ * </TooltipProvider>
208
+ *
209
+ * // Example of a Tooltip with a button
210
+ * <Tooltip content="Ta-da!">
211
+ * <button>Hover me</button>
212
+ * </Tooltip>
213
+ * ```
214
+ */
215
+ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
216
+ children,
217
+ disabled,
218
+ content,
219
+ ...rest
220
+ }, forwardedRef) {
221
+ if (disabled || typeUtils.isEmpty(content)) {
222
+ return children ?? null;
223
+ }
224
+ return /*#__PURE__*/React.createElement(TooltipImpl, Object.assign({
225
+ ref: forwardedRef,
226
+ content: content
227
+ }, rest), children);
228
+ });
229
+
220
230
  exports.Tooltip = Tooltip;
221
231
  exports.TooltipProvider = TooltipProvider;
222
232
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport { isBoolean } from '~/src/utils/typeUtils'\n\nimport {\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n disabled,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container: givenContainer,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n const delayHide = delayHideProp ?? globalDelayHide\n\n const defaultContainer = getRootElement()\n const container = givenContainer ?? defaultContainer\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (disabled) { return }\n\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n disabled,\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","Tooltip","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","disabled","content","description","icon","offset","container","givenContainer","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","defaultContainer","getRootElement","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source"],"mappings":";;;;;;;;;;AAuBA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,6BAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACI,OAAO;MAC1B,OAAO;AACLF,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,OAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACK,QAAQ;MAC3B,OAAO;AACLH,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,KAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACM,WAAW;MAC9B,OAAO;AACLJ,QAAAA,IAAI,EAAE,OAAO;AACbC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACO,QAAQ;MAC3B,OAAO;AACLL,QAAAA,IAAI,EAAE,OAAO;AACbC,QAAAA,KAAK,EAAE,OAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACQ,WAAW;MAC9B,OAAO;AACLN,QAAAA,IAAI,EAAE,OAAO;AACbC,QAAAA,KAAK,EAAE,KAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACS,YAAY;MAC/B,OAAO;AACLP,QAAAA,IAAI,EAAE,QAAQ;AACdC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,6BA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BAAW,EAAA;AAACE,IAAAA,MAAM,EAAErC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC;;;;;"}
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport {\n isBoolean,\n isEmpty,\n} from '~/src/utils/typeUtils'\n\nimport {\n type TooltipImplProps,\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\nconst TooltipImpl = forwardRef<HTMLDivElement, TooltipImplProps>(function TooltipImpl({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container: givenContainer,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n const delayHide = delayHideProp ?? globalDelayHide\n\n const defaultContainer = getRootElement()\n const container = givenContainer ?? defaultContainer\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n children,\n disabled,\n content,\n ...rest\n}, forwardedRef) {\n if (disabled || isEmpty(content)) {\n return children ?? null\n }\n\n return (\n <TooltipImpl\n ref={forwardedRef}\n content={content}\n {...rest}\n >\n { children }\n </TooltipImpl>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","TooltipImpl","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","content","description","icon","offset","container","givenContainer","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","defaultContainer","getRootElement","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source","Tooltip","disabled","isEmpty"],"mappings":";;;;;;;;;;AA2BA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,6BAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACI,OAAO;MAC1B,OAAO;AACLF,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,OAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACK,QAAQ;MAC3B,OAAO;AACLH,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,KAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACM,WAAW;MAC9B,OAAO;AACLJ,QAAAA,IAAI,EAAE,OAAO;AACbC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,6BAAe,CAACO,QAAQ;MAC3B,OAAO;AACLL,QAAAA,IAAI,EAAE,OAAO;AACbC,QAAAA,KAAK,EAAE,OAA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AC,aAAA,CAACmD,0BAAkB,QACfpC,WACgB,CAEF,CAAC,EAErBC,IAAI,iBACJjB,KAAA,CAAAC,aAAA,CAACmD,mBAAW,EAAA;AAACE,IAAAA,MAAM,EAAErC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC,CAAC,CAAA;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACasC,OAAO,gBAAG/C,gBAAU,CAA+B,SAAS+C,OAAOA,CAAC;EAC/E9D,QAAQ;EACR+D,QAAQ;EACRzC,OAAO;EACP,GAAGQ,IAAAA;AACL,CAAC,EAAEC,YAAY,EAAE;AACf,EAAA,IAAIgC,QAAQ,IAAIC,iBAAO,CAAC1C,OAAO,CAAC,EAAE;IAChC,OAAOtB,QAAQ,IAAI,IAAI,CAAA;AACzB,GAAA;EAEA,oBACEO,KAAA,CAAAC,aAAA,CAACM,WAAW,EAAAsC,MAAA,CAAAC,MAAA,CAAA;AACVC,IAAAA,GAAG,EAAEvB,YAAa;AAClBT,IAAAA,OAAO,EAAEA,OAAAA;GACLQ,EAAAA,IAAI,CAEN9B,EAAAA,QACS,CAAC,CAAA;AAElB,CAAC;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.types.js","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n DisableProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n"],"names":["TooltipPosition"],"mappings":";;AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
1
+ {"version":3,"file":"Tooltip.types.js","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipImplProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n\nexport interface TooltipProps extends\n DisableProps,\n TooltipImplProps {}\n"],"names":["TooltipPosition"],"mappings":";;AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -16,9 +16,10 @@ const ItemContainer = /*#__PURE__*/FoundationStyled(AlphaStack).attrs({
16
16
  }).withConfig({
17
17
  displayName: "SegmentedControlstyled__ItemContainer",
18
18
  componentId: "sc-15mhli4-0"
19
- })(["z-index:", ";"], ZIndex.Float);
19
+ })(["z-index:", ";overflow:hidden;"], ZIndex.Float);
20
20
  const ItemLabel = /*#__PURE__*/FoundationStyled(Text).attrs({
21
- bold: true
21
+ bold: true,
22
+ truncated: true
22
23
  }).withConfig({
23
24
  displayName: "SegmentedControlstyled__ItemLabel",
24
25
  componentId: "sc-15mhli4-1"
@@ -26,7 +27,7 @@ const ItemLabel = /*#__PURE__*/FoundationStyled(Text).attrs({
26
27
  const Item = /*#__PURE__*/FoundationStyled.button.withConfig({
27
28
  displayName: "SegmentedControlstyled__Item",
28
29
  componentId: "sc-15mhli4-2"
29
- })(["all:unset;position:relative;display:flex;flex:1;align-items:center;justify-content:center;", " &[data-checked]{color:var(--txt-black-darkest);cursor:default;}&:not([data-checked]){color:var(--txt-black-dark);cursor:pointer;}&:disabled{cursor:not-allowed;}&::after{position:absolute;top:0;left:0;z-index:", ";display:block;width:100%;height:100%;content:'';border-radius:inherit;", "}&:focus-visible{&::after{", "}}&:not([data-checked]):not(&:disabled):hover{background-color:var(--bg-black-light);}"], ({
30
+ })(["all:unset;position:relative;display:flex;flex:1;align-items:center;justify-content:center;min-width:0;", " &[data-checked]{color:var(--txt-black-darkest);cursor:default;}&:not([data-checked]){color:var(--txt-black-dark);cursor:pointer;}&:disabled{cursor:not-allowed;}&::after{position:absolute;top:0;left:0;z-index:", ";display:block;width:100%;height:100%;content:'';border-radius:inherit;", "}&:focus-visible{&::after{", "}}&:not([data-checked]):not(&:disabled):hover{background-color:var(--bg-black-light);}"], ({
30
31
  foundation
31
32
  }) => foundation?.transition?.getTransitionsCSS('background-color'), ZIndex.Float, ({
32
33
  foundation
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.styled.mjs","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"sourcesContent":["/* stylelint-disable declaration-block-semicolon-newline-after, rule-empty-line-before */\nimport {\n Transition,\n Typography,\n styled,\n} from '~/src/foundation'\n\nimport DisabledOpacity from '~/src/constants/DisabledOpacity'\nimport { ZIndex } from '~/src/constants/ZIndex'\n\nimport { AlphaStack } from '~/src/components/AlphaStack'\nimport { focusedInputWrapperStyle } from '~/src/components/Forms/Inputs/mixins'\nimport { Text } from '~/src/components/Text'\n\nimport { SegmentedControlSize } from './SegmentedControl.types'\n\nexport const ItemContainer = styled(AlphaStack).attrs({\n direction: 'horizontal',\n align: 'center',\n spacing: 2,\n})`\n z-index: ${ZIndex.Float};\n`\n\nexport const ItemLabel = styled(Text).attrs({ bold: true })`\n padding: 1px 4px;\n`\n\nexport const Item = styled.button`\n all: unset;\n\n position: relative;\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('background-color')}\n\n &[data-checked] {\n color: var(--txt-black-darkest);\n cursor: default;\n }\n\n &:not([data-checked]) {\n color: var(--txt-black-dark);\n cursor: pointer;\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* NOTE: (@ed) focus indicator */\n &::after {\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n display: block;\n width: 100%;\n height: 100%;\n content: '';\n border-radius: inherit;\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS(['box-shadow'])}\n }\n\n &:focus-visible {\n &::after {\n ${focusedInputWrapperStyle}\n }\n }\n\n &:not([data-checked]):not(&:disabled):hover {\n background-color: var(--bg-black-light);\n }\n`\n\nexport const indicatorTransitionMeta = {\n duration: Transition.TransitionDuration.M,\n}\n\nexport const Indicator = styled.div`\n --bezier-react-segmented-control-indicator-transform: none;\n --bezier-react-segmented-control-indicator-width: auto;\n --bezier-react-segmented-control-indicator-height: auto;\n\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n\n width: var(--bezier-react-segmented-control-indicator-width);\n height: var(--bezier-react-segmented-control-indicator-height);\n\n ${({ foundation }) => foundation?.elevation.ev1()}\n /* NOTE: (@ed) Overrides the elevation mixin. Do not change the order! */\n background-color: var(--bg-white-high);\n\n transform: var(--bezier-react-segmented-control-indicator-transform);\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('transform', indicatorTransitionMeta.duration)}\n`\n\nexport const Container = styled(AlphaStack).attrs({ direction: 'horizontal' })`\n --bezier-react-segmented-control-width: auto;\n\n position: relative;\n z-index: ${ZIndex.Base};\n box-sizing: border-box;\n width: var(--bezier-react-segmented-control-width);\n background-color: var(--bg-black-lighter);\n\n &.${SegmentedControlSize.XS} {\n height: 24px;\n padding: 1px;\n border-radius: 6px;\n ${Typography.Size13}\n\n ${Item},\n ${Indicator} {\n border-radius: 5px;\n }\n\n ${Item} {\n padding: 1px 0;\n }\n }\n\n &.${SegmentedControlSize.S} {\n height: 28px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 2px 0;\n }\n }\n\n &.${SegmentedControlSize.M} {\n height: 36px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 6px 0;\n }\n }\n\n &.${SegmentedControlSize.L} {\n height: 44px;\n padding: 4px;\n border-radius: 12px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 8px;\n }\n\n ${Item} {\n padding: 8px 0;\n }\n }\n\n &[data-disabled] {\n opacity: ${DisabledOpacity};\n\n ${Item},\n ${Indicator} {\n cursor: not-allowed;\n }\n }\n`\n"],"names":["ItemContainer","styled","AlphaStack","attrs","direction","align","spacing","withConfig","displayName","componentId","ZIndex","Float","ItemLabel","Text","bold","Item","button","foundation","transition","getTransitionsCSS","focusedInputWrapperStyle","indicatorTransitionMeta","duration","Transition","TransitionDuration","M","Indicator","div","elevation","ev1","Container","Base","SegmentedControlSize","XS","Typography","Size13","S","Size14","L","DisabledOpacity"],"mappings":";;;;;;;;;;AAAA;AAgBO,MAAMA,aAAa,gBAAGC,gBAAM,CAACC,UAAU,CAAC,CAACC,KAAK,CAAC;AACpDC,EAAAA,SAAS,EAAE,YAAY;AACvBC,EAAAA,KAAK,EAAE,QAAQ;AACfC,EAAAA,OAAO,EAAE,CAAA;AACX,CAAC,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CACWC,CAAAA,CAAAA,CAAAA,UAAAA,EAAAA,GAAAA,CAAAA,EAAAA,MAAM,CAACC,KAAK,EACxB;AAEM,MAAMC,SAAS,gBAAGX,gBAAM,CAACY,IAAI,CAAC,CAACV,KAAK,CAAC;AAAEW,EAAAA,IAAI,EAAE,IAAA;AAAK,CAAC,CAAC,CAAAP,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAE1D,CAAA,CAAA,CAAA,kBAAA,CAAA,EAAA;MAEYM,IAAI,gBAAGd,gBAAM,CAACe,MAAM,CAAAT,UAAA,CAAA;EAAAC,WAAA,EAAA,8BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAA,CAAA,4FAAA,EAAA,mNAAA,EAAA,yEAAA,EAAA,4BAAA,EAAA,wFAAA,CAAA,EAS7B,CAAC;AAAEQ,EAAAA,UAAAA;AAAW,CAAC,KAAKA,UAAU,EAAEC,UAAU,EAAEC,iBAAiB,CAAC,kBAAkB,CAAC,EAqBtET,MAAM,CAACC,KAAK,EAMrB,CAAC;AAAEM,EAAAA,UAAAA;AAAW,CAAC,KAAKA,UAAU,EAAEC,UAAU,EAAEC,iBAAiB,CAAC,CAAC,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EAEjBpB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACI,CAAC,EAItBF,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACP,CAAC,EAItBS,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACM,CAAC,EAItBJ,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAMKwB,eAAe,EAExBxB,IAAI,EACJW,SAAS;;;;"}
1
+ {"version":3,"file":"SegmentedControl.styled.mjs","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"sourcesContent":["/* stylelint-disable declaration-block-semicolon-newline-after, rule-empty-line-before */\nimport {\n Transition,\n Typography,\n styled,\n} from '~/src/foundation'\n\nimport DisabledOpacity from '~/src/constants/DisabledOpacity'\nimport { ZIndex } from '~/src/constants/ZIndex'\n\nimport { AlphaStack } from '~/src/components/AlphaStack'\nimport { focusedInputWrapperStyle } from '~/src/components/Forms/Inputs/mixins'\nimport { Text } from '~/src/components/Text'\n\nimport { SegmentedControlSize } from './SegmentedControl.types'\n\nexport const ItemContainer = styled(AlphaStack).attrs({\n direction: 'horizontal',\n align: 'center',\n spacing: 2,\n})`\n z-index: ${ZIndex.Float};\n overflow: hidden;\n`\n\nexport const ItemLabel = styled(Text).attrs({\n bold: true,\n truncated: true,\n})`\n padding: 1px 4px;\n`\n\nexport const Item = styled.button`\n all: unset;\n\n position: relative;\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n min-width: 0;\n\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('background-color')}\n\n &[data-checked] {\n color: var(--txt-black-darkest);\n cursor: default;\n }\n\n &:not([data-checked]) {\n color: var(--txt-black-dark);\n cursor: pointer;\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n /* NOTE: (@ed) focus indicator */\n &::after {\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n display: block;\n width: 100%;\n height: 100%;\n content: '';\n border-radius: inherit;\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS(['box-shadow'])}\n }\n\n &:focus-visible {\n &::after {\n ${focusedInputWrapperStyle}\n }\n }\n\n &:not([data-checked]):not(&:disabled):hover {\n background-color: var(--bg-black-light);\n }\n`\n\nexport const indicatorTransitionMeta = {\n duration: Transition.TransitionDuration.M,\n}\n\nexport const Indicator = styled.div`\n --bezier-react-segmented-control-indicator-transform: none;\n --bezier-react-segmented-control-indicator-width: auto;\n --bezier-react-segmented-control-indicator-height: auto;\n\n position: absolute;\n top: 0;\n left: 0;\n z-index: ${ZIndex.Float};\n\n width: var(--bezier-react-segmented-control-indicator-width);\n height: var(--bezier-react-segmented-control-indicator-height);\n\n ${({ foundation }) => foundation?.elevation.ev1()}\n /* NOTE: (@ed) Overrides the elevation mixin. Do not change the order! */\n background-color: var(--bg-white-high);\n\n transform: var(--bezier-react-segmented-control-indicator-transform);\n ${({ foundation }) => foundation?.transition?.getTransitionsCSS('transform', indicatorTransitionMeta.duration)}\n`\n\nexport const Container = styled(AlphaStack).attrs({ direction: 'horizontal' })`\n --bezier-react-segmented-control-width: auto;\n\n position: relative;\n z-index: ${ZIndex.Base};\n box-sizing: border-box;\n width: var(--bezier-react-segmented-control-width);\n background-color: var(--bg-black-lighter);\n\n &.${SegmentedControlSize.XS} {\n height: 24px;\n padding: 1px;\n border-radius: 6px;\n ${Typography.Size13}\n\n ${Item},\n ${Indicator} {\n border-radius: 5px;\n }\n\n ${Item} {\n padding: 1px 0;\n }\n }\n\n &.${SegmentedControlSize.S} {\n height: 28px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 2px 0;\n }\n }\n\n &.${SegmentedControlSize.M} {\n height: 36px;\n padding: 2px;\n border-radius: 8px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 6px;\n }\n\n ${Item} {\n padding: 6px 0;\n }\n }\n\n &.${SegmentedControlSize.L} {\n height: 44px;\n padding: 4px;\n border-radius: 12px;\n ${Typography.Size14}\n\n ${Item},\n ${Indicator} {\n border-radius: 8px;\n }\n\n ${Item} {\n padding: 8px 0;\n }\n }\n\n &[data-disabled] {\n opacity: ${DisabledOpacity};\n\n ${Item},\n ${Indicator} {\n cursor: not-allowed;\n }\n }\n`\n"],"names":["ItemContainer","styled","AlphaStack","attrs","direction","align","spacing","withConfig","displayName","componentId","ZIndex","Float","ItemLabel","Text","bold","truncated","Item","button","foundation","transition","getTransitionsCSS","focusedInputWrapperStyle","indicatorTransitionMeta","duration","Transition","TransitionDuration","M","Indicator","div","elevation","ev1","Container","Base","SegmentedControlSize","XS","Typography","Size13","S","Size14","L","DisabledOpacity"],"mappings":";;;;;;;;;;AAAA;AAgBO,MAAMA,aAAa,gBAAGC,gBAAM,CAACC,UAAU,CAAC,CAACC,KAAK,CAAC;AACpDC,EAAAA,SAAS,EAAE,YAAY;AACvBC,EAAAA,KAAK,EAAE,QAAQ;AACfC,EAAAA,OAAO,EAAE,CAAA;AACX,CAAC,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,uCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CACWC,CAAAA,CAAAA,CAAAA,UAAAA,EAAAA,mBAAAA,CAAAA,EAAAA,MAAM,CAACC,KAAK,EAExB;AAEM,MAAMC,SAAS,gBAAGX,gBAAM,CAACY,IAAI,CAAC,CAACV,KAAK,CAAC;AAC1CW,EAAAA,IAAI,EAAE,IAAI;AACVC,EAAAA,SAAS,EAAE,IAAA;AACb,CAAC,CAAC,CAAAR,UAAA,CAAA;EAAAC,WAAA,EAAA,mCAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAED,CAAA,CAAA,CAAA,kBAAA,CAAA,EAAA;MAEYO,IAAI,gBAAGf,gBAAM,CAACgB,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A,CAAA,wEAAA,EAAA,sHAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,6CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,qBAAA,EAAA,8CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,sBAAA,EAAA,4CAAA,EAAA,GAAA,EAAA,GAAA,EAAA,wBAAA,CAAA,EAIjEC,MAAM,CAACsB,IAAI,EAKlBC,oBAAoB,CAACC,EAAE,EAIvBC,UAAU,CAACC,MAAM,EAEjBpB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACI,CAAC,EAItBF,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACP,CAAC,EAItBS,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAKJiB,oBAAoB,CAACM,CAAC,EAItBJ,UAAU,CAACG,MAAM,EAEjBtB,IAAI,EACJW,SAAS,EAITX,IAAI,EAMKwB,eAAe,EAExBxB,IAAI,EACJW,SAAS;;;;"}
@@ -2,7 +2,7 @@ import React__default, { useMemo, forwardRef, useState, useRef, useEffect, useCa
2
2
  import { Provider as $a093c7e1ec25a057$export$2881499e37b75b9a, Root as $a093c7e1ec25a057$export$be92b6f5f03c0fe9, Trigger as $a093c7e1ec25a057$export$41fb9f06171c75f4, Portal as $a093c7e1ec25a057$export$602eac185826482c, Content as $a093c7e1ec25a057$export$7c6e2c02157bb7d2 } from '../../node_modules/@radix-ui/react-tooltip/dist/index.mjs';
3
3
  import { getRootElement } from '../../utils/domUtils.mjs';
4
4
  import { createContext } from '../../utils/reactUtils.mjs';
5
- import { isBoolean } from '../../utils/typeUtils.mjs';
5
+ import { isEmpty, isBoolean } from '../../utils/typeUtils.mjs';
6
6
  import { TooltipPosition } from './Tooltip.types.mjs';
7
7
  import { TooltipContent, TextContainer, Content, Description, Icon } from './Tooltip.styled.mjs';
8
8
 
@@ -111,31 +111,12 @@ function TooltipProvider({
111
111
  value: contextValue
112
112
  }, children));
113
113
  }
114
-
115
- /**
116
- * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
117
- *
118
- * @example
119
- *
120
- * ```tsx
121
- * // Anatomy of the Tooltip
122
- * <TooltipProvider>
123
- * <Tooltip />
124
- * </TooltipProvider>
125
- *
126
- * // Example of a Tooltip with a button
127
- * <Tooltip content="Ta-da!">
128
- * <button>Hover me</button>
129
- * </Tooltip>
130
- * ```
131
- */
132
- const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
114
+ const TooltipImpl = /*#__PURE__*/forwardRef(function TooltipImpl({
133
115
  as,
134
116
  children,
135
117
  defaultShow,
136
118
  onShow: onShowProp,
137
119
  onHide: onHideProp,
138
- disabled,
139
120
  content,
140
121
  description,
141
122
  icon,
@@ -172,9 +153,6 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
172
153
  onHideProp?.();
173
154
  }, [onHideProp]);
174
155
  const onOpenChange = useCallback(open => {
175
- if (disabled) {
176
- return;
177
- }
178
156
  if (open) {
179
157
  onShow();
180
158
  return;
@@ -190,7 +168,7 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
190
168
  return;
191
169
  }
192
170
  onHide();
193
- }, [disabled, delayHide, onShow, onHide]);
171
+ }, [delayHide, onShow, onHide]);
194
172
  return /*#__PURE__*/React__default.createElement($a093c7e1ec25a057$export$be92b6f5f03c0fe9, {
195
173
  open: show,
196
174
  defaultOpen: defaultShow,
@@ -215,5 +193,37 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
215
193
  })))));
216
194
  });
217
195
 
196
+ /**
197
+ * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
198
+ *
199
+ * @example
200
+ *
201
+ * ```tsx
202
+ * // Anatomy of the Tooltip
203
+ * <TooltipProvider>
204
+ * <Tooltip />
205
+ * </TooltipProvider>
206
+ *
207
+ * // Example of a Tooltip with a button
208
+ * <Tooltip content="Ta-da!">
209
+ * <button>Hover me</button>
210
+ * </Tooltip>
211
+ * ```
212
+ */
213
+ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip({
214
+ children,
215
+ disabled,
216
+ content,
217
+ ...rest
218
+ }, forwardedRef) {
219
+ if (disabled || isEmpty(content)) {
220
+ return children ?? null;
221
+ }
222
+ return /*#__PURE__*/React__default.createElement(TooltipImpl, Object.assign({
223
+ ref: forwardedRef,
224
+ content: content
225
+ }, rest), children);
226
+ });
227
+
218
228
  export { Tooltip, TooltipProvider };
219
229
  //# sourceMappingURL=Tooltip.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.mjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport { isBoolean } from '~/src/utils/typeUtils'\n\nimport {\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n disabled,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container: givenContainer,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n const delayHide = delayHideProp ?? globalDelayHide\n\n const defaultContainer = getRootElement()\n const container = givenContainer ?? defaultContainer\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (disabled) { return }\n\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n disabled,\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","Tooltip","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","disabled","content","description","icon","offset","container","givenContainer","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","defaultContainer","getRootElement","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source"],"mappings":";;;;;;;;AAuBA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,eAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,eAAe,CAACI,OAAO;MAC1B,OAAO;AACLF,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,OAAA;OACR,CAAA;IACH,KAAKH,eAAe,CAACK,QAAQ;MAC3B,OAAO;AACLH,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,KAAA;OACR,CAAA;IACH,KAAKH,eAAe,CAACM,WAAW;MAC9B,OAAO;AACLJ,QAAAA,IAAI,EAAE,OAAO;AACbC,QA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gB,EAAA,IAAA;AAAA,GAAA,CAAA,eAEhBpD,cAAA,CAAAC,aAAA,CAACoD,cAAqB,EAAA;AAACC,IAAAA,WAAW,EAAE7C,EAAAA;AAAG,GAAA,eACrCT,cAAA,CAAAC,aAAA,CAACoD,aAAoB,EACnBrD,IAAAA,eAAAA,cAAA,CAAAC,aAAA,CAACoD,OAAc,EACXrC,IAAAA,EAAAA,OACY,CAAC,EAEfC,WAAW,iBACXjB,cAAA,CAAAC,aAAA,CAACoD,WAAkB,QACfpC,WACgB,CAEF,CAAC,EAErBC,IAAI,iBACJlB,cAAA,CAAAC,aAAA,CAACoD,IAAW,EAAA;AAACE,IAAAA,MAAM,EAAErC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC;;;;"}
1
+ {"version":3,"file":"Tooltip.mjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport {\n isBoolean,\n isEmpty,\n} from '~/src/utils/typeUtils'\n\nimport {\n type TooltipImplProps,\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\nconst TooltipImpl = forwardRef<HTMLDivElement, TooltipImplProps>(function TooltipImpl({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container: givenContainer,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n const delayHide = delayHideProp ?? globalDelayHide\n\n const defaultContainer = getRootElement()\n const container = givenContainer ?? defaultContainer\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n children,\n disabled,\n content,\n ...rest\n}, forwardedRef) {\n if (disabled || isEmpty(content)) {\n return children ?? null\n }\n\n return (\n <TooltipImpl\n ref={forwardedRef}\n content={content}\n {...rest}\n >\n { children }\n </TooltipImpl>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","TooltipImpl","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","content","description","icon","offset","container","givenContainer","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","defaultContainer","getRootElement","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source","Tooltip","disabled","isEmpty"],"mappings":";;;;;;;;AA2BA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,eAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,EAAE,QAAA;OACR,CAAA;IACH,KAAKH,eAAe,CAACI,OAAO;MAC1B,OAAO;AACLF,QAAAA,IAAI,EAAE,KAAK;AAC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AAA,eAAe,EAAE5B,eAAgB;AACjC6B,IAAAA,gBAAgB,EAAE,CAAE;IACpBC,gBAAgB,EAAA,IAAA;AAAA,GAAA,CAAA,eAEhBnD,cAAA,CAAAC,aAAA,CAACmD,cAAqB,EAAA;AAACC,IAAAA,WAAW,EAAE5C,EAAAA;AAAG,GAAA,eACrCT,cAAA,CAAAC,aAAA,CAACmD,aAAoB,EACnBpD,IAAAA,eAAAA,cAAA,CAAAC,aAAA,CAACmD,OAAc,EACXrC,IAAAA,EAAAA,OACY,CAAC,EAEfC,WAAW,iBACXhB,cAAA,CAAAC,aAAA,CAACmD,WAAkB,QACfpC,WACgB,CAEF,CAAC,EAErBC,IAAI,iBACJjB,cAAA,CAAAC,aAAA,CAACmD,IAAW,EAAA;AAACE,IAAAA,MAAM,EAAErC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC,CAAC,CAAA;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACasC,OAAO,gBAAG/C,UAAU,CAA+B,SAAS+C,OAAOA,CAAC;EAC/E9D,QAAQ;EACR+D,QAAQ;EACRzC,OAAO;EACP,GAAGQ,IAAAA;AACL,CAAC,EAAEC,YAAY,EAAE;AACf,EAAA,IAAIgC,QAAQ,IAAIC,OAAO,CAAC1C,OAAO,CAAC,EAAE;IAChC,OAAOtB,QAAQ,IAAI,IAAI,CAAA;AACzB,GAAA;EAEA,oBACEO,cAAA,CAAAC,aAAA,CAACM,WAAW,EAAAsC,MAAA,CAAAC,MAAA,CAAA;AACVC,IAAAA,GAAG,EAAEvB,YAAa;AAClBT,IAAAA,OAAO,EAAEA,OAAAA;GACLQ,EAAAA,IAAI,CAEN9B,EAAAA,QACS,CAAC,CAAA;AAElB,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.types.mjs","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n DisableProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n"],"names":["TooltipPosition"],"mappings":"AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
1
+ {"version":3,"file":"Tooltip.types.mjs","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipImplProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n\nexport interface TooltipProps extends\n DisableProps,\n TooltipImplProps {}\n"],"names":["TooltipPosition"],"mappings":"AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
@@ -10,7 +10,8 @@ export declare const ItemLabel: import("styled-components").StyledComponent<impo
10
10
  foundation?: import("../../../foundation").Foundation | undefined;
11
11
  } & {
12
12
  bold: true;
13
- }, "bold">;
13
+ truncated: true;
14
+ }, "bold" | "truncated">;
14
15
  export declare const Item: import("styled-components").StyledComponent<"button", import("../../../foundation").Foundation, {
15
16
  foundation?: import("../../../foundation").Foundation | undefined;
16
17
  }, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.styled.d.ts","sourceRoot":"","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"names":[],"mappings":";AAgBA,eAAO,MAAM,aAAa;;;;;;qCAMzB,CAAA;AAED,eAAO,MAAM,SAAS;;;;UAErB,CAAA;AAED,eAAO,MAAM,IAAI;;SAgDhB,CAAA;AAED,eAAO,MAAM,uBAAuB;;CAEnC,CAAA;AAED,eAAO,MAAM,SAAS;;SAmBrB,CAAA;AAED,eAAO,MAAM,SAAS;;;;eAiFrB,CAAA"}
1
+ {"version":3,"file":"SegmentedControl.styled.d.ts","sourceRoot":"","sources":["../../../../../src/components/Forms/SegmentedControl/SegmentedControl.styled.ts"],"names":[],"mappings":";AAgBA,eAAO,MAAM,aAAa;;;;;;qCAOzB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;wBAKrB,CAAA;AAED,eAAO,MAAM,IAAI;;SAiDhB,CAAA;AAED,eAAO,MAAM,uBAAuB;;CAEnC,CAAA;AAED,eAAO,MAAM,SAAS;;SAmBrB,CAAA;AAED,eAAO,MAAM,SAAS;;;;eAiFrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAA;AAQd,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAA;AAqFxB;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,UAAkB,EAClB,SAAe,EACf,SAAa,EACb,aAAmB,GACpB,EAAE,oBAAoB,qBAgBtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,qFAsHlB,CAAA"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAA;AAWd,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAA;AAqFxB;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,UAAkB,EAClB,SAAe,EACf,SAAa,EACb,aAAmB,GACpB,EAAE,oBAAoB,qBAgBtB;AAsHD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,qFAmBlB,CAAA"}
@@ -116,7 +116,9 @@ interface TooltipOptions {
116
116
  }
117
117
  export interface TooltipProviderProps extends ChildrenProps, TooltipProviderOptions {
118
118
  }
119
- export interface TooltipProps extends BezierComponentProps, ChildrenProps<React.ReactElement>, ContentProps, DisableProps, Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>, TooltipOptions {
119
+ export interface TooltipImplProps extends BezierComponentProps, ChildrenProps<React.ReactElement>, ContentProps, Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>, TooltipOptions {
120
+ }
121
+ export interface TooltipProps extends DisableProps, TooltipImplProps {
120
122
  }
121
123
  export {};
122
124
  //# sourceMappingURL=Tooltip.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,mCAAkC;AAEnC;;GAEG;AACH,oBAAY,eAAe;IACzB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,UAAU,eAAe;CAC1B;AAED,UAAU,sBAAsB;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,UAAU,cAAc;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,SAAS,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAChD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC;QAAE,aAAa,EAAE,YAAY,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;CACrF;AAED,MAAM,WAAW,oBAAqB,SACpC,aAAa,EACb,sBAAsB;CAAG;AAE3B,MAAM,WAAW,YAAa,SAC5B,oBAAoB,EACpB,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,EACjC,YAAY,EACZ,YAAY,EACZ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,EACpF,cAAc;CAAG"}
1
+ {"version":3,"file":"Tooltip.types.d.ts","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,mCAAkC;AAEnC;;GAEG;AACH,oBAAY,eAAe;IACzB,SAAS,cAAc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WAAW,CAAC;QAAE,aAAa,EAAE,YAAY,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;CACrF;AAED,MAAM,WAAW,oBAAqB,SACpC,aAAa,EACb,sBAAsB;CAAG;AAE3B,MAAM,WAAW,gBAAiB,SAChC,oBAAoB,EACpB,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,EACjC,YAAY,EACZ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,EACpF,cAAc;CAAG;AAEnB,MAAM,WAAW,YAAa,SAC5B,YAAY,EACZ,gBAAgB;CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@channel.io/bezier-react",
3
- "version": "1.10.2",
3
+ "version": "1.11.0",
4
4
  "description": "React components library that implements Bezier design system.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,9 +20,13 @@ export const ItemContainer = styled(AlphaStack).attrs({
20
20
  spacing: 2,
21
21
  })`
22
22
  z-index: ${ZIndex.Float};
23
+ overflow: hidden;
23
24
  `
24
25
 
25
- export const ItemLabel = styled(Text).attrs({ bold: true })`
26
+ export const ItemLabel = styled(Text).attrs({
27
+ bold: true,
28
+ truncated: true,
29
+ })`
26
30
  padding: 1px 4px;
27
31
  `
28
32
 
@@ -34,6 +38,7 @@ export const Item = styled.button`
34
38
  flex: 1;
35
39
  align-items: center;
36
40
  justify-content: center;
41
+ min-width: 0;
37
42
 
38
43
  ${({ foundation }) => foundation?.transition?.getTransitionsCSS('background-color')}
39
44
 
@@ -147,7 +147,6 @@ exports[`Slider Snapshot should match snapshot 1`] = `
147
147
  data-radix-collection-item=""
148
148
  data-state="closed"
149
149
  role="slider"
150
- style=""
151
150
  tabindex="0"
152
151
  />
153
152
  </span>
@@ -40,42 +40,42 @@ describe('Tooltip', () => {
40
40
 
41
41
  describe('ARIA', () => {
42
42
  it('should be accessible', () => {
43
- const { container } = renderTooltip({ defaultShow: true })
43
+ const { container } = renderTooltip({ defaultShow: true, content: 'tooltip content' })
44
44
  expect(isInaccessible(container)).toBe(false)
45
45
  })
46
46
 
47
47
  it('The element that serves as the tooltip container has role `tooltip`.', () => {
48
- const { getByRole } = renderTooltip({ defaultShow: true })
48
+ const { getByRole } = renderTooltip({ defaultShow: true, content: 'tooltip content' })
49
49
  expect(getByRole('tooltip')).toBeInTheDocument()
50
50
  })
51
51
 
52
52
  it('The element that triggers the tooltip references the tooltip element with `aria-describedby`.', () => {
53
- const { getByRole } = renderTooltip({ defaultShow: true })
53
+ const { getByRole } = renderTooltip({ defaultShow: true, content: 'tooltip content' })
54
54
  expect(getByRole('button')).toHaveAttribute('aria-describedby', getByRole('tooltip').id)
55
55
  })
56
56
  })
57
57
 
58
58
  describe('User Interactions', () => {
59
59
  it('The tooltip content should be visible when hover over the trigger.', async () => {
60
- const { getByRole } = renderTooltip()
60
+ const { getByRole } = renderTooltip({ content: 'tooltip content' })
61
61
  await user.hover(getByRole('button'))
62
62
  expect(getByRole('tooltip')).toBeInTheDocument()
63
63
  })
64
64
 
65
65
  it('The tooltip content should be visible when the keyboard focuses on the trigger.', async () => {
66
- const { getByRole } = renderTooltip()
66
+ const { getByRole } = renderTooltip({ content: 'tooltip content' })
67
67
  await user.tab()
68
68
  expect(getByRole('tooltip')).toBeInTheDocument()
69
69
  })
70
70
 
71
71
  it('When the tooltip content is visible, pressing Esc should hide the tooltip content.', async () => {
72
- const { queryByRole } = renderTooltip({ defaultShow: true })
72
+ const { queryByRole } = renderTooltip({ defaultShow: true, content: 'tooltip content' })
73
73
  await user.keyboard('{Escape}')
74
74
  expect(queryByRole('tooltip')).not.toBeInTheDocument()
75
75
  })
76
76
 
77
77
  it('When the `allowHover` property is true, the tooltip content should be hoverable.', async () => {
78
- const { getByRole } = renderTooltip({ allowHover: true })
78
+ const { getByRole } = renderTooltip({ allowHover: true, content: 'tooltip content' })
79
79
  await user.hover(getByRole('button'))
80
80
  await user.hover(getByRole('tooltip'))
81
81
  expect(getByRole('tooltip')).toBeInTheDocument()
@@ -83,21 +83,45 @@ describe('Tooltip', () => {
83
83
 
84
84
  it('When the tooltip is visible, the `onShow` handler should be called.', async () => {
85
85
  const onShow = jest.fn()
86
- const { getByRole } = renderTooltip({ onShow })
86
+ const { getByRole } = renderTooltip({ onShow, content: 'tooltip content' })
87
87
  await user.hover(getByRole('button'))
88
88
  expect(onShow).toHaveBeenCalled()
89
89
  })
90
90
 
91
91
  it('When the tooltip is hidden, the `onHide` handler should be called.', async () => {
92
92
  const onHide = jest.fn()
93
- const { getByRole } = renderTooltip({ onHide })
93
+ const { getByRole } = renderTooltip({ onHide, content: 'tooltip content' })
94
94
  await user.hover(getByRole('button'))
95
95
  await user.unhover(getByRole('button'))
96
96
  expect(onHide).toHaveBeenCalled()
97
97
  })
98
98
 
99
+ it('If the `content` property is undefined, the tooltip should not be visible when hovering over it or with keyboard focus.', async () => {
100
+ const { getByRole, queryByRole } = renderTooltip({ content: undefined })
101
+ await user.hover(getByRole('button'))
102
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
103
+ await user.tab()
104
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
105
+ })
106
+
107
+ it('If the `content` property is null, the tooltip should not be visible when hovering over it or with keyboard focus.', async () => {
108
+ const { getByRole, queryByRole } = renderTooltip({ content: null })
109
+ await user.hover(getByRole('button'))
110
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
111
+ await user.tab()
112
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
113
+ })
114
+
115
+ it('If the `content` property is empty string, the tooltip should not be visible when hovering over it or with keyboard focus.', async () => {
116
+ const { getByRole, queryByRole } = renderTooltip({ content: '' })
117
+ await user.hover(getByRole('button'))
118
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
119
+ await user.tab()
120
+ expect(queryByRole('tooltip')).not.toBeInTheDocument()
121
+ })
122
+
99
123
  it('If the `disabled` property is true, the tooltip should not be visible when hovering over it or with keyboard focus.', async () => {
100
- const { getByRole, queryByRole } = renderTooltip({ disabled: true })
124
+ const { getByRole, queryByRole } = renderTooltip({ disabled: true, content: 'tooltip content' })
101
125
  await user.hover(getByRole('button'))
102
126
  expect(queryByRole('tooltip')).not.toBeInTheDocument()
103
127
  await user.tab()
@@ -105,7 +129,8 @@ describe('Tooltip', () => {
105
129
  })
106
130
 
107
131
  it('If the `delayShow` property is greater than 0, the tooltip should be delayed by that number of ms before appearing.', async () => {
108
- const { getByRole, queryByRole } = renderTooltip({ delayShow: 1000 })
132
+ // NOTE: (@ed) To avoid test failure due to timing issue
133
+ const { getByRole, queryByRole } = renderTooltip({ delayShow: 1000 - 10, content: 'tooltip content' })
109
134
  await user.hover(getByRole('button'))
110
135
  expect(queryByRole('tooltip')).not.toBeInTheDocument()
111
136
  await waitFor(() => {
@@ -114,7 +139,8 @@ describe('Tooltip', () => {
114
139
  })
115
140
 
116
141
  it('If the `delayHide` property is greater than 0, the tooltip should be delayed by that number of ms before disappearing.', async () => {
117
- const { getByRole, queryByRole } = renderTooltip({ delayHide: 1000 })
142
+ // NOTE: (@ed) To avoid test failure due to timing issue
143
+ const { getByRole, queryByRole } = renderTooltip({ delayHide: 1000 - 10, content: 'tooltip content' })
118
144
  await user.hover(getByRole('button'))
119
145
  await user.unhover(getByRole('button'))
120
146
  expect(queryByRole('tooltip')).toBeInTheDocument()
@@ -134,7 +160,7 @@ describe('TooltipProvider', () => {
134
160
  delayShow={0}
135
161
  {...rest}
136
162
  >
137
- <Tooltip>
163
+ <Tooltip content="tooltip content">
138
164
  <button type="button">
139
165
  Trigger
140
166
  </button>
@@ -11,9 +11,13 @@ import * as TooltipPrimitive from '@radix-ui/react-tooltip'
11
11
 
12
12
  import { getRootElement } from '~/src/utils/domUtils'
13
13
  import { createContext } from '~/src/utils/reactUtils'
14
- import { isBoolean } from '~/src/utils/typeUtils'
14
+ import {
15
+ isBoolean,
16
+ isEmpty,
17
+ } from '~/src/utils/typeUtils'
15
18
 
16
19
  import {
20
+ type TooltipImplProps,
17
21
  TooltipPosition,
18
22
  type TooltipProps,
19
23
  type TooltipProviderProps,
@@ -137,30 +141,12 @@ export function TooltipProvider({
137
141
  )
138
142
  }
139
143
 
140
- /**
141
- * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
142
- *
143
- * @example
144
- *
145
- * ```tsx
146
- * // Anatomy of the Tooltip
147
- * <TooltipProvider>
148
- * <Tooltip />
149
- * </TooltipProvider>
150
- *
151
- * // Example of a Tooltip with a button
152
- * <Tooltip content="Ta-da!">
153
- * <button>Hover me</button>
154
- * </Tooltip>
155
- * ```
156
- */
157
- export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({
144
+ const TooltipImpl = forwardRef<HTMLDivElement, TooltipImplProps>(function TooltipImpl({
158
145
  as,
159
146
  children,
160
147
  defaultShow,
161
148
  onShow: onShowProp,
162
149
  onHide: onHideProp,
163
- disabled,
164
150
  content,
165
151
  description,
166
152
  icon,
@@ -201,8 +187,6 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip
201
187
  }, [onHideProp])
202
188
 
203
189
  const onOpenChange = useCallback((open: boolean) => {
204
- if (disabled) { return }
205
-
206
190
  if (open) {
207
191
  onShow()
208
192
  return
@@ -222,7 +206,6 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip
222
206
 
223
207
  onHide()
224
208
  }, [
225
- disabled,
226
209
  delayHide,
227
210
  onShow,
228
211
  onHide,
@@ -273,3 +256,41 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip
273
256
  </TooltipPrimitive.Root>
274
257
  )
275
258
  })
259
+
260
+ /**
261
+ * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.
262
+ *
263
+ * @example
264
+ *
265
+ * ```tsx
266
+ * // Anatomy of the Tooltip
267
+ * <TooltipProvider>
268
+ * <Tooltip />
269
+ * </TooltipProvider>
270
+ *
271
+ * // Example of a Tooltip with a button
272
+ * <Tooltip content="Ta-da!">
273
+ * <button>Hover me</button>
274
+ * </Tooltip>
275
+ * ```
276
+ */
277
+ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({
278
+ children,
279
+ disabled,
280
+ content,
281
+ ...rest
282
+ }, forwardedRef) {
283
+ if (disabled || isEmpty(content)) {
284
+ return children ?? null
285
+ }
286
+
287
+ return (
288
+ <TooltipImpl
289
+ ref={forwardedRef}
290
+ content={content}
291
+ {...rest}
292
+ >
293
+ { children }
294
+ </TooltipImpl>
295
+ )
296
+ })
@@ -125,10 +125,13 @@ export interface TooltipProviderProps extends
125
125
  ChildrenProps,
126
126
  TooltipProviderOptions {}
127
127
 
128
- export interface TooltipProps extends
128
+ export interface TooltipImplProps extends
129
129
  BezierComponentProps,
130
130
  ChildrenProps<React.ReactElement>,
131
131
  ContentProps,
132
- DisableProps,
133
132
  Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,
134
133
  TooltipOptions {}
134
+
135
+ export interface TooltipProps extends
136
+ DisableProps,
137
+ TooltipImplProps {}