@koslibs/components 1.11.0 → 1.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @koslibs/components
2
2
 
3
+ ## 1.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#14](https://github.com/koslibs/components/pull/14) [`242a16c`](https://github.com/koslibs/components/commit/242a16ca5c8ba04bdfab319bf75752a9c4b62826) Thanks [@holypower777](https://github.com/holypower777)! - Добавлен проп `hasOutline` для Input, Textarea, Select и Collapse. Outline при фокусе и раскрытии Select теперь включается явно через `hasOutline={true}`; по умолчанию он выключен. Для отключения используется `hasOutline={false}`. Select передаёт настройку поисковому Input. В Storybook добавлены переключатели и примеры.
8
+
9
+ ## 1.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#13](https://github.com/koslibs/components/pull/13) [`02a80ad`](https://github.com/koslibs/components/commit/02a80ad207cb62f8084cacc343d5d1cb24861db2) Thanks [@holypower777](https://github.com/holypower777)! - Use @koslibs/builder 2 and @koslibs/configs 2 for development, builds and validation, and pin reusable Changeset and release workflows to configs v2.0.0.
14
+
15
+ Update @koslibs/icons to 1.2.1.
16
+
3
17
  ## 1.11.0
4
18
 
5
19
  ### Minor Changes
@@ -27,6 +27,11 @@ export type CollapseProps = Omit<HTMLAttributes<HTMLDivElement>, 'onTransitionEn
27
27
  * @default false
28
28
  */
29
29
  showLeftChevron?: boolean;
30
+ /**
31
+ * Показывает outline кнопки при клавиатурном фокусе.
32
+ * @default false
33
+ */
34
+ hasOutline?: boolean;
30
35
  /**
31
36
  * Запрос изменения состояния. В controlled-режиме обновите expanded.
32
37
  */
@@ -72,6 +77,11 @@ export declare const Collapse: import("react").ForwardRefExoticComponent<Omit<HT
72
77
  * @default false
73
78
  */
74
79
  showLeftChevron?: boolean;
80
+ /**
81
+ * Показывает outline кнопки при клавиатурном фокусе.
82
+ * @default false
83
+ */
84
+ hasOutline?: boolean;
75
85
  /**
76
86
  * Запрос изменения состояния. В controlled-режиме обновите expanded.
77
87
  */
@@ -4,7 +4,7 @@ import classnames from "classnames";
4
4
  import { forwardRef, useId, useLayoutEffect, useRef, useState } from "react";
5
5
  import { TypographyText } from "../Typography/text.js";
6
6
  import index_module from "./index.module.js";
7
- const Collapse = /*#__PURE__*/ forwardRef(({ expanded, defaultExpanded = false, collapsedLabel, expandedLabel, showRightChevron = true, showLeftChevron = false, onExpandedChange, onTransitionEnd, expandedContentClassName, dataTestId, className, children, ...restProps }, ref)=>{
7
+ const Collapse = /*#__PURE__*/ forwardRef(({ expanded, defaultExpanded = false, collapsedLabel, expandedLabel, showRightChevron = true, showLeftChevron = false, hasOutline = false, onExpandedChange, onTransitionEnd, expandedContentClassName, dataTestId, className, children, ...restProps }, ref)=>{
8
8
  const [expandedState, setExpandedState] = useState(defaultExpanded);
9
9
  const isExpanded = expanded ?? expandedState;
10
10
  const contentId = `collapse-${useId()}`;
@@ -51,6 +51,7 @@ const Collapse = /*#__PURE__*/ forwardRef(({ expanded, defaultExpanded = false,
51
51
  ...restProps,
52
52
  ref: ref,
53
53
  className: classnames(index_module.component, className),
54
+ "data-has-outline": hasOutline || void 0,
54
55
  "data-test-id": dataTestId,
55
56
  children: [
56
57
  label && /*#__PURE__*/ jsxs("button", {
@@ -37,6 +37,7 @@
37
37
  cursor: pointer;
38
38
  background: none;
39
39
  border: 0;
40
+ outline: none;
40
41
  display: inline-flex;
41
42
 
42
43
  &:hover {
@@ -47,12 +48,12 @@
47
48
  text-underline-offset: 3px;
48
49
  text-decoration: underline;
49
50
  }
51
+ }
50
52
 
51
- &:focus-visible {
52
- outline: 2px solid var(--collapse-focus-color);
53
- outline-offset: 2px;
54
- border-radius: var(--border-radius-4, 4px);
55
- }
53
+ .component-tPiInR[data-has-outline] .toggle-YA8uJB:focus-visible {
54
+ outline: 2px solid var(--collapse-focus-color);
55
+ outline-offset: 2px;
56
+ border-radius: var(--border-radius-4, 4px);
56
57
  }
57
58
 
58
59
  .icon-wFeaQN {
@@ -100,13 +100,13 @@
100
100
  }
101
101
  }
102
102
 
103
- .component-aUdiT5:not([data-disabled]) .field-MFnvYv:focus-within {
103
+ .component-aUdiT5[data-has-outline]:not([data-disabled]) .field-MFnvYv:focus-within {
104
104
  box-shadow: none;
105
105
  outline: 2px solid var(--input-focus-border-color);
106
106
  outline-offset: 0;
107
107
  }
108
108
 
109
- .component-aUdiT5[data-error]:not([data-disabled]) .field-MFnvYv:focus-within {
109
+ .component-aUdiT5[data-has-outline][data-error]:not([data-disabled]) .field-MFnvYv:focus-within {
110
110
  outline-color: var(--input-error-border-color);
111
111
  }
112
112
 
@@ -274,11 +274,6 @@
274
274
  color: var(--field-icon-color);
275
275
  }
276
276
 
277
- &:focus-visible {
278
- outline: 2px solid var(--input-focus-border-color);
279
- outline-offset: 2px;
280
- }
281
-
282
277
  & svg {
283
278
  width: var(--input-icon-size);
284
279
  height: var(--input-icon-size);
@@ -286,6 +281,11 @@
286
281
  }
287
282
  }
288
283
 
284
+ .component-aUdiT5[data-has-outline] .clear-A5Krz8:focus-visible {
285
+ outline: 2px solid var(--input-focus-border-color);
286
+ outline-offset: 2px;
287
+ }
288
+
289
289
  .component-aUdiT5 .message-ArUnJU {
290
290
  color: var(--input-hint-color);
291
291
  overflow-wrap: anywhere;
@@ -7,6 +7,7 @@ export declare const Input: import("react").ForwardRefExoticComponent<Omit<impor
7
7
  view?: "primary" | "secondary";
8
8
  size?: 40 | 48 | 56 | 64 | 72;
9
9
  block?: boolean;
10
+ hasOutline?: boolean;
10
11
  label?: import("react").ReactNode;
11
12
  labelView?: "outer" | "inner";
12
13
  hint?: import("react").ReactNode;
@@ -6,7 +6,7 @@ import { useDataTestId } from "../../hooks/use-data-test-id.js";
6
6
  import { Button } from "../Button/index.js";
7
7
  import { TypographyText } from "../Typography/text.js";
8
8
  import index_module from "./index.module.js";
9
- const Input = /*#__PURE__*/ forwardRef(({ view = 'primary', size = 40, block = false, label, labelView = 'outer', hint, error, leftAddon, rightAddon, clear = false, clearLabel = 'Очистить поле', value, defaultValue, maxLength, showValueLength = false, onChange, onClear, disabled = false, readOnly = false, type = 'text', id, className, style, fieldClassName, inputClassName, labelClassName, messageClassName, dataTestId, ...restProps }, ref)=>{
9
+ const Input = /*#__PURE__*/ forwardRef(({ view = 'primary', size = 40, block = false, hasOutline = false, label, labelView = 'outer', hint, error, leftAddon, rightAddon, clear = false, clearLabel = 'Очистить поле', value, defaultValue, maxLength, showValueLength = false, onChange, onClear, disabled = false, readOnly = false, type = 'text', id, className, style, fieldClassName, inputClassName, labelClassName, messageClassName, dataTestId, ...restProps }, ref)=>{
10
10
  const generatedId = useId();
11
11
  const inputId = id ?? generatedId;
12
12
  const inputRef = useRef(null);
@@ -92,6 +92,7 @@ const Input = /*#__PURE__*/ forwardRef(({ view = 'primary', size = 40, block = f
92
92
  style: style,
93
93
  "data-view": view,
94
94
  "data-block": block || void 0,
95
+ "data-has-outline": hasOutline || void 0,
95
96
  "data-disabled": disabled || void 0,
96
97
  "data-read-only": readOnly || void 0,
97
98
  "data-error": hasError || void 0,
@@ -35,6 +35,11 @@ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'v
35
35
  * @default false
36
36
  */
37
37
  block?: boolean;
38
+ /**
39
+ * Показывает outline при фокусе.
40
+ * @default false
41
+ */
42
+ hasOutline?: boolean;
38
43
  /**
39
44
  * Название поля. Связывается с input через htmlFor и id.
40
45
  */
@@ -1,7 +1,7 @@
1
1
  import type { SelectState } from '../hooks/use-select-state.js';
2
2
  import type { SelectProps } from '../types.js';
3
- type Props = Pick<SelectProps, 'multiple' | 'searchable' | 'searchPlaceholder' | 'noResultsText' | 'dataTestId'> & {
3
+ type Props = Pick<SelectProps, 'multiple' | 'searchable' | 'searchPlaceholder' | 'noResultsText' | 'dataTestId' | 'hasOutline'> & {
4
4
  state: SelectState;
5
5
  };
6
- export declare function SelectDropdown({ state, multiple, searchable, searchPlaceholder, noResultsText, dataTestId, }: Props): import("react").JSX.Element;
6
+ export declare function SelectDropdown({ state, multiple, searchable, hasOutline, searchPlaceholder, noResultsText, dataTestId, }: Props): import("react").JSX.Element;
7
7
  export {};
@@ -7,7 +7,7 @@ import { useDataTestId } from "../../../hooks/use-data-test-id.js";
7
7
  import { Input } from "../../Input/index.js";
8
8
  import { TypographyText } from "../../Typography/text.js";
9
9
  import index_module from "../index.module.js";
10
- function SelectDropdown({ state, multiple, searchable, searchPlaceholder = 'Поиск по списку', noResultsText = 'Ничего не найдено', dataTestId }) {
10
+ function SelectDropdown({ state, multiple, searchable, hasOutline, searchPlaceholder = 'Поиск по списку', noResultsText = 'Ничего не найдено', dataTestId }) {
11
11
  const getDataTestId = useDataTestId(dataTestId);
12
12
  const { options, selectedIds, search, activeId, setSearch, handleKeyDown, select } = state;
13
13
  const activeOptionRef = useRef(null);
@@ -23,6 +23,7 @@ function SelectDropdown({ state, multiple, searchable, searchPlaceholder = 'По
23
23
  searchable && /*#__PURE__*/ jsx(Input, {
24
24
  block: true,
25
25
  autoFocus: true,
26
+ hasOutline: hasOutline,
26
27
  size: 40,
27
28
  view: "secondary",
28
29
  value: search,
@@ -89,13 +89,13 @@
89
89
  }
90
90
  }
91
91
 
92
- .component-cM8DTg:not(.disabled-fZIeN_) .field-jGXYY5:focus-within, .component-cM8DTg.open-CCkiBd .field-jGXYY5 {
92
+ .component-cM8DTg[data-has-outline]:not(.disabled-fZIeN_) .field-jGXYY5:focus-within, .component-cM8DTg[data-has-outline].open-CCkiBd .field-jGXYY5 {
93
93
  box-shadow: none;
94
94
  outline: 2px solid var(--select-focus-border-color);
95
95
  outline-offset: 0;
96
96
  }
97
97
 
98
- .component-cM8DTg.error-TrKhzv:not(.disabled-fZIeN_) .field-jGXYY5:focus-within, .component-cM8DTg.error-TrKhzv.open-CCkiBd .field-jGXYY5 {
98
+ .component-cM8DTg[data-has-outline].error-TrKhzv:not(.disabled-fZIeN_) .field-jGXYY5:focus-within, .component-cM8DTg[data-has-outline].error-TrKhzv.open-CCkiBd .field-jGXYY5 {
99
99
  outline-color: var(--select-error-border-color);
100
100
  }
101
101
 
@@ -22,7 +22,7 @@ const dropdownOffset = [
22
22
  8
23
23
  ];
24
24
  const Select = /*#__PURE__*/ forwardRef((props, ref)=>{
25
- const { view = 'primary', size = 40, label, labelView = 'outer', block = false, placeholder = 'Выберите значение', hint, error, clear = false, disabled = false, readOnly = false, className, style, labelClassName, messageClassName, dropdownClassName, dataTestId, id, name, form, onClear: _onClear, getPortalContainer, options: _options, multiple, value: _value, defaultValue: _defaultValue, onChange: _onChange, searchable, searchPlaceholder, open: _open, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, noResultsText, ...buttonProps } = props;
25
+ const { view = 'primary', size = 40, label, labelView = 'outer', block = false, hasOutline = false, placeholder = 'Выберите значение', hint, error, clear = false, disabled = false, readOnly = false, className, style, labelClassName, messageClassName, dropdownClassName, dataTestId, id, name, form, onClear: _onClear, getPortalContainer, options: _options, multiple, value: _value, defaultValue: _defaultValue, onChange: _onChange, searchable, searchPlaceholder, open: _open, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, noResultsText, ...buttonProps } = props;
26
26
  const generatedId = useId();
27
27
  const triggerId = id ?? generatedId;
28
28
  const getDataTestId = useDataTestId(dataTestId);
@@ -48,6 +48,7 @@ const Select = /*#__PURE__*/ forwardRef((props, ref)=>{
48
48
  [index_module.labelRaised]: innerLabel && raisedLabel
49
49
  }, className),
50
50
  style: style,
51
+ "data-has-outline": hasOutline || void 0,
51
52
  "data-test-id": getDataTestId('form-control'),
52
53
  children: [
53
54
  hasLabel && 'outer' === labelView && /*#__PURE__*/ jsx("label", {
@@ -149,6 +150,7 @@ const Select = /*#__PURE__*/ forwardRef((props, ref)=>{
149
150
  state: state,
150
151
  multiple: multiple,
151
152
  searchable: searchable,
153
+ hasOutline: hasOutline,
152
154
  searchPlaceholder: searchPlaceholder,
153
155
  noResultsText: noResultsText,
154
156
  dataTestId: dataTestId
@@ -27,7 +27,7 @@ export type SelectChangePayload<Value = string | null> = {
27
27
  */
28
28
  selectedOptions: SelectOption[];
29
29
  };
30
- type CommonProps = Pick<InputProps, 'view' | 'size' | 'block' | 'hint' | 'error' | 'clear' | 'className' | 'style' | 'labelClassName' | 'messageClassName'> & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'name' | 'type' | 'className' | 'style'> & {
30
+ type CommonProps = Pick<InputProps, 'view' | 'size' | 'block' | 'hasOutline' | 'hint' | 'error' | 'clear' | 'className' | 'style' | 'labelClassName' | 'messageClassName'> & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'name' | 'type' | 'className' | 'style'> & {
31
31
  /**
32
32
  * Варианты с уникальными id. Порядок строк сохраняется при выборе.
33
33
  */
@@ -64,13 +64,13 @@
64
64
  }
65
65
  }
66
66
 
67
- .component-K9LhZN:not([data-disabled]) .field-GADSqb:focus-within {
67
+ .component-K9LhZN[data-has-outline]:not([data-disabled]) .field-GADSqb:focus-within {
68
68
  box-shadow: none;
69
69
  outline: 2px solid var(--input-focus-border-color);
70
70
  outline-offset: 0;
71
71
  }
72
72
 
73
- .component-K9LhZN[data-error]:not([data-disabled]) .field-GADSqb:focus-within {
73
+ .component-K9LhZN[data-has-outline][data-error]:not([data-disabled]) .field-GADSqb:focus-within {
74
74
  outline-color: var(--input-error-border-color);
75
75
  }
76
76
 
@@ -6,6 +6,7 @@ export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<im
6
6
  showValueLength?: boolean;
7
7
  view?: "primary" | "secondary";
8
8
  block?: boolean;
9
+ hasOutline?: boolean;
9
10
  label?: import("react").ReactNode;
10
11
  labelView?: "outer" | "inner";
11
12
  hint?: import("react").ReactNode;
@@ -7,7 +7,7 @@ import { Button } from "../Button/index.js";
7
7
  import { TypographyText } from "../Typography/text.js";
8
8
  import { useAutosize } from "./hooks/use-autosize.js";
9
9
  import index_module from "./index.module.js";
10
- const Textarea = /*#__PURE__*/ forwardRef(({ view = 'primary', block = false, label, labelView = 'outer', hint, error, minRows = 3, maxRows, autosize = false, resize = false, clear = false, value, defaultValue, maxLength, showValueLength = false, onChange, onClear, disabled = false, readOnly = false, id, className, style, fieldClassName, textareaClassName, labelClassName, messageClassName, dataTestId, ...restProps }, ref)=>{
10
+ const Textarea = /*#__PURE__*/ forwardRef(({ view = 'primary', block = false, hasOutline = false, label, labelView = 'outer', hint, error, minRows = 3, maxRows, autosize = false, resize = false, clear = false, value, defaultValue, maxLength, showValueLength = false, onChange, onClear, disabled = false, readOnly = false, id, className, style, fieldClassName, textareaClassName, labelClassName, messageClassName, dataTestId, ...restProps }, ref)=>{
11
11
  const generatedId = useId();
12
12
  const textareaId = id ?? generatedId;
13
13
  const textareaRef = useRef(null);
@@ -96,6 +96,7 @@ const Textarea = /*#__PURE__*/ forwardRef(({ view = 'primary', block = false, la
96
96
  },
97
97
  "data-view": view,
98
98
  "data-block": block || void 0,
99
+ "data-has-outline": hasOutline || void 0,
99
100
  "data-disabled": disabled || void 0,
100
101
  "data-read-only": readOnly || void 0,
101
102
  "data-error": Boolean(error) || void 0,
@@ -28,6 +28,11 @@ export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'v
28
28
  * @default false
29
29
  */
30
30
  block?: boolean;
31
+ /**
32
+ * Показывает outline поля при фокусе.
33
+ * @default false
34
+ */
35
+ hasOutline?: boolean;
31
36
  /**
32
37
  * Название поля. Клик переводит фокус в textarea.
33
38
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koslibs/components",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Shared React components for koslibs projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -68,8 +68,8 @@
68
68
  ]
69
69
  },
70
70
  "devDependencies": {
71
- "@koslibs/builder": "^1.0.0",
72
- "@koslibs/configs": "^1.0.0",
71
+ "@koslibs/builder": "^2.0.0",
72
+ "@koslibs/configs": "^2.0.0",
73
73
  "@types/node": "^24.19.0",
74
74
  "@types/react": "^18.3.18",
75
75
  "@types/react-dom": "^18.3.5",
@@ -81,7 +81,7 @@
81
81
  "react-dom": "^18.3.1 || ^19.0.0"
82
82
  },
83
83
  "dependencies": {
84
- "@koslibs/icons": "1.2.0",
84
+ "@koslibs/icons": "1.2.1",
85
85
  "@popperjs/core": "2.11.8",
86
86
  "classnames": "2.5.1"
87
87
  }