@salt-ds/lab 1.0.0-alpha.31 → 1.0.0-alpha.32
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.
- package/css/salt-lab.css +27 -18
- package/dist-cjs/app-header/AppHeader.css.js +1 -1
- package/dist-cjs/combo-box-next/ComboBoxNext.js +54 -57
- package/dist-cjs/combo-box-next/ComboBoxNext.js.map +1 -1
- package/dist-cjs/combo-box-next/useComboBoxNext.js +21 -9
- package/dist-cjs/combo-box-next/useComboBoxNext.js.map +1 -1
- package/dist-cjs/dialog/Dialog.js +28 -11
- package/dist-cjs/dialog/Dialog.js.map +1 -1
- package/dist-cjs/dialog/DialogContent.css.js +1 -1
- package/dist-cjs/dialog/DialogContext.js +2 -1
- package/dist-cjs/dialog/DialogContext.js.map +1 -1
- package/dist-cjs/dialog/DialogTitle.css.js +1 -1
- package/dist-cjs/dialog/DialogTitle.js +18 -4
- package/dist-cjs/dialog/DialogTitle.js.map +1 -1
- package/dist-cjs/drawer/Drawer.css.js +1 -1
- package/dist-cjs/drawer/Drawer.js +61 -36
- package/dist-cjs/drawer/Drawer.js.map +1 -1
- package/dist-cjs/drawer/DrawerCloseButton.css.js +6 -0
- package/dist-cjs/drawer/DrawerCloseButton.css.js.map +1 -0
- package/dist-cjs/drawer/DrawerCloseButton.js +44 -0
- package/dist-cjs/drawer/DrawerCloseButton.js.map +1 -0
- package/dist-cjs/dropdown-next/DropdownNext.js +49 -58
- package/dist-cjs/dropdown-next/DropdownNext.js.map +1 -1
- package/dist-cjs/index.js +3 -3
- package/dist-cjs/list-control/ListControlContext.js.map +1 -1
- package/dist-cjs/list-control/ListControlState.js +21 -20
- package/dist-cjs/list-control/ListControlState.js.map +1 -1
- package/dist-cjs/option/Option.js +0 -4
- package/dist-cjs/option/Option.js.map +1 -1
- package/dist-cjs/option/OptionList.css.js +1 -1
- package/dist-cjs/tabs-next/TabNext.css.js +1 -1
- package/dist-cjs/tabs-next/TabstripNext.css.js +1 -1
- package/dist-es/app-header/AppHeader.css.js +1 -1
- package/dist-es/combo-box-next/ComboBoxNext.js +55 -58
- package/dist-es/combo-box-next/ComboBoxNext.js.map +1 -1
- package/dist-es/combo-box-next/useComboBoxNext.js +21 -9
- package/dist-es/combo-box-next/useComboBoxNext.js.map +1 -1
- package/dist-es/dialog/Dialog.js +30 -14
- package/dist-es/dialog/Dialog.js.map +1 -1
- package/dist-es/dialog/DialogContent.css.js +1 -1
- package/dist-es/dialog/DialogContext.js +2 -1
- package/dist-es/dialog/DialogContext.js.map +1 -1
- package/dist-es/dialog/DialogTitle.css.js +1 -1
- package/dist-es/dialog/DialogTitle.js +19 -5
- package/dist-es/dialog/DialogTitle.js.map +1 -1
- package/dist-es/drawer/Drawer.css.js +1 -1
- package/dist-es/drawer/Drawer.js +65 -39
- package/dist-es/drawer/Drawer.js.map +1 -1
- package/dist-es/drawer/DrawerCloseButton.css.js +4 -0
- package/dist-es/drawer/DrawerCloseButton.css.js.map +1 -0
- package/dist-es/drawer/DrawerCloseButton.js +36 -0
- package/dist-es/drawer/DrawerCloseButton.js.map +1 -0
- package/dist-es/dropdown-next/DropdownNext.js +50 -59
- package/dist-es/dropdown-next/DropdownNext.js.map +1 -1
- package/dist-es/index.js +3 -3
- package/dist-es/list-control/ListControlContext.js.map +1 -1
- package/dist-es/list-control/ListControlState.js +21 -20
- package/dist-es/list-control/ListControlState.js.map +1 -1
- package/dist-es/option/Option.js +0 -4
- package/dist-es/option/Option.js.map +1 -1
- package/dist-es/option/OptionList.css.js +1 -1
- package/dist-es/tabs-next/TabNext.css.js +1 -1
- package/dist-es/tabs-next/TabstripNext.css.js +1 -1
- package/dist-types/combo-box-next/ComboBoxNext.d.ts +8 -0
- package/dist-types/combo-box-next/useComboBoxNext.d.ts +2 -5
- package/dist-types/dialog/Dialog.d.ts +16 -1
- package/dist-types/dialog/DialogContext.d.ts +2 -0
- package/dist-types/dialog/DialogTitle.d.ts +14 -6
- package/dist-types/drawer/Drawer.d.ts +13 -7
- package/dist-types/drawer/DrawerCloseButton.d.ts +2 -0
- package/dist-types/drawer/index.d.ts +1 -1
- package/dist-types/dropdown-next/DropdownNext.d.ts +8 -0
- package/dist-types/list-control/ListControlContext.d.ts +2 -1
- package/dist-types/list-control/ListControlState.d.ts +6 -6
- package/package.json +2 -2
- package/dist-cjs/drawer/useDrawer.js +0 -31
- package/dist-cjs/drawer/useDrawer.js.map +0 -1
- package/dist-es/drawer/useDrawer.js +0 -27
- package/dist-es/drawer/useDrawer.js.map +0 -1
- package/dist-types/drawer/useDrawer.d.ts +0 -25
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltDialogContent {\n color: var(--salt-content-primary-foreground);\n min-height: var(--salt-text-lineHeight);\n overflow-y: auto;\n background: var(--salt-container-primary-background);\n padding-bottom: var(--salt-spacing-50);\n\n margin-left: var(--salt-spacing-
|
|
3
|
+
var css_248z = ".saltDialogContent {\n color: var(--salt-content-primary-foreground);\n min-height: var(--salt-text-lineHeight);\n overflow-y: auto;\n background: var(--salt-container-primary-background);\n padding-bottom: var(--salt-spacing-50);\n\n margin-left: var(--salt-spacing-200);\n margin-right: var(--salt-spacing-300);\n padding-right: var(--salt-spacing-300);\n padding-left: var(--salt-spacing-100);\n border-bottom: var(--salt-size-border) var(--salt-separable-borderStyle) transparent;\n box-shadow: none;\n}\n\n.saltDialogContent-scroll {\n border-bottom: var(--salt-size-border) var(--salt-separable-borderStyle) var(--salt-separable-tertiary-borderColor);\n box-shadow: var(--salt-overlayable-shadow-scroll);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=DialogContent.css.js.map
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
|
|
7
7
|
const DialogContext = React.createContext({
|
|
8
|
-
status: void 0
|
|
8
|
+
status: void 0,
|
|
9
|
+
id: ""
|
|
9
10
|
});
|
|
10
11
|
const useDialogContext = () => {
|
|
11
12
|
return React.useContext(DialogContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogContext.js","sources":["../src/dialog/DialogContext.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { ValidationStatus } from \"@salt-ds/core\";\n\nexport const DialogContext = createContext<{\n status?: ValidationStatus;\n}>({\n status: undefined,\n});\n\nexport const useDialogContext = () => {\n return useContext(DialogContext);\n};\n"],"names":["createContext","useContext"],"mappings":";;;;;;AAGO,MAAM,gBAAgBA,
|
|
1
|
+
{"version":3,"file":"DialogContext.js","sources":["../src/dialog/DialogContext.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport { ValidationStatus } from \"@salt-ds/core\";\n\nexport const DialogContext = createContext<{\n status?: ValidationStatus;\n id: string | undefined;\n}>({\n status: undefined,\n id: \"\",\n});\n\nexport const useDialogContext = () => {\n return useContext(DialogContext);\n};\n"],"names":["createContext","useContext"],"mappings":";;;;;;AAGO,MAAM,gBAAgBA,mBAG1B,CAAA;AAAA,EACD,MAAQ,EAAA,KAAA,CAAA;AAAA,EACR,EAAI,EAAA,EAAA;AACN,CAAC,EAAA;AAEM,MAAM,mBAAmB,MAAM;AACpC,EAAA,OAAOC,iBAAW,aAAa,CAAA,CAAA;AACjC;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = "/* Styles applied to the root element */\n.saltDialogTitle {\n
|
|
3
|
+
var css_248z = "/* Styles applied to the root element */\n.saltDialogTitle {\n padding-bottom: var(--salt-spacing-100);\n padding-left: var(--salt-spacing-300);\n padding-right: var(--salt-spacing-300);\n align-items: center;\n display: flex;\n flex-direction: row;\n gap: var(--salt-spacing-100);\n}\n\n.saltDialogTitle-title {\n margin: 0;\n}\n\n/* Styles applied to the status indicator icon overriding its default size */\n.saltDialogTitle .saltStatusIndicator.saltIcon {\n --icon-size: var(--salt-text-h2-lineHeight);\n}\n\n/* Styles applied to DialogTitle when accent={true} */\n.saltDialogTitle-withAccent {\n position: relative;\n}\n\n.saltDialogTitle-withAccent::before {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n bottom: var(--salt-spacing-100);\n width: var(--salt-size-accent);\n background: var(--salt-accent-background);\n}\n\n.saltDialogTitle-error::before {\n background: var(--salt-status-error-borderColor);\n}\n\n.saltDialogTitle-info::before {\n background: var(--salt-status-info-borderColor);\n}\n\n.saltDialogTitle-success::before {\n background: var(--salt-status-success-borderColor);\n}\n\n.saltDialogTitle-warning::before {\n background: var(--salt-status-warning-borderColor);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=DialogTitle.css.js.map
|
|
@@ -16,13 +16,14 @@ var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
|
|
|
16
16
|
|
|
17
17
|
const withBaseName = core.makePrefixer("saltDialogTitle");
|
|
18
18
|
const DialogTitle = ({
|
|
19
|
-
children,
|
|
20
19
|
className,
|
|
20
|
+
title,
|
|
21
|
+
subtitle,
|
|
21
22
|
disableAccent,
|
|
22
23
|
status: statusProp,
|
|
23
24
|
...rest
|
|
24
25
|
}) => {
|
|
25
|
-
const { status: statusContext } = DialogContext.useDialogContext();
|
|
26
|
+
const { status: statusContext, id } = DialogContext.useDialogContext();
|
|
26
27
|
const targetWindow = window.useWindow();
|
|
27
28
|
styles.useComponentCssInjection({
|
|
28
29
|
testId: "salt-dialog-title",
|
|
@@ -30,7 +31,8 @@ const DialogTitle = ({
|
|
|
30
31
|
window: targetWindow
|
|
31
32
|
});
|
|
32
33
|
const status = statusProp != null ? statusProp : statusContext;
|
|
33
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
34
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
35
|
+
id,
|
|
34
36
|
className: clsx__default["default"](
|
|
35
37
|
withBaseName(),
|
|
36
38
|
{
|
|
@@ -44,7 +46,19 @@ const DialogTitle = ({
|
|
|
44
46
|
status && /* @__PURE__ */ jsxRuntime.jsx(core.StatusIndicator, {
|
|
45
47
|
status
|
|
46
48
|
}),
|
|
47
|
-
|
|
49
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
50
|
+
children: [
|
|
51
|
+
subtitle && /* @__PURE__ */ jsxRuntime.jsx(core.Text, {
|
|
52
|
+
as: "label",
|
|
53
|
+
variant: "secondary",
|
|
54
|
+
children: subtitle
|
|
55
|
+
}),
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.H2, {
|
|
57
|
+
className: clsx__default["default"](withBaseName("title")),
|
|
58
|
+
children: title
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
})
|
|
48
62
|
]
|
|
49
63
|
});
|
|
50
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogTitle.js","sources":["../src/dialog/DialogTitle.tsx"],"sourcesContent":["import { ComponentPropsWithoutRef } from \"react\";\nimport clsx from \"clsx\";\nimport {\n H2,\n StatusIndicator,\n ValidationStatus,\n makePrefixer,\n} from \"@salt-ds/core\";\nimport { useDialogContext } from \"./DialogContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport dialogTitleCss from \"./DialogTitle.css\";\n\nconst withBaseName = makePrefixer(\"saltDialogTitle\");\n\ninterface DialogTitleProps
|
|
1
|
+
{"version":3,"file":"DialogTitle.js","sources":["../src/dialog/DialogTitle.tsx"],"sourcesContent":["import { ReactNode, ComponentPropsWithoutRef } from \"react\";\nimport clsx from \"clsx\";\nimport {\n H2,\n StatusIndicator,\n ValidationStatus,\n makePrefixer,\n Text,\n} from \"@salt-ds/core\";\nimport { useDialogContext } from \"./DialogContext\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport dialogTitleCss from \"./DialogTitle.css\";\n\nconst withBaseName = makePrefixer(\"saltDialogTitle\");\n\ninterface DialogTitleProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"title\"> {\n /**\n * The status of the Dialog\n */\n status?: ValidationStatus | undefined;\n /**\n * Displays the accent bar in the Dialog Title */\n disableAccent?: boolean;\n /**\n * Displays the Dialog Title in a H2 component\n */\n title: ReactNode;\n /**\n * Displays the Dialog Subtitle in a Label component\n **/\n subtitle?: ReactNode;\n\n className?: string;\n}\n\nexport const DialogTitle = ({\n className,\n title,\n subtitle,\n disableAccent,\n status: statusProp,\n ...rest\n}: DialogTitleProps) => {\n const { status: statusContext, id } = useDialogContext();\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-dialog-title\",\n css: dialogTitleCss,\n window: targetWindow,\n });\n\n const status = statusProp ?? (statusContext as ValidationStatus);\n\n return (\n <div\n id={id as string}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"withAccent\")]: !disableAccent && !status,\n [withBaseName(status)]: !!status,\n },\n className\n )}\n {...rest}\n >\n {status && <StatusIndicator status={status} />}\n <div>\n {subtitle && (\n <Text as={\"label\"} variant=\"secondary\">\n {subtitle}\n </Text>\n )}\n <H2 className={clsx(withBaseName(\"title\"))}>{title}</H2>\n </div>\n </div>\n );\n};\n"],"names":["makePrefixer","useDialogContext","useWindow","useComponentCssInjection","dialogTitleCss","jsxs","clsx","jsx","StatusIndicator","Text","H2"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAM,YAAA,GAAeA,kBAAa,iBAAiB,CAAA,CAAA;AAuB5C,MAAM,cAAc,CAAC;AAAA,EAC1B,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,MAAQ,EAAA,UAAA;AAAA,EACL,GAAA,IAAA;AACL,CAAwB,KAAA;AACtB,EAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,EAAA,KAAOC,8BAAiB,EAAA,CAAA;AACvD,EAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,mBAAA;AAAA,IACR,GAAK,EAAAC,aAAA;AAAA,IACL,MAAQ,EAAA,YAAA;AAAA,GACT,CAAA,CAAA;AAED,EAAA,MAAM,SAAS,UAAe,IAAA,IAAA,GAAA,UAAA,GAAA,aAAA,CAAA;AAE9B,EAAA,uBACGC,eAAA,CAAA,KAAA,EAAA;AAAA,IACC,EAAA;AAAA,IACA,SAAW,EAAAC,wBAAA;AAAA,MACT,YAAa,EAAA;AAAA,MACb;AAAA,QACE,CAAC,YAAa,CAAA,YAAY,CAAI,GAAA,CAAC,iBAAiB,CAAC,MAAA;AAAA,QACjD,CAAC,YAAA,CAAa,MAAM,CAAA,GAAI,CAAC,CAAC,MAAA;AAAA,OAC5B;AAAA,MACA,SAAA;AAAA,KACF;AAAA,IACC,GAAG,IAAA;AAAA,IAEH,QAAA,EAAA;AAAA,MAAA,MAAA,oBAAWC,cAAA,CAAAC,oBAAA,EAAA;AAAA,QAAgB,MAAA;AAAA,OAAgB,CAAA;AAAA,sBAC3CH,eAAA,CAAA,KAAA,EAAA;AAAA,QACE,QAAA,EAAA;AAAA,UAAA,QAAA,oBACEE,cAAA,CAAAE,SAAA,EAAA;AAAA,YAAK,EAAI,EAAA,OAAA;AAAA,YAAS,OAAQ,EAAA,WAAA;AAAA,YACxB,QAAA,EAAA,QAAA;AAAA,WACH,CAAA;AAAA,0BAEDF,cAAA,CAAAG,OAAA,EAAA;AAAA,YAAG,SAAW,EAAAJ,wBAAA,CAAK,YAAa,CAAA,OAAO,CAAC,CAAA;AAAA,YAAI,QAAA,EAAA,KAAA;AAAA,WAAM,CAAA;AAAA,SAAA;AAAA,OACrD,CAAA;AAAA,KAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
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:
|
|
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: var(--salt-zIndex-drawer);\n position: fixed;\n top: 0;\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\" */\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
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=Drawer.css.js.map
|
|
@@ -9,19 +9,38 @@ var react = require('@floating-ui/react');
|
|
|
9
9
|
var core = require('@salt-ds/core');
|
|
10
10
|
var window = require('@salt-ds/window');
|
|
11
11
|
var styles = require('@salt-ds/styles');
|
|
12
|
-
var useDrawer = require('./useDrawer.js');
|
|
13
12
|
var Drawer$1 = require('./Drawer.css.js');
|
|
14
13
|
|
|
15
|
-
const
|
|
14
|
+
const ConditionalScrimWrapper = ({
|
|
15
|
+
condition,
|
|
16
|
+
children
|
|
17
|
+
}) => {
|
|
18
|
+
return condition ? /* @__PURE__ */ jsxRuntime.jsxs(core.Scrim, {
|
|
19
|
+
fixed: true,
|
|
20
|
+
children: [
|
|
21
|
+
" ",
|
|
22
|
+
children,
|
|
23
|
+
" "
|
|
24
|
+
]
|
|
25
|
+
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
26
|
+
children: [
|
|
27
|
+
children,
|
|
28
|
+
" "
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
16
32
|
const withBaseName = core.makePrefixer("saltDrawer");
|
|
17
33
|
const Drawer = React.forwardRef(function Drawer2(props, ref) {
|
|
34
|
+
var _a, _b;
|
|
18
35
|
const {
|
|
19
36
|
children,
|
|
20
37
|
className,
|
|
21
38
|
position = "left",
|
|
22
|
-
open =
|
|
39
|
+
open = false,
|
|
23
40
|
onOpenChange,
|
|
24
41
|
variant = "primary",
|
|
42
|
+
disableDismiss,
|
|
43
|
+
disableScrim,
|
|
25
44
|
...rest
|
|
26
45
|
} = props;
|
|
27
46
|
const targetWindow = window.useWindow();
|
|
@@ -31,49 +50,55 @@ const Drawer = React.forwardRef(function Drawer2(props, ref) {
|
|
|
31
50
|
window: targetWindow
|
|
32
51
|
});
|
|
33
52
|
const [showComponent, setShowComponent] = React.useState(false);
|
|
34
|
-
const {
|
|
53
|
+
const { Component: FloatingComponent } = core.useFloatingComponent();
|
|
54
|
+
const { context, floating, elements } = core.useFloatingUI({
|
|
35
55
|
open,
|
|
36
56
|
onOpenChange
|
|
37
57
|
});
|
|
38
|
-
const
|
|
58
|
+
const { getFloatingProps } = react.useInteractions([
|
|
59
|
+
react.useClick(context),
|
|
60
|
+
react.useDismiss(context, { enabled: !disableDismiss })
|
|
61
|
+
]);
|
|
62
|
+
const handleRef = core.useForkRef(floating, ref);
|
|
39
63
|
React.useEffect(() => {
|
|
40
64
|
if (open && !showComponent) {
|
|
41
65
|
setShowComponent(true);
|
|
42
66
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
if (!open && showComponent) {
|
|
68
|
+
const animate = setTimeout(() => {
|
|
69
|
+
setShowComponent(false);
|
|
70
|
+
}, 300);
|
|
71
|
+
return () => clearTimeout(animate);
|
|
72
|
+
}
|
|
73
|
+
}, [open, showComponent, setShowComponent]);
|
|
74
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConditionalScrimWrapper, {
|
|
75
|
+
condition: open && !disableScrim,
|
|
76
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(FloatingComponent, {
|
|
77
|
+
open: showComponent,
|
|
78
|
+
ref: handleRef,
|
|
79
|
+
role: "dialog",
|
|
80
|
+
width: (_a = elements.floating) == null ? void 0 : _a.offsetWidth,
|
|
81
|
+
height: (_b = elements.floating) == null ? void 0 : _b.offsetHeight,
|
|
82
|
+
"aria-modal": "true",
|
|
83
|
+
focusManagerProps: {
|
|
84
|
+
context
|
|
85
|
+
},
|
|
86
|
+
className: clsx.clsx(
|
|
87
|
+
withBaseName(),
|
|
88
|
+
withBaseName(position),
|
|
89
|
+
{
|
|
90
|
+
[withBaseName("enterAnimation")]: open,
|
|
91
|
+
[withBaseName("exitAnimation")]: !open,
|
|
92
|
+
[withBaseName(variant)]: variant
|
|
93
|
+
},
|
|
94
|
+
className
|
|
95
|
+
),
|
|
96
|
+
...getFloatingProps(),
|
|
97
|
+
...rest,
|
|
98
|
+
children
|
|
73
99
|
})
|
|
74
100
|
});
|
|
75
101
|
});
|
|
76
102
|
|
|
77
|
-
exports.DRAWER_POSITIONS = DRAWER_POSITIONS;
|
|
78
103
|
exports.Drawer = Drawer;
|
|
79
104
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../src/drawer/Drawer.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../src/drawer/Drawer.tsx"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n forwardRef,\n useEffect,\n useState,\n PropsWithChildren,\n} from \"react\";\nimport { clsx } from \"clsx\";\nimport { useClick, useDismiss, useInteractions } from \"@floating-ui/react\";\nimport {\n makePrefixer,\n Scrim,\n useFloatingComponent,\n useFloatingUI,\n useForkRef,\n} from \"@salt-ds/core\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport drawerCss from \"./Drawer.css\";\n\ninterface ConditionalScrimWrapperProps extends PropsWithChildren {\n condition: boolean;\n}\n\nconst ConditionalScrimWrapper = ({\n condition,\n children,\n}: ConditionalScrimWrapperProps) => {\n return condition ? <Scrim fixed> {children} </Scrim> : <>{children} </>;\n};\n\nexport interface DrawerProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Defines the drawer position within the screen. Defaults to `left`.\n */\n position?: \"left\" | \"top\" | \"right\" | \"bottom\";\n /**\n * Display or hide the component.\n */\n open?: boolean;\n /**\n * Callback function triggered when open state changes.\n */\n onOpenChange?: (newOpen: boolean) => void;\n /**\n * Change background color palette\n */\n variant?: \"primary\" | \"secondary\";\n /**\n * Prevent the dialog closing on click away\n * */\n disableDismiss?: boolean;\n /**\n * Prevent Scrim from rendering\n * */\n disableScrim?: boolean;\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 = false,\n onOpenChange,\n variant = \"primary\",\n disableDismiss,\n disableScrim,\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 const { Component: FloatingComponent } = useFloatingComponent();\n\n const { context, floating, elements } = useFloatingUI({\n open,\n onOpenChange,\n });\n\n const { getFloatingProps } = useInteractions([\n useClick(context),\n useDismiss(context, { enabled: !disableDismiss }),\n ]);\n\n const handleRef = useForkRef<HTMLDivElement>(floating, ref);\n\n useEffect(() => {\n if (open && !showComponent) {\n setShowComponent(true);\n }\n\n if (!open && showComponent) {\n const animate = setTimeout(() => {\n setShowComponent(false);\n }, 300); // var(--salt-duration-perceptible)\n return () => clearTimeout(animate);\n }\n }, [open, showComponent, setShowComponent]);\n\n return (\n <ConditionalScrimWrapper condition={open && !disableScrim}>\n <FloatingComponent\n open={showComponent}\n ref={handleRef}\n role={\"dialog\"}\n width={elements.floating?.offsetWidth}\n height={elements.floating?.offsetHeight}\n aria-modal=\"true\"\n focusManagerProps={{\n context: context,\n }}\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 {...getFloatingProps()}\n {...rest}\n >\n {children}\n </FloatingComponent>\n </ConditionalScrimWrapper>\n );\n});\n"],"names":["jsxs","Scrim","Fragment","makePrefixer","forwardRef","Drawer","useWindow","useComponentCssInjection","drawerCss","useState","useFloatingComponent","useFloatingUI","useInteractions","useClick","useDismiss","useForkRef","useEffect","jsx","clsx"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".saltDrawerCloseButton-container {\n position: relative;\n display: flex;\n justify-content: flex-end;\n}\n\n.saltButton-secondary.saltDrawerCloseButton {\n position: fixed;\n margin-top: calc(var(--salt-spacing-300) * -1);\n margin-right: calc(var(--salt-spacing-300) * -1);\n}\n";
|
|
4
|
+
|
|
5
|
+
module.exports = css_248z;
|
|
6
|
+
//# sourceMappingURL=DrawerCloseButton.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerCloseButton.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 core = require('@salt-ds/core');
|
|
9
|
+
var window = require('@salt-ds/window');
|
|
10
|
+
var styles = require('@salt-ds/styles');
|
|
11
|
+
var icons = require('@salt-ds/icons');
|
|
12
|
+
var DrawerCloseButton$1 = require('./DrawerCloseButton.css.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var clsx__default = /*#__PURE__*/_interopDefaultLegacy(clsx);
|
|
17
|
+
|
|
18
|
+
const withBaseName = core.makePrefixer("saltDrawerCloseButton");
|
|
19
|
+
const DrawerCloseButton = React.forwardRef(
|
|
20
|
+
function DrawerCloseButton2({ className, ...rest }, ref) {
|
|
21
|
+
const targetWindow = window.useWindow();
|
|
22
|
+
styles.useComponentCssInjection({
|
|
23
|
+
testId: "salt-drawer-close-button",
|
|
24
|
+
css: DrawerCloseButton$1,
|
|
25
|
+
window: targetWindow
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
28
|
+
className: withBaseName("container"),
|
|
29
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(core.Button, {
|
|
30
|
+
ref,
|
|
31
|
+
"aria-label": "Close Drawer",
|
|
32
|
+
variant: "secondary",
|
|
33
|
+
className: clsx__default["default"](withBaseName(), className),
|
|
34
|
+
...rest,
|
|
35
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseIcon, {
|
|
36
|
+
"aria-hidden": true
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
exports.DrawerCloseButton = DrawerCloseButton;
|
|
44
|
+
//# sourceMappingURL=DrawerCloseButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerCloseButton.js","sources":["../src/drawer/DrawerCloseButton.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\nimport clsx from \"clsx\";\nimport { Button, ButtonProps, makePrefixer } from \"@salt-ds/core\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { CloseIcon } from \"@salt-ds/icons\";\n\nimport drawerCloseButtonCss from \"./DrawerCloseButton.css\";\n\nconst withBaseName = makePrefixer(\"saltDrawerCloseButton\");\n\nexport const DrawerCloseButton = forwardRef<HTMLButtonElement, ButtonProps>(\n function DrawerCloseButton({ className, ...rest }, ref) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-drawer-close-button\",\n css: drawerCloseButtonCss,\n window: targetWindow,\n });\n\n return (\n <div className={withBaseName(\"container\")}>\n <Button\n ref={ref}\n aria-label=\"Close Drawer\"\n variant=\"secondary\"\n className={clsx(withBaseName(), className)}\n {...rest}\n >\n <CloseIcon aria-hidden />\n </Button>\n </div>\n );\n }\n);\n"],"names":["makePrefixer","forwardRef","DrawerCloseButton","useWindow","useComponentCssInjection","drawerCloseButtonCss","jsx","Button","clsx","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAM,YAAA,GAAeA,kBAAa,uBAAuB,CAAA,CAAA;AAElD,MAAM,iBAAoB,GAAAC,gBAAA;AAAA,EAC/B,SAASC,kBAAkB,CAAA,EAAE,SAAc,EAAA,GAAA,IAAA,IAAQ,GAAK,EAAA;AACtD,IAAA,MAAM,eAAeC,gBAAU,EAAA,CAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,0BAAA;AAAA,MACR,GAAK,EAAAC,mBAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AAED,IAAA,uBACGC,cAAA,CAAA,KAAA,EAAA;AAAA,MAAI,SAAA,EAAW,aAAa,WAAW,CAAA;AAAA,MACtC,QAAC,kBAAAA,cAAA,CAAAC,WAAA,EAAA;AAAA,QACC,GAAA;AAAA,QACA,YAAW,EAAA,cAAA;AAAA,QACX,OAAQ,EAAA,WAAA;AAAA,QACR,SAAW,EAAAC,wBAAA,CAAK,YAAa,EAAA,EAAG,SAAS,CAAA;AAAA,QACxC,GAAG,IAAA;AAAA,QAEJ,QAAC,kBAAAF,cAAA,CAAAG,eAAA,EAAA;AAAA,UAAU,aAAW,EAAA,IAAA;AAAA,SAAC,CAAA;AAAA,OACzB,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -47,7 +47,6 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
47
47
|
required: requiredProp,
|
|
48
48
|
variant = "primary",
|
|
49
49
|
validationStatus: validationStatusProp,
|
|
50
|
-
onClick,
|
|
51
50
|
onKeyDown,
|
|
52
51
|
onFocus,
|
|
53
52
|
onBlur,
|
|
@@ -106,8 +105,15 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
106
105
|
listRef
|
|
107
106
|
} = listControl;
|
|
108
107
|
const { Component: FloatingComponent } = core.useFloatingComponent();
|
|
109
|
-
const
|
|
110
|
-
|
|
108
|
+
const handleOpenChange = (newOpen, _event, reason) => {
|
|
109
|
+
const focusNotBlur = reason === "focus" && newOpen;
|
|
110
|
+
if (readOnly || focusNotBlur)
|
|
111
|
+
return;
|
|
112
|
+
setOpen(newOpen);
|
|
113
|
+
};
|
|
114
|
+
const { x, y, strategy, elements, floating, reference, context } = core.useFloatingUI({
|
|
115
|
+
open: openState && !readOnly && children != void 0,
|
|
116
|
+
onOpenChange: handleOpenChange,
|
|
111
117
|
placement: "bottom-start",
|
|
112
118
|
middleware: [
|
|
113
119
|
react.size({
|
|
@@ -121,16 +127,14 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
121
127
|
react.flip({ fallbackStrategy: "initialPlacement" })
|
|
122
128
|
]
|
|
123
129
|
});
|
|
130
|
+
const { getReferenceProps, getFloatingProps } = react.useInteractions([
|
|
131
|
+
react.useDismiss(context),
|
|
132
|
+
react.useFocus(context),
|
|
133
|
+
react.useClick(context)
|
|
134
|
+
]);
|
|
124
135
|
const buttonRef = React.useRef(null);
|
|
125
136
|
const handleTriggerRef = core.useForkRef(reference, buttonRef);
|
|
126
137
|
const handleButtonRef = core.useForkRef(handleTriggerRef, ref);
|
|
127
|
-
const handleClick = (event) => {
|
|
128
|
-
if (!readOnly) {
|
|
129
|
-
setFocusVisibleState(false);
|
|
130
|
-
setOpen(event, !openState);
|
|
131
|
-
}
|
|
132
|
-
onClick == null ? void 0 : onClick(event);
|
|
133
|
-
};
|
|
134
138
|
const typeaheadString = React.useRef("");
|
|
135
139
|
const typeaheadTimeout = React.useRef();
|
|
136
140
|
const handleTypeahead = (event) => {
|
|
@@ -142,7 +146,7 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
142
146
|
typeaheadString.current = "";
|
|
143
147
|
}, 500);
|
|
144
148
|
if (!openState) {
|
|
145
|
-
setOpen(
|
|
149
|
+
setOpen(true, "input");
|
|
146
150
|
}
|
|
147
151
|
let newOption = getOptionFromSearch(typeaheadString.current, activeState);
|
|
148
152
|
if (!newOption) {
|
|
@@ -161,7 +165,7 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
161
165
|
}
|
|
162
166
|
if (!openState) {
|
|
163
167
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
164
|
-
setOpen(
|
|
168
|
+
setOpen(true, void 0, event.key);
|
|
165
169
|
return;
|
|
166
170
|
}
|
|
167
171
|
}
|
|
@@ -201,12 +205,6 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
201
205
|
}
|
|
202
206
|
event.preventDefault();
|
|
203
207
|
select(event, activeState);
|
|
204
|
-
if (!multiselect) {
|
|
205
|
-
setOpen(event, false);
|
|
206
|
-
}
|
|
207
|
-
break;
|
|
208
|
-
case "Escape":
|
|
209
|
-
setOpen(event, false);
|
|
210
208
|
break;
|
|
211
209
|
case "Tab":
|
|
212
210
|
if (!multiselect && activeState) {
|
|
@@ -225,51 +223,43 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
225
223
|
setFocusedState(true);
|
|
226
224
|
onFocus == null ? void 0 : onFocus(event);
|
|
227
225
|
};
|
|
228
|
-
const ignoreBlur = React.useRef(false);
|
|
229
226
|
const handleBlur = (event) => {
|
|
230
|
-
if (!ignoreBlur.current) {
|
|
231
|
-
setOpen(event, false);
|
|
232
|
-
}
|
|
233
|
-
ignoreBlur.current = false;
|
|
234
227
|
setFocusedState(false);
|
|
235
228
|
onBlur == null ? void 0 : onBlur(event);
|
|
236
229
|
};
|
|
237
230
|
const handleListMouseOver = () => {
|
|
238
231
|
setFocusVisibleState(false);
|
|
239
232
|
};
|
|
240
|
-
const
|
|
241
|
-
ignoreBlur.current = true;
|
|
242
|
-
};
|
|
243
|
-
const handleListFocus = () => {
|
|
244
|
-
var _a2;
|
|
245
|
-
(_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
|
|
246
|
-
};
|
|
247
|
-
const handleListClick = () => {
|
|
233
|
+
const handleFocusButton = () => {
|
|
248
234
|
var _a2;
|
|
249
235
|
(_a2 = buttonRef.current) == null ? void 0 : _a2.focus();
|
|
250
236
|
};
|
|
251
237
|
React.useEffect(() => {
|
|
252
238
|
const activeIndex = activeState ? getIndexOfOption(activeState) : -1;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
} else {
|
|
259
|
-
if (selectedState.length > 0) {
|
|
260
|
-
const selected2 = getOptionsMatching(
|
|
261
|
-
(option) => option.value === selectedState[0]
|
|
262
|
-
).pop();
|
|
263
|
-
if (selected2) {
|
|
264
|
-
setActive(selected2);
|
|
265
|
-
}
|
|
266
|
-
} else {
|
|
267
|
-
setActive(getOptionAtIndex(0));
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
} else if (!openState) {
|
|
239
|
+
let newActive = void 0;
|
|
240
|
+
if (activeIndex > 0) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!openState) {
|
|
271
244
|
setActive(void 0);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (selectedState.length > 0) {
|
|
248
|
+
newActive = getOptionsMatching(
|
|
249
|
+
(option) => option.value === selectedState[0]
|
|
250
|
+
).pop();
|
|
251
|
+
}
|
|
252
|
+
if (!newActive) {
|
|
253
|
+
if (openKey.current === "ArrowDown") {
|
|
254
|
+
newActive = getOptionAtIndex(0);
|
|
255
|
+
} else if (openKey.current === "ArrowUp") {
|
|
256
|
+
newActive = getOptionAtIndex(options.length - 1);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (!newActive) {
|
|
260
|
+
newActive = getOptionAtIndex(0);
|
|
272
261
|
}
|
|
262
|
+
setActive(newActive);
|
|
273
263
|
}, [openState, children]);
|
|
274
264
|
const listId = core.useId();
|
|
275
265
|
return /* @__PURE__ */ jsxRuntime.jsxs(ListControlContext.ListControlContext.Provider, {
|
|
@@ -286,10 +276,6 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
286
276
|
className
|
|
287
277
|
),
|
|
288
278
|
ref: handleButtonRef,
|
|
289
|
-
onClick: handleClick,
|
|
290
|
-
onKeyDown: handleKeyDown,
|
|
291
|
-
onFocus: handleFocus,
|
|
292
|
-
onBlur: handleBlur,
|
|
293
279
|
role: "combobox",
|
|
294
280
|
type: "button",
|
|
295
281
|
disabled,
|
|
@@ -301,14 +287,19 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
301
287
|
"aria-describedby": clsx.clsx(formFieldDescribedBy, ariaDescribedBy) || void 0,
|
|
302
288
|
"aria-multiselectable": multiselect,
|
|
303
289
|
"aria-controls": openState ? listId : void 0,
|
|
304
|
-
...
|
|
290
|
+
...getReferenceProps({
|
|
291
|
+
onKeyDown: handleKeyDown,
|
|
292
|
+
onFocus: handleFocus,
|
|
293
|
+
onBlur: handleBlur,
|
|
294
|
+
...rest
|
|
295
|
+
}),
|
|
305
296
|
children: [
|
|
306
297
|
startAdornment,
|
|
307
298
|
/* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
308
299
|
className: clsx.clsx(withBaseName("content"), {
|
|
309
300
|
[withBaseName("placeholder")]: !valueState
|
|
310
301
|
}),
|
|
311
|
-
children: valueState
|
|
302
|
+
children: !valueState ? placeholder : valueState
|
|
312
303
|
}),
|
|
313
304
|
validationStatus && /* @__PURE__ */ jsxRuntime.jsx(core.StatusAdornment, {
|
|
314
305
|
status: validationStatus
|
|
@@ -320,6 +311,7 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
320
311
|
}),
|
|
321
312
|
/* @__PURE__ */ jsxRuntime.jsx(FloatingComponent, {
|
|
322
313
|
open: (openState || focusedState) && !readOnly && children != void 0,
|
|
314
|
+
...getFloatingProps(),
|
|
323
315
|
left: x != null ? x : 0,
|
|
324
316
|
top: y != null ? y : 0,
|
|
325
317
|
position: strategy,
|
|
@@ -330,9 +322,8 @@ const DropdownNext = React.forwardRef(function DropdownNext2(props, ref) {
|
|
|
330
322
|
id: listId,
|
|
331
323
|
collapsed: !openState,
|
|
332
324
|
onMouseOver: handleListMouseOver,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
onClick: handleListClick,
|
|
325
|
+
onFocus: handleFocusButton,
|
|
326
|
+
onClick: handleFocusButton,
|
|
336
327
|
ref: listRef,
|
|
337
328
|
children
|
|
338
329
|
})
|