@flipdish/ui-library 0.53.0 → 0.53.1
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/dist/components/atoms/CloseButton/index.cjs +1 -0
- package/dist/components/atoms/CloseButton/index.cjs.map +1 -1
- package/dist/components/atoms/CloseButton/index.d.ts.map +1 -1
- package/dist/components/atoms/CloseButton/index.js +1 -0
- package/dist/components/atoms/CloseButton/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs +29 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts +9 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js +27 -0
- package/dist/components/molecules/Dropdown/components/DropdownSelectionIndicator.js.map +1 -0
- package/dist/components/molecules/Dropdown/index.cjs +4 -30
- package/dist/components/molecules/Dropdown/index.cjs.map +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts +1 -1
- package/dist/components/molecules/Dropdown/index.d.ts.map +1 -1
- package/dist/components/molecules/Dropdown/index.js +6 -32
- package/dist/components/molecules/Dropdown/index.js.map +1 -1
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs +24 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.cjs.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts +10 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.d.ts.map +1 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.js +22 -0
- package/dist/components/molecules/Dropdown/utilities/dropdown.utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ const themes = {
|
|
|
16
16
|
light: 'text-fg-quaternary hover:bg-primary_hover hover:text-fg-quaternary_hover focus-visible:outline-2 focus-visible:outline-offset-2 outline-focus-ring',
|
|
17
17
|
dark: 'text-fg-white/70 hover:text-fg-white hover:bg-white/20 focus-visible:outline-2 focus-visible:outline-offset-2 outline-focus-ring',
|
|
18
18
|
};
|
|
19
|
+
// Comment to test native pipeline - please remove
|
|
19
20
|
/**
|
|
20
21
|
* Icon-only button that renders an × icon for dismissing overlays, toasts,
|
|
21
22
|
* banners, and drawers. Always supply a `label` for screen readers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","_jsx","AriaButton","cx","CloseIcon"],"mappings":";;;;;;;;AAOA,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxC;AAED,MAAM,MAAM,GAAG;AACb,IAAA,KAAK,EACH,oJAAoJ;AACtJ,IAAA,IAAI,EAAE,kIAAkI;CACzI;AAaD;;;;;AAKG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,UAAU,EAAoB,KAAI;AAC5I,IAAA,MAAM,iBAAiB,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AAEtH,IAAA,QACEC,cAAA,CAACC,0BAAU,EAAA,EAAA,GACL,UAAU,EAAA,aAAA,EACD,iBAAiB,EAAA,YAAA,EAClB,KAAK,IAAI,OAAO,EAC5B,SAAS,EAAE,CAAC,KAAK,KACfC,KAAE,CACA,yHAAyH,EACzH,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAChB,MAAM,CAAC,KAAK,CAAC,EACb,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGHF,eAACG,SAAS,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAED,KAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,EAAA,CACzF;AAEjB;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"sourcesContent":[null],"names":["useResolvedTestId","_jsx","AriaButton","cx","CloseIcon"],"mappings":";;;;;;;;AAOA,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxC;AAED,MAAM,MAAM,GAAG;AACb,IAAA,KAAK,EACH,oJAAoJ;AACtJ,IAAA,IAAI,EAAE,kIAAkI;CACzI;AAaD;AAEA;;;;;AAKG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,UAAU,EAAoB,KAAI;AAC5I,IAAA,MAAM,iBAAiB,GAAGA,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AAEtH,IAAA,QACEC,cAAA,CAACC,0BAAU,EAAA,EAAA,GACL,UAAU,EAAA,aAAA,EACD,iBAAiB,EAAA,YAAA,EAClB,KAAK,IAAI,OAAO,EAC5B,SAAS,EAAE,CAAC,KAAK,KACfC,KAAE,CACA,yHAAyH,EACzH,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAChB,MAAM,CAAC,KAAK,CAAC,EACb,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGHF,eAACG,SAAS,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAED,KAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,EAAA,CACzF;AAEjB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAelG,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,yGAAyG;IACzG,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAwB,KAAK,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAelG,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,yGAAyG;IACzG,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,6EAA8F,gBAAgB,gCAoBzI,CAAC"}
|
|
@@ -14,6 +14,7 @@ const themes = {
|
|
|
14
14
|
light: 'text-fg-quaternary hover:bg-primary_hover hover:text-fg-quaternary_hover focus-visible:outline-2 focus-visible:outline-offset-2 outline-focus-ring',
|
|
15
15
|
dark: 'text-fg-white/70 hover:text-fg-white hover:bg-white/20 focus-visible:outline-2 focus-visible:outline-offset-2 outline-focus-ring',
|
|
16
16
|
};
|
|
17
|
+
// Comment to test native pipeline - please remove
|
|
17
18
|
/**
|
|
18
19
|
* Icon-only button that renders an × icon for dismissing overlays, toasts,
|
|
19
20
|
* banners, and drawers. Always supply a `label` for screen readers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","CloseIcon"],"mappings":";;;;;;AAOA,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxC;AAED,MAAM,MAAM,GAAG;AACb,IAAA,KAAK,EACH,oJAAoJ;AACtJ,IAAA,IAAI,EAAE,kIAAkI;CACzI;AAaD;;;;;AAKG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,UAAU,EAAoB,KAAI;AAC5I,IAAA,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AAEtH,IAAA,QACEA,GAAA,CAACC,MAAU,EAAA,EAAA,GACL,UAAU,EAAA,aAAA,EACD,iBAAiB,EAAA,YAAA,EAClB,KAAK,IAAI,OAAO,EAC5B,SAAS,EAAE,CAAC,KAAK,KACf,EAAE,CACA,yHAAyH,EACzH,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAChB,MAAM,CAAC,KAAK,CAAC,EACb,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGHD,IAACE,CAAS,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,EAAA,CACzF;AAEjB;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/CloseButton/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaButton","CloseIcon"],"mappings":";;;;;;AAOA,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACtC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACvC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;CACxC;AAED,MAAM,MAAM,GAAG;AACb,IAAA,KAAK,EACH,oJAAoJ;AACtJ,IAAA,IAAI,EAAE,kIAAkI;CACzI;AAaD;AAEA;;;;;AAKG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,UAAU,EAAoB,KAAI;AAC5I,IAAA,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;AAEtH,IAAA,QACEA,GAAA,CAACC,MAAU,EAAA,EAAA,GACL,UAAU,EAAA,aAAA,EACD,iBAAiB,EAAA,YAAA,EAClB,KAAK,IAAI,OAAO,EAC5B,SAAS,EAAE,CAAC,KAAK,KACf,EAAE,CACA,yHAAyH,EACzH,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAChB,MAAM,CAAC,KAAK,CAAC,EACb,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAC/D,EAAA,QAAA,EAGHD,IAACE,CAAS,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,EAAA,CACzF;AAEjB;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
6
|
+
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
7
|
+
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
8
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
9
|
+
|
|
10
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
11
|
+
if (selectionIndicator === 'checkmark') {
|
|
12
|
+
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
13
|
+
}
|
|
14
|
+
if (selectionIndicator === 'checkbox') {
|
|
15
|
+
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
16
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
17
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx.cx('shrink-0', className) }));
|
|
18
|
+
}
|
|
19
|
+
if (selectionIndicator === 'radio') {
|
|
20
|
+
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
21
|
+
}
|
|
22
|
+
if (selectionIndicator === 'toggle') {
|
|
23
|
+
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx.cx('shrink-0', className) });
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.DropdownSelectionIndicator = DropdownSelectionIndicator;
|
|
29
|
+
//# sourceMappingURL=DropdownSelectionIndicator.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.cjs","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx","Check","cx","CheckboxBase","RadioButtonBase","ToggleBase"],"mappings":";;;;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,eAACC,aAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAEC,KAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEF,eAACG,qBAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAED,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOF,eAACI,2BAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEF,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOF,cAAA,CAACK,iBAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAEH,KAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DropdownSelectionIndicatorProps {
|
|
2
|
+
selectionIndicator: 'checkmark' | 'checkbox' | 'radio' | 'toggle' | 'none';
|
|
3
|
+
isSelected: boolean;
|
|
4
|
+
hasSubmenu?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DropdownSelectionIndicator: ({ selectionIndicator, isSelected, hasSubmenu, className }: DropdownSelectionIndicatorProps) => import("react").JSX.Element | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=DropdownSelectionIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"names":[],"mappings":"AAQA,UAAU,+BAA+B;IACvC,kBAAkB,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3E,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,0BAA0B,GAAI,2DAA2D,+BAA+B,uCAwBpI,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Check } from '@flipdish/ui-icons';
|
|
3
|
+
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
4
|
+
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
5
|
+
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
6
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
7
|
+
|
|
8
|
+
const DropdownSelectionIndicator = ({ selectionIndicator, isSelected, hasSubmenu, className }) => {
|
|
9
|
+
if (selectionIndicator === 'checkmark') {
|
|
10
|
+
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !isSelected && 'invisible', className) }));
|
|
11
|
+
}
|
|
12
|
+
if (selectionIndicator === 'checkbox') {
|
|
13
|
+
return (jsx(CheckboxBase, { isSelected: isSelected && !hasSubmenu,
|
|
14
|
+
// A selected item that opens a submenu is only partly chosen, so the box is mixed rather than checked.
|
|
15
|
+
isIndeterminate: isSelected && hasSubmenu, size: "sm", className: cx('shrink-0', className) }));
|
|
16
|
+
}
|
|
17
|
+
if (selectionIndicator === 'radio') {
|
|
18
|
+
return jsx(RadioButtonBase, { isSelected: isSelected, className: cx('shrink-0', className) });
|
|
19
|
+
}
|
|
20
|
+
if (selectionIndicator === 'toggle') {
|
|
21
|
+
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: isSelected, className: cx('shrink-0', className) });
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { DropdownSelectionIndicator };
|
|
27
|
+
//# sourceMappingURL=DropdownSelectionIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownSelectionIndicator.js","sources":["../../../../../src/components/molecules/Dropdown/components/DropdownSelectionIndicator.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAeO,MAAM,0BAA0B,GAAG,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAmC,KAAI;AACvI,IAAA,IAAI,kBAAkB,KAAK,WAAW,EAAE;QACtC,QACEA,IAAC,KAAK,EAAA,EAAA,aAAA,EAAa,MAAM,EAAC,SAAS,EAAE,EAAE,CAAC,uDAAuD,EAAE,CAAC,UAAU,IAAI,WAAW,EAAE,SAAS,CAAC,EAAA,CAAI;IAE/I;AACA,IAAA,IAAI,kBAAkB,KAAK,UAAU,EAAE;QACrC,QACEA,IAAC,YAAY,EAAA,EACX,UAAU,EAAE,UAAU,IAAI,CAAC,UAAU;;AAErC,YAAA,eAAe,EAAE,UAAU,IAAI,UAAU,EACzC,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CACpC;IAEN;AACA,IAAA,IAAI,kBAAkB,KAAK,OAAO,EAAE;AAClC,QAAA,OAAOA,IAAC,eAAe,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,GAAI;IAC1F;AACA,IAAA,IAAI,kBAAkB,KAAK,QAAQ,EAAE;QACnC,OAAOA,GAAA,CAAC,UAAU,EAAA,EAAC,IAAI,QAAC,IAAI,EAAC,IAAI,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAA,CAAI;IACpG;AACA,IAAA,OAAO,IAAI;AACb;;"}
|
|
@@ -4,47 +4,21 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var uiIcons = require('@flipdish/ui-icons');
|
|
5
5
|
var Avatar = require('@flipdish/ui-library/components/atoms/Avatar');
|
|
6
6
|
var Button = require('@flipdish/ui-library/components/atoms/Button');
|
|
7
|
-
var Checkbox = require('@flipdish/ui-library/components/atoms/Checkbox');
|
|
8
|
-
var RadioButton = require('@flipdish/ui-library/components/atoms/RadioButton');
|
|
9
|
-
var Toggle = require('@flipdish/ui-library/components/atoms/Toggle');
|
|
10
7
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
11
8
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
12
|
-
var React = require('react');
|
|
13
9
|
var reactAriaComponents = require('react-aria-components');
|
|
14
10
|
var ScrollClosingPopover = require('../../__internal__/popover/ScrollClosingPopover.cjs');
|
|
11
|
+
var DropdownSelectionIndicator = require('./components/DropdownSelectionIndicator.cjs');
|
|
12
|
+
var dropdown_utils = require('./utilities/dropdown.utils.cjs');
|
|
15
13
|
|
|
16
14
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
17
15
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
18
|
-
const
|
|
19
|
-
if (props.id !== undefined)
|
|
20
|
-
return testIdUtils.slugifyTestId(String(props.id));
|
|
21
|
-
if (typeof label === 'string')
|
|
22
|
-
return testIdUtils.slugifyTestId(label);
|
|
23
|
-
if (typeof children === 'string')
|
|
24
|
-
return testIdUtils.slugifyTestId(children);
|
|
25
|
-
return 'item';
|
|
26
|
-
};
|
|
27
|
-
const idPart = resolveIdPart();
|
|
16
|
+
const idPart = dropdown_utils.dropdownItemSegment(props.id, label, children);
|
|
28
17
|
const itemTestId = dataTestId ?? (prefix ? testIdUtils.joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
29
|
-
const SelectionIndicator = React.useCallback((state) => {
|
|
30
|
-
if (selectionIndicator === 'checkmark') {
|
|
31
|
-
return (jsxRuntime.jsx(uiIcons.Check, { "aria-hidden": "true", className: cx.cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
32
|
-
}
|
|
33
|
-
if (selectionIndicator === 'checkbox') {
|
|
34
|
-
return (jsxRuntime.jsx(Checkbox.CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx.cx('shrink-0', state.className) }));
|
|
35
|
-
}
|
|
36
|
-
if (selectionIndicator === 'radio') {
|
|
37
|
-
return jsxRuntime.jsx(RadioButton.RadioButtonBase, { isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
38
|
-
}
|
|
39
|
-
if (selectionIndicator === 'toggle') {
|
|
40
|
-
return jsxRuntime.jsx(Toggle.ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx.cx('shrink-0', state.className) });
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}, [selectionIndicator]);
|
|
44
18
|
if (unstyled) {
|
|
45
19
|
return jsxRuntime.jsx(reactAriaComponents.MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
46
20
|
}
|
|
47
|
-
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsxRuntime.jsx(
|
|
21
|
+
return (jsxRuntime.jsx(reactAriaComponents.MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx.cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsxRuntime.jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsxRuntime.jsx(Avatar.Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsxRuntime.jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsxRuntime.jsx("span", { className: cx.cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsxRuntime.jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsxRuntime.jsx(DropdownSelectionIndicator.DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsxRuntime.jsx(uiIcons.ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
48
22
|
};
|
|
49
23
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
50
24
|
const prefix = testIdUtils.useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","dropdownItemSegment","joinTestId","_jsx","AriaMenuItem","cx","_jsxs","DropdownSelectionIndicator","Avatar","ChevronRight","AriaMenu","ScrollClosingPopover","AriaSeparator","useResolvedTestId","Button","DotsVertical","TestIdProvider","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,MAAM,GAAGA,2BAAe,EAAE;AAChC,IAAA,MAAM,MAAM,GAAGC,kCAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IAC7D,MAAM,UAAU,GAAG,UAAU,KAAK,MAAM,GAAGC,sBAAU,CAAC,MAAM,EAAE,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS,CAAC;IAE5F,IAAI,QAAQ,EAAE;A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GAAG,KAAK,EAAqB,KAAI;AAC5F,IAAA,MAAM,UAAU,GAAGF,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AAEvG,IAAA,QACEV,cAAA,CAACa,0BAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/Bb,cAAA,CAACc,+BAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,+BAAe;AACxB,IAAA,aAAa,EAAEC,0BAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Button';
|
|
2
|
-
import {
|
|
2
|
+
import type { FC, SVGProps } from 'react';
|
|
3
3
|
import type { MenuItemProps as AriaMenuItemProps, MenuProps as AriaMenuProps, MenuTriggerProps as AriaMenuTriggerProps, PopoverProps as AriaPopoverProps, SeparatorProps as AriaSeparatorProps } from 'react-aria-components';
|
|
4
4
|
interface DropdownItemProps extends AriaMenuItemProps {
|
|
5
5
|
/** The label of the item to be displayed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"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AG,IAAI,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAYD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;8DAnBoD,iBAAiB;qBAnD1D,oBAAoB;WAjB9B,CAAC,SAAS,MAAM,2CAA2C,iBAAiB,CAAC,CAAC,CAAC;;;iIA3ElG,iBAAiB;uBAiHc,kBAAkB;uEAgBmD,uBAAuB;CA0C7H,CAAC"}
|
|
@@ -1,48 +1,22 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { DotsVertical,
|
|
2
|
+
import { DotsVertical, ChevronRight } from '@flipdish/ui-icons';
|
|
3
3
|
import { Avatar } from '@flipdish/ui-library/components/atoms/Avatar';
|
|
4
4
|
import { Button } from '@flipdish/ui-library/components/atoms/Button';
|
|
5
|
-
import { CheckboxBase } from '@flipdish/ui-library/components/atoms/Checkbox';
|
|
6
|
-
import { RadioButtonBase } from '@flipdish/ui-library/components/atoms/RadioButton';
|
|
7
|
-
import { ToggleBase } from '@flipdish/ui-library/components/atoms/Toggle';
|
|
8
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
9
|
-
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider
|
|
10
|
-
import { useCallback } from 'react';
|
|
6
|
+
import { useResolvedTestId, useTestIdPrefix, joinTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
11
7
|
import { Header, MenuSection, Separator, MenuItem, Menu, MenuTrigger } from 'react-aria-components';
|
|
12
8
|
import { ScrollClosingPopover } from '../../__internal__/popover/ScrollClosingPopover.js';
|
|
9
|
+
import { DropdownSelectionIndicator } from './components/DropdownSelectionIndicator.js';
|
|
10
|
+
import { dropdownItemSegment } from './utilities/dropdown.utils.js';
|
|
13
11
|
|
|
14
12
|
const DropdownItem = ({ label, children, addon, icon: Icon, avatarUrl, unstyled, selectionIndicator = 'checkmark', 'data-testid': dataTestId, ...props }) => {
|
|
15
13
|
const prefix = useTestIdPrefix();
|
|
16
|
-
const
|
|
17
|
-
if (props.id !== undefined)
|
|
18
|
-
return slugifyTestId(String(props.id));
|
|
19
|
-
if (typeof label === 'string')
|
|
20
|
-
return slugifyTestId(label);
|
|
21
|
-
if (typeof children === 'string')
|
|
22
|
-
return slugifyTestId(children);
|
|
23
|
-
return 'item';
|
|
24
|
-
};
|
|
25
|
-
const idPart = resolveIdPart();
|
|
14
|
+
const idPart = dropdownItemSegment(props.id, label, children);
|
|
26
15
|
const itemTestId = dataTestId ?? (prefix ? joinTestId(prefix, `item-${idPart}`) : undefined);
|
|
27
|
-
const SelectionIndicator = useCallback((state) => {
|
|
28
|
-
if (selectionIndicator === 'checkmark') {
|
|
29
|
-
return (jsx(Check, { "aria-hidden": "true", className: cx('size-4 shrink-0 stroke-[2.25px] text-fg-brand-primary', !state.isSelected && 'invisible', state.className) }));
|
|
30
|
-
}
|
|
31
|
-
if (selectionIndicator === 'checkbox') {
|
|
32
|
-
return (jsx(CheckboxBase, { isSelected: state.isSelected && !state.hasSubmenu, isIndeterminate: state.isSelected && state.hasSubmenu, size: "sm", className: cx('shrink-0', state.className) }));
|
|
33
|
-
}
|
|
34
|
-
if (selectionIndicator === 'radio') {
|
|
35
|
-
return jsx(RadioButtonBase, { isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
36
|
-
}
|
|
37
|
-
if (selectionIndicator === 'toggle') {
|
|
38
|
-
return jsx(ToggleBase, { slim: true, size: "sm", isSelected: state.isSelected, className: cx('shrink-0', state.className) });
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}, [selectionIndicator]);
|
|
42
16
|
if (unstyled) {
|
|
43
17
|
return jsx(MenuItem, { id: label, textValue: label, "data-testid": itemTestId, ...props });
|
|
44
18
|
}
|
|
45
|
-
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && jsx(
|
|
19
|
+
return (jsx(MenuItem, { ...props, "data-testid": itemTestId, className: (state) => cx('group block cursor-pointer px-1.5 py-px outline-hidden', state.isDisabled && 'cursor-not-allowed opacity-50', typeof props.className === 'function' ? props.className(state) : props.className), children: (state) => (jsxs("div", { className: cx('relative flex items-center rounded-md px-2.5 py-2 outline-focus-ring transition duration-100 ease-linear', !state.isDisabled && 'group-hover:bg-primary_hover', state.isFocused && 'bg-primary_hover', state.isFocusVisible && 'outline-2 -outline-offset-2', state.hasSubmenu && 'pr-1.5'), children: [state.selectionMode !== 'none' && !avatarUrl && !Icon && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "mr-2" })), avatarUrl && (jsx("div", { className: "mr-2 flex size-4 items-center justify-center", children: jsx(Avatar, { "aria-hidden": "true", size: "xs", src: avatarUrl, alt: label, className: "size-5" }) })), Icon && jsx(Icon, { "aria-hidden": "true", className: "mr-2 size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" }), jsx("span", { className: cx('grow truncate text-sm font-semibold text-secondary', state.isFocused && 'text-secondary_hover'), children: label || (typeof children === 'function' ? children(state) : children) }), addon && jsx("span", { className: "ml-1 shrink-0 pr-1 text-xs font-medium text-quaternary", children: addon }), state.selectionMode !== 'none' && (avatarUrl || Icon) && (jsx(DropdownSelectionIndicator, { selectionIndicator: selectionIndicator, isSelected: state.isSelected, hasSubmenu: state.hasSubmenu, className: "ml-1" })), state.hasSubmenu && jsx(ChevronRight, { "aria-hidden": "true", className: "ml-auto size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] })) }));
|
|
46
20
|
};
|
|
47
21
|
const DropdownMenu = ({ 'data-testid': dataTestId, ...props }) => {
|
|
48
22
|
const prefix = useTestIdPrefix();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/molecules/Dropdown/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaMenuItem","_jsxs","AriaMenu","AriaSeparator","AriaMenuTrigger","AriaMenuSection","AriaHeader"],"mappings":";;;;;;;;;;;AA4CA,MAAM,YAAY,GAAG,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,KAAK,EACL,IAAI,EAAE,IAAI,EACV,SAAS,EACT,QAAQ,EACR,kBAAkB,GAAG,WAAW,EAChC,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACU,KAAI;AACtB,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;AAChC,IAAA,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC;IAC7D,MAAM,UAAU,GAAG,UAAU,KAAK,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA,KAAA,EAAQ,MAAM,CAAA,CAAE,CAAC,GAAG,SAAS,CAAC;IAE5F,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAOA,GAAA,CAACC,QAAY,EAAA,EAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAA,aAAA,EAAe,UAAU,EAAA,GAAM,KAAK,GAAI;IAC1F;A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,QACEA,GAAA,CAAC,cAAc,EAAA,EAAC,KAAK,EAAE,UAAU,EAAA,QAAA,EAC/BA,GAAA,CAACK,WAAe,OAAK,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB,EAAA,CACzC;AAErB,CAAC;AAED;;;;;;;;AAQG;AACI,MAAM,QAAQ,GAAG;AACtB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,eAAe;AACxB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAEC,WAAe;AACxB,IAAA,aAAa,EAAEC,MAAU;AACzB,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,SAAS,EAAE,iBAAiB;AAC5B,IAAA,UAAU,EAAE,kBAAkB;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Chooses the test-id segment for a dropdown item.
|
|
7
|
+
*
|
|
8
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
9
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
10
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
11
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
12
|
+
*/
|
|
13
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
14
|
+
if (id !== undefined)
|
|
15
|
+
return testIdUtils.slugifyTestId(String(id));
|
|
16
|
+
if (typeof label === 'string')
|
|
17
|
+
return testIdUtils.slugifyTestId(label);
|
|
18
|
+
if (typeof children === 'string')
|
|
19
|
+
return testIdUtils.slugifyTestId(children);
|
|
20
|
+
return 'item';
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.dropdownItemSegment = dropdownItemSegment;
|
|
24
|
+
//# sourceMappingURL=dropdown.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.cjs","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":["slugifyTestId"],"mappings":";;;;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAOA,yBAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAOA,yBAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chooses the test-id segment for a dropdown item.
|
|
3
|
+
*
|
|
4
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
5
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
6
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
7
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
8
|
+
*/
|
|
9
|
+
export declare const dropdownItemSegment: (id: string | number | undefined, label: string | undefined, children: unknown) => string;
|
|
10
|
+
//# sourceMappingURL=dropdown.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,OAAO,KAAG,MAKnH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { slugifyTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Chooses the test-id segment for a dropdown item.
|
|
5
|
+
*
|
|
6
|
+
* @param id The item's `id`, when one was set. `0` counts; only a missing id is skipped.
|
|
7
|
+
* @param label The visible label. Used when `id` is missing and the label is text.
|
|
8
|
+
* @param children The item's children. Used when they are a string and neither `id` nor a text label is set.
|
|
9
|
+
* @returns A slug of the first of those that is set, or `item` when none is.
|
|
10
|
+
*/
|
|
11
|
+
const dropdownItemSegment = (id, label, children) => {
|
|
12
|
+
if (id !== undefined)
|
|
13
|
+
return slugifyTestId(String(id));
|
|
14
|
+
if (typeof label === 'string')
|
|
15
|
+
return slugifyTestId(label);
|
|
16
|
+
if (typeof children === 'string')
|
|
17
|
+
return slugifyTestId(children);
|
|
18
|
+
return 'item';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { dropdownItemSegment };
|
|
22
|
+
//# sourceMappingURL=dropdown.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown.utils.js","sources":["../../../../../src/components/molecules/Dropdown/utilities/dropdown.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;AAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAA+B,EAAE,KAAyB,EAAE,QAAiB,KAAY;IAC3H,IAAI,EAAE,KAAK,SAAS;AAAE,QAAA,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,KAAK,CAAC;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ;AAAE,QAAA,OAAO,aAAa,CAAC,QAAQ,CAAC;AAChE,IAAA,OAAO,MAAM;AACf;;"}
|