@salt-ds/core 0.0.0-snapshot-20230802154358 → 0.0.0-snapshot-20230811150341

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 (52) hide show
  1. package/dist-cjs/accordion/AccordionHeader.css.js +1 -1
  2. package/dist-cjs/accordion/AccordionPanel.css.js +1 -1
  3. package/dist-cjs/accordion/AccordionPanel.js +1 -27
  4. package/dist-cjs/accordion/AccordionPanel.js.map +1 -1
  5. package/dist-cjs/checkbox/Checkbox.css.js +1 -1
  6. package/dist-cjs/index.js +4 -5
  7. package/dist-cjs/index.js.map +1 -1
  8. package/dist-cjs/radio-button/RadioButton.css.js +1 -1
  9. package/dist-cjs/tooltip/Tooltip.js +19 -53
  10. package/dist-cjs/tooltip/Tooltip.js.map +1 -1
  11. package/dist-cjs/tooltip/TooltipBase.js +62 -0
  12. package/dist-cjs/tooltip/TooltipBase.js.map +1 -0
  13. package/dist-cjs/tooltip/useTooltip.js +8 -7
  14. package/dist-cjs/tooltip/useTooltip.js.map +1 -1
  15. package/dist-cjs/utils/useFloatingUI.js +83 -2
  16. package/dist-cjs/utils/useFloatingUI.js.map +1 -1
  17. package/dist-es/accordion/AccordionHeader.css.js +1 -1
  18. package/dist-es/accordion/AccordionPanel.css.js +1 -1
  19. package/dist-es/accordion/AccordionPanel.js +2 -28
  20. package/dist-es/accordion/AccordionPanel.js.map +1 -1
  21. package/dist-es/checkbox/Checkbox.css.js +1 -1
  22. package/dist-es/index.js +1 -3
  23. package/dist-es/index.js.map +1 -1
  24. package/dist-es/radio-button/RadioButton.css.js +1 -1
  25. package/dist-es/tooltip/Tooltip.js +19 -53
  26. package/dist-es/tooltip/Tooltip.js.map +1 -1
  27. package/dist-es/tooltip/TooltipBase.js +58 -0
  28. package/dist-es/tooltip/TooltipBase.js.map +1 -0
  29. package/dist-es/tooltip/useTooltip.js +8 -7
  30. package/dist-es/tooltip/useTooltip.js.map +1 -1
  31. package/dist-es/utils/useFloatingUI.js +81 -4
  32. package/dist-es/utils/useFloatingUI.js.map +1 -1
  33. package/dist-types/index.d.ts +0 -1
  34. package/dist-types/tooltip/TooltipBase.d.ts +13 -0
  35. package/dist-types/tooltip/useTooltip.d.ts +5 -0
  36. package/dist-types/utils/useFloatingUI.d.ts +45 -1
  37. package/package.json +2 -2
  38. package/dist-cjs/drawer/Drawer.css.js +0 -6
  39. package/dist-cjs/drawer/Drawer.css.js.map +0 -1
  40. package/dist-cjs/drawer/Drawer.js +0 -82
  41. package/dist-cjs/drawer/Drawer.js.map +0 -1
  42. package/dist-cjs/drawer/useDrawer.js +0 -36
  43. package/dist-cjs/drawer/useDrawer.js.map +0 -1
  44. package/dist-es/drawer/Drawer.css.js +0 -4
  45. package/dist-es/drawer/Drawer.css.js.map +0 -1
  46. package/dist-es/drawer/Drawer.js +0 -77
  47. package/dist-es/drawer/Drawer.js.map +0 -1
  48. package/dist-es/drawer/useDrawer.js +0 -32
  49. package/dist-es/drawer/useDrawer.js.map +0 -1
  50. package/dist-types/drawer/Drawer.d.ts +0 -22
  51. package/dist-types/drawer/index.d.ts +0 -2
  52. package/dist-types/drawer/useDrawer.d.ts +0 -27
@@ -1,5 +1,35 @@
1
- import type { Middleware, Placement, Strategy } from "@floating-ui/react";
1
+ import type { Middleware, Placement, Platform, Strategy } from "@floating-ui/react";
2
2
  import { useFloating } from "@floating-ui/react";
3
+ import { ReactNode, ForwardRefExoticComponent, RefAttributes } from "react";
4
+ export declare type FloatingComponentProps = {
5
+ /**
6
+ * Whether the floating component is disabled (used for determinig whether to show the component)
7
+ */
8
+ disabled?: boolean;
9
+ /**
10
+ * Whether the floating component is open (used for determinig whether to show the component)
11
+ * We pass this as a prop rather than not rendering the component to allow more advanced use-cases e.g.
12
+ * for caching windows and reusing them, rather than always spawning a new one
13
+ */
14
+ open: boolean;
15
+ /**
16
+ * Position props for the floating component
17
+ */
18
+ top: number;
19
+ left: number;
20
+ position: Strategy;
21
+ };
22
+ declare const DefaultFloatingComponent: ForwardRefExoticComponent<FloatingComponentProps & {
23
+ children?: ReactNode;
24
+ } & RefAttributes<HTMLElement>>;
25
+ export interface FloatingComponentContextType {
26
+ Component: typeof DefaultFloatingComponent;
27
+ }
28
+ export interface FloatingComponentProviderProps extends FloatingComponentContextType {
29
+ children: ReactNode;
30
+ }
31
+ export declare function FloatingComponentProvider(props: FloatingComponentProviderProps): JSX.Element;
32
+ export declare function useFloatingComponent(): FloatingComponentContextType;
3
33
  export declare type UseFloatingUIProps = {
4
34
  /**
5
35
  * Sets position relative to trigger.
@@ -16,6 +46,19 @@ export declare type UseFloatingUIProps = {
16
46
  */
17
47
  onOpenChange?: (open: boolean) => void;
18
48
  };
49
+ declare type FloatingPlatformContextType = {
50
+ platform: Platform;
51
+ middleware: Middleware[];
52
+ animationFrame: boolean;
53
+ };
54
+ export interface FloatingPlatformProviderProps {
55
+ platform?: Platform;
56
+ middleware?: Middleware[];
57
+ children: ReactNode;
58
+ animationFrame?: boolean;
59
+ }
60
+ export declare function FloatingPlatformProvider(props: FloatingPlatformProviderProps): JSX.Element;
61
+ export declare function useFloatingPlatform(): FloatingPlatformContextType;
19
62
  export declare const DEFAULT_FLOATING_UI_MIDDLEWARE: {
20
63
  name: string;
21
64
  options?: any;
@@ -32,3 +75,4 @@ export declare const DEFAULT_FLOATING_UI_MIDDLEWARE: {
32
75
  }) => import("@floating-ui/react").MiddlewareReturn | Promise<import("@floating-ui/react").MiddlewareReturn>;
33
76
  }[];
34
77
  export declare function useFloatingUI(props: UseFloatingUIProps): ReturnType<typeof useFloating>;
78
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salt-ds/core",
3
- "version": "0.0.0-snapshot-20230802154358",
3
+ "version": "0.0.0-snapshot-20230811150341",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist-cjs/index.js",
6
6
  "sideEffects": false,
@@ -25,7 +25,7 @@
25
25
  "@floating-ui/react": "^0.23.0",
26
26
  "@salt-ds/window": "^0.1.1",
27
27
  "@salt-ds/styles": "^0.1.1",
28
- "@salt-ds/icons": "^0.0.0-snapshot-20230802154358"
28
+ "@salt-ds/icons": "^1.6.0"
29
29
  },
30
30
  "files": [
31
31
  "dist-cjs",
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var css_248z = "/* Styles applied to Drawer component */\n.saltDrawer {\n background: var(--drawer-background);\n display: flex;\n flex-direction: column;\n max-height: 100%;\n max-width: 100%;\n overflow: auto;\n padding: var(--salt-spacing-300);\n box-shadow: var(--salt-overlayable-shadow-modal);\n z-index: calc(var(--salt-zIndex-appHeader) - 1);\n position: fixed;\n top: 0;\n}\n\n.saltDrawer-overlay {\n background: var(--salt-overlayable-background);\n z-index: var(--salt-zIndex-drawer);\n}\n\n/* Styles applied when variant = \"primary\" */\n.saltDrawer-primary {\n --drawer-background: var(--salt-container-primary-background);\n}\n\n/* Styles applied when variant = \"secondary\" */\n.saltDrawer-secondary {\n --drawer-background: var(--salt-container-secondary-background);\n}\n\n/* Styles applied when position = \"top\" */\n.saltDrawer-top {\n left: 0;\n right: 0;\n bottom: auto;\n}\n\n/* Styles applied when position = \"top\" and the component mounts */\n.saltDrawer-top.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-bottom);\n}\n\n/* Styles applied when position = \"top\" and the component unmounts */\n.saltDrawer-top.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-bottom);\n}\n\n/* Styles applied when position = \"right\" or position = \"left\" */\n.saltDrawer-right,\n.saltDrawer-left {\n width: calc(10 * var(--salt-size-base));\n}\n\n/* Styles applied when position = \"right\" */\n.saltDrawer-right {\n left: auto;\n right: 0;\n height: 100%;\n}\n\n/* Styles applied when position = \"right\" and the component mounts */\n.saltDrawer-right.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-right);\n}\n\n/* Styles applied when position = \"right\" and the component unmounts */\n.saltDrawer-right.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-right);\n}\n\n/* Styles applied when position = \"left\" */\n.saltDrawer-left {\n left: 0;\n right: auto;\n height: 100%;\n}\n\n/* Styles applied when position = \"left\" and the component mounts */\n.saltDrawer-left.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-left);\n}\n\n/* Styles applied when position = \"left\" and the component unmounts */\n.saltDrawer-left.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-left);\n}\n\n/* Styles applied when position = \"bottom\" */\n.saltDrawer-bottom {\n left: 0;\n right: 0;\n bottom: 0;\n top: auto;\n}\n\n/* Styles applied when position = \"bottom\" and the component mounts */\n.saltDrawer-bottom.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-top);\n}\n\n/* Styles applied when position = \"bottom\" and the component unmounts */\n.saltDrawer-bottom.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-top);\n}\n";
4
-
5
- module.exports = css_248z;
6
- //# sourceMappingURL=Drawer.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawer.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var jsxRuntime = require('react/jsx-runtime');
6
- var React = require('react');
7
- var clsx = require('clsx');
8
- var react = require('@floating-ui/react');
9
- var makePrefixer = require('../utils/makePrefixer.js');
10
- require('../utils/useFloatingUI.js');
11
- var useForkRef = require('../utils/useForkRef.js');
12
- require('../utils/useId.js');
13
- require('../salt-provider/SaltProvider.js');
14
- require('../viewport/ViewportProvider.js');
15
- var window = require('@salt-ds/window');
16
- var styles = require('@salt-ds/styles');
17
- var useDrawer = require('./useDrawer.js');
18
- var Drawer$1 = require('./Drawer.css.js');
19
-
20
- const DRAWER_POSITIONS = ["left", "top", "right", "bottom"];
21
- const withBaseName = makePrefixer.makePrefixer("saltDrawer");
22
- const Drawer = React.forwardRef(function Drawer2(props, ref) {
23
- const {
24
- children,
25
- className,
26
- position = "left",
27
- open = true,
28
- onOpenChange,
29
- variant = "primary",
30
- ...rest
31
- } = props;
32
- const targetWindow = window.useWindow();
33
- styles.useComponentCssInjection({
34
- testId: "salt-drawer",
35
- css: Drawer$1,
36
- window: targetWindow
37
- });
38
- const [showComponent, setShowComponent] = React.useState(false);
39
- const { floating, context } = useDrawer.useDrawer({
40
- open,
41
- onOpenChange
42
- });
43
- const floatingRef = useForkRef.useForkRef(floating, ref);
44
- React.useEffect(() => {
45
- if (open && !showComponent) {
46
- setShowComponent(true);
47
- }
48
- }, [open, showComponent]);
49
- return /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, {
50
- children: showComponent && /* @__PURE__ */ jsxRuntime.jsx(react.FloatingOverlay, {
51
- className: withBaseName("overlay"),
52
- lockScroll: true,
53
- children: /* @__PURE__ */ jsxRuntime.jsx(react.FloatingFocusManager, {
54
- context,
55
- children: /* @__PURE__ */ jsxRuntime.jsx("div", {
56
- ref: floatingRef,
57
- className: clsx.clsx(
58
- withBaseName(),
59
- withBaseName(position),
60
- {
61
- [withBaseName("enterAnimation")]: open,
62
- [withBaseName("exitAnimation")]: !open,
63
- [withBaseName(variant)]: variant
64
- },
65
- className
66
- ),
67
- onAnimationEnd: () => {
68
- if (!open && showComponent) {
69
- setShowComponent(false);
70
- }
71
- },
72
- ...rest,
73
- children
74
- })
75
- })
76
- })
77
- });
78
- });
79
-
80
- exports.DRAWER_POSITIONS = DRAWER_POSITIONS;
81
- exports.Drawer = Drawer;
82
- //# sourceMappingURL=Drawer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawer.js","sources":["../src/drawer/Drawer.tsx"],"sourcesContent":["import { forwardRef, HTMLAttributes, useEffect, useState } from \"react\";\nimport { clsx } from \"clsx\";\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n} from \"@floating-ui/react\";\nimport { makePrefixer, useForkRef } from \"../utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useDrawer } from \"./useDrawer\";\n\nimport drawerCss from \"./Drawer.css\";\n\nexport const DRAWER_POSITIONS = [\"left\", \"top\", \"right\", \"bottom\"] as const;\n\nexport type DrawerPositions = typeof DRAWER_POSITIONS[number];\n\nexport interface DrawerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Defines the drawer position within the screen.\n */\n position?: DrawerPositions;\n /**\n * Display or hide the component.\n */\n open?: boolean;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Change background color palette\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nconst withBaseName = makePrefixer(\"saltDrawer\");\n\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n props,\n ref\n) {\n const {\n children,\n className,\n position = \"left\",\n open = true,\n onOpenChange,\n variant = \"primary\",\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-drawer\",\n css: drawerCss,\n window: targetWindow,\n });\n\n const [showComponent, setShowComponent] = useState(false);\n\n const { floating, context } = useDrawer({\n open,\n onOpenChange,\n });\n\n const floatingRef = useForkRef<HTMLDivElement>(floating, ref);\n\n useEffect(() => {\n if (open && !showComponent) {\n setShowComponent(true);\n }\n }, [open, showComponent]);\n\n return (\n <FloatingPortal>\n {showComponent && (\n <FloatingOverlay className={withBaseName(\"overlay\")} lockScroll>\n <FloatingFocusManager context={context}>\n <div\n ref={floatingRef}\n className={clsx(\n withBaseName(),\n withBaseName(position),\n {\n [withBaseName(\"enterAnimation\")]: open,\n [withBaseName(\"exitAnimation\")]: !open,\n [withBaseName(variant)]: variant,\n },\n className\n )}\n onAnimationEnd={() => {\n if (!open && showComponent) {\n setShowComponent(false);\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </FloatingOverlay>\n )}\n </FloatingPortal>\n );\n});\n"],"names":["makePrefixer","forwardRef","Drawer","useWindow","useComponentCssInjection","drawerCss","useState","useDrawer","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AA,CAAAE,qBAAA,EAAA;AAAA,MAAgB,SAAA,EAAW,aAAa,SAAS,CAAA;AAAA,MAAG,UAAU,EAAA,IAAA;AAAA,MAC7D,QAAC,kBAAAF,cAAA,CAAAG,0BAAA,EAAA;AAAA,QAAqB,OAAA;AAAA,QACpB,QAAC,kBAAAH,cAAA,CAAA,KAAA,EAAA;AAAA,UACC,GAAK,EAAA,WAAA;AAAA,UACL,SAAW,EAAAI,SAAA;AAAA,YACT,YAAa,EAAA;AAAA,YACb,aAAa,QAAQ,CAAA;AAAA,YACrB;AAAA,cACE,CAAC,YAAa,CAAA,gBAAgB,CAAI,GAAA,IAAA;AAAA,cAClC,CAAC,YAAA,CAAa,eAAe,CAAA,GAAI,CAAC,IAAA;AAAA,cAClC,CAAC,YAAa,CAAA,OAAO,CAAI,GAAA,OAAA;AAAA,aAC3B;AAAA,YACA,SAAA;AAAA,WACF;AAAA,UACA,gBAAgB,MAAM;AACpB,YAAI,IAAA,CAAC,QAAQ,aAAe,EAAA;AAC1B,cAAA,gBAAA,CAAiB,KAAK,CAAA,CAAA;AAAA,aACxB;AAAA,WACF;AAAA,UACC,GAAG,IAAA;AAAA,UAEH,QAAA;AAAA,SACH,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ,CAAC;;;;;"}
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var react = require('@floating-ui/react');
6
- require('react');
7
- var useFloatingUI = require('../utils/useFloatingUI.js');
8
- require('../utils/useId.js');
9
- require('../salt-provider/SaltProvider.js');
10
- require('../viewport/ViewportProvider.js');
11
- require('clsx');
12
-
13
- function useDrawer(props) {
14
- const { open, onOpenChange } = props;
15
- const { context, floating } = useFloatingUI.useFloatingUI({
16
- open,
17
- onOpenChange
18
- });
19
- const click = react.useClick(context);
20
- const role = react.useRole(context);
21
- const dismiss = react.useDismiss(context);
22
- const { getFloatingProps, getReferenceProps } = react.useInteractions([
23
- role,
24
- dismiss,
25
- click
26
- ]);
27
- return {
28
- getFloatingProps,
29
- getReferenceProps,
30
- floating,
31
- context
32
- };
33
- }
34
-
35
- exports.useDrawer = useDrawer;
36
- //# sourceMappingURL=useDrawer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDrawer.js","sources":["../src/drawer/useDrawer.ts"],"sourcesContent":["import {\n useClick,\n useDismiss,\n useInteractions,\n useRole,\n} from \"@floating-ui/react\";\nimport { useFloatingUI, UseFloatingUIProps } from \"../utils\";\n\nexport type UseDrawerProps = Partial<\n Pick<UseFloatingUIProps, \"onOpenChange\" | \"open\">\n>;\n\nexport function useDrawer(props: UseDrawerProps) {\n const { open, onOpenChange } = props;\n\n const { context, floating } = useFloatingUI({\n open,\n onOpenChange,\n });\n\n const click = useClick(context);\n const role = useRole(context);\n const dismiss = useDismiss(context);\n\n const { getFloatingProps, getReferenceProps } = useInteractions([\n role,\n dismiss,\n click,\n ]);\n\n return {\n getFloatingProps,\n getReferenceProps,\n floating,\n context,\n };\n}\n"],"names":["useFloatingUI","useClick","useRole","useDismiss","useInteractions"],"mappings":";;;;;;;;;;;;AAYO,SAAS,UAAU,KAAuB,EAAA;AAC/C,EAAM,MAAA,EAAE,IAAM,EAAA,YAAA,EAAiB,GAAA,KAAA,CAAA;AAE/B,EAAA,MAAM,EAAE,OAAA,EAAS,QAAS,EAAA,GAAIA,2BAAc,CAAA;AAAA,IAC1C,IAAA;AAAA,IACA,YAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAM,MAAA,KAAA,GAAQC,eAAS,OAAO,CAAA,CAAA;AAC9B,EAAM,MAAA,IAAA,GAAOC,cAAQ,OAAO,CAAA,CAAA;AAC5B,EAAM,MAAA,OAAA,GAAUC,iBAAW,OAAO,CAAA,CAAA;AAElC,EAAA,MAAM,EAAE,gBAAA,EAAkB,iBAAkB,EAAA,GAAIC,qBAAgB,CAAA;AAAA,IAC9D,IAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL,gBAAA;AAAA,IACA,iBAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,4 +0,0 @@
1
- var css_248z = "/* Styles applied to Drawer component */\n.saltDrawer {\n background: var(--drawer-background);\n display: flex;\n flex-direction: column;\n max-height: 100%;\n max-width: 100%;\n overflow: auto;\n padding: var(--salt-spacing-300);\n box-shadow: var(--salt-overlayable-shadow-modal);\n z-index: calc(var(--salt-zIndex-appHeader) - 1);\n position: fixed;\n top: 0;\n}\n\n.saltDrawer-overlay {\n background: var(--salt-overlayable-background);\n z-index: var(--salt-zIndex-drawer);\n}\n\n/* Styles applied when variant = \"primary\" */\n.saltDrawer-primary {\n --drawer-background: var(--salt-container-primary-background);\n}\n\n/* Styles applied when variant = \"secondary\" */\n.saltDrawer-secondary {\n --drawer-background: var(--salt-container-secondary-background);\n}\n\n/* Styles applied when position = \"top\" */\n.saltDrawer-top {\n left: 0;\n right: 0;\n bottom: auto;\n}\n\n/* Styles applied when position = \"top\" and the component mounts */\n.saltDrawer-top.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-bottom);\n}\n\n/* Styles applied when position = \"top\" and the component unmounts */\n.saltDrawer-top.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-bottom);\n}\n\n/* Styles applied when position = \"right\" or position = \"left\" */\n.saltDrawer-right,\n.saltDrawer-left {\n width: calc(10 * var(--salt-size-base));\n}\n\n/* Styles applied when position = \"right\" */\n.saltDrawer-right {\n left: auto;\n right: 0;\n height: 100%;\n}\n\n/* Styles applied when position = \"right\" and the component mounts */\n.saltDrawer-right.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-right);\n}\n\n/* Styles applied when position = \"right\" and the component unmounts */\n.saltDrawer-right.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-right);\n}\n\n/* Styles applied when position = \"left\" */\n.saltDrawer-left {\n left: 0;\n right: auto;\n height: 100%;\n}\n\n/* Styles applied when position = \"left\" and the component mounts */\n.saltDrawer-left.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-left);\n}\n\n/* Styles applied when position = \"left\" and the component unmounts */\n.saltDrawer-left.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-left);\n}\n\n/* Styles applied when position = \"bottom\" */\n.saltDrawer-bottom {\n left: 0;\n right: 0;\n bottom: 0;\n top: auto;\n}\n\n/* Styles applied when position = \"bottom\" and the component mounts */\n.saltDrawer-bottom.saltDrawer-enterAnimation {\n animation: var(--salt-animation-slide-in-top);\n}\n\n/* Styles applied when position = \"bottom\" and the component unmounts */\n.saltDrawer-bottom.saltDrawer-exitAnimation {\n animation: var(--salt-animation-slide-out-top);\n}\n";
2
-
3
- export { css_248z as default };
4
- //# sourceMappingURL=Drawer.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawer.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,77 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useEffect } from 'react';
3
- import { clsx } from 'clsx';
4
- import { FloatingPortal, FloatingOverlay, FloatingFocusManager } from '@floating-ui/react';
5
- import { makePrefixer } from '../utils/makePrefixer.js';
6
- import '../utils/useFloatingUI.js';
7
- import { useForkRef } from '../utils/useForkRef.js';
8
- import '../utils/useId.js';
9
- import '../salt-provider/SaltProvider.js';
10
- import '../viewport/ViewportProvider.js';
11
- import { useWindow } from '@salt-ds/window';
12
- import { useComponentCssInjection } from '@salt-ds/styles';
13
- import { useDrawer } from './useDrawer.js';
14
- import css_248z from './Drawer.css.js';
15
-
16
- const DRAWER_POSITIONS = ["left", "top", "right", "bottom"];
17
- const withBaseName = makePrefixer("saltDrawer");
18
- const Drawer = forwardRef(function Drawer2(props, ref) {
19
- const {
20
- children,
21
- className,
22
- position = "left",
23
- open = true,
24
- onOpenChange,
25
- variant = "primary",
26
- ...rest
27
- } = props;
28
- const targetWindow = useWindow();
29
- useComponentCssInjection({
30
- testId: "salt-drawer",
31
- css: css_248z,
32
- window: targetWindow
33
- });
34
- const [showComponent, setShowComponent] = useState(false);
35
- const { floating, context } = useDrawer({
36
- open,
37
- onOpenChange
38
- });
39
- const floatingRef = useForkRef(floating, ref);
40
- useEffect(() => {
41
- if (open && !showComponent) {
42
- setShowComponent(true);
43
- }
44
- }, [open, showComponent]);
45
- return /* @__PURE__ */ jsx(FloatingPortal, {
46
- children: showComponent && /* @__PURE__ */ jsx(FloatingOverlay, {
47
- className: withBaseName("overlay"),
48
- lockScroll: true,
49
- children: /* @__PURE__ */ jsx(FloatingFocusManager, {
50
- context,
51
- children: /* @__PURE__ */ jsx("div", {
52
- ref: floatingRef,
53
- className: clsx(
54
- withBaseName(),
55
- withBaseName(position),
56
- {
57
- [withBaseName("enterAnimation")]: open,
58
- [withBaseName("exitAnimation")]: !open,
59
- [withBaseName(variant)]: variant
60
- },
61
- className
62
- ),
63
- onAnimationEnd: () => {
64
- if (!open && showComponent) {
65
- setShowComponent(false);
66
- }
67
- },
68
- ...rest,
69
- children
70
- })
71
- })
72
- })
73
- });
74
- });
75
-
76
- export { DRAWER_POSITIONS, Drawer };
77
- //# sourceMappingURL=Drawer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Drawer.js","sources":["../src/drawer/Drawer.tsx"],"sourcesContent":["import { forwardRef, HTMLAttributes, useEffect, useState } from \"react\";\nimport { clsx } from \"clsx\";\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n} from \"@floating-ui/react\";\nimport { makePrefixer, useForkRef } from \"../utils\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useDrawer } from \"./useDrawer\";\n\nimport drawerCss from \"./Drawer.css\";\n\nexport const DRAWER_POSITIONS = [\"left\", \"top\", \"right\", \"bottom\"] as const;\n\nexport type DrawerPositions = typeof DRAWER_POSITIONS[number];\n\nexport interface DrawerProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Defines the drawer position within the screen.\n */\n position?: DrawerPositions;\n /**\n * Display or hide the component.\n */\n open?: boolean;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Change background color palette\n */\n variant?: \"primary\" | \"secondary\";\n}\n\nconst withBaseName = makePrefixer(\"saltDrawer\");\n\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n props,\n ref\n) {\n const {\n children,\n className,\n position = \"left\",\n open = true,\n onOpenChange,\n variant = \"primary\",\n ...rest\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-drawer\",\n css: drawerCss,\n window: targetWindow,\n });\n\n const [showComponent, setShowComponent] = useState(false);\n\n const { floating, context } = useDrawer({\n open,\n onOpenChange,\n });\n\n const floatingRef = useForkRef<HTMLDivElement>(floating, ref);\n\n useEffect(() => {\n if (open && !showComponent) {\n setShowComponent(true);\n }\n }, [open, showComponent]);\n\n return (\n <FloatingPortal>\n {showComponent && (\n <FloatingOverlay className={withBaseName(\"overlay\")} lockScroll>\n <FloatingFocusManager context={context}>\n <div\n ref={floatingRef}\n className={clsx(\n withBaseName(),\n withBaseName(position),\n {\n [withBaseName(\"enterAnimation\")]: open,\n [withBaseName(\"exitAnimation\")]: !open,\n [withBaseName(variant)]: variant,\n },\n className\n )}\n onAnimationEnd={() => {\n if (!open && showComponent) {\n setShowComponent(false);\n }\n }}\n {...rest}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </FloatingOverlay>\n )}\n </FloatingPortal>\n );\n});\n"],"names":["Drawer","drawerCss"],"mappings":";;;;;;;;;;;;;;;AAcO,MAAM,gBAAmB,GAAA,CAAC,MAAQ,EAAA,KAAA,EAAO,SAAS,QAAQ,EAAA;AAuBjE,MAAM,YAAA,GAAe,aAAa,YAAY,CAAA,CAAA;AAEvC,MAAM,MAAS,GA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,SAAW,EAAA,IAAA;AAAA,YACT,YAAa,EAAA;AAAA,YACb,aAAa,QAAQ,CAAA;AAAA,YACrB;AAAA,cACE,CAAC,YAAa,CAAA,gBAAgB,CAAI,GAAA,IAAA;AAAA,cAClC,CAAC,YAAA,CAAa,eAAe,CAAA,GAAI,CAAC,IAAA;AAAA,cAClC,CAAC,YAAa,CAAA,OAAO,CAAI,GAAA,OAAA;AAAA,aAC3B;AAAA,YACA,SAAA;AAAA,WACF;AAAA,UACA,gBAAgB,MAAM;AACpB,YAAI,IAAA,CAAC,QAAQ,aAAe,EAAA;AAC1B,cAAA,gBAAA,CAAiB,KAAK,CAAA,CAAA;AAAA,aACxB;AAAA,WACF;AAAA,UACC,GAAG,IAAA;AAAA,UAEH,QAAA;AAAA,SACH,CAAA;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ,CAAC;;;;"}
@@ -1,32 +0,0 @@
1
- import { useClick, useRole, useDismiss, useInteractions } from '@floating-ui/react';
2
- import 'react';
3
- import { useFloatingUI } from '../utils/useFloatingUI.js';
4
- import '../utils/useId.js';
5
- import '../salt-provider/SaltProvider.js';
6
- import '../viewport/ViewportProvider.js';
7
- import 'clsx';
8
-
9
- function useDrawer(props) {
10
- const { open, onOpenChange } = props;
11
- const { context, floating } = useFloatingUI({
12
- open,
13
- onOpenChange
14
- });
15
- const click = useClick(context);
16
- const role = useRole(context);
17
- const dismiss = useDismiss(context);
18
- const { getFloatingProps, getReferenceProps } = useInteractions([
19
- role,
20
- dismiss,
21
- click
22
- ]);
23
- return {
24
- getFloatingProps,
25
- getReferenceProps,
26
- floating,
27
- context
28
- };
29
- }
30
-
31
- export { useDrawer };
32
- //# sourceMappingURL=useDrawer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useDrawer.js","sources":["../src/drawer/useDrawer.ts"],"sourcesContent":["import {\n useClick,\n useDismiss,\n useInteractions,\n useRole,\n} from \"@floating-ui/react\";\nimport { useFloatingUI, UseFloatingUIProps } from \"../utils\";\n\nexport type UseDrawerProps = Partial<\n Pick<UseFloatingUIProps, \"onOpenChange\" | \"open\">\n>;\n\nexport function useDrawer(props: UseDrawerProps) {\n const { open, onOpenChange } = props;\n\n const { context, floating } = useFloatingUI({\n open,\n onOpenChange,\n });\n\n const click = useClick(context);\n const role = useRole(context);\n const dismiss = useDismiss(context);\n\n const { getFloatingProps, getReferenceProps } = useInteractions([\n role,\n dismiss,\n click,\n ]);\n\n return {\n getFloatingProps,\n getReferenceProps,\n floating,\n context,\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAYO,SAAS,UAAU,KAAuB,EAAA;AAC/C,EAAM,MAAA,EAAE,IAAM,EAAA,YAAA,EAAiB,GAAA,KAAA,CAAA;AAE/B,EAAA,MAAM,EAAE,OAAA,EAAS,QAAS,EAAA,GAAI,aAAc,CAAA;AAAA,IAC1C,IAAA;AAAA,IACA,YAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAM,MAAA,KAAA,GAAQ,SAAS,OAAO,CAAA,CAAA;AAC9B,EAAM,MAAA,IAAA,GAAO,QAAQ,OAAO,CAAA,CAAA;AAC5B,EAAM,MAAA,OAAA,GAAU,WAAW,OAAO,CAAA,CAAA;AAElC,EAAA,MAAM,EAAE,gBAAA,EAAkB,iBAAkB,EAAA,GAAI,eAAgB,CAAA;AAAA,IAC9D,IAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAO,OAAA;AAAA,IACL,gBAAA;AAAA,IACA,iBAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,22 +0,0 @@
1
- import { HTMLAttributes } from "react";
2
- export declare const DRAWER_POSITIONS: readonly ["left", "top", "right", "bottom"];
3
- export declare type DrawerPositions = typeof DRAWER_POSITIONS[number];
4
- export interface DrawerProps extends HTMLAttributes<HTMLDivElement> {
5
- /**
6
- * Defines the drawer position within the screen.
7
- */
8
- position?: DrawerPositions;
9
- /**
10
- * Display or hide the component.
11
- */
12
- open?: boolean;
13
- /**
14
- * Callback function triggered when open state changes.
15
- */
16
- onOpenChange?: (open: boolean) => void;
17
- /**
18
- * Change background color palette
19
- */
20
- variant?: "primary" | "secondary";
21
- }
22
- export declare const Drawer: import("react").ForwardRefExoticComponent<DrawerProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,2 +0,0 @@
1
- export * from "./Drawer";
2
- export * from "./useDrawer";
@@ -1,27 +0,0 @@
1
- /// <reference types="react" />
2
- import { UseFloatingUIProps } from "../utils";
3
- export declare type UseDrawerProps = Partial<Pick<UseFloatingUIProps, "onOpenChange" | "open">>;
4
- export declare function useDrawer(props: UseDrawerProps): {
5
- getFloatingProps: (userProps?: import("react").HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
6
- getReferenceProps: (userProps?: import("react").HTMLProps<Element> | undefined) => Record<string, unknown>;
7
- floating: (node: HTMLElement | null) => void;
8
- context: {
9
- x: number | null;
10
- y: number | null;
11
- placement: import("@floating-ui/react").Placement;
12
- strategy: import("@floating-ui/react").Strategy;
13
- middlewareData: import("@floating-ui/react").MiddlewareData;
14
- update: () => void;
15
- reference: (node: import("@floating-ui/react").ReferenceType | null) => void;
16
- floating: (node: HTMLElement | null) => void;
17
- isPositioned: boolean;
18
- open: boolean;
19
- onOpenChange: (open: boolean) => void;
20
- events: import("@floating-ui/react").FloatingEvents;
21
- dataRef: import("react").MutableRefObject<import("@floating-ui/react").ContextData>;
22
- nodeId: string | undefined;
23
- floatingId: string;
24
- refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
25
- elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
26
- };
27
- };