@acusti/dropdown 0.38.7 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,74 +5,74 @@
5
5
  * @flow
6
6
  */
7
7
 
8
- import * as React from 'react';
8
+ import * as React from "react";
9
9
  declare type ChildrenTuple = [React.Node, React.Node];
10
10
  export type Item = {|
11
- element: HTMLElement | null,
12
- event: Event | SyntheticEvent<HTMLElement>,
13
- label: string,
14
- value: string,
11
+ element: HTMLElement | null,
12
+ event: Event | SyntheticEvent<HTMLElement>,
13
+ label: string,
14
+ value: string,
15
15
  |};
16
16
  export type Props = {|
17
- /**
18
- * Boolean indicating if the user can submit a value not already in the
19
- * dropdown.
20
- */
21
- allowCreate?: boolean,
17
+ /**
18
+ * Boolean indicating if the user can submit a value not already in the
19
+ * dropdown.
20
+ */
21
+ allowCreate?: boolean,
22
22
 
23
- /**
24
- * Boolean indicating if the user can submit an empty value (i.e. clear
25
- * the value). Defaults to true.
26
- */
27
- allowEmpty?: boolean,
23
+ /**
24
+ * Boolean indicating if the user can submit an empty value (i.e. clear
25
+ * the value). Defaults to true.
26
+ */
27
+ allowEmpty?: boolean,
28
28
 
29
- /**
30
- * Can take a single React element or exactly two renderable children.
31
- */
32
- children: React.Node | ChildrenTuple,
33
- className?: string,
34
- disabled?: boolean,
29
+ /**
30
+ * Can take a single React element or exactly two renderable children.
31
+ */
32
+ children: React.Node | ChildrenTuple,
33
+ className?: string,
34
+ disabled?: boolean,
35
35
 
36
- /**
37
- * Group identifier string links dropdowns together into a menu
38
- * (like macOS top menubar).
39
- */
40
- group?: string,
41
- hasItems?: boolean,
42
- isOpenOnMount?: boolean,
43
- isSearchable?: boolean,
44
- keepOpenOnSubmit?: boolean,
45
- label?: string,
36
+ /**
37
+ * Group identifier string links dropdowns together into a menu
38
+ * (like macOS top menubar).
39
+ */
40
+ group?: string,
41
+ hasItems?: boolean,
42
+ isOpenOnMount?: boolean,
43
+ isSearchable?: boolean,
44
+ keepOpenOnSubmit?: boolean,
45
+ label?: string,
46
46
 
47
- /**
48
- * Only usable in conjunction with {isSearchable: true}.
49
- * Used as search input’s name.
50
- */
51
- name?: string,
52
- onClick?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
53
- onClose?: () => mixed,
54
- onMouseDown?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
55
- onMouseUp?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
56
- onOpen?: () => mixed,
57
- onSubmitItem?: (payload: Item) => void,
47
+ /**
48
+ * Only usable in conjunction with {isSearchable: true}.
49
+ * Used as search input’s name.
50
+ */
51
+ name?: string,
52
+ onClick?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
53
+ onClose?: () => mixed,
54
+ onMouseDown?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
55
+ onMouseUp?: (event: SyntheticMouseEvent<HTMLElement>) => mixed,
56
+ onOpen?: () => mixed,
57
+ onSubmitItem?: (payload: Item) => void,
58
58
 
59
- /**
60
- * Only usable in conjunction with {isSearchable: true}.
61
- * Used as search input’s placeholder.
62
- */
63
- placeholder?: string,
64
- style?: {| [string]: string | number |},
59
+ /**
60
+ * Only usable in conjunction with {isSearchable: true}.
61
+ * Used as search input’s placeholder.
62
+ */
63
+ placeholder?: string,
64
+ style?: {| [string]: string | number |},
65
65
 
66
- /**
67
- * Only usable in conjunction with {isSearchable: true}.
68
- * Used as search input’s tabIndex.
69
- */
70
- tabIndex?: number,
66
+ /**
67
+ * Only usable in conjunction with {isSearchable: true}.
68
+ * Used as search input’s tabIndex.
69
+ */
70
+ tabIndex?: number,
71
71
 
72
- /**
73
- * Used as search input’s value if props.isSearchable === true
74
- * Used to determine if value has changed to avoid triggering onSubmitItem if not
75
- */
76
- value?: string,
72
+ /**
73
+ * Used as search input’s value if props.isSearchable === true
74
+ * Used to determine if value has changed to avoid triggering onSubmitItem if not
75
+ */
76
+ value?: string,
77
77
  |};
78
78
  declare export default function Dropdown(x: Props): React.Node;
@@ -8,26 +8,18 @@ afterEach(cleanup);
8
8
  describe('Dropdown.js', () => {
9
9
  it('renders its contents as a dropdown menu with an empty button to trigger it when it’s rendered with a single child', async () => {
10
10
  const user = userEvent.setup();
11
- render(
12
- React.createElement(
13
- Dropdown,
14
- null,
15
- React.createElement(
16
- 'ul',
17
- { 'data-testid': 'dropdown-list' },
18
- React.createElement('li', null, '0px'),
19
- React.createElement('li', null, '4px'),
20
- React.createElement('li', null, '9px'),
21
- React.createElement('li', null, '18px'),
22
- React.createElement('li', null, '36px'),
23
- React.createElement('li', null, '54px'),
24
- React.createElement('li', null, '72px'),
25
- React.createElement('li', null, '144px'),
26
- React.createElement('li', null, '167px'),
27
- React.createElement('li', null, '198px'),
28
- ),
29
- ),
30
- );
11
+ render(React.createElement(Dropdown, null,
12
+ React.createElement("ul", { "data-testid": "dropdown-list" },
13
+ React.createElement("li", null, "0px"),
14
+ React.createElement("li", null, "4px"),
15
+ React.createElement("li", null, "9px"),
16
+ React.createElement("li", null, "18px"),
17
+ React.createElement("li", null, "36px"),
18
+ React.createElement("li", null, "54px"),
19
+ React.createElement("li", null, "72px"),
20
+ React.createElement("li", null, "144px"),
21
+ React.createElement("li", null, "167px"),
22
+ React.createElement("li", null, "198px"))));
31
23
  const trigger = screen.getByRole('button');
32
24
  expect(trigger.innerHTML).toBe('');
33
25
  await user.click(trigger);
@@ -35,30 +27,22 @@ describe('Dropdown.js', () => {
35
27
  });
36
28
  it('renders the first child as a trigger and the second child as a dropdown when given two children', async () => {
37
29
  const user = userEvent.setup();
38
- render(
39
- React.createElement(
40
- Dropdown,
41
- null,
42
- 'File',
43
- React.createElement(
44
- 'ul',
45
- { 'data-testid': 'file-menu' },
46
- React.createElement('li', null, 'New Window'),
47
- React.createElement('li', null, 'New Private Window'),
48
- React.createElement('li', null, 'New Tab'),
49
- React.createElement('li', null, 'New Empty Tab Group'),
50
- React.createElement('li', null, 'Open File\u2026'),
51
- React.createElement('li', null, 'Open Location\u2026'),
52
- React.createElement('li', { className: 'separator' }),
53
- React.createElement('li', null, 'Close Window'),
54
- React.createElement('li', null, 'Close All Window'),
55
- React.createElement('li', null, 'Close Tab'),
56
- React.createElement('li', null, 'Save As\u2026'),
57
- React.createElement('li', { className: 'separator' }),
58
- React.createElement('li', null, 'Print\u2026'),
59
- ),
60
- ),
61
- );
30
+ render(React.createElement(Dropdown, null,
31
+ "File",
32
+ React.createElement("ul", { "data-testid": "file-menu" },
33
+ React.createElement("li", null, "New Window"),
34
+ React.createElement("li", null, "New Private Window"),
35
+ React.createElement("li", null, "New Tab"),
36
+ React.createElement("li", null, "New Empty Tab Group"),
37
+ React.createElement("li", null, "Open File\u2026"),
38
+ React.createElement("li", null, "Open Location\u2026"),
39
+ React.createElement("li", { className: "separator" }),
40
+ React.createElement("li", null, "Close Window"),
41
+ React.createElement("li", null, "Close All Window"),
42
+ React.createElement("li", null, "Close Tab"),
43
+ React.createElement("li", null, "Save As\u2026"),
44
+ React.createElement("li", { className: "separator" }),
45
+ React.createElement("li", null, "Print\u2026"))));
62
46
  const trigger = screen.getByRole('button');
63
47
  expect(trigger.innerHTML).toBe('File');
64
48
  await user.click(trigger);
@@ -70,30 +54,22 @@ describe('Dropdown.js', () => {
70
54
  let openedCount = 0;
71
55
  const handleOpen = () => openedCount++;
72
56
  const user = userEvent.setup();
73
- render(
74
- React.createElement(
75
- Dropdown,
76
- { onClose: handleClose, onOpen: handleOpen },
77
- 'File',
78
- React.createElement(
79
- 'ul',
80
- { 'data-testid': 'file-menu' },
81
- React.createElement('li', null, 'New Window'),
82
- React.createElement('li', null, 'New Private Window'),
83
- React.createElement('li', null, 'New Tab'),
84
- React.createElement('li', null, 'New Empty Tab Group'),
85
- React.createElement('li', null, 'Open File\u2026'),
86
- React.createElement('li', null, 'Open Location\u2026'),
87
- React.createElement('li', { className: 'separator' }),
88
- React.createElement('li', null, 'Close Window'),
89
- React.createElement('li', null, 'Close All Window'),
90
- React.createElement('li', null, 'Close Tab'),
91
- React.createElement('li', null, 'Save As\u2026'),
92
- React.createElement('li', { className: 'separator' }),
93
- React.createElement('li', null, 'Print\u2026'),
94
- ),
95
- ),
96
- );
57
+ render(React.createElement(Dropdown, { onClose: handleClose, onOpen: handleOpen },
58
+ "File",
59
+ React.createElement("ul", { "data-testid": "file-menu" },
60
+ React.createElement("li", null, "New Window"),
61
+ React.createElement("li", null, "New Private Window"),
62
+ React.createElement("li", null, "New Tab"),
63
+ React.createElement("li", null, "New Empty Tab Group"),
64
+ React.createElement("li", null, "Open File\u2026"),
65
+ React.createElement("li", null, "Open Location\u2026"),
66
+ React.createElement("li", { className: "separator" }),
67
+ React.createElement("li", null, "Close Window"),
68
+ React.createElement("li", null, "Close All Window"),
69
+ React.createElement("li", null, "Close Tab"),
70
+ React.createElement("li", null, "Save As\u2026"),
71
+ React.createElement("li", { className: "separator" }),
72
+ React.createElement("li", null, "Print\u2026"))));
97
73
  const trigger = screen.getByRole('button');
98
74
  expect(closedCount).toBe(0);
99
75
  expect(openedCount).toBe(0);
@@ -112,17 +88,8 @@ describe('Dropdown.js', () => {
112
88
  let openedCount = 0;
113
89
  const handleOpen = () => openedCount++;
114
90
  const user = userEvent.setup();
115
- render(
116
- React.createElement(
117
- Dropdown,
118
- { isOpenOnMount: true, onClose: handleClose, onOpen: handleOpen },
119
- React.createElement(
120
- 'p',
121
- { 'data-testid': 'dropdown-body' },
122
- 'this is the dropdown contents',
123
- ),
124
- ),
125
- );
91
+ render(React.createElement(Dropdown, { isOpenOnMount: true, onClose: handleClose, onOpen: handleOpen },
92
+ React.createElement("p", { "data-testid": "dropdown-body" }, "this is the dropdown contents")));
126
93
  const trigger = screen.getByRole('button');
127
94
  expect(screen.getByTestId('dropdown-body')).toBeTruthy();
128
95
  expect(openedCount).toBe(1);
@@ -132,4 +99,4 @@ describe('Dropdown.js', () => {
132
99
  expect(screen.queryByTestId('dropdown-body')).toBe(null);
133
100
  });
134
101
  });
135
- //# sourceMappingURL=Dropdown.test.js.map
102
+ //# sourceMappingURL=Dropdown.test.js.map
package/dist/helpers.d.ts CHANGED
@@ -1,47 +1,32 @@
1
- export declare const ITEM_SELECTOR = '[data-ukt-item], [data-ukt-value]';
2
- export declare const getItemElements: (
3
- dropdownElement: HTMLElement | null,
4
- ) => NodeListOf<Element> | HTMLCollection | null;
5
- export declare const getActiveItemElement: (
6
- dropdownElement: HTMLElement | null,
7
- ) => HTMLElement | null;
8
- export declare const setActiveItem: ({
9
- dropdownElement,
10
- element,
11
- index,
12
- indexAddend,
13
- isExactMatch,
14
- text,
15
- }:
16
- | {
17
- dropdownElement: HTMLElement;
18
- element: HTMLElement;
19
- index?: null | undefined;
20
- indexAddend?: null | undefined;
21
- isExactMatch?: null | undefined;
22
- text?: null | undefined;
23
- }
24
- | {
25
- dropdownElement: HTMLElement;
26
- element?: null | undefined;
27
- index: number;
28
- indexAddend?: null | undefined;
29
- isExactMatch?: null | undefined;
30
- text?: null | undefined;
31
- }
32
- | {
33
- dropdownElement: HTMLElement;
34
- element?: null | undefined;
35
- index?: null | undefined;
36
- indexAddend: number;
37
- isExactMatch?: null | undefined;
38
- text?: null | undefined;
39
- }
40
- | {
41
- dropdownElement: HTMLElement;
42
- element?: null | undefined;
43
- index?: null | undefined;
44
- indexAddend?: null | undefined;
45
- isExactMatch?: boolean | undefined;
46
- text: string;
47
- }) => void;
1
+ export declare const ITEM_SELECTOR = "[data-ukt-item], [data-ukt-value]";
2
+ export declare const getItemElements: (dropdownElement: HTMLElement | null) => NodeListOf<Element> | HTMLCollection | null;
3
+ export declare const getActiveItemElement: (dropdownElement: HTMLElement | null) => HTMLElement | null;
4
+ export declare const setActiveItem: ({ dropdownElement, element, index, indexAddend, isExactMatch, text, }: {
5
+ dropdownElement: HTMLElement;
6
+ element: HTMLElement;
7
+ index?: null | undefined;
8
+ indexAddend?: null | undefined;
9
+ isExactMatch?: null | undefined;
10
+ text?: null | undefined;
11
+ } | {
12
+ dropdownElement: HTMLElement;
13
+ element?: null | undefined;
14
+ index: number;
15
+ indexAddend?: null | undefined;
16
+ isExactMatch?: null | undefined;
17
+ text?: null | undefined;
18
+ } | {
19
+ dropdownElement: HTMLElement;
20
+ element?: null | undefined;
21
+ index?: null | undefined;
22
+ indexAddend: number;
23
+ isExactMatch?: null | undefined;
24
+ text?: null | undefined;
25
+ } | {
26
+ dropdownElement: HTMLElement;
27
+ element?: null | undefined;
28
+ index?: null | undefined;
29
+ indexAddend?: null | undefined;
30
+ isExactMatch?: boolean | undefined;
31
+ text: string;
32
+ }) => void;
package/dist/helpers.js CHANGED
@@ -2,16 +2,20 @@ import { getBestMatch } from '@acusti/matchmaking';
2
2
  import { BODY_SELECTOR } from './styles.js';
3
3
  export const ITEM_SELECTOR = `[data-ukt-item], [data-ukt-value]`;
4
4
  export const getItemElements = (dropdownElement) => {
5
- if (!dropdownElement) return null;
5
+ if (!dropdownElement)
6
+ return null;
6
7
  const bodyElement = dropdownElement.querySelector(BODY_SELECTOR);
7
- if (!bodyElement) return null;
8
+ if (!bodyElement)
9
+ return null;
8
10
  let items = bodyElement.querySelectorAll(ITEM_SELECTOR);
9
- if (items.length) return items;
11
+ if (items.length)
12
+ return items;
10
13
  // If no items found via [data-ukt-item] or [data-ukt-value] selector,
11
14
  // use first instance of multiple children found
12
15
  items = bodyElement.children;
13
16
  while (items.length === 1) {
14
- if (!items[0].children) break;
17
+ if (!items[0].children)
18
+ break;
15
19
  items = items[0].children;
16
20
  }
17
21
  // If unable to find an element with more than one child, treat direct child as items
@@ -21,7 +25,8 @@ export const getItemElements = (dropdownElement) => {
21
25
  return items;
22
26
  };
23
27
  export const getActiveItemElement = (dropdownElement) => {
24
- if (!dropdownElement) return null;
28
+ if (!dropdownElement)
29
+ return null;
25
30
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
26
31
  return dropdownElement.querySelector('[data-ukt-active]');
27
32
  };
@@ -32,45 +37,40 @@ const clearItemElementsState = (itemElements) => {
32
37
  }
33
38
  });
34
39
  };
35
- export const setActiveItem = ({
36
- dropdownElement,
37
- element,
38
- index,
39
- indexAddend,
40
- isExactMatch,
41
- text,
42
- }) => {
40
+ export const setActiveItem = ({ dropdownElement, element, index, indexAddend, isExactMatch, text, }) => {
43
41
  const items = getItemElements(dropdownElement);
44
- if (!items) return;
42
+ if (!items)
43
+ return;
45
44
  const itemElements = Array.from(items);
46
- if (!itemElements.length) return;
45
+ if (!itemElements.length)
46
+ return;
47
47
  const lastIndex = itemElements.length - 1;
48
- const currentActiveIndex = itemElements.findIndex((itemElement) =>
49
- itemElement.hasAttribute('data-ukt-active'),
50
- );
48
+ const currentActiveIndex = itemElements.findIndex((itemElement) => itemElement.hasAttribute('data-ukt-active'));
51
49
  let nextActiveIndex = currentActiveIndex;
52
50
  if (typeof index === 'number') {
53
51
  // Negative index means count back from the end
54
52
  nextActiveIndex = index < 0 ? itemElements.length + index : index;
55
53
  }
56
54
  if (element) {
57
- nextActiveIndex = itemElements.findIndex(
58
- (itemElement) => itemElement === element,
59
- );
60
- } else if (typeof indexAddend === 'number') {
55
+ nextActiveIndex = itemElements.findIndex((itemElement) => itemElement === element);
56
+ }
57
+ else if (typeof indexAddend === 'number') {
61
58
  // If there’s no currentActiveIndex and we are handling -1, start at lastIndex
62
59
  if (currentActiveIndex === -1 && indexAddend === -1) {
63
60
  nextActiveIndex = lastIndex;
64
- } else {
61
+ }
62
+ else {
65
63
  nextActiveIndex += indexAddend;
66
64
  }
67
65
  // Keep it within the bounds of the items list
68
66
  if (nextActiveIndex < 0) {
69
67
  nextActiveIndex = 0;
70
- } else if (nextActiveIndex > lastIndex) {
68
+ }
69
+ else if (nextActiveIndex > lastIndex) {
71
70
  nextActiveIndex = lastIndex;
72
71
  }
73
- } else if (typeof text === 'string') {
72
+ }
73
+ else if (typeof text === 'string') {
74
74
  // If text is empty, clear existing active items and early return
75
75
  if (!text) {
76
76
  clearItemElementsState(itemElements);
@@ -79,19 +79,19 @@ export const setActiveItem = ({
79
79
  const itemTexts = itemElements.map((itemElement) => itemElement.innerText);
80
80
  if (isExactMatch) {
81
81
  const textToCompare = text.toLowerCase();
82
- nextActiveIndex = itemTexts.findIndex((itemText) =>
83
- itemText.toLowerCase().startsWith(textToCompare),
84
- );
82
+ nextActiveIndex = itemTexts.findIndex((itemText) => itemText.toLowerCase().startsWith(textToCompare));
85
83
  // If isExactMatch is required and no exact match was found, clear active items
86
84
  if (nextActiveIndex === -1) {
87
85
  clearItemElementsState(itemElements);
88
86
  }
89
- } else {
87
+ }
88
+ else {
90
89
  const bestMatch = getBestMatch({ items: itemTexts, text });
91
90
  nextActiveIndex = itemTexts.findIndex((text) => text === bestMatch);
92
91
  }
93
92
  }
94
- if (nextActiveIndex === -1 || nextActiveIndex === currentActiveIndex) return;
93
+ if (nextActiveIndex === -1 || nextActiveIndex === currentActiveIndex)
94
+ return;
95
95
  // Clear any existing active dropdown body item state
96
96
  clearItemElementsState(itemElements);
97
97
  const nextActiveItem = items[nextActiveIndex];
@@ -101,11 +101,11 @@ export const setActiveItem = ({
101
101
  let { parentElement } = nextActiveItem;
102
102
  let scrollableParent = null;
103
103
  while (!scrollableParent && parentElement && parentElement !== dropdownElement) {
104
- const isScrollable =
105
- parentElement.scrollHeight > parentElement.clientHeight + 15;
104
+ const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;
106
105
  if (isScrollable) {
107
106
  scrollableParent = parentElement;
108
- } else {
107
+ }
108
+ else {
109
109
  parentElement = parentElement.parentElement;
110
110
  }
111
111
  }
@@ -119,7 +119,8 @@ export const setActiveItem = ({
119
119
  // Item isn’t fully visible; adjust scrollTop to put item within closest edge
120
120
  if (isAboveTop) {
121
121
  scrollTop -= parentRect.top - itemRect.top;
122
- } else {
122
+ }
123
+ else {
123
124
  scrollTop += itemRect.bottom - parentRect.bottom;
124
125
  }
125
126
  scrollableParent.scrollTop = scrollTop;
@@ -127,4 +128,4 @@ export const setActiveItem = ({
127
128
  }
128
129
  }
129
130
  };
130
- //# sourceMappingURL=helpers.js.map
131
+ //# sourceMappingURL=helpers.js.map
@@ -5,45 +5,45 @@
5
5
  * @flow
6
6
  */
7
7
 
8
- declare export var ITEM_SELECTOR: '[data-ukt-item], [data-ukt-value]';
8
+ declare export var ITEM_SELECTOR: "[data-ukt-item], [data-ukt-value]";
9
9
  declare export var getItemElements: (
10
- dropdownElement: HTMLElement | null,
10
+ dropdownElement: HTMLElement | null
11
11
  ) => NodeListOf<Element> | HTMLCollection | null;
12
12
  declare export var getActiveItemElement: (
13
- dropdownElement: HTMLElement | null,
13
+ dropdownElement: HTMLElement | null
14
14
  ) => HTMLElement | null;
15
15
  declare export var setActiveItem: (
16
- x:
17
- | {|
18
- dropdownElement: HTMLElement,
19
- element: HTMLElement,
20
- index?: null | void,
21
- indexAddend?: null | void,
22
- isExactMatch?: null | void,
23
- text?: null | void,
24
- |}
25
- | {|
26
- dropdownElement: HTMLElement,
27
- element?: null | void,
28
- index: number,
29
- indexAddend?: null | void,
30
- isExactMatch?: null | void,
31
- text?: null | void,
32
- |}
33
- | {|
34
- dropdownElement: HTMLElement,
35
- element?: null | void,
36
- index?: null | void,
37
- indexAddend: number,
38
- isExactMatch?: null | void,
39
- text?: null | void,
40
- |}
41
- | {|
42
- dropdownElement: HTMLElement,
43
- element?: null | void,
44
- index?: null | void,
45
- indexAddend?: null | void,
46
- isExactMatch?: boolean | void,
47
- text: string,
48
- |},
16
+ x:
17
+ | {|
18
+ dropdownElement: HTMLElement,
19
+ element: HTMLElement,
20
+ index?: null | void,
21
+ indexAddend?: null | void,
22
+ isExactMatch?: null | void,
23
+ text?: null | void,
24
+ |}
25
+ | {|
26
+ dropdownElement: HTMLElement,
27
+ element?: null | void,
28
+ index: number,
29
+ indexAddend?: null | void,
30
+ isExactMatch?: null | void,
31
+ text?: null | void,
32
+ |}
33
+ | {|
34
+ dropdownElement: HTMLElement,
35
+ element?: null | void,
36
+ index?: null | void,
37
+ indexAddend: number,
38
+ isExactMatch?: null | void,
39
+ text?: null | void,
40
+ |}
41
+ | {|
42
+ dropdownElement: HTMLElement,
43
+ element?: null | void,
44
+ index?: null | void,
45
+ indexAddend?: null | void,
46
+ isExactMatch?: boolean | void,
47
+ text: string,
48
+ |}
49
49
  ) => void;
package/dist/styles.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- export declare const ROOT_CLASS_NAME = 'uktdropdown';
2
- export declare const ROOT_SELECTOR = '.uktdropdown';
3
- export declare const BODY_CLASS_NAME = 'uktdropdown-body';
4
- export declare const LABEL_CLASS_NAME = 'uktdropdown-label';
5
- export declare const LABEL_TEXT_CLASS_NAME = 'uktdropdown-label-text';
6
- export declare const TRIGGER_CLASS_NAME = 'uktdropdown-trigger';
7
- export declare const BODY_SELECTOR = '.uktdropdown-body';
8
- export declare const LABEL_SELECTOR = '.uktdropdown-label';
9
- export declare const LABEL_TEXT_SELECTOR = '.uktdropdown-label-text';
10
- export declare const TRIGGER_SELECTOR = '.uktdropdown-trigger';
11
- export declare const BODY_MAX_HEIGHT_VAR = '--uktdd-body-max-height';
12
- export declare const BODY_MAX_WIDTH_VAR = '--uktdd-body-max-width';
13
- export declare const STYLES =
14
- '\n:root {\n --uktdd-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105,162,249);\n --uktdd-body-color-hover: #fff;\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100vh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100vw - var(--uktdd-body-buffer));\n --uktdd-body-pad-bottom: 9px;\n --uktdd-body-pad-left: 12px;\n --uktdd-body-pad-right: 12px;\n --uktdd-body-pad-top: 9px;\n --uktdd-label-pad-right: 10px;\n}\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n.uktdropdown {\n position: relative;\n display: inline-block;\n}\n.uktdropdown.disabled {\n pointer-events: none;\n}\n.uktdropdown > * {\n cursor: default;\n}\n.uktdropdown-label {\n display: flex;\n}\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n.uktdropdown-body {\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n max-height: var(--uktdd-body-max-height);\n min-height: 50px;\n max-width: var(--uktdd-body-max-width);\n min-width: 100%;\n overflow: auto;\n z-index: 2;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0,0,0,0.25);\n}\n.uktdropdown-body.calculating-position {\n visibility: hidden;\n}\n.uktdropdown-body.out-of-bounds-bottom:not(.out-of-bounds-top) {\n top: auto;\n bottom: 100%;\n}\n.uktdropdown-body.out-of-bounds-right:not(.out-of-bounds-left) {\n left: auto;\n right: 0px;\n}\n.uktdropdown-label + .uktdropdown-body {\n left: auto;\n right: 0;\n}\n.uktdropdown-body.has-items {\n user-select: none;\n}\n.uktdropdown-body [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n}\n';
1
+ export declare const ROOT_CLASS_NAME = "uktdropdown";
2
+ export declare const ROOT_SELECTOR = ".uktdropdown";
3
+ export declare const BODY_CLASS_NAME = "uktdropdown-body";
4
+ export declare const LABEL_CLASS_NAME = "uktdropdown-label";
5
+ export declare const LABEL_TEXT_CLASS_NAME = "uktdropdown-label-text";
6
+ export declare const TRIGGER_CLASS_NAME = "uktdropdown-trigger";
7
+ export declare const BODY_SELECTOR = ".uktdropdown-body";
8
+ export declare const LABEL_SELECTOR = ".uktdropdown-label";
9
+ export declare const LABEL_TEXT_SELECTOR = ".uktdropdown-label-text";
10
+ export declare const TRIGGER_SELECTOR = ".uktdropdown-trigger";
11
+ export declare const BODY_MAX_HEIGHT_VAR = "--uktdd-body-max-height";
12
+ export declare const BODY_MAX_WIDTH_VAR = "--uktdd-body-max-width";
13
+ export declare const STYLES = "\n:root {\n --uktdd-font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n --uktdd-body-bg-color: #fff;\n --uktdd-body-bg-color-hover: rgb(105,162,249);\n --uktdd-body-color-hover: #fff;\n --uktdd-body-buffer: 10px;\n --uktdd-body-max-height: calc(100vh - var(--uktdd-body-buffer));\n --uktdd-body-max-width: calc(100vw - var(--uktdd-body-buffer));\n --uktdd-body-pad-bottom: 9px;\n --uktdd-body-pad-left: 12px;\n --uktdd-body-pad-right: 12px;\n --uktdd-body-pad-top: 9px;\n --uktdd-label-pad-right: 10px;\n}\n.uktdropdown,\n.uktdropdown-trigger {\n font-family: var(--uktdd-font-family);\n}\n.uktdropdown {\n position: relative;\n display: inline-block;\n}\n.uktdropdown.disabled {\n pointer-events: none;\n}\n.uktdropdown > * {\n cursor: default;\n}\n.uktdropdown-label {\n display: flex;\n}\n.uktdropdown-label-text {\n padding-right: var(--uktdd-label-pad-right);\n}\n.uktdropdown-body {\n box-sizing: border-box;\n position: absolute;\n top: 100%;\n max-height: var(--uktdd-body-max-height);\n min-height: 50px;\n max-width: var(--uktdd-body-max-width);\n min-width: 100%;\n overflow: auto;\n z-index: 2;\n padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);\n background-color: var(--uktdd-body-bg-color);\n box-shadow: 0 8px 18px rgba(0,0,0,0.25);\n}\n.uktdropdown-body.calculating-position {\n visibility: hidden;\n}\n.uktdropdown-body.out-of-bounds-bottom:not(.out-of-bounds-top) {\n top: auto;\n bottom: 100%;\n}\n.uktdropdown-body.out-of-bounds-right:not(.out-of-bounds-left) {\n left: auto;\n right: 0px;\n}\n.uktdropdown-label + .uktdropdown-body {\n left: auto;\n right: 0;\n}\n.uktdropdown-body.has-items {\n user-select: none;\n}\n.uktdropdown-body [data-ukt-active] {\n background-color: var(--uktdd-body-bg-color-hover);\n color: var(--uktdd-body-color-hover);\n}\n";
package/dist/styles.js CHANGED
@@ -83,4 +83,4 @@ ${BODY_SELECTOR} [data-ukt-active] {
83
83
  color: var(--uktdd-body-color-hover);
84
84
  }
85
85
  `;
86
- //# sourceMappingURL=styles.js.map
86
+ //# sourceMappingURL=styles.js.map