@koslibs/components 1.17.0 → 1.19.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 +12 -0
- package/dist/components/Datepicker/datepicker-popover.d.ts +4 -0
- package/dist/components/Datepicker/datepicker-popover.js +60 -0
- package/dist/components/Datepicker/datepicker.js +11 -19
- package/dist/components/Datepicker/index.d.ts +2 -1
- package/dist/components/Datepicker/index.js +1 -0
- package/dist/components/Datepicker/types.d.ts +7 -0
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/types.d.ts +3 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @koslibs/components
|
|
2
2
|
|
|
3
|
+
## 1.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#22](https://github.com/koslibs/components/pull/22) [`0a705c8`](https://github.com/koslibs/components/commit/0a705c882c901841c80288c7aebd4201721681c9) Thanks [@holypower777](https://github.com/holypower777)! - Добавлен DatepickerPopover для подключения к своему триггеру и внешнего управления видимостью календаря.
|
|
8
|
+
|
|
9
|
+
## 1.18.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#21](https://github.com/koslibs/components/pull/21) [`0c010e3`](https://github.com/koslibs/components/commit/0c010e36657f39517053465e5d4864936b11f164) Thanks [@holypower777](https://github.com/holypower777)! - Export `SelectSingleProps` and `SelectMultipleProps` from the package root and the `Select` entry point so consumers can type change handlers for either selection mode directly.
|
|
14
|
+
|
|
3
15
|
## 1.17.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PopoverProps } from '../Popover/index.js';
|
|
2
|
+
import type { DatepickerPopoverProps, DatepickerValueProps } from './types.js';
|
|
3
|
+
export declare const DatepickerPopoverSurface: import("react").ForwardRefExoticComponent<Omit<PopoverProps, "className" | "offset"> & Pick<DatepickerValueProps, "mode"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const DatepickerPopover: import("react").ForwardRefExoticComponent<DatepickerPopoverProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useDataTestId } from "../../hooks/use-data-test-id.js";
|
|
5
|
+
import { Popover } from "../Popover/index.js";
|
|
6
|
+
import { DatepickerPanel } from "./datepicker-panel.js";
|
|
7
|
+
import { useDatepickerValue } from "./hooks/use-datepicker-value.js";
|
|
8
|
+
import index_module from "./index.module.js";
|
|
9
|
+
const offset = [
|
|
10
|
+
0,
|
|
11
|
+
8
|
|
12
|
+
];
|
|
13
|
+
const DatepickerPopoverSurface = /*#__PURE__*/ forwardRef(({ mode, children, ...props }, ref)=>/*#__PURE__*/ jsx(Popover, {
|
|
14
|
+
...props,
|
|
15
|
+
ref: ref,
|
|
16
|
+
offset: offset,
|
|
17
|
+
className: classnames(index_module.popup, 'range' === mode && index_module.rangePopup),
|
|
18
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
19
|
+
className: index_module.panelContainer,
|
|
20
|
+
children: children
|
|
21
|
+
})
|
|
22
|
+
}));
|
|
23
|
+
const DatepickerPopover = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
24
|
+
const { open, anchorElement, position, getPortalContainer, outsideClick, onClose, onCancel, dataTestId, id, className, style } = props;
|
|
25
|
+
const selection = useDatepickerValue(props);
|
|
26
|
+
const getId = useDataTestId(dataTestId);
|
|
27
|
+
const handleChange = (event, { value })=>{
|
|
28
|
+
selection.commit(event, value);
|
|
29
|
+
};
|
|
30
|
+
const valueProps = 'range' === props.mode ? {
|
|
31
|
+
mode: 'range',
|
|
32
|
+
value: 'object' == typeof selection.value ? selection.value : null,
|
|
33
|
+
onChange: handleChange
|
|
34
|
+
} : {
|
|
35
|
+
mode: 'single',
|
|
36
|
+
value: 'string' == typeof selection.value ? selection.value : null,
|
|
37
|
+
onChange: handleChange
|
|
38
|
+
};
|
|
39
|
+
return /*#__PURE__*/ jsx(DatepickerPopoverSurface, {
|
|
40
|
+
ref: ref,
|
|
41
|
+
mode: props.mode,
|
|
42
|
+
open: open,
|
|
43
|
+
anchorElement: anchorElement,
|
|
44
|
+
position: position,
|
|
45
|
+
getPortalContainer: getPortalContainer,
|
|
46
|
+
outsideClick: outsideClick,
|
|
47
|
+
onClose: onClose,
|
|
48
|
+
dataTestId: dataTestId,
|
|
49
|
+
children: /*#__PURE__*/ jsx(DatepickerPanel, {
|
|
50
|
+
...valueProps,
|
|
51
|
+
id: id,
|
|
52
|
+
className: className,
|
|
53
|
+
style: style,
|
|
54
|
+
onCancel: onCancel ?? onClose,
|
|
55
|
+
dataTestId: getId('panel')
|
|
56
|
+
}, props.mode ?? 'single')
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
DatepickerPopover.displayName = 'DatepickerPopover';
|
|
60
|
+
export { DatepickerPopover, DatepickerPopoverSurface };
|
|
@@ -5,9 +5,9 @@ import classnames from "classnames";
|
|
|
5
5
|
import { forwardRef, useId, useImperativeHandle } from "react";
|
|
6
6
|
import { useDataTestId } from "../../hooks/use-data-test-id.js";
|
|
7
7
|
import { Button } from "../Button/index.js";
|
|
8
|
-
import { Popover } from "../Popover/index.js";
|
|
9
8
|
import { TypographyText } from "../Typography/text.js";
|
|
10
9
|
import { DatepickerPanel } from "./datepicker-panel.js";
|
|
10
|
+
import { DatepickerPopoverSurface } from "./datepicker-popover.js";
|
|
11
11
|
import { useDatepickerState } from "./hooks/use-datepicker-state.js";
|
|
12
12
|
import { formatDate } from "./utils/date-utils.js";
|
|
13
13
|
import index_module from "./index.module.js";
|
|
@@ -18,10 +18,6 @@ const textSizes = {
|
|
|
18
18
|
64: 14,
|
|
19
19
|
72: 16
|
|
20
20
|
};
|
|
21
|
-
const offset = [
|
|
22
|
-
0,
|
|
23
|
-
8
|
|
24
|
-
];
|
|
25
21
|
const Datepicker = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
26
22
|
const { mode, value: _value, defaultValue: _defaultValue, onChange: _onChange, view = 'primary', size = 40, label, labelView = 'outer', hint, error, block = false, hasOutline = false, clear = false, disabled = false, readOnly = false, placeholder = 'range' === mode ? 'Choose dates' : 'Choose date', open: _open, defaultOpen: _defaultOpen, onOpenChange: _onOpenChange, onClear: _onClear, id, name, form, className, style, labelClassName, messageClassName, panelClassName, getPortalContainer, dataTestId, ...buttonProps } = props;
|
|
27
23
|
const generatedId = useId();
|
|
@@ -165,27 +161,23 @@ const Datepicker = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
165
161
|
disabled: disabled,
|
|
166
162
|
form: form
|
|
167
163
|
})),
|
|
168
|
-
/*#__PURE__*/ jsx(
|
|
164
|
+
/*#__PURE__*/ jsx(DatepickerPopoverSurface, {
|
|
169
165
|
ref: state.popupRef,
|
|
166
|
+
mode: state.mode,
|
|
170
167
|
open: state.open,
|
|
171
168
|
anchorElement: state.anchor,
|
|
172
|
-
offset: offset,
|
|
173
169
|
onClose: handleClose,
|
|
174
170
|
escapeKeyDown: false,
|
|
175
171
|
getPortalContainer: getPortalContainer,
|
|
176
|
-
className: classnames(index_module.popup, 'range' === state.mode && index_module.rangePopup),
|
|
177
172
|
dataTestId: getId('popup'),
|
|
178
|
-
children: /*#__PURE__*/ jsx(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
dataTestId: getId('panel')
|
|
187
|
-
}, `${state.mode}-${state.session}`)
|
|
188
|
-
})
|
|
173
|
+
children: /*#__PURE__*/ jsx(DatepickerPanel, {
|
|
174
|
+
id: panelId,
|
|
175
|
+
...panelProps,
|
|
176
|
+
onChange: handleChange,
|
|
177
|
+
onCancel: handleCancel,
|
|
178
|
+
className: panelClassName,
|
|
179
|
+
dataTestId: getId('panel')
|
|
180
|
+
}, `${state.mode}-${state.session}`)
|
|
189
181
|
})
|
|
190
182
|
]
|
|
191
183
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { Datepicker } from './datepicker.js';
|
|
2
2
|
export { DatepickerPanel } from './datepicker-panel.js';
|
|
3
|
-
export
|
|
3
|
+
export { DatepickerPopover } from './datepicker-popover.js';
|
|
4
|
+
export type { DatepickerProps, DatepickerPanelProps, DatepickerPopoverProps, DatepickerRange, DatepickerChangePayload, } from './types.js';
|
|
@@ -79,6 +79,13 @@ export type DatepickerPanelProps = DatepickerValueProps & {
|
|
|
79
79
|
*/
|
|
80
80
|
dataTestId?: string;
|
|
81
81
|
};
|
|
82
|
+
export type DatepickerPopoverProps = DatepickerPanelProps & Pick<PopoverProps, 'open' | 'anchorElement' | 'position' | 'getPortalContainer' | 'outsideClick'> & {
|
|
83
|
+
/**
|
|
84
|
+
* Запрос закрытия при клике снаружи или Escape. Cancel и Escape внутри панели
|
|
85
|
+
* используют onCancel, если он задан. Видимость меняется через open.
|
|
86
|
+
*/
|
|
87
|
+
onClose?: VoidFunction;
|
|
88
|
+
};
|
|
82
89
|
type FieldProps = Pick<InputProps, 'view' | 'size' | 'block' | 'label' | 'labelView' | 'hint' | 'error' | 'hasOutline' | 'clear' | 'labelClassName' | 'messageClassName'> & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'name' | 'type' | 'style'> & {
|
|
83
90
|
/**
|
|
84
91
|
* Стили обёртки поля и её CSS-переменные.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Select } from './select.js';
|
|
2
|
-
export type { SelectProps, SelectOption, SelectChangeEvent, SelectChangePayload } from './types.js';
|
|
2
|
+
export type { SelectProps, SelectSingleProps, SelectMultipleProps, SelectOption, SelectChangeEvent, SelectChangePayload, } from './types.js';
|
|
@@ -141,5 +141,7 @@ type MultipleProps = {
|
|
|
141
141
|
*/
|
|
142
142
|
onChange?: (event: SelectChangeEvent, payload: SelectChangePayload<string[]>) => void;
|
|
143
143
|
};
|
|
144
|
-
export type
|
|
144
|
+
export type SelectSingleProps = CommonProps & SingleProps;
|
|
145
|
+
export type SelectMultipleProps = CommonProps & MultipleProps;
|
|
146
|
+
export type SelectProps = SelectSingleProps | SelectMultipleProps;
|
|
145
147
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export { Chips } from './components/Chips/index.js';
|
|
|
4
4
|
export type { ChipsProps, ChipsItem, ChipsChangePayload } from './components/Chips/index.js';
|
|
5
5
|
export { Input } from './components/Input/index.js';
|
|
6
6
|
export type { InputProps } from './components/Input/index.js';
|
|
7
|
-
export { Datepicker, DatepickerPanel } from './components/Datepicker/index.js';
|
|
8
|
-
export type { DatepickerProps, DatepickerPanelProps, DatepickerRange, DatepickerChangePayload, } from './components/Datepicker/index.js';
|
|
7
|
+
export { Datepicker, DatepickerPanel, DatepickerPopover } from './components/Datepicker/index.js';
|
|
8
|
+
export type { DatepickerProps, DatepickerPanelProps, DatepickerPopoverProps, DatepickerRange, DatepickerChangePayload, } from './components/Datepicker/index.js';
|
|
9
9
|
export { Select } from './components/Select/index.js';
|
|
10
|
-
export type { SelectProps, SelectOption, SelectChangeEvent, SelectChangePayload, } from './components/Select/index.js';
|
|
10
|
+
export type { SelectProps, SelectSingleProps, SelectMultipleProps, SelectOption, SelectChangeEvent, SelectChangePayload, } from './components/Select/index.js';
|
|
11
11
|
export { Textarea } from './components/Textarea/index.js';
|
|
12
12
|
export type { TextareaProps } from './components/Textarea/index.js';
|
|
13
13
|
export { Tab, Tabs } from './components/Tabs/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Button } from "./components/Button/index.js";
|
|
2
2
|
export { Chips } from "./components/Chips/index.js";
|
|
3
3
|
export { Input } from "./components/Input/index.js";
|
|
4
|
-
export { Datepicker, DatepickerPanel } from "./components/Datepicker/index.js";
|
|
4
|
+
export { Datepicker, DatepickerPanel, DatepickerPopover } from "./components/Datepicker/index.js";
|
|
5
5
|
export { Select } from "./components/Select/index.js";
|
|
6
6
|
export { Textarea } from "./components/Textarea/index.js";
|
|
7
7
|
export { Tab, Tabs } from "./components/Tabs/index.js";
|