@pixum/combobox 5.10.4-alpha.24 → 5.10.4-alpha.7
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/CHANGELOG.md +730 -0
- package/lib/ComboBox.d.ts +6 -28
- package/lib/ComboBox.js +78 -177
- package/lib/ComboBox.js.map +1 -1
- package/lib/hooks/index.d.ts +0 -2
- package/lib/hooks/index.js +0 -2
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useIsDesktopScreenWidth.d.ts +0 -5
- package/lib/hooks/useIsDesktopScreenWidth.js +24 -34
- package/lib/hooks/useIsDesktopScreenWidth.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/partials/ComboBoxOptions.d.ts +4 -15
- package/lib/partials/ComboBoxOptions.js +21 -25
- package/lib/partials/ComboBoxOptions.js.map +1 -1
- package/lib/partials/ComboBoxOptionsItems.d.ts +17 -32
- package/lib/partials/ComboBoxOptionsItems.js +14 -46
- package/lib/partials/ComboBoxOptionsItems.js.map +1 -1
- package/lib/partials/ComboBoxOptionsSlot.d.ts +16 -17
- package/lib/partials/ComboBoxOptionsSlot.js +11 -26
- package/lib/partials/ComboBoxOptionsSlot.js.map +1 -1
- package/lib/partials/index.d.ts +1 -2
- package/lib/partials/index.js +1 -2
- package/lib/partials/index.js.map +1 -1
- package/lib/styles.css +1 -1
- package/lib/types.d.ts +51 -122
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +2 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +8 -8
- package/lib/ComboBox.module.css +0 -1
- package/lib/hooks/useComboBox.d.ts +0 -60
- package/lib/hooks/useComboBox.js +0 -226
- package/lib/hooks/useComboBox.js.map +0 -1
- package/lib/hooks/useComboBoxFocus.d.ts +0 -35
- package/lib/hooks/useComboBoxFocus.js +0 -49
- package/lib/hooks/useComboBoxFocus.js.map +0 -1
- package/lib/partials/ComboBoxNoResults.d.ts +0 -14
- package/lib/partials/ComboBoxNoResults.js +0 -18
- package/lib/partials/ComboBoxNoResults.js.map +0 -1
- package/lib/partials/ComboBoxOptionsGroup.d.ts +0 -15
- package/lib/partials/ComboBoxOptionsGroup.js +0 -31
- package/lib/partials/ComboBoxOptionsGroup.js.map +0 -1
- package/lib/utils/options.d.ts +0 -77
- package/lib/utils/options.js +0 -145
- package/lib/utils/options.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxOptions.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ComboBoxOptions.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,cAAc,EACd,WAAW,EACX,aAAa,GACQ;IACrB,MAAM,SAAS,GAAG,uBAAuB,EAAE,CAAA;IAC3C,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAEhD,SAAS,CAAC,GAAG,EAAE;QACb,8DAA8D;QAC9D,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE;YACzC,sBAAsB,CAAC,SAAS,CAAC,CAAA;QACnC,CAAC,CAAC,CAAA;QAEF,OAAO,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;IAE/B,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,8BAA8B,mBAAe,MAAM,aAChE,mBAAmB,CAAC,CAAC,CAAC,CACrB,KAAC,oBAAoB,IACnB,KAAK,EAAE,OAAO,EACd,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,GACxB,CACH,CAAC,CAAC,CAAC,CACF,4BACG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CACxC,KAAC,4BAA4B,IAE3B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,IALnB,2BAA2B,KAAK,EAAE,CAMvC,CACH,CAAC,GACD,CACJ,EACA,aAAa,IAAI,CAChB,cAAK,SAAS,EAAC,wCAAwC,YACpD,aAAa,GACV,CACP,IACI,CACR,CAAA;AACH,CAAC;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -1,39 +1,24 @@
|
|
|
1
1
|
import { LeadingType } from '@pixum/menu-item';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import type { ComboBoxOptionItemProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the ComboBoxOptionsItems component
|
|
5
|
+
*/
|
|
6
|
+
interface ComboBoxOptionsItemsProps {
|
|
7
|
+
/** Array of option items to display */
|
|
8
|
+
items: ComboBoxOptionItemProps[];
|
|
9
|
+
/** Currently selected option value */
|
|
10
|
+
selectedOption?: string;
|
|
11
|
+
/** Callback fired when an option is clicked */
|
|
12
|
+
onClick?: (value: string) => void;
|
|
13
|
+
/** Type of leading element to display (icon, avatar, etc.) */
|
|
11
14
|
leadingType?: LeadingType;
|
|
12
|
-
/** Called with the value of the clicked option. */
|
|
13
|
-
onOptionClick: (value: string) => void;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* The options are deliberately not focusable: the focus stays in the input
|
|
19
|
-
* field and the highlight is driven by `aria-activedescendant`. Checkbox
|
|
20
|
-
* options are ordinary options with `aria-selected` - inside a listbox that is
|
|
21
|
-
* the state screen readers announce, and it keeps mouse and keyboard selection
|
|
22
|
-
* on exactly the same code path.
|
|
23
|
-
*
|
|
24
|
-
* An option is a `MenuItemProps` object, so everything except the ComboBox
|
|
25
|
-
* specific `key` and `disabled` is spread onto the `MenuItem` unchanged.
|
|
26
|
-
* Consumers that pass further MenuItem props keep working without the ComboBox
|
|
27
|
-
* having to know about them; only `selected`, `tabIndex` and the keyboard
|
|
28
|
-
* handling are owned by the ComboBox and therefore not overridable.
|
|
29
|
-
*
|
|
30
|
-
* Styling hooks: every option carries its state as a data attribute
|
|
31
|
-
* (`data-selected`, `data-active`, `data-disabled`), so consumers can style
|
|
32
|
-
* options without knowing the hashed module class names. The selection state is
|
|
33
|
-
* left to `MenuItem` itself - the component does not add a `selected` class of
|
|
34
|
-
* its own, which would be impossible to override from the outside.
|
|
17
|
+
* ComboBoxOptionsItems component that renders individual menu items.
|
|
18
|
+
* Handles click events and displays selected state for each option.
|
|
35
19
|
*
|
|
36
20
|
* @param props - The props for the ComboBoxOptionsItems component
|
|
37
|
-
* @returns A list of
|
|
21
|
+
* @returns A list of clickable menu items
|
|
38
22
|
*/
|
|
39
|
-
export declare function ComboBoxOptionsItems({
|
|
23
|
+
export declare function ComboBoxOptionsItems({ items, selectedOption, onClick, leadingType, }: ComboBoxOptionsItemsProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
@@ -1,56 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import MenuItem
|
|
2
|
+
import MenuItem from '@pixum/menu-item';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import { toMenuItemProps } from '../utils';
|
|
5
|
-
import styles from '../ComboBox.module.css';
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* The options are deliberately not focusable: the focus stays in the input
|
|
10
|
-
* field and the highlight is driven by `aria-activedescendant`. Checkbox
|
|
11
|
-
* options are ordinary options with `aria-selected` - inside a listbox that is
|
|
12
|
-
* the state screen readers announce, and it keeps mouse and keyboard selection
|
|
13
|
-
* on exactly the same code path.
|
|
14
|
-
*
|
|
15
|
-
* An option is a `MenuItemProps` object, so everything except the ComboBox
|
|
16
|
-
* specific `key` and `disabled` is spread onto the `MenuItem` unchanged.
|
|
17
|
-
* Consumers that pass further MenuItem props keep working without the ComboBox
|
|
18
|
-
* having to know about them; only `selected`, `tabIndex` and the keyboard
|
|
19
|
-
* handling are owned by the ComboBox and therefore not overridable.
|
|
20
|
-
*
|
|
21
|
-
* Styling hooks: every option carries its state as a data attribute
|
|
22
|
-
* (`data-selected`, `data-active`, `data-disabled`), so consumers can style
|
|
23
|
-
* options without knowing the hashed module class names. The selection state is
|
|
24
|
-
* left to `MenuItem` itself - the component does not add a `selected` class of
|
|
25
|
-
* its own, which would be impossible to override from the outside.
|
|
5
|
+
* ComboBoxOptionsItems component that renders individual menu items.
|
|
6
|
+
* Handles click events and displays selected state for each option.
|
|
26
7
|
*
|
|
27
8
|
* @param props - The props for the ComboBoxOptionsItems component
|
|
28
|
-
* @returns A list of
|
|
9
|
+
* @returns A list of clickable menu items
|
|
29
10
|
*/
|
|
30
|
-
export function ComboBoxOptionsItems({
|
|
31
|
-
|
|
32
|
-
return (_jsx(_Fragment, { children: options.map(({ item, id, value, disabled }) => {
|
|
11
|
+
export function ComboBoxOptionsItems({ items, selectedOption, onClick, leadingType, }) {
|
|
12
|
+
return (_jsx(_Fragment, { children: items.map((item) => {
|
|
33
13
|
var _a;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, onPointerDown: event => event.stopPropagation(),
|
|
43
|
-
// No preventDefault on touchstart, scrolling in the sheet must work.
|
|
44
|
-
onTouchStart: event => event.stopPropagation(), onClickCapture: event => {
|
|
45
|
-
event.stopPropagation();
|
|
46
|
-
if (disabled)
|
|
47
|
-
return;
|
|
48
|
-
onOptionClick(value);
|
|
49
|
-
}, children: _jsx(MenuItem, Object.assign({}, menuItemProps, { tabIndex: -1, disableKeyboardNav: true,
|
|
50
|
-
// A leading type set on the ComboBox wins over the option's own
|
|
51
|
-
// one: it is what makes multi select look like a checkbox list.
|
|
52
|
-
leadingProps: leadingType
|
|
53
|
-
? Object.assign(Object.assign({}, menuItemProps.leadingProps), { name: value, type: leadingType }) : menuItemProps.leadingProps, selected: isSelected })) }, (_a = item.key) !== null && _a !== void 0 ? _a : `combobox-item-wrapper-${id}`));
|
|
14
|
+
const itemText = item.text;
|
|
15
|
+
const isSelected = selectedOption === itemText;
|
|
16
|
+
return (_jsx("div", { className: "combobox__option-wrapper", role: "button", tabIndex: 0, onPointerDown: e => e.stopPropagation(), onTouchStart: e => e.stopPropagation(), onMouseDown: e => e.stopPropagation(), onClickCapture: e => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(itemText);
|
|
19
|
+
}, children: _jsx(MenuItem, { tabIndex: -1, className: clsx(isSelected && 'selected'), onMouseEnter: item.onMouseEnter, leadingProps: leadingType ? { name: itemText, type: leadingType } : undefined, selected: selectedOption === itemText, text: itemText, subtext: item.subtext, subItemProps: {
|
|
20
|
+
text: (_a = item.subItemProps) === null || _a === void 0 ? void 0 : _a.text,
|
|
21
|
+
} }) }, `combobox-item-wrapper-${itemText}`));
|
|
54
22
|
}) }));
|
|
55
23
|
}
|
|
56
24
|
//# sourceMappingURL=ComboBoxOptionsItems.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxOptionsItems.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsItems.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ComboBoxOptionsItems.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsItems.tsx"],"names":[],"mappings":";AAAA,OAAO,QAAyB,MAAM,kBAAkB,CAAA;AACxD,OAAO,IAAI,MAAM,MAAM,CAAA;AAiBvB;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,EACnC,KAAK,EACL,cAAc,EACd,OAAO,EACP,WAAW,GACe;IAC1B,OAAO,CACL,4BACG,KAAK,CAAC,GAAG,CAAC,CAAC,IAA6B,EAAE,EAAE;;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAA;YAC1B,MAAM,UAAU,GAAG,cAAc,KAAK,QAAQ,CAAA;YAE9C,OAAO,CACL,cAEE,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,EACX,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACvC,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACtC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EACrC,cAAc,EAAE,CAAC,CAAC,EAAE;oBAClB,CAAC,CAAC,eAAe,EAAE,CAAA;oBACnB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,QAAQ,CAAC,CAAA;gBACrB,CAAC,YAED,KAAC,QAAQ,IACP,QAAQ,EAAE,CAAC,CAAC,EACZ,SAAS,EAAE,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,EACzC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,YAAY,EACV,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,EAEjE,QAAQ,EAAE,cAAc,KAAK,QAAQ,EACrC,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,YAAY,EAAE;wBACZ,IAAI,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,IAAI;qBAC9B,GACD,IAzBG,yBAAyB,QAAQ,EAAE,CA0BpC,CACP,CAAA;QACH,CAAC,CAAC,GACD,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
export interface ComboBoxOptionsSlotProps {
|
|
4
|
+
/** The content to render inside the options slot */
|
|
4
5
|
children: ReactNode;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
className?: string;
|
|
7
|
+
role?: string;
|
|
8
|
+
tag?: 'div' | 'ul' | 'ol' | 'dl';
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
|
-
* Styled container for
|
|
11
|
+
* Styled container for optionsSlot content.
|
|
10
12
|
*
|
|
11
|
-
* Applies the standard ComboBox dropdown appearance
|
|
12
|
-
* border radius, box
|
|
13
|
-
* replicate it in every
|
|
14
|
-
* (`role`, `aria-*`, ...) is forwarded, because the slot content owns its own
|
|
15
|
-
* accessibility semantics.
|
|
13
|
+
* Applies the standard ComboBox dropdown appearance — white background,
|
|
14
|
+
* border, border-radius, box-shadow and top margin — so consumers don't
|
|
15
|
+
* have to replicate it in every optionsSlot implementation.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* navigation: content rendered here has to bring its own key handling.
|
|
17
|
+
* Use it as the outermost wrapper of your optionsSlot:
|
|
19
18
|
*
|
|
20
19
|
* ```tsx
|
|
21
20
|
* import ComboBox, { ComboBoxOptionsSlot } from '@pixum/combobox'
|
|
22
21
|
*
|
|
23
22
|
* <ComboBox
|
|
24
23
|
* optionsSlot={
|
|
25
|
-
* <ComboBoxOptionsSlot
|
|
24
|
+
* <ComboBoxOptionsSlot>
|
|
26
25
|
* <MyCustomOptionsList />
|
|
27
26
|
* </ComboBoxOptionsSlot>
|
|
28
27
|
* }
|
|
29
28
|
* />
|
|
30
29
|
* ```
|
|
31
30
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @returns A styled wrapper matching the ComboBox dropdown look
|
|
31
|
+
* @param children - The slot content to render inside the container
|
|
32
|
+
* @returns A styled wrapper div matching the ComboBox dropdown look
|
|
34
33
|
*/
|
|
35
|
-
export declare function ComboBoxOptionsSlot({ children, className, tag,
|
|
34
|
+
export declare function ComboBoxOptionsSlot({ children, className, role, tag, }: ComboBoxOptionsSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,47 +1,32 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import '../styles.css';
|
|
13
3
|
import Menu from '@pixum/menu';
|
|
14
4
|
import clsx from 'clsx';
|
|
15
|
-
import styles from '../ComboBox.module.css';
|
|
16
5
|
/**
|
|
17
|
-
* Styled container for
|
|
6
|
+
* Styled container for optionsSlot content.
|
|
18
7
|
*
|
|
19
|
-
* Applies the standard ComboBox dropdown appearance
|
|
20
|
-
* border radius, box
|
|
21
|
-
* replicate it in every
|
|
22
|
-
* (`role`, `aria-*`, ...) is forwarded, because the slot content owns its own
|
|
23
|
-
* accessibility semantics.
|
|
8
|
+
* Applies the standard ComboBox dropdown appearance — white background,
|
|
9
|
+
* border, border-radius, box-shadow and top margin — so consumers don't
|
|
10
|
+
* have to replicate it in every optionsSlot implementation.
|
|
24
11
|
*
|
|
25
|
-
*
|
|
26
|
-
* navigation: content rendered here has to bring its own key handling.
|
|
12
|
+
* Use it as the outermost wrapper of your optionsSlot:
|
|
27
13
|
*
|
|
28
14
|
* ```tsx
|
|
29
15
|
* import ComboBox, { ComboBoxOptionsSlot } from '@pixum/combobox'
|
|
30
16
|
*
|
|
31
17
|
* <ComboBox
|
|
32
18
|
* optionsSlot={
|
|
33
|
-
* <ComboBoxOptionsSlot
|
|
19
|
+
* <ComboBoxOptionsSlot>
|
|
34
20
|
* <MyCustomOptionsList />
|
|
35
21
|
* </ComboBoxOptionsSlot>
|
|
36
22
|
* }
|
|
37
23
|
* />
|
|
38
24
|
* ```
|
|
39
25
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns A styled wrapper matching the ComboBox dropdown look
|
|
26
|
+
* @param children - The slot content to render inside the container
|
|
27
|
+
* @returns A styled wrapper div matching the ComboBox dropdown look
|
|
42
28
|
*/
|
|
43
|
-
export function ComboBoxOptionsSlot(
|
|
44
|
-
|
|
45
|
-
return (_jsx(Menu, Object.assign({ tag: tag, className: clsx(styles.optionsSlot, className) }, rest, { children: children })));
|
|
29
|
+
export function ComboBoxOptionsSlot({ children, className = '', role = '', tag = 'ul', }) {
|
|
30
|
+
return (_jsx(Menu, { tag: tag, className: clsx(className, 'combobox__options-slot'), role: role, children: children }));
|
|
46
31
|
}
|
|
47
32
|
//# sourceMappingURL=ComboBoxOptionsSlot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComboBoxOptionsSlot.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsSlot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComboBoxOptionsSlot.js","sourceRoot":"","sources":["../../src/partials/ComboBoxOptionsSlot.tsx"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAA;AACtB,OAAO,IAAI,MAAM,aAAa,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AASvB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,IAAI,GAAG,EAAE,EACT,GAAG,GAAG,IAAI,GACe;IACzB,OAAO,CACL,KAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,wBAAwB,CAAC,EACpD,IAAI,EAAE,IAAI,YAET,QAAQ,GACJ,CACR,CAAA;AACH,CAAC"}
|
package/lib/partials/index.d.ts
CHANGED
package/lib/partials/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './ComboBoxOptions';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './ComboBoxOptionsWithGrouping';
|
|
3
3
|
export * from './ComboBoxOptionsItems';
|
|
4
4
|
export * from './ComboBoxOptionsSlot';
|
|
5
|
-
export * from './ComboBoxNoResults';
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/partials/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/partials/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
package/lib/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.combobox{position:relative;width:100%}.combobox .combobox--headline[class*=text--]+*{margin-top:var(--spacing)}.combobox .combobox--header,.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{position:relative}.combobox__bottom-sheet .combobox--header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2);width:100%}.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{display:flex;flex-direction:column;max-height:none;overflow:scroll;width:100%}.combobox__bottom-sheet ul.combobox__options-slot{margin:0;padding:0}.combobox .combobox__option-wrapper,.combobox__bottom-sheet .combobox__option-wrapper{touch-action:manipulation;-webkit-tap-highlight-color:transparent;cursor:pointer;-webkit-user-select:none;user-select:none}.combobox .combobox__options .combobox__sticky-header,.combobox__bottom-sheet .combobox__options .combobox__sticky-header{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:-webkit-sticky;position:sticky;top:0}.combobox__options .text--caption{color:var(--color-on-secondary)}.combobox .combobox__options .item-header,.combobox__bottom-sheet .combobox__options .item-header{display:flex;justify-content:space-between}.combobox .combobox__options .combobox__option-details,.combobox__bottom-sheet .combobox__options .combobox__option-details{background-color:var(--color-surface);bottom:0;padding-left:var(--spacing);padding-right:var(--spacing);position:-webkit-sticky;position:sticky}.combobox .combobox--no-results-text,.combobox__bottom-sheet .combobox--no-results-text{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.combobox .combobox__options,.combobox .combobox__options-slot{border-radius:12px;margin-top:var(--spacing);
|
|
1
|
+
.combobox{position:relative;width:100%}.combobox .combobox--headline[class*=text--]+*{margin-top:var(--spacing)}.combobox .combobox--header,.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{position:relative}.combobox__bottom-sheet .combobox--header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2);width:100%}.combobox .combobox__options,.combobox .combobox__options-slot,.combobox__bottom-sheet .combobox__options,.combobox__bottom-sheet .combobox__options-slot{display:flex;flex-direction:column;max-height:none;overflow:scroll;width:100%}.combobox__bottom-sheet ul.combobox__options-slot{margin:0;padding:0}.combobox .combobox__option-wrapper,.combobox__bottom-sheet .combobox__option-wrapper{touch-action:manipulation;-webkit-tap-highlight-color:transparent;cursor:pointer;-webkit-user-select:none;user-select:none}.combobox .combobox__options .combobox__sticky-header,.combobox__bottom-sheet .combobox__options .combobox__sticky-header{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:-webkit-sticky;position:sticky;top:0}.combobox__options .text--caption{color:var(--color-on-secondary)}.combobox .combobox__options .item-header,.combobox__bottom-sheet .combobox__options .item-header{display:flex;justify-content:space-between}.combobox .combobox__options .combobox__option-details,.combobox__bottom-sheet .combobox__options .combobox__option-details{background-color:var(--color-surface);bottom:0;padding-left:var(--spacing);padding-right:var(--spacing);position:-webkit-sticky;position:sticky}.combobox .combobox--no-results-text,.combobox__bottom-sheet .combobox--no-results-text{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.combobox .combobox__options,.combobox .combobox__options-slot{border-radius:12px;margin-top:var(--spacing);overflow:auto;position:absolute}}.combobox ul.combobox__options-slot{list-style:none;padding:0}.combobox .combobox__options-slot{margin-top:var(--spacing)}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,149 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { LeadingType, MenuItemProps } from '@pixum/menu-item';
|
|
2
|
+
import { ThemeType } from '@pixum/theme-provider';
|
|
3
|
+
import { InputModesType } from '@pixum/web-input';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Everything a `MenuItem` understands is accepted and forwarded unchanged -
|
|
8
|
-
* the ComboBox only adds `key` and `disabled` on top. That keeps existing
|
|
9
|
-
* consumers working: they pass their MenuItem props as they always did, and
|
|
10
|
-
* props the ComboBox does not know about still reach the `MenuItem`.
|
|
5
|
+
* Props for the ComboBoxOptions component
|
|
11
6
|
*/
|
|
12
|
-
export interface ComboBoxOptionItemProps extends MenuItemProps {
|
|
13
|
-
/** Unique key for the option item */
|
|
14
|
-
key?: string;
|
|
15
|
-
/** Disabled options are rendered, but skipped by mouse and keyboard. */
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/** Options are accepted either as a flat list or grouped by a group headline. */
|
|
19
|
-
export type ComboBoxOptionsInput = ComboBoxOptionItemProps[] | Record<string, ComboBoxOptionItemProps[]>;
|
|
20
|
-
/**
|
|
21
|
-
* An option after normalisation. Flat and grouped options are reduced to this
|
|
22
|
-
* shape once, so keyboard navigation, rendering and ARIA ids all work on the
|
|
23
|
-
* very same list in the very same order.
|
|
24
|
-
*/
|
|
25
|
-
export interface ComboBoxOption {
|
|
26
|
-
/** The original option as handed in by the consumer. */
|
|
27
|
-
item: ComboBoxOptionItemProps;
|
|
28
|
-
/**
|
|
29
|
-
* Stable value of the option, reported by `onOptionItemClick` and compared
|
|
30
|
-
* against `value`. Resolved by `resolveOptionValue`: the option's `text` when
|
|
31
|
-
* it is a string, otherwise `key`, otherwise the render index.
|
|
32
|
-
*/
|
|
33
|
-
value: string;
|
|
34
|
-
/** Position in render order. Drives the DOM id and the keyboard navigation. */
|
|
35
|
-
index: number;
|
|
36
|
-
/** DOM id, referenced by `aria-activedescendant`. */
|
|
37
|
-
id: string;
|
|
38
|
-
/** Group headline the option belongs to, `undefined` for flat lists. */
|
|
39
|
-
group?: string;
|
|
40
|
-
/** Whether the option can be activated. */
|
|
41
|
-
disabled: boolean;
|
|
42
|
-
}
|
|
43
|
-
/** Options of one render group, produced by `groupOptions`. */
|
|
44
|
-
export interface ComboBoxOptionGroup {
|
|
45
|
-
/** Group headline, `undefined` for flat lists. */
|
|
46
|
-
group?: string;
|
|
47
|
-
/** Options of this group, still carrying their global render index. */
|
|
48
|
-
options: ComboBoxOption[];
|
|
49
|
-
}
|
|
50
|
-
/** ARIA props for the element that owns the `combobox` role. */
|
|
51
|
-
export interface ComboBoxAriaProps {
|
|
52
|
-
role: 'combobox';
|
|
53
|
-
'aria-expanded': boolean;
|
|
54
|
-
'aria-haspopup': 'listbox';
|
|
55
|
-
'aria-controls': string | undefined;
|
|
56
|
-
'aria-activedescendant': string | undefined;
|
|
57
|
-
'aria-autocomplete': 'list' | 'none';
|
|
58
|
-
}
|
|
59
|
-
/** ARIA props for the element that owns the `listbox` role. */
|
|
60
|
-
export interface ListboxAriaProps {
|
|
61
|
-
role: 'listbox';
|
|
62
|
-
id: string;
|
|
63
|
-
/** Only set for multi select; single select listboxes omit it. */
|
|
64
|
-
'aria-multiselectable'?: boolean;
|
|
65
|
-
}
|
|
66
|
-
/** Props of the rendered options list. */
|
|
67
7
|
export interface ComboBoxOptionsProps {
|
|
68
|
-
/**
|
|
69
|
-
options:
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
activeOptionId?: string;
|
|
76
|
-
/** Type of the leading element, e.g. a checkbox for multi select. */
|
|
8
|
+
/** Options to display in the combobox, can be grouped or a flat array */
|
|
9
|
+
options: Record<string, ComboBoxOptionItemProps[]> | ComboBoxOptionItemProps[];
|
|
10
|
+
/** Currently selected option value */
|
|
11
|
+
selectedOption?: string;
|
|
12
|
+
/** Callback fired when an option is clicked */
|
|
13
|
+
onClick?: (value: string) => void;
|
|
14
|
+
/** Type of leading element to display (icon, avatar, etc.) */
|
|
77
15
|
leadingType?: LeadingType;
|
|
78
|
-
/** Additional details
|
|
16
|
+
/** Additional details to display below the options */
|
|
79
17
|
optionDetails?: React.ReactNode;
|
|
80
|
-
/** Called with the value of the clicked option. */
|
|
81
|
-
onOptionClick: (value: string) => void;
|
|
82
18
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Props for the ComboBox component
|
|
21
|
+
*/
|
|
22
|
+
export interface ComboBoxProps extends ComboBoxOptionsProps {
|
|
23
|
+
/** Additional CSS class name for the component */
|
|
86
24
|
className?: string;
|
|
87
|
-
/** Name attribute for the input field
|
|
25
|
+
/** Name attribute for the input field */
|
|
88
26
|
name?: string;
|
|
89
|
-
/** Headline text displayed in
|
|
27
|
+
/** Headline text displayed in mobile bottom sheet */
|
|
90
28
|
headline?: string;
|
|
91
|
-
/** Helper text displayed below the input
|
|
29
|
+
/** Helper text displayed below the input */
|
|
92
30
|
helperText?: string;
|
|
93
|
-
/**
|
|
31
|
+
/** ID attribute for the input field */
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Label text for the input field */
|
|
94
34
|
label?: string;
|
|
95
|
-
/**
|
|
96
|
-
options: ComboBoxOptionsInput;
|
|
97
|
-
/** Whether the popover / bottom sheet is currently open. */
|
|
35
|
+
/** Whether the dropdown/bottom sheet is currently open */
|
|
98
36
|
isOpen: boolean;
|
|
99
|
-
/** State setter
|
|
37
|
+
/** State setter function to control open/close state */
|
|
100
38
|
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
101
|
-
/**
|
|
102
|
-
* Selected value: a string for single select, an array of strings when
|
|
103
|
-
* `multiple` is set.
|
|
104
|
-
*/
|
|
105
|
-
value?: string | string[];
|
|
106
|
-
/** Allows selecting several options; combine with a checkbox `leadingType`. */
|
|
107
|
-
multiple?: boolean;
|
|
108
|
-
/** Called with the value of the selected (in multi select: toggled) option. */
|
|
109
|
-
onOptionItemClick?: (value: string) => void;
|
|
110
|
-
/** Called when the search input value changes. */
|
|
39
|
+
/** Callback fired when the search input value changes */
|
|
111
40
|
onChange?: (value: string) => void;
|
|
112
|
-
/**
|
|
41
|
+
/** Callback fired when an option item is clicked */
|
|
42
|
+
onOptionItemClick?: (value: string) => void;
|
|
43
|
+
/** Callback fired when user clicks outside the component */
|
|
113
44
|
onOutsideClick?: () => void;
|
|
114
|
-
/**
|
|
45
|
+
/** Callback fired when the input field is clicked */
|
|
115
46
|
onClick?: () => void;
|
|
116
|
-
/**
|
|
47
|
+
/** Callback fired when the bottom sheet is closed */
|
|
117
48
|
onSheetClose?: () => void;
|
|
118
|
-
/** Placeholder text for the input field
|
|
49
|
+
/** Placeholder text for the input field */
|
|
119
50
|
placeholder?: string;
|
|
120
|
-
/** Search pattern for input validation
|
|
51
|
+
/** Search pattern/regex for input validation */
|
|
121
52
|
searchPattern?: string;
|
|
122
|
-
/**
|
|
53
|
+
/** Current value of the combobox */
|
|
54
|
+
value?: string;
|
|
55
|
+
/** Text to display when no results are found */
|
|
123
56
|
noResultsText?: string;
|
|
124
|
-
/** Input mode for mobile keyboards. */
|
|
57
|
+
/** Input mode for mobile keyboards (text, numeric, etc.) */
|
|
125
58
|
inputMode?: InputModesType;
|
|
126
|
-
/**
|
|
59
|
+
/** Whether to show the search input field */
|
|
127
60
|
withSearch?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
openOnEnter?: boolean;
|
|
130
|
-
/** Whether the combobox is disabled. */
|
|
61
|
+
/** Whether the combobox is disabled */
|
|
131
62
|
disabled?: boolean;
|
|
132
|
-
/**
|
|
63
|
+
/** Show disabled style + horizontal shimmer animation while content is loading */
|
|
133
64
|
loading?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
leadingType?: LeadingType;
|
|
136
|
-
/** Additional details rendered below the options. */
|
|
137
|
-
optionDetails?: React.ReactNode;
|
|
138
|
-
/** Theme configuration for the component. */
|
|
65
|
+
/** Theme configuration for the component */
|
|
139
66
|
theme?: ThemeType;
|
|
140
|
-
/** Custom slot that replaces the standard options
|
|
67
|
+
/** Custom slot that replaces the standard options/no-results block */
|
|
141
68
|
optionsSlot?: React.ReactNode;
|
|
142
|
-
/** Icon element displayed at the leading side of the trigger input
|
|
143
|
-
leadingIcon?: React.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
69
|
+
/** Icon element displayed at the leading (left) side of the trigger input */
|
|
70
|
+
leadingIcon?: React.ReactNode;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Props for individual ComboBox option items
|
|
74
|
+
*/
|
|
75
|
+
export interface ComboBoxOptionItemProps extends MenuItemProps {
|
|
76
|
+
/** Unique key for the option item */
|
|
77
|
+
key?: string;
|
|
149
78
|
}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './calculateListMaxHeight';
|
|
2
|
+
export * from './scrollOptionToViewport';
|
package/lib/utils/index.js
CHANGED
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixum/combobox",
|
|
3
|
-
"version": "5.10.4-alpha.
|
|
3
|
+
"version": "5.10.4-alpha.7+9ee03b937",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@pixum/bottom-sheet": "
|
|
9
|
-
"@pixum/menu": "
|
|
10
|
-
"@pixum/menu-item": "
|
|
11
|
-
"@pixum/text": "
|
|
12
|
-
"@pixum/theme-provider": "
|
|
13
|
-
"@pixum/web-input": "2.
|
|
8
|
+
"@pixum/bottom-sheet": "3.0.18",
|
|
9
|
+
"@pixum/menu": "3.0.14",
|
|
10
|
+
"@pixum/menu-item": "2.0.14",
|
|
11
|
+
"@pixum/text": "2.0.20",
|
|
12
|
+
"@pixum/theme-provider": "4.2.20",
|
|
13
|
+
"@pixum/web-input": "2.1.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"lib"
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"sideEffects": [
|
|
19
19
|
"*.css"
|
|
20
20
|
],
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "9ee03b937d4faf9771fdf0c1efb0e4defbc3ae78"
|
|
22
22
|
}
|
package/lib/ComboBox.module.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.comboBox{position:relative;width:100%}.comboBox .headline[class*=text--]+*{margin-top:var(--spacing)}:is(.comboBox,.sheet) :is(.panel,.optionsSlot,.header){position:relative;width:100%}:is(.comboBox,.sheet) .panel{display:flex;flex-direction:column;max-height:inherit;overflow:hidden}:is(.sheet) .panel{box-shadow:none}:is(.comboBox,.sheet) :is(.options,.optionsSlot){display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;scroll-padding-block-start:var(--combobox-sticky-offset,2.75rem)}.sheet .header{align-items:flex-start;height:auto;margin:var(--spacing-5) auto var(--spacing-2);padding:0 var(--spacing-2)}:is(.comboBox,.sheet) ul.optionsSlot{list-style:none;padding:0}:is(.comboBox,.sheet) .option{cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none}:is(.comboBox,.sheet) .optionCheckbox[data-selected=true] :global(.menu-item){background-color:initial}:is(.comboBox,.sheet) .option.optionActive :global(.menu-item),:is(.comboBox,.sheet) .optionCheckbox.optionActive :global(.menu-item){background-color:var(--color-canvas--hover)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item){background-color:var(--color-accent);color:var(--color-surface)}:is(.comboBox,.sheet) .option[aria-disabled=true]{cursor:not-allowed;opacity:.5}@media (forced-colors:active){:is(.comboBox,.sheet) .option.optionActive :global(.menu-item){outline:2px solid Highlight;outline-offset:-2px}}:is(.comboBox,.sheet) .stickyHeader{background-color:var(--color-surface);border-bottom:1px solid var(--color-dim);padding:var(--spacing-1_25) var(--spacing-2);position:-webkit-sticky;position:sticky;top:0}:is(.comboBox,.sheet) .options :global(.text--caption){color:var(--color-on-secondary)}:is(.comboBox,.sheet) .option[data-selected=true]:not(.optionCheckbox) :global(.menu-item .text--caption){color:var(--color-surface)}:is(.comboBox,.sheet) .options :global(.item-header){display:flex;justify-content:space-between}:is(.comboBox,.sheet) .optionDetails{background-color:var(--color-surface);border-top:1px solid var(--color-dim);flex:0 0 auto;padding:var(--spacing-1_25) var(--spacing)}:is(.comboBox,.sheet) .noResults{padding:var(--spacing-2) var(--spacing);text-align:center}@media screen and (min-width:960px){.comboBox :is(.panel,.optionsSlot){border-radius:var(--border-radius-3);margin-top:var(--spacing);max-height:330px;position:absolute}}
|