@mbao01/common 0.0.43 → 0.0.44

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.
Files changed (63) hide show
  1. package/dist/types/components/DatetimePicker/DatetimeGrid.d.ts +26 -0
  2. package/dist/types/components/DatetimePicker/DatetimePicker.d.ts +13 -0
  3. package/dist/types/components/DatetimePicker/constants.d.ts +15 -0
  4. package/dist/types/components/DatetimePicker/index.d.ts +1 -0
  5. package/dist/types/components/DatetimePicker/types.d.ts +25 -0
  6. package/dist/types/components/Form/DatetimeInput/DatetimeCalendar.d.ts +5 -0
  7. package/dist/types/components/Form/DatetimeInput/DatetimeInput.d.ts +83 -0
  8. package/dist/types/components/Form/DatetimeInput/DatetimeInputContext.d.ts +2 -0
  9. package/dist/types/components/Form/DatetimeInput/NaturalLanguageInput.d.ts +5 -0
  10. package/dist/types/components/Form/DatetimeInput/TimePicker.d.ts +1 -0
  11. package/dist/types/components/Form/DatetimeInput/constants.d.ts +24 -0
  12. package/dist/types/components/Form/DatetimeInput/helpers.d.ts +27 -0
  13. package/dist/types/components/Form/DatetimeInput/hooks/index.d.ts +1 -0
  14. package/dist/types/components/Form/DatetimeInput/hooks/useDateInput/index.d.ts +1 -0
  15. package/dist/types/components/Form/DatetimeInput/hooks/useDateInput/useDateInput.d.ts +1 -0
  16. package/dist/types/components/Form/DatetimeInput/index.d.ts +1 -0
  17. package/dist/types/components/Form/DatetimeInput/types.d.ts +31 -0
  18. package/dist/types/components/Form/MultiSelect/MultiSelect.d.ts +46 -0
  19. package/dist/types/components/Form/MultiSelect/MultiSelectContext.d.ts +2 -0
  20. package/dist/types/components/Form/MultiSelect/constants.d.ts +19 -0
  21. package/dist/types/components/Form/MultiSelect/hooks/index.d.ts +1 -0
  22. package/dist/types/components/Form/MultiSelect/hooks/useMultiSelect/index.d.ts +1 -0
  23. package/dist/types/components/Form/MultiSelect/hooks/useMultiSelect/useMultiSelect.d.ts +1 -0
  24. package/dist/types/components/Form/MultiSelect/index.d.ts +1 -0
  25. package/dist/types/components/Form/MultiSelect/types.d.ts +31 -0
  26. package/dist/types/components/Form/TagsInput/TagsInput.d.ts +13 -0
  27. package/dist/types/components/Form/TagsInput/constants.d.ts +16 -0
  28. package/dist/types/components/Form/TagsInput/index.d.ts +1 -0
  29. package/dist/types/components/Form/TagsInput/types.d.ts +9 -0
  30. package/dist/types/components/Form/index.d.ts +2 -0
  31. package/dist/types/index.d.ts +1 -0
  32. package/package.json +4 -2
  33. package/src/components/DatetimePicker/DatetimeGrid.tsx +59 -0
  34. package/src/components/DatetimePicker/DatetimePicker.tsx +59 -0
  35. package/src/components/DatetimePicker/constants.ts +102 -0
  36. package/src/components/DatetimePicker/index.ts +1 -0
  37. package/src/components/DatetimePicker/types.ts +36 -0
  38. package/src/components/Form/DatetimeInput/DatetimeCalendar.tsx +68 -0
  39. package/src/components/Form/DatetimeInput/DatetimeInput.tsx +90 -0
  40. package/src/components/Form/DatetimeInput/DatetimeInputContext.tsx +4 -0
  41. package/src/components/Form/DatetimeInput/NaturalLanguageInput.tsx +73 -0
  42. package/src/components/Form/DatetimeInput/TimePicker.tsx +202 -0
  43. package/src/components/Form/DatetimeInput/constants.ts +135 -0
  44. package/src/components/Form/DatetimeInput/helpers.ts +93 -0
  45. package/src/components/Form/DatetimeInput/hooks/index.ts +1 -0
  46. package/src/components/Form/DatetimeInput/hooks/useDateInput/index.ts +1 -0
  47. package/src/components/Form/DatetimeInput/hooks/useDateInput/useDateInput.ts +10 -0
  48. package/src/components/Form/DatetimeInput/index.ts +1 -0
  49. package/src/components/Form/DatetimeInput/types.ts +36 -0
  50. package/src/components/Form/MultiSelect/MultiSelect.tsx +348 -0
  51. package/src/components/Form/MultiSelect/MultiSelectContext.tsx +4 -0
  52. package/src/components/Form/MultiSelect/constants.ts +103 -0
  53. package/src/components/Form/MultiSelect/hooks/index.ts +1 -0
  54. package/src/components/Form/MultiSelect/hooks/useMultiSelect/index.ts +1 -0
  55. package/src/components/Form/MultiSelect/hooks/useMultiSelect/useMultiSelect.ts +10 -0
  56. package/src/components/Form/MultiSelect/index.ts +1 -0
  57. package/src/components/Form/MultiSelect/types.ts +46 -0
  58. package/src/components/Form/TagsInput/TagsInput.tsx +278 -0
  59. package/src/components/Form/TagsInput/constants.ts +87 -0
  60. package/src/components/Form/TagsInput/index.ts +1 -0
  61. package/src/components/Form/TagsInput/types.ts +10 -0
  62. package/src/components/Form/index.ts +2 -0
  63. package/src/index.ts +1 -0
@@ -0,0 +1,26 @@
1
+ export declare const DatetimeGrid: import('react').ForwardRefExoticComponent<{
2
+ format: import('./types').DatetimeFormatDefaults;
3
+ disabled?: boolean;
4
+ className?: string;
5
+ timescape: Pick<{
6
+ readonly _manager: import('timescape').TimescapeManager;
7
+ readonly getInputProps: (type: import('timescape').DateType, opts?: {
8
+ ref?: import('react').MutableRefObject<HTMLInputElement | null>;
9
+ autofocus?: boolean;
10
+ }) => {
11
+ ref: (element: HTMLInputElement | null) => void;
12
+ };
13
+ readonly getRootProps: () => {
14
+ ref: (element: HTMLElement | null) => void | null;
15
+ };
16
+ readonly options: import('timescape/react').Options;
17
+ readonly update: import('react').Dispatch<import('react').SetStateAction<import('timescape/react').Options>>;
18
+ }, "getRootProps" | "getInputProps">;
19
+ placeholders: import('./types').InputPlaceholders;
20
+ } & {
21
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | undefined;
22
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
23
+ outline?: boolean | undefined;
24
+ wide?: boolean | undefined;
25
+ disabled?: boolean | undefined;
26
+ } & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,13 @@
1
+ export declare const DatetimePicker: import('react').ForwardRefExoticComponent<Omit<import('timescape/react').Options, "onChangeDate"> & {
2
+ format?: import('./types').DatetimeFormatDefaults;
3
+ disabled?: boolean;
4
+ placeholders?: import('./types').InputPlaceholders;
5
+ onChange?: import('timescape/react').Options["onChangeDate"];
6
+ className?: string;
7
+ } & {
8
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | undefined;
9
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
10
+ outline?: boolean | undefined;
11
+ wide?: boolean | undefined;
12
+ disabled?: boolean | undefined;
13
+ } & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,15 @@
1
+ import { DateFormat, DatetimeFormatDefaults, InputPlaceholders, TimeFormat } from './types';
2
+ export declare const DEFAULTS: DatetimeFormatDefaults;
3
+ export declare const INPUT_PLACEHOLDERS: InputPlaceholders;
4
+ export declare const getDatetimeGridClasses: (props?: ({
5
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | null | undefined;
6
+ outline?: boolean | null | undefined;
7
+ disabled?: boolean | null | undefined;
8
+ wide?: boolean | null | undefined;
9
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
10
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
+ export declare const getDatetimeSeparatorClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
12
+ export declare const getDatetimeInputClasses: (props?: ({
13
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
14
+ unit?: DateFormat | TimeFormat | null | undefined;
15
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { DatetimePicker } from './DatetimePicker';
@@ -0,0 +1,25 @@
1
+ import { Options, useTimescape } from 'timescape/react';
2
+ import { VariantProps } from '../../libs';
3
+ import { getDatetimeGridClasses } from './constants';
4
+ export type DateFormat = "days" | "months" | "years";
5
+ export type TimeFormat = "hours" | "minutes" | "seconds" | "am/pm";
6
+ type TimescapeReturn = ReturnType<typeof useTimescape>;
7
+ type DatetimeArray<T extends DateFormat | TimeFormat> = T[];
8
+ export type DatetimeFormatDefaults = [DatetimeArray<DateFormat>] | [DatetimeArray<TimeFormat>] | [DatetimeArray<DateFormat>, DatetimeArray<TimeFormat>] | [DatetimeArray<TimeFormat>, DatetimeArray<DateFormat>];
9
+ export type InputPlaceholders = Record<DateFormat | TimeFormat, string>;
10
+ type DatetimeGridVariantProps = VariantProps<typeof getDatetimeGridClasses>;
11
+ export type DatetimeGridProps = {
12
+ format: DatetimeFormatDefaults;
13
+ disabled?: boolean;
14
+ className?: string;
15
+ timescape: Pick<TimescapeReturn, "getRootProps" | "getInputProps">;
16
+ placeholders: InputPlaceholders;
17
+ } & DatetimeGridVariantProps;
18
+ export type DatetimePickerProps = Omit<Options, "onChangeDate"> & {
19
+ format?: DatetimeFormatDefaults;
20
+ disabled?: boolean;
21
+ placeholders?: InputPlaceholders;
22
+ onChange?: Options["onChangeDate"];
23
+ className?: string;
24
+ } & DatetimeGridVariantProps;
25
+ export {};
@@ -0,0 +1,5 @@
1
+ import { DatetimeCalendarProps } from './types';
2
+ export declare const DatetimeCalendar: {
3
+ ({ size, disabled, className, ...props }: DatetimeCalendarProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
@@ -0,0 +1,83 @@
1
+ export declare const DatetimeInput: import('react').ForwardRefExoticComponent<{
2
+ disabled?: boolean;
3
+ } & {
4
+ locale?: Intl.LocalesArgument;
5
+ } & Omit<import('../Input/types').InputProps, "type" | "defaultValue" | "onBlur" | "ref" | "disabled" | "value"> & {
6
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | undefined;
7
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
8
+ outline?: boolean | undefined;
9
+ wide?: boolean | undefined;
10
+ disabled?: boolean | undefined;
11
+ } & {
12
+ date?: Date;
13
+ calendar?: {
14
+ className?: string | undefined;
15
+ autoFocus?: boolean | undefined;
16
+ dir?: HTMLDivElement["dir"] | undefined;
17
+ hidden?: import('react-day-picker').Matcher | import('react-day-picker').Matcher[] | undefined;
18
+ id?: string | undefined;
19
+ lang?: HTMLDivElement["lang"] | undefined;
20
+ nonce?: HTMLDivElement["nonce"];
21
+ style?: React.CSSProperties | undefined;
22
+ title?: HTMLDivElement["title"] | undefined;
23
+ footer?: React.ReactNode | string;
24
+ required?: boolean | undefined;
25
+ month?: Date | undefined;
26
+ classNames?: (Partial<import('react-day-picker').ClassNames> & Partial<import('react-day-picker').DeprecatedUI<string>>) | undefined;
27
+ showOutsideDays?: boolean | undefined;
28
+ modifiersClassNames?: import('react-day-picker').ModifiersClassNames | undefined;
29
+ styles?: (Partial<import('react-day-picker').Styles> & Partial<import('react-day-picker').DeprecatedUI<React.CSSProperties>>) | undefined;
30
+ modifiersStyles?: import('react-day-picker').ModifiersStyles | undefined;
31
+ defaultMonth?: Date | undefined;
32
+ numberOfMonths?: number | undefined;
33
+ startMonth?: Date | undefined;
34
+ fromDate?: Date | undefined;
35
+ fromMonth?: Date | undefined;
36
+ fromYear?: number | undefined;
37
+ endMonth?: Date | undefined;
38
+ toDate?: Date | undefined;
39
+ toMonth?: Date | undefined;
40
+ toYear?: number | undefined;
41
+ pagedNavigation?: boolean | undefined;
42
+ reverseMonths?: boolean | undefined;
43
+ hideNavigation?: boolean | undefined;
44
+ disableNavigation?: boolean | undefined;
45
+ captionLayout?: ("label" | "dropdown" | "dropdown-months" | "dropdown-years") | undefined;
46
+ fixedWeeks?: boolean | undefined;
47
+ hideWeekdays?: boolean | undefined;
48
+ showWeekNumber?: boolean | undefined;
49
+ ISOWeek?: boolean | undefined;
50
+ timeZone?: string | undefined;
51
+ components?: Partial<import('react-day-picker').CustomComponents> | undefined;
52
+ today?: Date | undefined;
53
+ modifiers?: Record<string, import('react-day-picker').Matcher | import('react-day-picker').Matcher[] | undefined> | undefined;
54
+ labels?: Partial<import('react-day-picker').Labels> | undefined;
55
+ formatters?: Partial<import('react-day-picker').Formatters> | undefined;
56
+ locale?: Partial<import('react-day-picker').Locale> | undefined;
57
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | undefined;
58
+ firstWeekContainsDate?: (1 | 4) | undefined;
59
+ useAdditionalWeekYearTokens?: boolean | undefined;
60
+ useAdditionalDayOfYearTokens?: boolean | undefined;
61
+ onMonthChange?: import('react-day-picker').MonthChangeEventHandler | undefined;
62
+ onNextClick?: import('react-day-picker').MonthChangeEventHandler | undefined;
63
+ onPrevClick?: import('react-day-picker').MonthChangeEventHandler | undefined;
64
+ onWeekNumberClick?: any;
65
+ onDayClick?: import('react-day-picker').DayEventHandler<React.MouseEvent> | undefined;
66
+ onDayFocus?: import('react-day-picker').DayEventHandler<React.FocusEvent> | undefined;
67
+ onDayBlur?: import('react-day-picker').DayEventHandler<React.FocusEvent> | undefined;
68
+ onDayKeyDown?: import('react-day-picker').DayEventHandler<React.KeyboardEvent> | undefined;
69
+ onDayMouseEnter?: import('react-day-picker').DayEventHandler<React.MouseEvent> | undefined;
70
+ onDayMouseLeave?: import('react-day-picker').DayEventHandler<React.MouseEvent> | undefined;
71
+ dateLib?: Partial<import('react-day-picker').DateLib> | undefined;
72
+ onDayKeyUp?: import('react-day-picker').DayEventHandler<React.KeyboardEvent> | undefined;
73
+ onDayKeyPress?: import('react-day-picker').DayEventHandler<React.KeyboardEvent> | undefined;
74
+ onDayPointerEnter?: import('react-day-picker').DayEventHandler<React.PointerEvent> | undefined;
75
+ onDayPointerLeave?: import('react-day-picker').DayEventHandler<React.PointerEvent> | undefined;
76
+ onDayTouchCancel?: import('react-day-picker').DayEventHandler<React.TouchEvent> | undefined;
77
+ onDayTouchEnd?: import('react-day-picker').DayEventHandler<React.TouchEvent> | undefined;
78
+ onDayTouchMove?: import('react-day-picker').DayEventHandler<React.TouchEvent> | undefined;
79
+ onDayTouchStart?: import('react-day-picker').DayEventHandler<React.TouchEvent> | undefined;
80
+ };
81
+ defaultDate?: Date;
82
+ onDateChange?: (date: Date | undefined) => void;
83
+ } & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,2 @@
1
+ import { DatetimeInputContextProps } from './types';
2
+ export declare const DatetimeInputContext: import('react').Context<DatetimeInputContextProps | null>;
@@ -0,0 +1,5 @@
1
+ export declare const NaturalLanguageInput: import('react').ForwardRefExoticComponent<{
2
+ disabled?: boolean;
3
+ } & {
4
+ locale?: Intl.LocalesArgument;
5
+ } & Omit<import('../Input/types').InputProps, "type" | "defaultValue" | "onBlur" | "ref" | "disabled" | "value"> & import('react').RefAttributes<HTMLInputElement>>;
@@ -0,0 +1 @@
1
+ export declare const TimePicker: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ export declare const DEFAULT_SIZE = 96;
2
+ export declare const getDatetimeInputContainerClasses: (props?: ({
3
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | null | undefined;
4
+ outline?: boolean | null | undefined;
5
+ disabled?: boolean | null | undefined;
6
+ wide?: boolean | null | undefined;
7
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
8
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
+ export declare const getDatetimeCalendarTriggerClasses: (props?: ({
10
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
11
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
12
+ export declare const getDatetimeCalendarIconClasses: (props?: ({
13
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
14
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
15
+ export declare const getTimePickerClasses: (props?: ({
16
+ selected?: boolean | null | undefined;
17
+ suggested?: boolean | null | undefined;
18
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
19
+ export declare const getTimePickerListClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
20
+ export declare const getTimePickerScrollAreaClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
21
+ export declare const getNaturalLanguageInputClasses: (props?: ({
22
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
23
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
24
+ export declare const getDatetimeCalendarClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
@@ -0,0 +1,27 @@
1
+ import { TimeString } from './types';
2
+ /**
3
+ * Utility function that parses dates.
4
+ * Parses a given date string using the `chrono-node` library.
5
+ *
6
+ * @param str - A string representation of a date and time.
7
+ * @returns A `Date` object representing the parsed date and time, or `null` if the string could not be parsed.
8
+ */
9
+ export declare const parseDateTime: (str: Date | string) => Date | undefined;
10
+ /**
11
+ * Converts a given timestamp or the current date and time to a string representation in the local time zone.
12
+ * format: `HH:mm`, adjusted for the local time zone.
13
+ *
14
+ * @param timestamp {Date | string}
15
+ * @returns A string representation of the timestamp
16
+ */
17
+ export declare const getDateTimeLocal: (timestamp?: Date) => string;
18
+ /**
19
+ * Formats a given date and time object or string into a human-readable string representation.
20
+ * "MMM D, YYYY h:mm A" (e.g. "Jan 1, 2023 12:00 PM").
21
+ *
22
+ * @param date - {Date | string}
23
+ * @returns A string representation of the date and time
24
+ */
25
+ export declare const formatDateTime: (date: Date | string, locale?: Intl.LocalesArgument) => string;
26
+ export declare const getParsedTime: (date: Date) => TimeString;
27
+ export declare const setDateTime: (date: Date, time: TimeString) => Date;
@@ -0,0 +1 @@
1
+ export { useDateInput } from './useDateInput';
@@ -0,0 +1 @@
1
+ export { useDateInput } from './useDateInput';
@@ -0,0 +1 @@
1
+ export declare const useDateInput: () => import('../../types').DatetimeInputContextProps;
@@ -0,0 +1 @@
1
+ export { DatetimeInput } from './DatetimeInput';
@@ -0,0 +1,31 @@
1
+ import { VariantProps } from '../../../libs';
2
+ import { CalendarProps } from '../../Calendar/types';
3
+ import { InputProps } from '../Input/types';
4
+ import { getDatetimeInputContainerClasses } from './constants';
5
+ type DisabledType = {
6
+ disabled?: boolean;
7
+ };
8
+ type VariantType = VariantProps<typeof getDatetimeInputContainerClasses>;
9
+ type NaturalLanguageInputType = DisabledType & {
10
+ locale?: Intl.LocalesArgument;
11
+ } & Omit<InputProps, "type" | "ref" | "value" | "defaultValue" | "onBlur" | "disabled">;
12
+ type CalendarType = Omit<CalendarProps, "mode" | "disabled">;
13
+ export type DatetimeInputProps = NaturalLanguageInputType & VariantType & {
14
+ date?: Date;
15
+ calendar?: CalendarType;
16
+ defaultDate?: Date;
17
+ onDateChange?: (date: Date | undefined) => void;
18
+ };
19
+ export type DatetimeInputContextProps = {
20
+ value?: Date;
21
+ onDateChange: (date: Date | undefined) => void;
22
+ time: TimeString;
23
+ onTimeChange: (time: TimeString) => void;
24
+ };
25
+ export type DatetimeCalendarProps = VariantType & CalendarType & DisabledType;
26
+ export type NaturalLanguageInputProps = NaturalLanguageInputType;
27
+ type Hours = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`;
28
+ type Minutes = `${0 | 1 | 2 | 3 | 4 | 5}${0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
29
+ type PM_AM = "AM" | "PM";
30
+ export type TimeString = `${Hours}:${Minutes} ${PM_AM}` | "";
31
+ export {};
@@ -0,0 +1,46 @@
1
+ import { Item, MultiSelectContentProps, MultiSelectInputProps, MultiSelectProps, MultiSelectTriggerProps } from './types';
2
+ declare const MultiSelect: {
3
+ ({ values, onValuesChange, loop, className, children, dir, ...props }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
4
+ Trigger: {
5
+ ({ className, children, size, wide, outline, variant, disabled, ...props }: MultiSelectTriggerProps): import("react/jsx-runtime").JSX.Element;
6
+ displayName: string;
7
+ };
8
+ Input: {
9
+ ({ className, ...props }: MultiSelectInputProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
12
+ Content: import('react').ForwardRefExoticComponent<MultiSelectContentProps & import('react').RefAttributes<HTMLDivElement>>;
13
+ List: import('react').ForwardRefExoticComponent<Omit<Omit<{
14
+ children?: React.ReactNode;
15
+ } & Pick<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import('react').HTMLAttributes<HTMLDivElement>> & {
16
+ ref?: React.Ref<HTMLDivElement>;
17
+ } & {
18
+ asChild?: boolean;
19
+ }, "asChild" | "key" | keyof import('react').HTMLAttributes<HTMLDivElement>> & {
20
+ label?: string;
21
+ } & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
22
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
23
+ } & import('react').RefAttributes<HTMLDivElement>>;
24
+ Item: import('react').ForwardRefExoticComponent<Item & Omit<Omit<{
25
+ children?: React.ReactNode;
26
+ } & Omit<Pick<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import('react').HTMLAttributes<HTMLDivElement>> & {
27
+ ref?: React.Ref<HTMLDivElement>;
28
+ } & {
29
+ asChild?: boolean;
30
+ }, "asChild" | "key" | keyof import('react').HTMLAttributes<HTMLDivElement>>, "onSelect" | "disabled" | "value"> & {
31
+ disabled?: boolean;
32
+ onSelect?: (value: string) => void;
33
+ value?: string;
34
+ keywords?: string[];
35
+ forceMount?: boolean;
36
+ } & import('react').RefAttributes<HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
37
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
38
+ disabled?: boolean | undefined;
39
+ included?: boolean | undefined;
40
+ } & import('react').RefAttributes<HTMLDivElement>>;
41
+ };
42
+ export declare const MultiSelectTrigger: {
43
+ ({ className, children, size, wide, outline, variant, disabled, ...props }: MultiSelectTriggerProps): import("react/jsx-runtime").JSX.Element;
44
+ displayName: string;
45
+ };
46
+ export { MultiSelect };
@@ -0,0 +1,2 @@
1
+ import { MultiSelectContextProps } from './types';
2
+ export declare const MultiSelectContext: import('react').Context<MultiSelectContextProps | null>;
@@ -0,0 +1,19 @@
1
+ export declare const getMultiSelectClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
2
+ export declare const getMultiSelectTriggerClasses: (props?: ({
3
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | null | undefined;
4
+ outline?: boolean | null | undefined;
5
+ disabled?: boolean | null | undefined;
6
+ wide?: boolean | null | undefined;
7
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
8
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
+ export declare const getMultiSelectItemClasses: (props?: ({
10
+ included?: boolean | null | undefined;
11
+ disabled?: boolean | null | undefined;
12
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
13
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
14
+ export declare const getMultiSelectListClasses: (props?: ({
15
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
16
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
17
+ export declare const getMultiSelectTagClasses: (props?: ({
18
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
19
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -0,0 +1 @@
1
+ export { useMultiSelect } from './useMultiSelect';
@@ -0,0 +1 @@
1
+ export { useMultiSelect } from './useMultiSelect';
@@ -0,0 +1 @@
1
+ export declare const useMultiSelect: () => import('../../types').MultiSelectContextProps;
@@ -0,0 +1 @@
1
+ export { MultiSelect } from './MultiSelect';
@@ -0,0 +1,31 @@
1
+ import { ComponentPropsWithoutRef, HTMLAttributes } from 'react';
2
+ import { VariantProps } from '../../../libs';
3
+ import { Command } from '../../Command';
4
+ import { getMultiSelectItemClasses, getMultiSelectListClasses, getMultiSelectTriggerClasses } from './constants';
5
+ export type Item = {
6
+ value: string;
7
+ label?: string;
8
+ };
9
+ export type MultiSelectProps = React.ComponentPropsWithoutRef<typeof Command> & {
10
+ loop?: boolean;
11
+ values: Item["value"][];
12
+ onValuesChange: (value: string[]) => void;
13
+ };
14
+ export type MultiSelectContextProps = {
15
+ values: Item["value"][];
16
+ onValueChange: (value: Item["value"], label?: Item["label"]) => void;
17
+ items: Item[];
18
+ open: boolean;
19
+ setOpen: (value: boolean) => void;
20
+ inputValue: string;
21
+ setInputValue: React.Dispatch<React.SetStateAction<string>>;
22
+ activeIndex: number;
23
+ setActiveIndex: React.Dispatch<React.SetStateAction<number>>;
24
+ ref: React.RefObject<HTMLInputElement>;
25
+ handleSelect: (e: React.SyntheticEvent<HTMLInputElement>) => void;
26
+ };
27
+ export type MultiSelectTriggerProps = HTMLAttributes<HTMLDivElement> & VariantProps<typeof getMultiSelectTriggerClasses>;
28
+ export type MultiSelectInputProps = ComponentPropsWithoutRef<typeof Command.Input>;
29
+ export type MultiSelectContentProps = HTMLAttributes<HTMLDivElement>;
30
+ export type MultiSelectListProps = ComponentPropsWithoutRef<typeof Command.List> & VariantProps<typeof getMultiSelectListClasses>;
31
+ export type MultiSelectItemProps = Item & ComponentPropsWithoutRef<typeof Command.Item> & VariantProps<typeof getMultiSelectItemClasses>;
@@ -0,0 +1,13 @@
1
+ export declare const TagsInput: import('react').ForwardRefExoticComponent<import('react').HTMLAttributes<HTMLDivElement> & {
2
+ defaultTags?: string[];
3
+ onChange?: (value: string[], inputValue: string) => void;
4
+ placeholder?: string;
5
+ maxItems?: number;
6
+ minItems?: number;
7
+ } & {
8
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | undefined;
9
+ size?: "xs" | "sm" | "md" | "lg" | undefined;
10
+ outline?: boolean | undefined;
11
+ wide?: boolean | undefined;
12
+ disabled?: boolean | undefined;
13
+ } & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ export declare const SPLITTER_REGEX: RegExp;
2
+ export declare const FORMATTING_REGEX: RegExp;
3
+ export declare const getTagsClasses: (props?: ({
4
+ variant?: "accent" | "default" | "error" | "info" | "primary" | "secondary" | "success" | "warning" | "ghost" | null | undefined;
5
+ outline?: boolean | null | undefined;
6
+ disabled?: boolean | null | undefined;
7
+ wide?: boolean | null | undefined;
8
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
9
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
+ export declare const getTagClasses: (props?: ({
11
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
12
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
13
+ export declare const getTagsInputClasses: (props?: ({
14
+ size?: "xs" | "sm" | "md" | "lg" | null | undefined;
15
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
16
+ export declare const getTagDeleteClasses: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
@@ -0,0 +1 @@
1
+ export { TagsInput } from './TagsInput';
@@ -0,0 +1,9 @@
1
+ import { VariantProps } from '../../../libs';
2
+ import { getTagsClasses } from './constants';
3
+ export type TagsInputProps = React.HTMLAttributes<HTMLDivElement> & {
4
+ defaultTags?: string[];
5
+ onChange?: (value: string[], inputValue: string) => void;
6
+ placeholder?: string;
7
+ maxItems?: number;
8
+ minItems?: number;
9
+ } & VariantProps<typeof getTagsClasses>;
@@ -1,3 +1,4 @@
1
+ export { DatetimeInput } from './DatetimeInput';
1
2
  export { Input } from './Input';
2
3
  export { OtpInput } from './OtpInput';
3
4
  export { Phone } from './Phone';
@@ -7,6 +8,7 @@ export { Select } from './Select';
7
8
  export { Slider } from './Slider';
8
9
  export { Switch } from './Switch';
9
10
  export { Checkbox } from './Checkbox';
11
+ export { TagsInput } from './TagsInput';
10
12
  export { Textarea } from './Textarea';
11
13
  export { TextField } from './TextField';
12
14
  export { Label } from './components/Label';
@@ -24,6 +24,7 @@ export * from './components/Table';
24
24
  export * from './components/Tabs';
25
25
  export * from './components/Text';
26
26
  /** data input */
27
+ export * from './components/DatetimePicker';
27
28
  export * from './components/FileUploader';
28
29
  export * from './components/Form';
29
30
  export * from './components/Combobox';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.43",
4
+ "version": "0.0.44",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -93,6 +93,7 @@
93
93
  "@radix-ui/react-toggle-group": "^1.1.0",
94
94
  "@radix-ui/react-tooltip": "^1.1.2",
95
95
  "@tailwindcss/typography": "^0.5.15",
96
+ "chrono-node": "^2.7.7",
96
97
  "class-variance-authority": "^0.7.0",
97
98
  "clsx": "^2.1.1",
98
99
  "cmdk": "^1.0.0",
@@ -153,6 +154,7 @@
153
154
  "react-router-dom": "^6.26.2",
154
155
  "storybook": "^8.3.4",
155
156
  "tailwindcss": "^3.4.13",
157
+ "timescape": "^0.5.2",
156
158
  "typescript": "^5.6.2",
157
159
  "vite": "^5.4.8",
158
160
  "vite-plugin-dts": "^4.2.2",
@@ -163,5 +165,5 @@
163
165
  "react-dom": "^18.2.0",
164
166
  "typescript": "^5.2.2"
165
167
  },
166
- "gitHead": "a1d0e5c38ce829a3fcf38487bee6bfffba27e2b8"
168
+ "gitHead": "8e4871acb249c39327ba4a5b8bdb92770d649b4e"
167
169
  }
@@ -0,0 +1,59 @@
1
+ import { forwardRef, Fragment } from "react";
2
+ import type { DatetimeGridProps } from "./types";
3
+ import { cn } from "../../utilities";
4
+ import { Input } from "../Form";
5
+ import {
6
+ getDatetimeGridClasses,
7
+ getDatetimeInputClasses,
8
+ getDatetimeSeparatorClasses,
9
+ } from "./constants";
10
+
11
+ export const DatetimeGrid = forwardRef<HTMLDivElement, DatetimeGridProps>(
12
+ ({ format, disabled, className, timescape, placeholders, variant, outline, wide, size }, ref) => {
13
+ return (
14
+ <div
15
+ className={cn(
16
+ getDatetimeGridClasses({ size, wide, outline, variant, disabled }),
17
+ className
18
+ )}
19
+ {...timescape.getRootProps()}
20
+ ref={ref}
21
+ >
22
+ {format?.length
23
+ ? format.map((group, i) => (
24
+ <Fragment key={`group-${i}`}>
25
+ {group?.length
26
+ ? group.map((unit, j) => (
27
+ <Fragment key={unit}>
28
+ <Input
29
+ size={size}
30
+ disabled={disabled}
31
+ className={cn(getDatetimeInputClasses({ size, unit }))}
32
+ {...timescape.getInputProps(unit)}
33
+ placeholder={placeholders[unit]}
34
+ />
35
+ {i === 0 && j < group.length - 1 ? (
36
+ // date separator
37
+ <span className={cn(getDatetimeSeparatorClasses())}>/</span>
38
+ ) : (
39
+ j < group.length - 2 && (
40
+ // time separator
41
+ <span className={cn(getDatetimeSeparatorClasses())}>:</span>
42
+ )
43
+ )}
44
+ </Fragment>
45
+ ))
46
+ : null}
47
+ {format[1]?.length && !i ? (
48
+ // date-time separator - only if both date and time are present
49
+ <span className={cn(getDatetimeSeparatorClasses(), "opacity-30 text-xl")}>|</span>
50
+ ) : null}
51
+ </Fragment>
52
+ ))
53
+ : null}
54
+ </div>
55
+ );
56
+ }
57
+ );
58
+
59
+ DatetimeGrid.displayName = "DatetimeGrid";
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ import { forwardRef, useCallback } from "react";
4
+ import { useTimescape } from "timescape/react";
5
+ import type { DatetimePickerProps } from "./types";
6
+ import { DEFAULTS, INPUT_PLACEHOLDERS } from "./constants";
7
+ import { DatetimeGrid } from "./DatetimeGrid";
8
+
9
+ export const DatetimePicker = forwardRef<HTMLDivElement, DatetimePickerProps>(
10
+ (
11
+ {
12
+ format = DEFAULTS,
13
+ placeholders,
14
+ onChange,
15
+ className,
16
+ date,
17
+ minDate,
18
+ maxDate,
19
+ hour12 = true,
20
+ digits,
21
+ wrapAround,
22
+ snapToStep,
23
+ ...props
24
+ },
25
+ ref
26
+ ) => {
27
+ const handleDateChange = useCallback(
28
+ (date: Date | undefined) => {
29
+ if (onChange) {
30
+ onChange(date);
31
+ }
32
+ },
33
+ [onChange]
34
+ );
35
+ const timescape = useTimescape({
36
+ date,
37
+ onChangeDate: handleDateChange,
38
+ minDate,
39
+ maxDate,
40
+ hour12,
41
+ digits,
42
+ wrapAround,
43
+ snapToStep,
44
+ });
45
+
46
+ return (
47
+ <DatetimeGrid
48
+ format={format}
49
+ className={className}
50
+ timescape={timescape}
51
+ placeholders={placeholders ?? INPUT_PLACEHOLDERS}
52
+ ref={ref}
53
+ {...props}
54
+ />
55
+ );
56
+ }
57
+ );
58
+
59
+ DatetimePicker.displayName = "DatetimePicker";