@drivy/cobalt 2.19.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/components/Calendar/CalendarRangePicker/CalendarRangePickerDay.js +14 -7
  2. package/components/Calendar/CalendarRangePicker/CalendarRangePickerDay.js.map +1 -1
  3. package/components/PhotoDropzone/index.js +1 -1
  4. package/components/PhotoDropzone/index.js.map +1 -1
  5. package/components/Popover/DesktopPopover.js +27 -0
  6. package/components/Popover/DesktopPopover.js.map +1 -0
  7. package/components/Popover/PopoverWrapper.js +49 -0
  8. package/components/Popover/PopoverWrapper.js.map +1 -0
  9. package/components/Popover/TooltipWrapper.js +10 -0
  10. package/components/Popover/TooltipWrapper.js.map +1 -0
  11. package/components/Popover/index.js +8 -40
  12. package/components/Popover/index.js.map +1 -1
  13. package/components/Popover/popoverRegistry.js +15 -0
  14. package/components/Popover/popoverRegistry.js.map +1 -0
  15. package/components/Popover/tooltipConfig.js +12 -0
  16. package/components/Popover/tooltipConfig.js.map +1 -0
  17. package/components/Popover/useDesktopPopoverCore.js +102 -0
  18. package/components/Popover/useDesktopPopoverCore.js.map +1 -0
  19. package/components/Popover/useSingletonPopover.js +148 -0
  20. package/components/Popover/useSingletonPopover.js.map +1 -0
  21. package/images/empty-states/connect-device.png +0 -0
  22. package/images/empty-states/connect-device@2x.png +0 -0
  23. package/images/empty-states/connect-device@3x.png +0 -0
  24. package/images/empty-states/couch-man@2x.png +0 -0
  25. package/images/empty-states/couch-man@3x.png +0 -0
  26. package/images/empty-states/fridge-man.png +0 -0
  27. package/images/empty-states/fridge-man@2x.png +0 -0
  28. package/images/empty-states/fridge-man@3x.png +0 -0
  29. package/images/empty-states/generic-list@1x.png +0 -0
  30. package/images/empty-states/generic-list@2x.png +0 -0
  31. package/images/empty-states/generic-list@3x.png +0 -0
  32. package/images/empty-states/location.png +0 -0
  33. package/images/empty-states/location@2x.png +0 -0
  34. package/images/empty-states/location@3x.png +0 -0
  35. package/images/empty-states/network@1x.png +0 -0
  36. package/images/empty-states/network@2x.png +0 -0
  37. package/images/empty-states/network@3x.png +0 -0
  38. package/images/empty-states/payment.png +0 -0
  39. package/images/empty-states/payment@2x.png +0 -0
  40. package/images/empty-states/payment@3x.png +0 -0
  41. package/images/empty-states/repair-man-open.png +0 -0
  42. package/images/empty-states/repair-man-open@2x.png +0 -0
  43. package/images/empty-states/repair-man-open@3x.png +0 -0
  44. package/images/empty-states/repair-man.png +0 -0
  45. package/images/empty-states/repair-man@2x.png +0 -0
  46. package/images/empty-states/repair-man@3x.png +0 -0
  47. package/images/empty-states/spotlight-car.png +0 -0
  48. package/images/empty-states/spotlight-car@2x.png +0 -0
  49. package/images/empty-states/spotlight-car@3x.png +0 -0
  50. package/images/empty-states/telescope.png +0 -0
  51. package/images/empty-states/telescope@2x.png +0 -0
  52. package/images/empty-states/telescope@3x.png +0 -0
  53. package/images/empty-states/thumb-up.png +0 -0
  54. package/images/empty-states/thumb-up@2x.png +0 -0
  55. package/images/empty-states/thumb-up@3x.png +0 -0
  56. package/index.js +5 -0
  57. package/index.js.map +1 -1
  58. package/package.json +27 -27
  59. package/styles/components/Calendar/CalendarRangePicker/index.scss +0 -8
  60. package/styles/components/Popover/index.scss +29 -72
  61. package/types/src/components/Popover/DesktopPopover.d.ts +2 -0
  62. package/types/src/components/Popover/PopoverWrapper.d.ts +13 -0
  63. package/types/src/components/Popover/TooltipWrapper.d.ts +3 -0
  64. package/types/src/components/Popover/index.d.ts +13 -24
  65. package/types/src/components/Popover/popoverRegistry.d.ts +4 -0
  66. package/types/src/components/Popover/tooltipConfig.d.ts +9 -0
  67. package/types/src/components/Popover/useDesktopPopoverCore.d.ts +44 -0
  68. package/types/src/components/Popover/useSingletonPopover.d.ts +17 -0
  69. package/types/src/index.d.ts +6 -0
  70. package/utils/getCobaltTailwindcssConfig.js.map +1 -1
  71. package/components/Calendar/CalendarRangePicker/DayTooltip.js +0 -23
  72. package/components/Calendar/CalendarRangePicker/DayTooltip.js.map +0 -1
  73. package/components/Popover/LazyTippy.js +0 -9
  74. package/components/Popover/LazyTippy.js.map +0 -1
  75. package/types/src/__tests__/AsyncComponent.d.ts +0 -6
  76. package/types/src/components/Calendar/CalendarRangePicker/DayTooltip.d.ts +0 -3
  77. package/types/src/components/Popover/LazyTippy.d.ts +0 -3
@@ -0,0 +1,148 @@
1
+ import { useState, useRef, useCallback, useEffect } from 'react';
2
+ import { registerPopover } from './popoverRegistry.js';
3
+ import { useDesktopPopoverCore } from './useDesktopPopoverCore.js';
4
+
5
+ function normalizeDelay(delay) {
6
+ var _a, _b;
7
+ if (typeof delay === "number") {
8
+ return { open: delay, close: delay };
9
+ }
10
+ return {
11
+ open: (_a = delay === null || delay === void 0 ? void 0 : delay.open) !== null && _a !== void 0 ? _a : 0,
12
+ close: (_b = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _b !== void 0 ? _b : 0,
13
+ };
14
+ }
15
+ function useSingletonPopover({ trigger = "mouseenter", delay = 0, interactive = false, gracePeriod = 100, ...options }) {
16
+ const [isOpen, setIsOpen] = useState(false);
17
+ const [referenceElement, setReferenceElement] = useState(null);
18
+ const [content, setContent] = useState(null);
19
+ const openTimeoutRef = useRef(null);
20
+ const closeTimeoutRef = useRef(null);
21
+ const delays = normalizeDelay(delay);
22
+ const clearOpenTimeout = useCallback(() => {
23
+ if (openTimeoutRef.current != null) {
24
+ window.clearTimeout(openTimeoutRef.current);
25
+ openTimeoutRef.current = null;
26
+ }
27
+ }, []);
28
+ const clearCloseTimeout = useCallback(() => {
29
+ if (closeTimeoutRef.current != null) {
30
+ window.clearTimeout(closeTimeoutRef.current);
31
+ closeTimeoutRef.current = null;
32
+ }
33
+ }, []);
34
+ useEffect(() => {
35
+ return () => {
36
+ if (openTimeoutRef.current != null) {
37
+ window.clearTimeout(openTimeoutRef.current);
38
+ }
39
+ if (closeTimeoutRef.current != null) {
40
+ window.clearTimeout(closeTimeoutRef.current);
41
+ }
42
+ };
43
+ }, []);
44
+ const closePopover = useCallback((immediate = false, useGracePeriod = false) => {
45
+ clearOpenTimeout();
46
+ const run = () => {
47
+ setIsOpen(false);
48
+ };
49
+ const closeDelay = useGracePeriod
50
+ ? Math.max(delays.close, gracePeriod)
51
+ : delays.close;
52
+ if (immediate || closeDelay === 0) {
53
+ clearCloseTimeout();
54
+ run();
55
+ return;
56
+ }
57
+ clearCloseTimeout();
58
+ closeTimeoutRef.current = window.setTimeout(run, closeDelay);
59
+ }, [clearOpenTimeout, clearCloseTimeout, delays.close, gracePeriod]);
60
+ useEffect(() => {
61
+ return registerPopover(() => {
62
+ closePopover(true);
63
+ });
64
+ }, [closePopover]);
65
+ const core = useDesktopPopoverCore({
66
+ ...options,
67
+ isOpen,
68
+ onOpenChange: setIsOpen,
69
+ referenceElement,
70
+ trigger: "manual",
71
+ interactive,
72
+ getFloatingExtraProps: interactive && trigger === "mouseenter"
73
+ ? () => ({
74
+ onMouseEnter: () => {
75
+ clearCloseTimeout();
76
+ },
77
+ onMouseLeave: () => {
78
+ closePopover(false, true);
79
+ },
80
+ })
81
+ : undefined,
82
+ });
83
+ const openWithItem = (item, element, immediate = false) => {
84
+ clearCloseTimeout();
85
+ const run = () => {
86
+ setReferenceElement(element);
87
+ core.refs.setReference(element);
88
+ setContent(item.content);
89
+ setIsOpen(true);
90
+ };
91
+ const shouldOpenImmediately = immediate || isOpen || delays.open === 0;
92
+ if (shouldOpenImmediately) {
93
+ clearOpenTimeout();
94
+ run();
95
+ return;
96
+ }
97
+ clearOpenTimeout();
98
+ openTimeoutRef.current = window.setTimeout(run, delays.open);
99
+ };
100
+ const getReferenceProps = (item, userProps = {}) => {
101
+ const { onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, onClick, ...restUserProps } = userProps;
102
+ return core.getReferenceProps({
103
+ ...restUserProps,
104
+ onMouseEnter: (e) => {
105
+ onMouseEnter === null || onMouseEnter === void 0 ? void 0 : onMouseEnter(e);
106
+ if (trigger === "mouseenter") {
107
+ openWithItem(item, e.currentTarget);
108
+ }
109
+ },
110
+ onPointerEnter: (e) => {
111
+ onPointerEnter === null || onPointerEnter === void 0 ? void 0 : onPointerEnter(e);
112
+ },
113
+ onMouseLeave: (e) => {
114
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
115
+ if (trigger === "mouseenter" && !interactive) {
116
+ closePopover(false, true);
117
+ }
118
+ },
119
+ onPointerLeave: (e) => {
120
+ onPointerLeave === null || onPointerLeave === void 0 ? void 0 : onPointerLeave(e);
121
+ },
122
+ onClick: (e) => {
123
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
124
+ if (trigger === "click") {
125
+ const sameReference = referenceElement === e.currentTarget;
126
+ setReferenceElement(e.currentTarget);
127
+ core.refs.setReference(e.currentTarget);
128
+ setContent(item.content);
129
+ if (sameReference && isOpen) {
130
+ setIsOpen(false);
131
+ }
132
+ else {
133
+ setIsOpen(true);
134
+ }
135
+ }
136
+ },
137
+ });
138
+ };
139
+ return {
140
+ getReferenceProps,
141
+ renderFloating: () => content == null ? null : core.renderFloating(content),
142
+ close: () => closePopover(true),
143
+ isOpen,
144
+ };
145
+ }
146
+
147
+ export { useSingletonPopover };
148
+ //# sourceMappingURL=useSingletonPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSingletonPopover.js","sources":["../../../src/components/Popover/useSingletonPopover.tsx"],"sourcesContent":["import type React from \"react\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { registerPopover } from \"./popoverRegistry\"\nimport type { UseDesktopPopoverCoreOptions } from \"./useDesktopPopoverCore\"\nimport { useDesktopPopoverCore } from \"./useDesktopPopoverCore\"\n\ntype SingletonItem = {\n content: React.ReactNode\n}\n\ntype SingletonReferenceProps = React.HTMLAttributes<HTMLElement>\n\ntype SingletonOptions = Omit<\n UseDesktopPopoverCoreOptions,\n | \"isOpen\"\n | \"onOpenChange\"\n | \"referenceElement\"\n | \"trigger\"\n | \"getFloatingExtraProps\"\n> & {\n trigger?: \"click\" | \"mouseenter\"\n gracePeriod?: number\n}\n\nfunction normalizeDelay(delay: SingletonOptions[\"delay\"]) {\n if (typeof delay === \"number\") {\n return { open: delay, close: delay }\n }\n\n return {\n open: delay?.open ?? 0,\n close: delay?.close ?? 0,\n }\n}\n\nexport function useSingletonPopover({\n trigger = \"mouseenter\",\n delay = 0,\n interactive = false,\n gracePeriod = 100,\n ...options\n}: SingletonOptions) {\n const [isOpen, setIsOpen] = useState(false)\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(\n null,\n )\n const [content, setContent] = useState<React.ReactNode>(null)\n\n const openTimeoutRef = useRef<number | null>(null)\n const closeTimeoutRef = useRef<number | null>(null)\n\n const delays = normalizeDelay(delay)\n\n const clearOpenTimeout = useCallback(() => {\n if (openTimeoutRef.current != null) {\n window.clearTimeout(openTimeoutRef.current)\n openTimeoutRef.current = null\n }\n }, [])\n\n const clearCloseTimeout = useCallback(() => {\n if (closeTimeoutRef.current != null) {\n window.clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = null\n }\n }, [])\n\n useEffect(() => {\n return () => {\n if (openTimeoutRef.current != null) {\n window.clearTimeout(openTimeoutRef.current)\n }\n\n if (closeTimeoutRef.current != null) {\n window.clearTimeout(closeTimeoutRef.current)\n }\n }\n }, [])\n\n const closePopover = useCallback(\n (immediate = false, useGracePeriod = false) => {\n clearOpenTimeout()\n\n const run = () => {\n setIsOpen(false)\n }\n\n const closeDelay = useGracePeriod\n ? Math.max(delays.close, gracePeriod)\n : delays.close\n\n if (immediate || closeDelay === 0) {\n clearCloseTimeout()\n run()\n return\n }\n\n clearCloseTimeout()\n closeTimeoutRef.current = window.setTimeout(run, closeDelay)\n },\n [clearOpenTimeout, clearCloseTimeout, delays.close, gracePeriod],\n )\n\n useEffect(() => {\n return registerPopover(() => {\n closePopover(true)\n })\n }, [closePopover])\n\n const core = useDesktopPopoverCore({\n ...options,\n isOpen,\n onOpenChange: setIsOpen,\n referenceElement,\n trigger: \"manual\",\n interactive,\n getFloatingExtraProps:\n interactive && trigger === \"mouseenter\"\n ? () => ({\n onMouseEnter: () => {\n clearCloseTimeout()\n },\n onMouseLeave: () => {\n closePopover(false, true)\n },\n })\n : undefined,\n })\n\n const openWithItem = (\n item: SingletonItem,\n element: HTMLElement,\n immediate = false,\n ) => {\n clearCloseTimeout()\n\n const run = () => {\n setReferenceElement(element)\n core.refs.setReference(element)\n setContent(item.content)\n setIsOpen(true)\n }\n\n const shouldOpenImmediately = immediate || isOpen || delays.open === 0\n\n if (shouldOpenImmediately) {\n clearOpenTimeout()\n run()\n return\n }\n\n clearOpenTimeout()\n openTimeoutRef.current = window.setTimeout(run, delays.open)\n }\n\n const getReferenceProps = (\n item: SingletonItem,\n userProps: SingletonReferenceProps = {},\n ) => {\n const {\n onMouseEnter,\n onMouseLeave,\n onPointerEnter,\n onPointerLeave,\n onClick,\n ...restUserProps\n } = userProps\n\n return core.getReferenceProps({\n ...restUserProps,\n\n onMouseEnter: (e: React.MouseEvent<HTMLElement>) => {\n onMouseEnter?.(e)\n\n if (trigger === \"mouseenter\") {\n openWithItem(item, e.currentTarget)\n }\n },\n\n onPointerEnter: (e: React.PointerEvent<HTMLElement>) => {\n onPointerEnter?.(e)\n },\n\n onMouseLeave: (e: React.MouseEvent<HTMLElement>) => {\n onMouseLeave?.(e)\n\n if (trigger === \"mouseenter\" && !interactive) {\n closePopover(false, true)\n }\n },\n\n onPointerLeave: (e: React.PointerEvent<HTMLElement>) => {\n onPointerLeave?.(e)\n },\n\n onClick: (e: React.MouseEvent<HTMLElement>) => {\n onClick?.(e)\n\n if (trigger === \"click\") {\n const sameReference = referenceElement === e.currentTarget\n\n setReferenceElement(e.currentTarget)\n core.refs.setReference(e.currentTarget)\n setContent(item.content)\n\n if (sameReference && isOpen) {\n setIsOpen(false)\n } else {\n setIsOpen(true)\n }\n }\n },\n })\n }\n\n return {\n getReferenceProps,\n renderFloating: () =>\n content == null ? null : core.renderFloating(content),\n close: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AAI,CAAC,CAAA;iBAC1B;aACF;AAED,YAAA,cAAc,EAAE,CAAC,CAAkC,KAAI;AACrD,gBAAA,cAAc,aAAd,cAAc,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAd,cAAc,CAAG,CAAC,CAAC,CAAA;aACpB;AAED,YAAA,OAAO,EAAE,CAAC,CAAgC,KAAI;AAC5C,gBAAA,OAAO,aAAP,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAP,OAAO,CAAG,CAAC,CAAC,CAAA;AAEZ,gBAAA,IAAI,OAAO,KAAK,OAAO,EAAE;AACvB,oBAAA,MAAM,aAAa,GAAG,gBAAgB,KAAK,CAAC,CAAC,aAAa,CAAA;AAE1D,oBAAA,mBAAmB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;oBACpC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;AACvC,oBAAA,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAExB,oBAAA,IAAI,aAAa,IAAI,MAAM,EAAE;wBAC3B,SAAS,CAAC,KAAK,CAAC,CAAA;qBACjB;yBAAM;wBACL,SAAS,CAAC,IAAI,CAAC,CAAA;qBAChB;iBACF;aACF;AACF,SAAA,CAAC,CAAA;AACJ,KAAC,CAAA;IAED,OAAO;QACL,iBAAiB;AACjB,QAAA,cAAc,EAAE,MACd,OAAO,IAAI,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;AACvD,QAAA,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC;QAC/B,MAAM;KACP,CAAA;AACH;;;;"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/index.js CHANGED
@@ -50,6 +50,11 @@ export { default as PhotoDropzone } from './components/PhotoDropzone/index.js';
50
50
  export { Pill, PillGroup } from './components/Pill/index.js';
51
51
  export { PlateNumber } from './components/PlateNumber/index.js';
52
52
  export { default as Popover } from './components/Popover/index.js';
53
+ export { PopoverWrapper } from './components/Popover/PopoverWrapper.js';
54
+ export { hideAllPopovers } from './components/Popover/popoverRegistry.js';
55
+ export { TooltipWrapper } from './components/Popover/TooltipWrapper.js';
56
+ export { tooltipConfig } from './components/Popover/tooltipConfig.js';
57
+ export { useSingletonPopover } from './components/Popover/useSingletonPopover.js';
53
58
  export { PriceTable, PriceTableRow } from './components/PriceTable/index.js';
54
59
  export { ProgressBanner } from './components/ProgressBanner/index.js';
55
60
  export { ProgressBar } from './components/ProgressBar/index.js';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "2.19.1",
3
+ "version": "3.0.0",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
- "main": "src/index.js",
5
+ "main": "index.js",
6
6
  "types": "types/src/index.d.ts",
7
7
  "sideEffects": [
8
8
  "*.css",
@@ -11,7 +11,8 @@
11
11
  "engines": {
12
12
  "node": ">=24.14.1"
13
13
  },
14
- "module": "src/index.js",
14
+ "packageManager": "pnpm@11.1.3+sha512.c85357fe17ca12dd23dd7071822666dfd7e3cb76fe214e3370b5ea2fb34f2a231185509b63e717f3cd0acb38dd3f8d82bcd5e8172400ae678b70ea4fbed0896d",
15
+ "module": "index.js",
15
16
  "license": "MIT",
16
17
  "author": {
17
18
  "name": "Tim Petricola",
@@ -20,17 +21,16 @@
20
21
  },
21
22
  "dependencies": {
22
23
  "@ark-ui/react": "5.30.0",
24
+ "@floating-ui/react": "0.27.10",
23
25
  "@juggle/resize-observer": "3.4.0",
24
26
  "@lottiefiles/react-lottie-player": "3.6.0",
25
- "@tippyjs/react": "4.2.6",
26
27
  "classnames": "2.5.1",
27
28
  "date-fns": "2.30.0",
28
29
  "lodash.throttle": "4.1.1",
29
30
  "media-typer": "1.1.0",
30
31
  "nanoid": "5.1.11",
31
32
  "postcss": "8.5.14",
32
- "tailwindcss": "3.4.19",
33
- "tippy.js": "6.3.7"
33
+ "tailwindcss": "3.4.19"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^18.3.1",
@@ -65,7 +65,7 @@
65
65
  "jest": "29.7.0",
66
66
  "jest-environment-jsdom": "29.7.0",
67
67
  "nested-object-access": "^0.2.5",
68
- "np": "10.3.0",
68
+ "np": "11.2.1",
69
69
  "postcss-flexbugs-fixes": "5.0.2",
70
70
  "postcss-loader": "8.2.1",
71
71
  "react": "18.3.1",
@@ -89,6 +89,25 @@
89
89
  "ts-jest": "29.4.9",
90
90
  "typescript": "5.9.3"
91
91
  },
92
+ "scripts": {
93
+ "build": "./scripts/build.sh",
94
+ "build:dev": "pnpm build && yalc publish dist/",
95
+ "build:publish": "pnpm build && pnpm np --contents dist --package-manager npm",
96
+ "deploy": "./scripts/publishToBranch.sh",
97
+ "lint": "biome check && stylelint \"src/**/*.scss\"",
98
+ "lint:fix": "biome check --fix && stylelint \"src/**/*.scss\" --fix",
99
+ "scss:vars": "ts-node -e 'console.log(require(\"./utils/tailwindcssThemeHelpers.js\").getFlattenedTheme())'",
100
+ "binary": "sh ./scripts/buildCobaltBinary.sh",
101
+ "storybook:prepare": "PLAYGROUND_GENERATION=true npx tailwindcss -i ./src/utilities.css -o ./src/_generated_tailwind_playground.css && PLAYGROUND_GENERATION=false",
102
+ "storybook": "pnpm storybook:prepare && storybook dev -p 6006",
103
+ "storybook:build": "pnpm storybook:prepare && storybook build",
104
+ "build:icons": "./scripts/buildIcons.sh",
105
+ "build:illustrations": "./scripts/buildIllustrations.sh",
106
+ "build:theme": "node ./scripts/buildThemeCSSVariables.mts",
107
+ "test": "jest",
108
+ "typecheck": "tsc",
109
+ "version": "cp package.json dist/package.json"
110
+ },
92
111
  "keywords": [
93
112
  "drivy",
94
113
  "cobalt"
@@ -108,24 +127,5 @@
108
127
  "publishConfig": {
109
128
  "registry": "https://registry.npmjs.org",
110
129
  "access": "public"
111
- },
112
- "scripts": {
113
- "build": "./scripts/build.sh",
114
- "build:dev": "pnpm build && yalc publish dist/",
115
- "build:publish": "pnpm build && pnpm np --contents dist",
116
- "deploy": "./scripts/publishToBranch.sh",
117
- "lint": "biome check && stylelint \"src/**/*.scss\"",
118
- "lint:fix": "biome check --fix && stylelint \"src/**/*.scss\" --fix",
119
- "scss:vars": "ts-node -e 'console.log(require(\"./utils/tailwindcssThemeHelpers.js\").getFlattenedTheme())'",
120
- "binary": "sh ./scripts/buildCobaltBinary.sh",
121
- "storybook:prepare": "PLAYGROUND_GENERATION=true npx tailwindcss -i ./src/utilities.css -o ./src/_generated_tailwind_playground.css && PLAYGROUND_GENERATION=false",
122
- "storybook": "pnpm storybook:prepare && storybook dev -p 6006",
123
- "storybook:build": "pnpm storybook:prepare && storybook build",
124
- "build:icons": "./scripts/buildIcons.sh",
125
- "build:illustrations": "./scripts/buildIllustrations.sh",
126
- "build:theme": "node ./scripts/buildThemeCSSVariables.mts",
127
- "test": "jest",
128
- "typecheck": "tsc",
129
- "version": "cp package.json dist/package.json"
130
130
  }
131
- }
131
+ }
@@ -305,11 +305,3 @@
305
305
  }
306
306
  }
307
307
  }
308
-
309
- .tippy-box[data-theme~="range-picker"] {
310
- @apply c-p-xs;
311
-
312
- .tippy-content {
313
- min-width: unset;
314
- }
315
- }
@@ -1,90 +1,47 @@
1
- @import "tippy.js/dist/tippy.css";
2
- @import "tippy.js/themes/light.css";
3
- @import "tippy.js/animations/shift-away-subtle.css";
4
-
5
- [data-theme~="cobalt-popover"] {
6
- &.tippy-box {
7
- @apply c-bg-surfaceBright c-text-onSurface c-shadow-lg c-rounded-lg;
8
- }
9
-
10
- .tippy-content {
11
- padding: 0;
12
- min-width: 16rem;
13
-
14
- @apply c-rounded-lg;
15
- }
16
-
17
- &[data-placement^="top"] > .tippy-arrow::before {
18
- border-top-color: theme("colors.surfaceBright") !important;
19
- }
20
-
21
- &[data-placement^="bottom"] > .tippy-arrow::before {
22
- border-bottom-color: theme("colors.surfaceBright") !important;
23
- }
24
-
25
- &[data-placement^="left"] > .tippy-arrow::before {
26
- border-left-color: theme("colors.surfaceBright") !important;
27
- }
28
-
29
- &[data-placement^="right"] > .tippy-arrow::before {
30
- border-right-color: theme("colors.surfaceBright") !important;
31
- }
1
+ .cobalt-popover {
2
+ @apply c-bg-surfaceBright c-text-onSurface c-shadow-lg c-rounded-lg;
3
+ padding: 0;
4
+ min-width: 16rem;
5
+ max-width: 500px;
32
6
  }
33
7
 
34
- [data-theme~="cobalt-popover--fitContent"] {
35
- .tippy-content {
36
- min-width: auto;
37
- }
8
+ .cobalt-popover--fitContent {
9
+ min-width: auto;
10
+ max-width: none;
38
11
  }
39
12
 
40
- [data-theme~="cobalt-popover--withArrow"] {
41
- &.tippy-box {
42
- @apply c-rounded-xl;
43
- }
13
+ .cobalt-popover--withArrow {
14
+ @apply c-rounded-xl;
15
+ }
44
16
 
45
- .tippy-content {
46
- @apply c-rounded-xl;
47
- }
17
+ .cobalt-popover--withBorder {
18
+ @apply c-border c-border-outline;
48
19
  }
49
20
 
50
21
  .cobalt-popover--bodySpacing {
51
22
  padding: theme("spacing.md");
52
23
  }
53
24
 
25
+ .cobalt-popover__arrow {
26
+ fill: theme("colors.surfaceBright");
27
+ }
28
+
54
29
  .use-cobalt-dark-theme {
55
- [data-theme~="cobalt-popover"] {
30
+ .cobalt-popover {
56
31
  box-shadow: 0 0 0 1px theme("colors.outline");
32
+ }
57
33
 
58
- &[data-placement^="top"] > .tippy-arrow {
59
- bottom: -1px;
60
-
61
- &::before {
62
- border-top-color: theme("colors.outline") !important;
63
- }
64
- }
65
-
66
- &[data-placement^="bottom"] > .tippy-arrow {
67
- top: -1px;
68
-
69
- &::before {
70
- border-bottom-color: theme("colors.outline") !important;
71
- }
72
- }
73
-
74
- &[data-placement^="left"] > .tippy-arrow {
75
- right: -1px;
34
+ .cobalt-popover__arrow {
35
+ fill: theme("colors.surfaceBright");
36
+ stroke: theme("colors.outline");
37
+ stroke-width: 1;
38
+ }
39
+ }
76
40
 
77
- &::before {
78
- border-left-color: theme("colors.outline") !important;
79
- }
80
- }
41
+ .cobalt-popover[data-theme~="tooltip"] {
42
+ @apply c-py-2xs c-px-xs c-rounded c-text-body-sm;
81
43
 
82
- &[data-placement^="right"] > .tippy-arrow {
83
- left: -1px;
44
+ min-width: auto;
84
45
 
85
- &::before {
86
- border-right-color: theme("colors.outline") !important;
87
- }
88
- }
89
- }
46
+ box-shadow: elevation(), elevation(md);
90
47
  }
@@ -0,0 +1,2 @@
1
+ import type { PopoverPropsType } from ".";
2
+ export declare const DesktopPopover: ({ targetRef, children, isOpen, onOpenChange, ...rest }: PopoverPropsType) => import("react").ReactNode;
@@ -0,0 +1,13 @@
1
+ import React, { type ReactElement, type Ref } from "react";
2
+ import { type PopoverPropsType } from ".";
3
+ type RefableElement = ReactElement & {
4
+ ref?: Ref<HTMLElement>;
5
+ };
6
+ export type PopoverWrapperPropsType = Omit<PopoverPropsType, "targetRef" | "children" | "isOpen"> & {
7
+ content: React.ReactNode;
8
+ disabled?: boolean;
9
+ isOpenByDefault?: boolean;
10
+ children: RefableElement;
11
+ };
12
+ export declare function PopoverWrapper({ content, children, trigger, onOpenChange, isOpenByDefault, disabled, responsive, ...popoverProps }: PopoverWrapperPropsType): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type PopoverWrapperPropsType } from "./PopoverWrapper";
2
+ export type TooltipWrapperPropsType = Omit<PopoverWrapperPropsType, "responsive">;
3
+ export declare function TooltipWrapper({ content, children, ...popoverProps }: TooltipWrapperPropsType): import("react/jsx-runtime").JSX.Element;
@@ -1,29 +1,18 @@
1
- import { type TippyProps } from "@tippyjs/react";
2
1
  import type React from "react";
3
- export type PopoverPropsType = {
4
- children?: React.ReactNode;
2
+ import type { DesktopPopoverCoreRefs, PopoverConfig } from "./useDesktopPopoverCore";
3
+ type DesktopPopoverRenderProps = {
4
+ refs: DesktopPopoverCoreRefs;
5
+ getReferenceProps: ReturnType<typeof import("@floating-ui/react").useInteractions>["getReferenceProps"];
6
+ renderFloating: (content: React.ReactNode) => React.ReactNode;
7
+ };
8
+ export type DesktopPopoverChildren = React.ReactNode | ((props: DesktopPopoverRenderProps) => React.ReactNode);
9
+ export type PopoverPropsType = PopoverConfig & {
10
+ children?: DesktopPopoverChildren;
5
11
  isOpen: boolean;
6
- close: () => void;
12
+ onOpenChange?: (open: boolean) => void;
7
13
  "aria-label"?: string;
8
- bodySpacing?: boolean;
9
- onShow?: () => void;
10
- onHidden?: () => void;
11
- targetRef: TippyProps["reference"];
12
- arrow?: boolean;
13
- placement?: TippyProps["placement"];
14
- flip?: boolean;
15
- theme?: string;
16
- distance?: number;
17
- zIndex?: number;
18
- appendToBody?: boolean;
19
- fitContent?: boolean;
20
- /**
21
- * __Only for desktop popover__
22
- *
23
- * Allow to render the content only when the popover is mounted in the DOM
24
- * Useful to render async content in the popover
25
- */
26
- lazy?: boolean;
14
+ targetRef: React.RefObject<Element | null> | Element | null;
15
+ responsive?: boolean;
27
16
  };
28
- declare const Popover: ({ isOpen, targetRef, close, "aria-label": ariaLabel, children, bodySpacing, onShow, onHidden, arrow, placement, flip, theme, distance, zIndex, appendToBody, fitContent, lazy, }: PopoverPropsType) => import("react/jsx-runtime").JSX.Element;
17
+ declare const Popover: ({ arrow, placement, bodySpacing, appendToBody, fitContent, responsive, ...restProps }: PopoverPropsType) => import("react/jsx-runtime").JSX.Element;
29
18
  export default Popover;
@@ -0,0 +1,4 @@
1
+ type CloseFn = () => void;
2
+ export declare const registerPopover: (close: CloseFn) => () => void;
3
+ export declare const hideAllPopovers: () => void;
4
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const tooltipConfig: {
2
+ trigger: "mouseenter";
3
+ interactive: false;
4
+ tooltip: true;
5
+ arrow: true;
6
+ placement: "top";
7
+ bodySpacing: false;
8
+ appendToBody: true;
9
+ };
@@ -0,0 +1,44 @@
1
+ import { type Placement } from "@floating-ui/react";
2
+ import type React from "react";
3
+ export type PopoverConfig = {
4
+ placement?: Placement;
5
+ flip?: boolean;
6
+ arrow?: boolean;
7
+ theme?: string;
8
+ tooltip?: boolean;
9
+ lightMode?: boolean;
10
+ zIndex?: number;
11
+ appendToBody?: boolean;
12
+ withBorder?: boolean;
13
+ fitContent?: boolean;
14
+ trigger?: "click" | "mouseenter";
15
+ interactive?: boolean;
16
+ delay?: number | {
17
+ open?: number;
18
+ close?: number;
19
+ };
20
+ offset?: [number, number];
21
+ bodySpacing?: boolean;
22
+ onShow?: () => void;
23
+ onHidden?: () => void;
24
+ };
25
+ export type UseDesktopPopoverCoreOptions = Omit<PopoverConfig, "trigger"> & {
26
+ isOpen: boolean;
27
+ onOpenChange?: (open: boolean) => void;
28
+ referenceElement: Element | null;
29
+ trigger?: "click" | "mouseenter" | "manual";
30
+ ariaLabel?: string;
31
+ getFloatingExtraProps?: () => React.HTMLAttributes<HTMLElement>;
32
+ };
33
+ export type DesktopPopoverCoreRefs = {
34
+ setReference: (node: Element | null) => void;
35
+ setFloating: (node: HTMLElement | null) => void;
36
+ };
37
+ type UseDesktopPopoverCoreReturnType = {
38
+ refs: DesktopPopoverCoreRefs;
39
+ getReferenceProps: ReturnType<typeof import("@floating-ui/react").useInteractions>["getReferenceProps"];
40
+ renderFloating: (content: React.ReactNode) => React.ReactNode;
41
+ isMounted: boolean;
42
+ };
43
+ export declare function useDesktopPopoverCore({ isOpen, onOpenChange, referenceElement, placement, flip, tooltip, arrow: showArrow, theme, zIndex, appendToBody, fitContent, withBorder, trigger, interactive, delay, offset, bodySpacing, ariaLabel, onShow, onHidden, getFloatingExtraProps, }: UseDesktopPopoverCoreOptions): UseDesktopPopoverCoreReturnType;
44
+ export {};