kamotive_ui 1.2.20 → 1.2.21

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.
@@ -11,7 +11,7 @@ import { ChevronRight } from '../../Icons/ChevronRight/ChevronRight';
11
11
  import { ChevronLeft } from '../../Icons/ChevronLeft/ChevronLeft';
12
12
  import { Button } from '../Button/Button';
13
13
  registerLocale('ru', ru);
14
- const CustomInput = forwardRef(({ value = '', onClick, onDateChange, onClose, className }, ref) => {
14
+ const CustomInput = forwardRef(({ value = '', onClick, onDateChange, onClose, className, disabled = false, readOnly = false }, ref) => {
15
15
  const inputRef = useRef(null);
16
16
  const [selectedPart, setSelectedPart] = useState(null);
17
17
  const [tempInput, setTempInput] = useState('');
@@ -38,7 +38,9 @@ const CustomInput = forwardRef(({ value = '', onClick, onDateChange, onClose, cl
38
38
  };
39
39
  const updateInputValue = (char, position) => {
40
40
  setShouldReselect(true);
41
- setInput(input.substring(0, position) + char + input.substring(position + char.length));
41
+ if (!readOnly) {
42
+ setInput(input.substring(0, position) + char + input.substring(position + char.length));
43
+ }
42
44
  };
43
45
  const handleClick = (e) => {
44
46
  e.preventDefault();
@@ -174,7 +176,9 @@ const CustomInput = forwardRef(({ value = '', onClick, onDateChange, onClose, cl
174
176
  }
175
177
  }, []);
176
178
  useEffect(() => {
177
- setInput(value);
179
+ if (!readOnly) {
180
+ setInput(value);
181
+ }
178
182
  }, [value]);
179
183
  useEffect(() => {
180
184
  setTempInput('');
@@ -185,9 +189,9 @@ const CustomInput = forwardRef(({ value = '', onClick, onDateChange, onClose, cl
185
189
  useImperativeHandle(ref, () => ({
186
190
  removeSelection,
187
191
  }), [removeSelection]);
188
- return (React.createElement("input", { ref: inputRef, value: input, onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, readOnly: true, className: className }));
192
+ return (React.createElement("input", { ref: inputRef, value: input, onClick: handleClick, onKeyDown: handleKeyDown, onFocus: handleFocus, onBlur: handleBlur, readOnly: readOnly, disabled: disabled, className: className }));
189
193
  });
190
- export const DateInput = ({ id, label = 'Выберите дату', size = 'lg', value, style, className, disabled = false, readOnly = disabled, isLeftLabel = false, icon, error = false, helperText, onChange, onBlur, required = false, minDate = new Date('1975-12-31'), maxDate = new Date('2074-12-31'), inputClassName, calendarClassName, dateFormat = 'dd.MM.yyyy', }) => {
194
+ export const DateInput = ({ id, label = 'Выберите дату', size = 'lg', value, style, className, disabled = false, readOnly = false, isLeftLabel = false, icon, error = false, helperText, onChange, onBlur, required = false, minDate = new Date('1975-12-31'), maxDate = new Date('2074-12-31'), inputClassName, calendarClassName, dateFormat = 'dd.MM.yyyy', }) => {
191
195
  const wrapperClassess = classNames(styles['wrapper--input'], className, {
192
196
  [styles['wrapper--left']]: isLeftLabel,
193
197
  [styles['wrapper--input-label']]: label && !isLeftLabel && !required,
@@ -322,7 +326,7 @@ export const DateInput = ({ id, label = 'Выберите дату', size = 'lg'
322
326
  return (React.createElement("div", { className: wrapperClassess, style: style },
323
327
  label && (React.createElement(Typography, { variant: "Caption", className: labelClasses }, label)),
324
328
  React.createElement("div", { className: styles.icon, onClick: () => { var _a; return (_a = datePickerRef.current) === null || _a === void 0 ? void 0 : _a.setOpen(true); } }, icon || React.createElement(IconCalendar10, null)),
325
- React.createElement(DatePicker, Object.assign({ id: id, ref: datePickerRef, selected: selectedDate, onChange: handleDateChange, onBlur: onBlur, dateFormat: dateFormat, locale: "ru", readOnly: readOnly, showPopperArrow: false, calendarClassName: classNames(styles.calendar, calendarClassName), popperClassName: styles.calendarPopper, onCalendarClose: () => setIsMonthPickerOpen(false), minDate: minDate, maxDate: maxDate, inline: false, calendarStartDay: 1, dayClassName: (date) => {
329
+ React.createElement(DatePicker, Object.assign({ id: id, ref: datePickerRef, selected: selectedDate, onChange: handleDateChange, onBlur: onBlur, dateFormat: dateFormat, locale: "ru", readOnly: readOnly, disabled: disabled, showPopperArrow: false, calendarClassName: classNames(styles.calendar, calendarClassName), popperClassName: styles.calendarPopper, onCalendarClose: () => setIsMonthPickerOpen(false), minDate: minDate, maxDate: maxDate, inline: false, calendarStartDay: 1, dayClassName: (date) => {
326
330
  return date.getMonth() === (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getMonth()) && date.getFullYear() === (selectedDate === null || selectedDate === void 0 ? void 0 : selectedDate.getFullYear())
327
331
  ? 'current-month-day'
328
332
  : '';
@@ -331,6 +335,6 @@ export const DateInput = ({ id, label = 'Выберите дату', size = 'lg'
331
335
  : {
332
336
  renderCustomHeader: renderCustomHeader,
333
337
  renderDayContents: renderDayContents,
334
- }), { customInput: React.createElement(CustomInput, { ref: inputRef, className: classNames(inputClassess, inputClassName), onDateChange: handleCustomInputChange, onClose: handleCloseDatePicker }) })),
338
+ }), { customInput: React.createElement(CustomInput, { ref: inputRef, className: classNames(inputClassess, inputClassName), onDateChange: handleCustomInputChange, onClose: handleCloseDatePicker, disabled: disabled, readOnly: readOnly }) })),
335
339
  error && helperText && (React.createElement(Typography, { variant: "Caption", className: classNames(styles.helperText, styles[size]) }, helperText))));
336
340
  };
@@ -2,15 +2,16 @@ import React from 'react';
2
2
  import styles from './Tab.module.css';
3
3
  import classNames from 'classnames';
4
4
  import { Typography } from '../Typography/Typography';
5
- export const Tab = ({ value, onClick, onMouseEnter, label, selected, disabled = false }) => {
5
+ export const Tab = ({ value, onClick, onMouseEnter, label, selected, disabled = false, style, className }) => {
6
6
  const handleClick = (e) => {
7
7
  if (onClick && value && !disabled) {
8
8
  onClick(value);
9
9
  }
10
10
  };
11
11
  return (React.createElement("button", { role: "tab", "aria-selected": selected, "aria-disabled": disabled, value: value, className: classNames(styles.tab, {
12
- [styles['selected']]: selected,
13
- [styles['disabled']]: disabled,
14
- }), onClick: handleClick, onMouseEnter: onMouseEnter },
12
+ [styles.selected]: selected,
13
+ [styles.disabled]: disabled,
14
+ [className || '']: className,
15
+ }), onClick: handleClick, onMouseEnter: onMouseEnter, style: style },
15
16
  React.createElement(Typography, { variant: selected ? 'Body1-SemiBold' : 'Body1' }, label)));
16
17
  };
@@ -1,5 +1,7 @@
1
1
  .tab {
2
- width: 126px;
2
+ /* width: 126px; */
3
+ width: 100%;
4
+ white-space: nowrap;
3
5
  height: 24px;
4
6
  padding: 3px 10px;
5
7
  display: flex;
@@ -1,7 +1,7 @@
1
1
  ;
2
2
  import React from 'react';
3
3
  import styles from './Tabs.module.css';
4
- export const Tabs = ({ value, onChange, children }) => {
4
+ export const Tabs = ({ value, onChange, children, style, className }) => {
5
5
  var _a;
6
6
  const selectedTabContent = (_a = children === null || children === void 0 ? void 0 : children.find((child) => child.props.value === value)) === null || _a === void 0 ? void 0 : _a.props.children;
7
7
  const handleTabChange = (newValue) => {
@@ -10,7 +10,7 @@ export const Tabs = ({ value, onChange, children }) => {
10
10
  }
11
11
  };
12
12
  return (React.createElement(React.Fragment, null,
13
- React.createElement("div", { role: "tablist", className: styles.tabs }, children === null || children === void 0 ? void 0 : children.map((child, index) => React.cloneElement(child, {
13
+ React.createElement("div", { role: "tablist", className: styles.tabs + ' ' + (className || ''), style: style }, children === null || children === void 0 ? void 0 : children.map((child, index) => React.cloneElement(child, {
14
14
  key: index,
15
15
  selected: child.props.value === value,
16
16
  disabled: child.props.disabled,
@@ -9,7 +9,9 @@
9
9
  }
10
10
 
11
11
  .tab {
12
- width: 126px;
12
+ /* width: 126px; */
13
+ width: 100%;
14
+ white-space: nowrap;
13
15
  height: 24px;
14
16
  padding: 3px 10px;
15
17
  display: flex;
@@ -315,6 +315,10 @@ export interface TabProps {
315
315
  disabled?: boolean;
316
316
  /** Табы */
317
317
  children?: React.ReactNode;
318
+ /** Стили передаваемые напрямую */
319
+ style?: CSSProperties;
320
+ /** Дополнительный класс */
321
+ className?: string;
318
322
  }
319
323
  export interface TabsProps {
320
324
  /** Табы */
@@ -323,6 +327,10 @@ export interface TabsProps {
323
327
  value?: string;
324
328
  /** Обработчик изменения значения */
325
329
  onChange?: (value: string) => void;
330
+ /** Стили передаваемые напрямую */
331
+ style?: CSSProperties;
332
+ /** Дополнительный класс */
333
+ className?: string;
326
334
  }
327
335
  export interface ColorPickerProps {
328
336
  /** Цвет выбранный пользователем */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kamotive_ui",
3
- "version": "1.2.20",
3
+ "version": "1.2.21",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [