sy-ui-lib 1.0.14 → 1.0.16
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/components/DatePicker/DatePicker.component.d.ts +58 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.types.d.ts +15 -16
- package/dist/components/Dropdown/Dropdown.stories.d.ts +1 -1
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -2
- package/dist/components/MultiSelectDropdown/MultiSelectDropdown.component.d.ts +1 -1
- package/dist/components/MultiSelectDropdown/MultiSelectDropdown.stories.d.ts +9 -6
- package/dist/components/MultiSelectDropdown/MultiSelectDropdown.types.d.ts +2 -2
- package/dist/index.cjs +16 -11
- package/dist/index.css +1 -1
- package/dist/index.js +1396 -1371
- package/package.json +1 -1
|
@@ -1,3 +1,61 @@
|
|
|
1
1
|
import { DatePickerProps } from './DatePicker.types';
|
|
2
|
+
/**
|
|
3
|
+
* DatePicker Component
|
|
4
|
+
*
|
|
5
|
+
* A flexible and reusable date picker component that supports both single date
|
|
6
|
+
* selection and date range selection. It provides built-in constraints, default
|
|
7
|
+
* selections, and responsive sizing for different UI needs.
|
|
8
|
+
*
|
|
9
|
+
* Props:
|
|
10
|
+
* @param {string} [title="Date"] Label or placeholder text displayed when no date is selected.
|
|
11
|
+
* @param {"single" | "range"} [variant="single"] Determines the mode of the date picker.
|
|
12
|
+
* Use `"single"` for selecting one date or `"range"` for selecting a start and end date.
|
|
13
|
+
* @param {Date} [value] Selected date value (used in single mode).
|
|
14
|
+
* @param {(date: Date | undefined) => void} [onChange] Callback triggered when a single date is selected.
|
|
15
|
+
* @param {Date} [fromDate] Start date (used in range mode).
|
|
16
|
+
* @param {Date} [toDate] - End date (used in range mode).
|
|
17
|
+
* @param {(date: Date | undefined) => void} [onFromChange] Callback triggered when the "from" date changes.
|
|
18
|
+
* @param {(date: Date | undefined) => void} [onToChange] Callback triggered when the "to" date changes.
|
|
19
|
+
* @param {"sm" | "lg" | "full"} [size="sm"] - Controls the width of the date picker.
|
|
20
|
+
* `"sm"` for compact, `"lg"` for wider input, and `"full"` for full width.
|
|
21
|
+
* @param {"sm" | "lg"} [height="lg"] - Controls the height of the input field.
|
|
22
|
+
* @param {number} [maxPastDays] - Restricts selection to only the last N days from today.
|
|
23
|
+
* @param {number} [maxRangeDays] - Limits the maximum selectable range between "from" and "to" dates.
|
|
24
|
+
* @param {boolean} [currentSelected=false] - If true, automatically selects today's date
|
|
25
|
+
* (or default range if range mode is enabled).
|
|
26
|
+
* @param {number} [rangeDays=0] - Defines the default range in days (used when `currentSelected` is true).
|
|
27
|
+
* Example: If `rangeDays = 4`, then range will be from (today - 4 days) to today.
|
|
28
|
+
* @returns A responsive date picker component supporting both single and range selection modes.
|
|
29
|
+
* @example
|
|
30
|
+
* Single Date:
|
|
31
|
+
* <DatePicker
|
|
32
|
+
* title="Select Date"
|
|
33
|
+
* variant="single"
|
|
34
|
+
* value={date}
|
|
35
|
+
* onChange={(d) => setDate(d)}
|
|
36
|
+
* />
|
|
37
|
+
*
|
|
38
|
+
* Date Range:
|
|
39
|
+
* <DatePicker
|
|
40
|
+
* variant="range"
|
|
41
|
+
* fromDate={from}
|
|
42
|
+
* toDate={to}
|
|
43
|
+
* onFromChange={setFrom}
|
|
44
|
+
* onToChange={setTo}
|
|
45
|
+
* />
|
|
46
|
+
*
|
|
47
|
+
* Default Today:
|
|
48
|
+
* <DatePicker
|
|
49
|
+
* variant="single"
|
|
50
|
+
* currentSelected
|
|
51
|
+
* />
|
|
52
|
+
*
|
|
53
|
+
* Last N Days Range:
|
|
54
|
+
* <DatePicker
|
|
55
|
+
* variant="range"
|
|
56
|
+
* currentSelected
|
|
57
|
+
* rangeDays={7}
|
|
58
|
+
* />
|
|
59
|
+
*/
|
|
2
60
|
declare const DatePicker: React.FC<DatePickerProps>;
|
|
3
61
|
export default DatePicker;
|
|
@@ -5,5 +5,8 @@ export default meta;
|
|
|
5
5
|
type Story = StoryObj<DatePickerProps>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const CustomTitle: Story;
|
|
8
|
+
export declare const Sizes: Story;
|
|
9
|
+
export declare const Heights: Story;
|
|
8
10
|
export declare const MaxPastDays: Story;
|
|
9
11
|
export declare const Range: Story;
|
|
12
|
+
export declare const RangeFull: Story;
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { ButtonSize } from '../Button';
|
|
2
|
-
/** "single": For selecting a single date. "range": For selecting a date range*/
|
|
3
1
|
export type DatePickerMode = "single" | "range";
|
|
4
|
-
|
|
2
|
+
export type DatePickerSize = "sm" | "lg" | "full";
|
|
5
3
|
export interface DatePickerProps {
|
|
6
|
-
/**
|
|
4
|
+
/** Label / placeholder */
|
|
7
5
|
title?: string;
|
|
8
|
-
/**
|
|
6
|
+
/** Mode */
|
|
9
7
|
variant?: DatePickerMode;
|
|
10
|
-
/**
|
|
8
|
+
/** Single date */
|
|
11
9
|
value?: Date;
|
|
12
|
-
/**
|
|
10
|
+
/** Single change */
|
|
13
11
|
onChange?: (date: Date | undefined) => void;
|
|
14
|
-
/**
|
|
12
|
+
/** Range: from */
|
|
15
13
|
fromDate?: Date;
|
|
16
|
-
/**
|
|
14
|
+
/** Range: to */
|
|
17
15
|
toDate?: Date;
|
|
18
|
-
/**
|
|
16
|
+
/** Range handlers */
|
|
19
17
|
onFromChange?: (date: Date | undefined) => void;
|
|
20
|
-
/** Callback when "to" date changes */
|
|
21
18
|
onToChange?: (date: Date | undefined) => void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
size?: DatePickerSize;
|
|
20
|
+
/** height controlled from parent */
|
|
21
|
+
height?: "sm" | "lg";
|
|
22
|
+
/** Constraints */
|
|
25
23
|
maxPastDays?: number;
|
|
26
|
-
/** Maximum selectable past days */
|
|
27
24
|
maxRangeDays?: number;
|
|
28
|
-
/**
|
|
25
|
+
/** Default select */
|
|
29
26
|
currentSelected?: boolean;
|
|
27
|
+
/** Default select range */
|
|
28
|
+
rangeDays?: number;
|
|
30
29
|
}
|
|
@@ -6,5 +6,5 @@ type Story = StoryObj<DropdownProps>;
|
|
|
6
6
|
export declare const SmallDropdown: Story;
|
|
7
7
|
export declare const LargeDropdown: Story;
|
|
8
8
|
export declare const SelectedOption: Story;
|
|
9
|
-
/** Stateless dropdown for downloads (doesn’t store selected)*/
|
|
10
9
|
export declare const StatelessDropdown: Story;
|
|
10
|
+
export declare const FullWidthDropdown: Story;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ButtonSize } from '../Button';
|
|
2
1
|
/**
|
|
3
2
|
* Represents an individual option in the dropdown.
|
|
4
3
|
*/
|
|
@@ -10,10 +9,11 @@ export interface DropdownOptionValues {
|
|
|
10
9
|
}
|
|
11
10
|
/** Props associated with Dropdown component*/
|
|
12
11
|
export interface DropdownProps {
|
|
12
|
+
variant?: "small" | "large";
|
|
13
13
|
/** The fallback label to display when no option is selected. */
|
|
14
14
|
label: string;
|
|
15
15
|
/** Defines the size of the dropdown button and options. default value is "sm" */
|
|
16
|
-
size?:
|
|
16
|
+
size?: "sm" | "lg" | "full";
|
|
17
17
|
/** List of dropdown options available for selection. */
|
|
18
18
|
options: DropdownOptionValues[];
|
|
19
19
|
/** Currently selected option. Must be one of the items from `options`. */
|
|
@@ -18,5 +18,5 @@ import { MultiSelectDropdownProps } from './MultiSelectDropdown.types';
|
|
|
18
18
|
* onSelect={(items) => console.log(items)}
|
|
19
19
|
* />
|
|
20
20
|
*/
|
|
21
|
-
declare const MultiSelectDropdown: ({ label, size, options, selected, onSelect, }: MultiSelectDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare const MultiSelectDropdown: ({ label, size, variant, options, selected, onSelect, }: MultiSelectDropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
export default MultiSelectDropdown;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
3
|
-
declare const meta: Meta<
|
|
2
|
+
import { MultiSelectDropdownProps } from './MultiSelectDropdown.types';
|
|
3
|
+
declare const meta: Meta<MultiSelectDropdownProps>;
|
|
4
4
|
export default meta;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/** Default story for the MultiSelectDropdown component.*/
|
|
5
|
+
type Story = StoryObj<MultiSelectDropdownProps>;
|
|
6
|
+
/** Default */
|
|
8
7
|
export declare const Default: Story;
|
|
9
|
-
/**
|
|
8
|
+
/** With Pre-selected */
|
|
10
9
|
export declare const Selected: Story;
|
|
10
|
+
/** Small Variant */
|
|
11
|
+
export declare const SmallVariant: Story;
|
|
12
|
+
/** Full Width */
|
|
13
|
+
export declare const FullWidth: Story;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ButtonSize } from '../Button';
|
|
2
1
|
export interface MultiSelectOptionValues {
|
|
3
2
|
/** The visible label shown in the dropdown list and selected state */
|
|
4
3
|
label: string;
|
|
@@ -7,10 +6,11 @@ export interface MultiSelectOptionValues {
|
|
|
7
6
|
}
|
|
8
7
|
/** Props associated with Dropdown component*/
|
|
9
8
|
export interface MultiSelectDropdownProps {
|
|
9
|
+
variant?: "small" | "large";
|
|
10
10
|
/** The fallback label to display when no option is selected. */
|
|
11
11
|
label: string;
|
|
12
12
|
/** Defines the size of the dropdown button and options. default value is "sm" */
|
|
13
|
-
size?:
|
|
13
|
+
size?: "sm" | "lg" | "full";
|
|
14
14
|
/** List of dropdown options available for selection. */
|
|
15
15
|
options: MultiSelectOptionValues[];
|
|
16
16
|
/** Currently selected option. Must be one of the items from `options`. */
|