@povio/ui 2.1.25 → 2.1.27

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/Button.js CHANGED
@@ -34,7 +34,7 @@ const Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, li
34
34
  children: /* @__PURE__ */ jsx(ButtonContent, {
35
35
  isLoading,
36
36
  icon: Icon,
37
- text: children,
37
+ content: children,
38
38
  ref: onContentRef,
39
39
  hideText: props.iconOnly,
40
40
  iconPosition,
@@ -4,7 +4,7 @@ import { Typography } from "./Typography.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { clsx } from "clsx";
6
6
  import { isValidElement } from "react";
7
- const ButtonContent = ({ ref, text, isLoading, className, icon: Icon, iconClassName, hideText, iconPosition, typography }) => {
7
+ const ButtonContent = ({ ref, content, isLoading, className, icon: Icon, iconClassName, hideText, iconPosition, typography }) => {
8
8
  let iconOrLoader = null;
9
9
  if (isLoading) iconOrLoader = /* @__PURE__ */ jsx(Loader, { className: "shrink-0" });
10
10
  else if (Icon) if (isValidElement(Icon)) iconOrLoader = Icon;
@@ -21,7 +21,7 @@ const ButtonContent = ({ ref, text, isLoading, className, icon: Icon, iconClassN
21
21
  ...typography,
22
22
  className: clsx("hyphens-auto md:truncate", hideText && "sr-only"),
23
23
  ref,
24
- children: text
24
+ children: content
25
25
  })]
26
26
  });
27
27
  };
package/dist/Calendar2.js CHANGED
@@ -7,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { useState } from "react";
9
9
  import { useCalendar } from "@react-aria/calendar";
10
- const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply,...props }) => {
10
+ const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, onMonthYearChange,...props }) => {
11
11
  const [toggleState, setToggleState] = useState(null);
12
12
  const { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(props.calendarProps, props.state);
13
13
  const handleDateChange = () => {
@@ -21,11 +21,13 @@ const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply
21
21
  });
22
22
  if (toggleState === "month") return /* @__PURE__ */ jsx(MonthPicker, {
23
23
  state: props.state,
24
- onSelectionChange: () => setToggleState(null)
24
+ onSelectionChange: () => setToggleState(null),
25
+ onDateChange: onMonthYearChange
25
26
  });
26
27
  if (toggleState === "year") return /* @__PURE__ */ jsx(YearPicker, {
27
28
  state: props.state,
28
- onSelectionChange: () => setToggleState(null)
29
+ onSelectionChange: () => setToggleState(null),
30
+ onDateChange: onMonthYearChange
29
31
  });
30
32
  if (toggleState === "time" && includesTime) return /* @__PURE__ */ jsx("div", {
31
33
  className: "flex h-72 w-80 items-center justify-center",
@@ -18,7 +18,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
18
18
  var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
19
19
  var DatePickerBase = (props) => {
20
20
  const ui = UIConfig.useConfig();
21
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry,...rest } = props;
21
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange,...rest } = props;
22
22
  const formFieldProps = {
23
23
  error,
24
24
  label,
@@ -91,6 +91,15 @@ var DatePickerBase = (props) => {
91
91
  state.setValue(dialogState.value);
92
92
  state.toggle();
93
93
  };
94
+ const onMonthYearChange = (selectedDate) => {
95
+ if (!shouldUpdateDateOnMonthYearChange) return;
96
+ const updatedDate = (dialogState.value || state.value || today(getLocalTimeZone())).set({
97
+ year: selectedDate.year,
98
+ month: selectedDate.month
99
+ });
100
+ dialogState.setValue(updatedDate);
101
+ calendarState.setFocusedDate(updatedDate);
102
+ };
94
103
  const onTodayPress = () => {
95
104
  dialogState.setValue(today(getLocalTimeZone()));
96
105
  calendarState.setFocusedDate(today(getLocalTimeZone()));
@@ -146,7 +155,8 @@ var DatePickerBase = (props) => {
146
155
  children: /* @__PURE__ */ jsx(Calendar, {
147
156
  state: calendarState,
148
157
  calendarProps,
149
- onApply
158
+ onApply,
159
+ onMonthYearChange
150
160
  })
151
161
  })]
152
162
  })
@@ -16,7 +16,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
16
16
  var PLACEHOLDER_VALUE = new CalendarDateTime(2024, 1, 1);
17
17
  var DateTimePickerBase = (props) => {
18
18
  const ui = UIConfig.useConfig();
19
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry,...rest } = props;
19
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange,...rest } = props;
20
20
  const formFieldProps = {
21
21
  error,
22
22
  label,
@@ -94,6 +94,21 @@ var DateTimePickerBase = (props) => {
94
94
  state.setValue(dialogState.value);
95
95
  state.toggle();
96
96
  };
97
+ const onMonthYearChange = (selectedDate) => {
98
+ if (!shouldUpdateDateOnMonthYearChange) return;
99
+ const baseDate = dialogState.value || state.value;
100
+ if (baseDate) {
101
+ const updatedDate = baseDate.set({
102
+ year: selectedDate.year,
103
+ month: selectedDate.month
104
+ });
105
+ dialogState.setValue(updatedDate);
106
+ calendarState.setFocusedDate(updatedDate);
107
+ return;
108
+ }
109
+ dialogState.setValue(toCalendarDateTime(selectedDate));
110
+ calendarState.setFocusedDate(selectedDate);
111
+ };
97
112
  const onTodayPress = () => {
98
113
  dialogState.setValue(toCalendarDateTime(now(getLocalTimeZone())));
99
114
  calendarState.setFocusedDate(today(getLocalTimeZone()));
@@ -167,7 +182,8 @@ var DateTimePickerBase = (props) => {
167
182
  calendarProps,
168
183
  includesTime: true,
169
184
  datePickerState: dialogState,
170
- onApply
185
+ onApply,
186
+ onMonthYearChange
171
187
  })
172
188
  })]
173
189
  })
@@ -3,7 +3,7 @@ import { jsx } from "react/jsx-runtime";
3
3
  import { clsx } from "clsx";
4
4
  import { ListBox, ListBoxItem } from "react-aria-components";
5
5
  import { useDateFormatter } from "@react-aria/i18n";
6
- const MonthPicker = ({ state, onSelectionChange }) => {
6
+ const MonthPicker = ({ state, onSelectionChange, onDateChange }) => {
7
7
  const formatter = useDateFormatter({
8
8
  month: "long",
9
9
  timeZone: state.timeZone
@@ -31,8 +31,9 @@ const MonthPicker = ({ state, onSelectionChange }) => {
31
31
  onSelectionChange: (key) => {
32
32
  if (key === "all") return;
33
33
  if (typeof [...key][0] === "number") {
34
- const date = state.focusedDate.set({ month: [...key][0] });
35
- state.setFocusedDate(date);
34
+ const selectedDate = state.focusedDate.set({ month: [...key][0] });
35
+ state.setFocusedDate(selectedDate);
36
+ onDateChange?.(selectedDate);
36
37
  }
37
38
  onSelectionChange(key);
38
39
  },
@@ -23,7 +23,7 @@ const PillButton = ({ children, dismissable, toggle, icon, iconPosition,...props
23
23
  className: props.className
24
24
  }),
25
25
  children: /* @__PURE__ */ jsx(ButtonContent, {
26
- text: children,
26
+ content: children,
27
27
  ref: onContentRef,
28
28
  icon: dismissable ? CloseIcon : icon,
29
29
  iconPosition: dismissable ? "right" : iconPosition,
@@ -6,7 +6,7 @@ import { ListBox, ListBoxItem } from "react-aria-components";
6
6
  import { useMemo } from "react";
7
7
  import { today } from "@internationalized/date";
8
8
  import { useDateFormatter } from "@react-aria/i18n";
9
- const YearPicker = ({ state, onSelectionChange }) => {
9
+ const YearPicker = ({ state, onSelectionChange, onDateChange }) => {
10
10
  const formatter = useDateFormatter({
11
11
  year: "numeric",
12
12
  timeZone: state.timeZone
@@ -39,8 +39,9 @@ const YearPicker = ({ state, onSelectionChange }) => {
39
39
  if (key === "all") return;
40
40
  const index = [...key][0];
41
41
  if (typeof index === "number") {
42
- const date = state.focusedDate.set({ year: years[index].value });
43
- state.setFocusedDate(date);
42
+ const selectedDate = state.focusedDate.set({ year: years[index].value });
43
+ state.setFocusedDate(selectedDate);
44
+ onDateChange?.(selectedDate);
44
45
  }
45
46
  onSelectionChange(key);
46
47
  },
@@ -1,4 +1,4 @@
1
- import { FC, ReactElement, SVGProps } from 'react';
1
+ import { FC, ReactElement, ReactNode, SVGProps } from 'react';
2
2
  import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
3
3
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
4
4
  import { LinkNavigationProps } from '../../text/Link/Link';
@@ -17,7 +17,7 @@ type ToggleButtonProps = {
17
17
  isSelected?: boolean;
18
18
  } & AriaToggleButtonProps);
19
19
  export type ButtonProps<IconOnly extends boolean = false> = ButtonVariantProps & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<IconOnly> & ToggleButtonProps & {
20
- children: string;
20
+ children: ReactNode;
21
21
  isLoading?: boolean;
22
22
  link?: LinkNavigationProps;
23
23
  noDisableWhenLoading?: boolean;
@@ -1,9 +1,9 @@
1
- import { FC, SVGProps } from 'react';
1
+ import { FC, ReactNode, SVGProps } from 'react';
2
2
  import { ButtonProps as AriaButtonProps, ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
3
3
  import { PillButtonVariants } from './pillButton.cva';
4
4
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
5
  export interface PillButtonProps extends AriaButtonProps, Omit<AriaToggleButtonProps, keyof AriaButtonProps>, ButtonContentVariantProps, PillButtonVariants {
6
- children: string;
6
+ children: ReactNode;
7
7
  dismissable?: boolean;
8
8
  toggle?: boolean;
9
9
  icon?: FC<SVGProps<SVGSVGElement>>;
@@ -1,10 +1,11 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ButtonProps as AriaButtonProps } from 'react-aria-components';
2
3
  import { ButtonIconProps } from '../Button/Button';
3
4
  import { ButtonVariantProps } from '../Button/button.cva';
4
5
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
6
  import { LinkNavigationProps } from '../../text/Link/Link';
6
7
  export type TextButtonProps = Omit<ButtonVariantProps, "variant"> & ButtonContentVariantProps & AriaButtonProps & ButtonIconProps<true | false> & {
7
- children: string;
8
+ children: ReactNode;
8
9
  isLoading?: boolean;
9
10
  link?: LinkNavigationProps;
10
11
  disableTooltip?: boolean;
@@ -1,9 +1,10 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ToggleButtonProps as AriaToggleButtonProps } from 'react-aria-components';
2
3
  import { ButtonIconProps } from '../Button/Button';
3
4
  import { ButtonVariantProps } from '../Button/button.cva';
4
5
  import { ButtonContentVariantProps } from '../shared/buttonContent.cva';
5
6
  export type ToggleButtonProps = ButtonVariantProps & ButtonContentVariantProps & AriaToggleButtonProps & ButtonIconProps<true | false> & {
6
- children: string;
7
+ children: ReactNode;
7
8
  disableTooltip?: boolean;
8
9
  };
9
10
  export declare const ToggleButton: ({ children, ...props }: ToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
- import { FC, ReactElement, Ref, SVGProps } from 'react';
1
+ import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
2
2
  import { ButtonVariantProps } from '../Button/button.cva';
3
3
  import { ButtonContentVariantProps } from './buttonContent.cva';
4
4
  import { TypographyVariantProps } from '../../text/Typography/typography.cva';
5
5
  interface ButtonContentProps extends ButtonContentVariantProps, Pick<ButtonVariantProps, "size"> {
6
6
  ref?: Ref<HTMLHeadingElement>;
7
- text: string;
7
+ content: ReactNode;
8
8
  isLoading?: boolean;
9
9
  className?: string;
10
10
  icon?: FC<SVGProps<SVGSVGElement>> | ReactElement;
@@ -12,5 +12,5 @@ interface ButtonContentProps extends ButtonContentVariantProps, Pick<ButtonVaria
12
12
  hideText?: boolean;
13
13
  typography?: TypographyVariantProps;
14
14
  }
15
- export declare const ButtonContent: ({ ref, text, isLoading, className, icon: Icon, iconClassName, hideText, iconPosition, typography, }: ButtonContentProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const ButtonContent: ({ ref, content, isLoading, className, icon: Icon, iconClassName, hideText, iconPosition, typography, }: ButtonContentProps) => import("react/jsx-runtime").JSX.Element;
16
16
  export {};
@@ -15,6 +15,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
15
15
  isDirty?: boolean;
16
16
  disableManualEntry?: boolean;
17
17
  placeholder?: string;
18
+ shouldUpdateDateOnMonthYearChange?: boolean;
18
19
  }
19
20
  export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
20
21
  value?: string | null;
@@ -15,6 +15,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
15
15
  isDirty?: boolean;
16
16
  disableManualEntry?: boolean;
17
17
  placeholder?: string;
18
+ shouldUpdateDateOnMonthYearChange?: boolean;
18
19
  }
19
20
  export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
20
21
  value?: string | null;
@@ -1,3 +1,4 @@
1
+ import { CalendarDate } from '@internationalized/date';
1
2
  import { CalendarState, CalendarStateOptions } from '@react-stately/calendar';
2
3
  import { DatePickerState } from 'react-stately';
3
4
  type DateTimeCalendarProps = {
@@ -14,7 +15,8 @@ type CalendarProps = DateTimeCalendarProps & {
14
15
  state: CalendarState;
15
16
  calendarProps: Omit<CalendarStateOptions, "locale" | "createCalendar">;
16
17
  onApply: () => void;
18
+ onMonthYearChange?: (selectedDate: CalendarDate) => void;
17
19
  };
18
20
  export type ToggleState = "month" | "year" | "time";
19
- export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, onMonthYearChange, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
20
22
  export {};
@@ -1,7 +1,9 @@
1
+ import { CalendarDate } from '@internationalized/date';
1
2
  import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
2
3
  import { Key } from 'react-aria-components';
3
4
  export interface MonthPickerProps {
4
5
  state: CalendarState | RangeCalendarState;
5
6
  onSelectionChange: (key: Set<Key>) => void;
7
+ onDateChange?: (selectedDate: CalendarDate) => void;
6
8
  }
7
- export declare const MonthPicker: ({ state, onSelectionChange }: MonthPickerProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const MonthPicker: ({ state, onSelectionChange, onDateChange }: MonthPickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,10 @@
1
+ import { CalendarDate } from '@internationalized/date';
1
2
  import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
2
3
  import { Key } from 'react-aria-components';
3
4
  interface YearPickerProps {
4
5
  state: CalendarState | RangeCalendarState;
5
6
  onSelectionChange: (key: Set<Key>) => void;
7
+ onDateChange?: (selectedDate: CalendarDate) => void;
6
8
  }
7
- export declare const YearPicker: ({ state, onSelectionChange }: YearPickerProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const YearPicker: ({ state, onSelectionChange, onDateChange }: YearPickerProps) => import("react/jsx-runtime").JSX.Element;
8
10
  export {};
@@ -1,6 +1,6 @@
1
- import { JSX, Ref } from 'react';
1
+ import { JSX, ReactNode, Ref } from 'react';
2
2
  export interface TooltipEllipsisProps {
3
- text: string;
3
+ text: ReactNode;
4
4
  children: (ref: Ref<HTMLHeadingElement> | undefined) => JSX.Element;
5
5
  isDisabled?: boolean;
6
6
  }
@@ -20,7 +20,7 @@ export declare namespace UIConfig {
20
20
  select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType">;
21
21
  toggle: Pick<ToggleProps, "variant">;
22
22
  slider: Pick<SliderProps, "minValue" | "maxValue">;
23
- dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry">;
23
+ dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry" | "shouldUpdateDateOnMonthYearChange">;
24
24
  actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
25
25
  }
26
26
  interface ProviderProps {
@@ -35,7 +35,8 @@ let UIConfig;
35
35
  dateInput: {
36
36
  todayIcon: false,
37
37
  shouldForceLeadingZeros: false,
38
- disableManualEntry: false
38
+ disableManualEntry: false,
39
+ shouldUpdateDateOnMonthYearChange: false
39
40
  },
40
41
  actionModal: {
41
42
  titleTypography: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.1.25",
3
+ "version": "2.1.27",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",