@snack-uikit/list 0.3.1-preview-357970fd.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.3.1 (2024-02-08)
7
+
8
+ ### Only dependencies have been changed
9
+ * [@snack-uikit/search-private@0.1.4](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/search-private/CHANGELOG.md)
10
+
11
+
12
+
13
+
14
+
6
15
  # 0.3.0 (2024-02-07)
7
16
 
8
17
 
@@ -23,7 +23,7 @@ export function BaseItem(_a) {
23
23
  const { option, caption, description } = content || {};
24
24
  const interactive = !inactive;
25
25
  const { parentResetActiveFocusIndex } = useParentListContext();
26
- const { size, marker, parent } = useListContext();
26
+ const { size, marker } = useListContext();
27
27
  const { level = 0 } = useCollapseContext();
28
28
  const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
29
29
  const isChecked = isSelectionSingle ? value === id : value === null || value === void 0 ? void 0 : value.includes(id);
@@ -68,7 +68,7 @@ export function BaseItem(_a) {
68
68
  e.stopPropagation();
69
69
  };
70
70
  const props = extractSupportProps(rest);
71
- const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: 1 }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
71
+ const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "aria-disabled": disabled || undefined, onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: 1 }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
72
72
  if (!itemWrapRender) {
73
73
  return item;
74
74
  }
@@ -72,7 +72,6 @@
72
72
  }
73
73
 
74
74
  .content{
75
- overflow:hidden;
76
75
  flex-grow:1;
77
76
  flex-shrink:1;
78
77
  box-sizing:border-box;
@@ -171,13 +170,6 @@
171
170
  letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
172
171
  paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
173
172
  }
174
- .droplistItem[data-parent=list]{
175
- width:100%;
176
- }
177
- .droplistItem[data-parent=droplist]{
178
- width:-moz-max-content;
179
- width:max-content;
180
- }
181
173
  .droplistItem[data-non-pointer]{
182
174
  cursor:inherit;
183
175
  }
@@ -95,7 +95,7 @@ export function Droplist(_a) {
95
95
  parentResetNestedIndex: resetNestedIndex,
96
96
  parentResetActiveFocusIndex: resetActiveFocusIndex,
97
97
  toggleOpenCollapsedItems: id => setOpenCollapsedItems((items = []) => items.includes(id) ? items.filter(item => item !== id) : items === null || items === void 0 ? void 0 : items.concat([id])),
98
- }, children: _jsx(Dropdown, Object.assign({ content: _jsx(ListPrivate, Object.assign({}, slicedItems, props, { onKeyDown: handleListKeyDown, tabIndex: 0, ref: listRef, search: search, limitedScrollHeight: true, parent: 'droplist' })), trigger: trigger, placement: placement, widthStrategy: widthStrategy }, (triggerElemRefProp
98
+ }, children: _jsx(Dropdown, Object.assign({ content: _jsx(ListPrivate, Object.assign({ onKeyDown: handleListKeyDown, tabIndex: 0, ref: listRef, search: search, limitedScrollHeight: true }, slicedItems, props)), trigger: trigger, placement: placement, widthStrategy: widthStrategy }, (triggerElemRefProp
99
99
  ? {}
100
100
  : {
101
101
  triggerRef: triggerElemRef,
@@ -87,5 +87,5 @@ export const List = forwardRef((_a, ref) => {
87
87
  parentResetActiveFocusIndex: resetActiveFocusIndex,
88
88
  openCollapsedItems,
89
89
  toggleOpenCollapsedItems: id => setOpenCollapsedItems((items = []) => items.includes(id) ? items.filter(item => item !== id) : items === null || items === void 0 ? void 0 : items.concat([id])),
90
- }, children: _jsxs("div", { className: cn(styles.wrapper, className), "data-active": isActive || undefined, children: [_jsx(ListPrivate, Object.assign({}, props, slicedItems, { ref: mergeRefs(ref, listRef), onFocus: handleOnFocus, onKeyDown: mergedHandlerKeyDown, tabIndex: tabIndex, search: search, nested: false, parent: 'list' })), _jsx(HiddenTabButton, { ref: btnRef, listRef: listRef, tabIndex: tabIndex })] }) }) })));
90
+ }, children: _jsxs("div", { className: cn(styles.wrapper, className), "data-active": isActive || undefined, children: [_jsx(ListPrivate, Object.assign({}, props, slicedItems, { ref: mergeRefs(ref, listRef), onFocus: handleOnFocus, onKeyDown: mergedHandlerKeyDown, tabIndex: tabIndex, search: search, nested: false })), _jsx(HiddenTabButton, { ref: btnRef, listRef: listRef, tabIndex: tabIndex })] }) }) })));
91
91
  });
@@ -19,7 +19,7 @@ export declare const ListPrivate: import("react").ForwardRefExoticComponent<{
19
19
  } | undefined;
20
20
  className?: string | undefined;
21
21
  onKeyDown?(e: import("react").KeyboardEvent<HTMLElement>): void;
22
- } & import("../contexts").SelectionState & import("../contexts").ListContextType & import("../../../types").ScrollProps & import("../contexts").ListContextPrivateType & {
22
+ } & import("../contexts").SelectionState & import("../contexts").ListContextType & import("../../../types").ScrollProps & {
23
23
  nested?: boolean | undefined;
24
24
  active?: boolean | undefined;
25
25
  tabIndex?: number | undefined;
@@ -22,7 +22,7 @@ import commonStyles from '../styles.module.css';
22
22
  import styles from './styles.module.css';
23
23
  export const ListPrivate = forwardRef((_a, ref) => {
24
24
  var _b, _c;
25
- var { items, pinTop, pinBottom, onKeyDown, onBlur, onFocus, tabIndex, active, scroll, nested, search, scrollRef, scrollContainerRef, footer, loading, noData = 'No data', noResults = 'No results', size = 's', marker, limitedScrollHeight, className, parent = 'list' } = _a, props = __rest(_a, ["items", "pinTop", "pinBottom", "onKeyDown", "onBlur", "onFocus", "tabIndex", "active", "scroll", "nested", "search", "scrollRef", "scrollContainerRef", "footer", "loading", "noData", "noResults", "size", "marker", "limitedScrollHeight", "className", "parent"]);
25
+ var { items, pinTop, pinBottom, onKeyDown, onBlur, onFocus, tabIndex, active, scroll, nested, search, scrollRef, scrollContainerRef, footer, loading, noData = 'No data', noResults = 'No results', size = 's', marker, limitedScrollHeight, className } = _a, props = __rest(_a, ["items", "pinTop", "pinBottom", "onKeyDown", "onBlur", "onFocus", "tabIndex", "active", "scroll", "nested", "search", "scrollRef", "scrollContainerRef", "footer", "loading", "noData", "noResults", "size", "marker", "limitedScrollHeight", "className"]);
26
26
  const itemsJSX = useRenderItems(items);
27
27
  const itemsPinTopJSX = useRenderItems(pinTop !== null && pinTop !== void 0 ? pinTop : []);
28
28
  const itemsPinBottomJSX = useRenderItems(pinBottom !== null && pinBottom !== void 0 ? pinBottom : []);
@@ -35,7 +35,7 @@ export const ListPrivate = forwardRef((_a, ref) => {
35
35
  [commonStyles.scrollContainerL]: scroll && limitedScrollHeight && size === 'l',
36
36
  }), barHideStrategy: 'leave', size: size === 's' ? 's' : 'm', ref: scrollContainerRef, children: [content, _jsx("div", { className: styles.scrollStub, ref: scrollRef })] })) : (_jsx(_Fragment, { children: content })), (Number(pinBottom === null || pinBottom === void 0 ? void 0 : pinBottom.length) > 0 || footer) && (_jsxs(PinBottomGroupItem, { children: [Number(pinBottom === null || pinBottom === void 0 ? void 0 : pinBottom.length) > 0 && itemsPinBottomJSX, footer && _jsx("div", { className: styles.footer, children: footer })] }))] }) })));
37
37
  if (!nested) {
38
- return (_jsx(ListContextProvider, { size: size, marker: marker, parent: parent, children: listJSX }));
38
+ return (_jsx(ListContextProvider, { size: size, marker: marker, children: listJSX }));
39
39
  }
40
40
  return (_jsx("li", { style: { listStyleType: 'none' }, role: 'menuitem', children: listJSX }));
41
41
  });
@@ -38,6 +38,9 @@
38
38
  .footer{
39
39
  display:flex;
40
40
  flex-direction:column;
41
+ gap:var(--dimension-050m, 4px);
42
+ align-items:center;
43
+ justify-content:center;
41
44
  box-sizing:border-box;
42
45
  padding:var(--dimension-050m, 4px);
43
46
  }
@@ -5,13 +5,10 @@ export type ListContextType = {
5
5
  /** Отображать ли маркер у выбранного жлемента списка */
6
6
  marker?: boolean;
7
7
  };
8
- export type ListContextPrivateType = {
9
- parent?: 'list' | 'droplist';
10
- };
11
8
  type Child = {
12
9
  children: ReactNode;
13
10
  };
14
- export declare const ListContext: import("react").Context<ListContextType & ListContextPrivateType>;
15
- export declare const useListContext: () => ListContextType & ListContextPrivateType;
16
- export declare function ListContextProvider({ children, ...props }: ListContextType & Child & ListContextPrivateType): import("react/jsx-runtime").JSX.Element;
11
+ export declare const ListContext: import("react").Context<ListContextType>;
12
+ export declare const useListContext: () => ListContextType;
13
+ export declare function ListContextProvider({ children, ...props }: ListContextType & Child): import("react/jsx-runtime").JSX.Element;
17
14
  export {};
@@ -13,8 +13,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { createContext, useContext } from 'react';
14
14
  export const ListContext = createContext({});
15
15
  export const useListContext = () => useContext(ListContext);
16
- function extractListProps({ size, marker, parent }) {
17
- return { size, marker, parent };
16
+ function extractListProps({ size, marker }) {
17
+ return { size, marker };
18
18
  }
19
19
  export function ListContextProvider(_a) {
20
20
  var { children } = _a, props = __rest(_a, ["children"]);
@@ -3,7 +3,7 @@ import { DropdownProps } from '@snack-uikit/dropdown';
3
3
  import { WithSupportProps } from '@snack-uikit/utils';
4
4
  import { ScrollProps, SearchState } from '../../types';
5
5
  import { ItemProps } from '../Items';
6
- import { ListContextPrivateType, ListContextType, SelectionState } from './contexts';
6
+ import { ListContextType, SelectionState } from './contexts';
7
7
  type CollapseState = {
8
8
  value?: (string | number)[];
9
9
  onChange?(value: (string | number)[]): void;
@@ -45,7 +45,7 @@ export type DroplistProps = {
45
45
  /** Триггер для дроплиста */
46
46
  children?: ReactNode;
47
47
  } & Pick<DropdownProps, 'trigger' | 'placement' | 'widthStrategy' | 'open' | 'onOpenChange'> & Omit<ListProps, 'tabIndex' | 'onKeyDown'>;
48
- export type ListPrivateProps = ListProps & ListContextPrivateType & {
48
+ export type ListPrivateProps = ListProps & {
49
49
  nested?: boolean;
50
50
  active?: boolean;
51
51
  tabIndex?: number;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "List",
7
- "version": "0.3.1-preview-357970fd.0",
7
+ "version": "0.3.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -37,7 +37,7 @@
37
37
  "@snack-uikit/icons": "0.20.1",
38
38
  "@snack-uikit/loaders": "0.5.0",
39
39
  "@snack-uikit/scroll": "0.5.0",
40
- "@snack-uikit/search-private": "0.1.3",
40
+ "@snack-uikit/search-private": "0.1.4",
41
41
  "@snack-uikit/toggles": "0.9.5",
42
42
  "@snack-uikit/truncate-string": "0.4.7",
43
43
  "@snack-uikit/utils": "3.2.0",
@@ -45,5 +45,5 @@
45
45
  "merge-refs": "1.2.2",
46
46
  "uncontrollable": "8.0.4"
47
47
  },
48
- "gitHead": "2a29639b6595426f8870afc293553dd9ee12f188"
48
+ "gitHead": "eb20092ecd05743f00831dfa51a3f5db2416be8f"
49
49
  }
@@ -39,7 +39,7 @@ export function BaseItem({
39
39
  const interactive = !inactive;
40
40
 
41
41
  const { parentResetActiveFocusIndex } = useParentListContext();
42
- const { size, marker, parent } = useListContext();
42
+ const { size, marker } = useListContext();
43
43
  const { level = 0 } = useCollapseContext();
44
44
  const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
45
45
 
@@ -112,7 +112,6 @@ export function BaseItem({
112
112
  data-variant={mode || undefined}
113
113
  data-open={open || undefined}
114
114
  aria-disabled={disabled || undefined}
115
- data-parent={parent || 'list'}
116
115
  onKeyDown={handleItemKeyDown}
117
116
  onFocus={handleItemFocus}
118
117
  style={{ '--level': level }}
@@ -104,7 +104,6 @@ $typography: (
104
104
  }
105
105
 
106
106
  .content {
107
- overflow: hidden;
108
107
  flex-grow: 1;
109
108
  flex-shrink: 1;
110
109
  box-sizing: border-box;
@@ -135,14 +134,6 @@ $typography: (
135
134
  }
136
135
  }
137
136
 
138
- &[data-parent='list'] {
139
- width: 100%;
140
- }
141
-
142
- &[data-parent='droplist'] {
143
- width: max-content;
144
- }
145
-
146
137
  &[data-non-pointer] {
147
138
  cursor: inherit;
148
139
  }
@@ -147,14 +147,13 @@ export function Droplist({
147
147
  <Dropdown
148
148
  content={
149
149
  <ListPrivate
150
- {...slicedItems}
151
- {...props}
152
150
  onKeyDown={handleListKeyDown}
153
151
  tabIndex={0}
154
152
  ref={listRef}
155
153
  search={search}
156
154
  limitedScrollHeight
157
- parent='droplist'
155
+ {...slicedItems}
156
+ {...props}
158
157
  />
159
158
  }
160
159
  trigger={trigger}
@@ -141,7 +141,6 @@ export const List = forwardRef<HTMLElement, ListProps>(
141
141
  tabIndex={tabIndex}
142
142
  search={search}
143
143
  nested={false}
144
- parent='list'
145
144
  />
146
145
 
147
146
  <HiddenTabButton ref={btnRef} listRef={listRef} tabIndex={tabIndex} />
@@ -36,7 +36,6 @@ export const ListPrivate = forwardRef<HTMLElement, ListPrivateProps>(
36
36
  marker,
37
37
  limitedScrollHeight,
38
38
  className,
39
- parent = 'list',
40
39
  ...props
41
40
  },
42
41
  ref,
@@ -136,7 +135,7 @@ export const ListPrivate = forwardRef<HTMLElement, ListPrivateProps>(
136
135
 
137
136
  if (!nested) {
138
137
  return (
139
- <ListContextProvider size={size} marker={marker} parent={parent}>
138
+ <ListContextProvider size={size} marker={marker}>
140
139
  {listJSX}
141
140
  </ListContextProvider>
142
141
  );
@@ -39,6 +39,10 @@ $loader-height: (
39
39
  .footer {
40
40
  display: flex;
41
41
  flex-direction: column;
42
+ gap: $dimension-050m;
43
+ align-items: center;
44
+ justify-content: center;
45
+
42
46
  box-sizing: border-box;
43
47
  padding: $dimension-050m;
44
48
  }
@@ -7,22 +7,18 @@ export type ListContextType = {
7
7
  marker?: boolean;
8
8
  };
9
9
 
10
- export type ListContextPrivateType = {
11
- parent?: 'list' | 'droplist';
12
- };
13
-
14
10
  type Child = {
15
11
  children: ReactNode;
16
12
  };
17
13
 
18
- export const ListContext = createContext<ListContextType & ListContextPrivateType>({});
14
+ export const ListContext = createContext<ListContextType>({});
19
15
 
20
16
  export const useListContext = () => useContext(ListContext);
21
17
 
22
- function extractListProps<T extends ListContextType & ListContextPrivateType>({ size, marker, parent }: T) {
23
- return { size, marker, parent };
18
+ function extractListProps<T extends ListContextType>({ size, marker }: T) {
19
+ return { size, marker };
24
20
  }
25
21
 
26
- export function ListContextProvider({ children, ...props }: ListContextType & Child & ListContextPrivateType) {
22
+ export function ListContextProvider({ children, ...props }: ListContextType & Child) {
27
23
  return <ListContext.Provider value={extractListProps(props)}>{children}</ListContext.Provider>;
28
24
  }
@@ -5,7 +5,7 @@ import { WithSupportProps } from '@snack-uikit/utils';
5
5
 
6
6
  import { ScrollProps, SearchState } from '../../types';
7
7
  import { ItemProps } from '../Items';
8
- import { ListContextPrivateType, ListContextType, SelectionState } from './contexts';
8
+ import { ListContextType, SelectionState } from './contexts';
9
9
 
10
10
  type CollapseState = {
11
11
  value?: (string | number)[];
@@ -56,13 +56,12 @@ export type DroplistProps = {
56
56
  } & Pick<DropdownProps, 'trigger' | 'placement' | 'widthStrategy' | 'open' | 'onOpenChange'> &
57
57
  Omit<ListProps, 'tabIndex' | 'onKeyDown'>;
58
58
 
59
- export type ListPrivateProps = ListProps &
60
- ListContextPrivateType & {
61
- nested?: boolean;
62
- active?: boolean;
63
- tabIndex?: number;
64
- onFocus?(e: FocusEvent<HTMLElement>): void;
65
- onBlur?(e: FocusEvent<HTMLElement>): void;
66
- onKeyDown?(e: KeyboardEvent<HTMLElement>): void;
67
- limitedScrollHeight?: boolean;
68
- };
59
+ export type ListPrivateProps = ListProps & {
60
+ nested?: boolean;
61
+ active?: boolean;
62
+ tabIndex?: number;
63
+ onFocus?(e: FocusEvent<HTMLElement>): void;
64
+ onBlur?(e: FocusEvent<HTMLElement>): void;
65
+ onKeyDown?(e: KeyboardEvent<HTMLElement>): void;
66
+ limitedScrollHeight?: boolean;
67
+ };