@homecode/ui 4.16.0 → 4.17.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/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export { Calendar } from './src/components/Calendar/Calendar.js';
5
5
  export { Checkbox } from './src/components/Checkbox/Checkbox.js';
6
6
  export { Container } from './src/components/Container/Container.js';
7
7
  export { DatePicker } from './src/components/DatePicker/DatePicker.js';
8
+ export { DatePickerInput } from './src/components/DatePickerInput/DatePickerInput.js';
8
9
  export { DateTime, formatDate } from './src/components/DateTime/DateTime.js';
9
10
  export { Draggable } from './src/components/Draggable/Draggable.js';
10
11
  export { Expand } from './src/components/Expand/Expand.js';
@@ -36,7 +36,7 @@ function DatePicker(props) {
36
36
  }
37
37
  return (createElement(Button, { ...props, variant: "clear", className: cn(classes), size: size, key: `${year}-${month}-${day}` }, day));
38
38
  }, [size, isPicking, isRange, value, onChange]);
39
- return (jsxs("div", { className: cn(S.root, props.className), onPointerDown: onPointerDown, onPointerUp: onPointerUp, children: [jsx(Calendar, { size: size, hideOtherMonthDays: true, ...calendarProps, renderDay: renderDay, value: isRange ? value[0] : value, onDayPointerDown: onFirstDateChange }), isRange && (jsx(Calendar, { size: size, hideOtherMonthDays: true, ...calendarProps, renderDay: renderDay, value: value[1], onDayPointerDown: val => onChange([value[0], val]), onDayPointerUp: val => onChange([value[0], val]) }))] }));
39
+ return (jsxs("div", { className: cn(S.root, props.className), onPointerDown: onPointerDown, onPointerUp: onPointerUp, children: [jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: isRange ? value[0] : value, onDayPointerDown: onFirstDateChange, onDayPointerUp: undefined }), isRange && (jsx(Calendar, { size: size, hideOtherMonthDays: isRange, ...calendarProps, renderDay: renderDay, value: value[1], onDayPointerDown: val => onChange([value[0], val]), onDayPointerUp: val => onChange([value[0], val]) }))] }));
40
40
  }
41
41
 
42
42
  export { DatePicker };
@@ -0,0 +1,17 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import cn from 'classnames';
3
+ import { DateTime } from '../DateTime/DateTime.js';
4
+ import { DatePicker } from '../DatePicker/DatePicker.js';
5
+ import { Button } from '../Button/Button.js';
6
+ import { Popup } from '../Popup/Popup.js';
7
+ import S from './DatePickerInput.styl.js';
8
+
9
+ function DatePickerInput(props) {
10
+ const { value, variant = 'default', size = 'm', popupProps, displayFormat = 'MMM Do YYYY', } = props;
11
+ const isRange = Array.isArray(value);
12
+ return (jsx(Popup, { size: size, focusControl: true, direction: "bottom-right", ...popupProps, trigger: jsx(Button, { variant: variant, size: size, children: isRange ? (jsxs(Fragment, { children: [jsx(DateTime, { value: new Date(value[0].year, value[0].month - 1, value[0].day), format: displayFormat }), ' - ', jsx(DateTime, { value: new Date(value[1].year, value[1].month - 1, value[1].day), format: displayFormat })] })) : (jsx(DateTime, { value: new Date(value.year, value.month - 1, value.day), format: displayFormat })) }), contentProps: {
13
+ className: cn(S.popupContent, isRange && S.range, S[`size-${size}`]),
14
+ }, content: jsx(DatePicker, { ...props, className: S.content, calendarProps: { className: S.calendar } }) }));
15
+ }
16
+
17
+ export { DatePickerInput };
@@ -0,0 +1,7 @@
1
+ import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
2
+
3
+ var css_248z = ".DatePickerInput_popupContent__rcVHH{min-width:-moz-fit-content;min-width:fit-content}.DatePickerInput_content__yll-b{padding:.5em}.DatePickerInput_range__xWj9K .DatePickerInput_content__yll-b{display:flex;flex-direction:row;flex-wrap:nowrap;gap:1em}.DatePickerInput_range__xWj9K .DatePickerInput_calendar__vf0za{width:50%}.DatePickerInput_size-s__5t05o{border-radius:6px!important}.DatePickerInput_size-s__5t05o .DatePickerInput_content__yll-b{min-width:12em;padding:8px}.DatePickerInput_range__xWj9K.DatePickerInput_size-s__5t05o .DatePickerInput_content__yll-b{min-width:25em}.DatePickerInput_size-m__TTkHV{border-radius:9px!important}.DatePickerInput_size-m__TTkHV .DatePickerInput_content__yll-b{min-width:16em;padding:12px}.DatePickerInput_range__xWj9K.DatePickerInput_size-m__TTkHV .DatePickerInput_content__yll-b{min-width:33em}.DatePickerInput_size-l__-fWkE{border-radius:12px!important}.DatePickerInput_size-l__-fWkE .DatePickerInput_content__yll-b{min-width:20em;padding:14px}.DatePickerInput_range__xWj9K.DatePickerInput_size-l__-fWkE .DatePickerInput_content__yll-b{min-width:41em}";
4
+ var S = {"popupContent":"DatePickerInput_popupContent__rcVHH","content":"DatePickerInput_content__yll-b","range":"DatePickerInput_range__xWj9K","calendar":"DatePickerInput_calendar__vf0za","size-s":"DatePickerInput_size-s__5t05o","size-m":"DatePickerInput_size-m__TTkHV","size-l":"DatePickerInput_size-l__-fWkE"};
5
+ styleInject(css_248z);
6
+
7
+ export { S as default };
@@ -28,6 +28,7 @@ import '../Checkbox/Checkbox.styl.js';
28
28
  import '../Container/Container.styl.js';
29
29
  import '../DatePicker/DatePicker.styl.js';
30
30
  import 'moment';
31
+ import '../DatePickerInput/DatePickerInput.styl.js';
31
32
  import '../Draggable/Draggable.styl.js';
32
33
  import '../Expand/Expand.styl.js';
33
34
  import '../Form/Form.styl.js';
@@ -334,7 +335,7 @@ class Input extends Component {
334
335
  const classes = cn(S.root, isTextArea && S.isTextArea, S[`size-${size}`], S[`variant-${variant}`], isFocused && S.isFocused, error && S.hasError, hasClear && S.hasClear, disabled && S.isDisabled, className);
335
336
  return (
336
337
  // @ts-ignore
337
- jsxs("div", { className: classes, title: value, children: [jsxs("label", { className: S.main, children: [jsx("div", { className: S.border, suppressHydrationWarning: true, style: { clipPath: labelClipPath } }, "border"), this.renderAddon('left'), this.wrapControll(createElement(Control, { ...controlProps, className: cn(S.control, controlProps?.className), ref: this.inputRef, key: "control" })), isNumber && (jsxs("div", { className: S.numberArrows, children: [jsx(Button, { variant: "clear", onClick: () => this.onNumberWheel(1), children: jsx(Icon, { type: "chevronUp", size: size }) }), jsx(Button, { variant: "clear", onClick: () => this.onNumberWheel(-1), children: jsx(Icon, { type: "chevronDown", size: size }) })] })), isTextArea && controlProps.placeholder && (jsx("span", { className: S.placeholder, spellCheck: false, children: controlProps.placeholder })), jsx(Label, { className: S.label, size: size, isOnTop: isLabelOnTop, isError: Boolean(error), onClipPathChange: this.onLabelClipPathChange, children: label }, "label"), this.renderAddon('right'), required && jsx(RequiredStar, { size: size }, "required-star")] }, "main"), hasClear && !disabled && hasValue && (jsx(Button, { className: S.clearButton, variant: "clear", size: size, square: true, onClick: this.onClearPress, title: "", children: jsx(Icon, { className: S.clearIcon, size: size, type: "close" }) }, "clear")), !disabled && typeof error === 'string' && (jsx(AssistiveText, { variant: "danger", size: size, children: error }, "assistive-text"))] }));
338
+ jsxs("div", { className: classes, title: value, children: [jsxs("label", { className: S.main, children: [jsx("div", { className: S.border, suppressHydrationWarning: true, style: { clipPath: labelClipPath } }, "border"), this.renderAddon('left'), this.wrapControll(createElement(Control, { ...controlProps, className: cn(S.control, controlProps?.className), ref: this.inputRef, key: "control" })), isNumber && (jsxs("div", { className: S.numberArrows, children: [jsx(Button, { variant: "clear", onClick: () => this.onNumberWheel(1), tabIndex: -1, children: jsx(Icon, { type: "chevronUp", size: size }) }), jsx(Button, { variant: "clear", onClick: () => this.onNumberWheel(-1), tabIndex: -1, children: jsx(Icon, { type: "chevronDown", size: size }) })] })), isTextArea && controlProps.placeholder && (jsx("span", { className: S.placeholder, spellCheck: false, children: controlProps.placeholder })), jsx(Label, { className: S.label, size: size, isOnTop: isLabelOnTop, isError: Boolean(error), onClipPathChange: this.onLabelClipPathChange, children: label }, "label"), this.renderAddon('right'), required && jsx(RequiredStar, { size: size }, "required-star")] }, "main"), hasClear && !disabled && hasValue && (jsx(Button, { className: S.clearButton, variant: "clear", size: size, square: true, onClick: this.onClearPress, title: "", children: jsx(Icon, { className: S.clearIcon, size: size, type: "close" }) }, "clear")), !disabled && typeof error === 'string' && (jsx(AssistiveText, { variant: "danger", size: size, children: error }, "assistive-text"))] }));
338
339
  }
339
340
  }
340
341
 
@@ -31,6 +31,7 @@ import '../Checkbox/Checkbox.styl.js';
31
31
  import '../Container/Container.styl.js';
32
32
  import '../DatePicker/DatePicker.styl.js';
33
33
  import 'moment';
34
+ import '../DatePickerInput/DatePickerInput.styl.js';
34
35
  import { Draggable } from '../Draggable/Draggable.js';
35
36
  import '../Expand/Expand.styl.js';
36
37
  import '../Form/Form.styl.js';
@@ -5,14 +5,14 @@ export type Day = Date & {
5
5
  };
6
6
  export type DayProps = {
7
7
  className: string;
8
- onPointerDown: () => void;
9
- onPointerUp: () => void;
8
+ onPointerDown?: () => void;
9
+ onPointerUp?: () => void;
10
10
  };
11
11
  export type Props = {
12
12
  className?: string;
13
13
  value: Date;
14
- onDayPointerDown: (value: Date) => void;
15
- onDayPointerUp: (value: Date) => void;
14
+ onDayPointerDown?: (value: Date) => void;
15
+ onDayPointerUp?: (value: Date) => void;
16
16
  startOfWeek?: number;
17
17
  size?: Size;
18
18
  renderDay?: (day: Day, dayProps: DayProps) => ReactNode;
@@ -6,5 +6,5 @@ export type Props = {
6
6
  value: Value;
7
7
  onChange: (value: Value) => void;
8
8
  size?: Size;
9
- calendarProps?: CalendarProps;
9
+ calendarProps?: Partial<CalendarProps>;
10
10
  };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import * as T from './DatePickerInput.types';
3
+ export declare function DatePickerInput(props: T.Props): JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { Date, Size, Variant } from 'uilib/types';
2
+ import type { Props as PopupProps } from 'uilib/components/Popup/Popup.types';
3
+ export type Value = Date | [Date, Date];
4
+ export type Props = {
5
+ className?: string;
6
+ size?: Size;
7
+ displayFormat?: string;
8
+ value: Value;
9
+ onChange: (value: Value) => void;
10
+ variant?: Variant;
11
+ popupProps?: PopupProps;
12
+ };
@@ -5,6 +5,7 @@ export * from './Calendar/Calendar';
5
5
  export * from './Checkbox/Checkbox';
6
6
  export * from './Container/Container';
7
7
  export * from './DatePicker/DatePicker';
8
+ export * from './DatePickerInput/DatePickerInput';
8
9
  export * from './DateTime/DateTime';
9
10
  export * from './Draggable/Draggable';
10
11
  export * from './Expand/Expand';
@@ -19,3 +19,4 @@ export type Date = {
19
19
  day?: number;
20
20
  ISO?: string;
21
21
  };
22
+ export type Variant = 'default' | 'outlined';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homecode/ui",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "React UI components library",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",