@koobiq/react-components 0.0.1-beta.37 → 0.0.1-beta.38
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/Calendar/Calendar.js +2 -1
- package/dist/components/Calendar/components/CalendarCell/CalendarCell.js +2 -0
- package/dist/components/Calendar/components/CalendarCell/CalendarCell.module.css.js +4 -1
- package/dist/components/Calendar/types.d.ts +3 -1
- package/dist/components/DatePicker/DatePicker.d.ts +5 -3
- package/dist/components/DatePicker/DatePicker.js +101 -0
- package/dist/components/DatePicker/DatePicker.module.css.js +8 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DatePicker/types.d.ts +34 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/style.css +21 -6
- package/package.json +7 -7
- package/dist/components/DatePicker/DatePicker._stories_.d.ts +0 -13
|
@@ -9,6 +9,7 @@ import { CalendarHeader } from "./components/CalendarHeader/CalendarHeader.js";
|
|
|
9
9
|
import { CalendarGrid } from "./components/CalendarGrid/CalendarGrid.js";
|
|
10
10
|
const textNormal = utilClasses.typography["text-normal"];
|
|
11
11
|
function CalendarRender(props, ref) {
|
|
12
|
+
const { style, className } = props;
|
|
12
13
|
const { locale } = useLocale();
|
|
13
14
|
const state = useCalendarState({
|
|
14
15
|
createCalendar,
|
|
@@ -20,7 +21,7 @@ function CalendarRender(props, ref) {
|
|
|
20
21
|
state
|
|
21
22
|
);
|
|
22
23
|
const rootProps = mergeProps(
|
|
23
|
-
{ className: clsx(s.base, textNormal,
|
|
24
|
+
{ className: clsx(s.base, textNormal, className), style, ref },
|
|
24
25
|
calendarProps
|
|
25
26
|
);
|
|
26
27
|
return /* @__PURE__ */ jsxs("div", { ...rootProps, children: [
|
|
@@ -13,6 +13,7 @@ function CalendarCell({ state, date }) {
|
|
|
13
13
|
cellProps,
|
|
14
14
|
isSelected,
|
|
15
15
|
isDisabled,
|
|
16
|
+
isInvalid,
|
|
16
17
|
isPressed,
|
|
17
18
|
buttonProps,
|
|
18
19
|
isUnavailable,
|
|
@@ -35,6 +36,7 @@ function CalendarCell({ state, date }) {
|
|
|
35
36
|
isHovered && s.hovered,
|
|
36
37
|
isDisabled && s.disabled,
|
|
37
38
|
isSelected && s.selected,
|
|
39
|
+
isInvalid && s.invalid,
|
|
38
40
|
isUnavailable && s.unavailable,
|
|
39
41
|
isSelected && textNormalMedium,
|
|
40
42
|
isFocusVisible && s.focusVisible
|
|
@@ -6,6 +6,7 @@ const focusVisible = "kbq-calendarcell-focusVisible-d92d99";
|
|
|
6
6
|
const selected = "kbq-calendarcell-selected-62a719";
|
|
7
7
|
const disabled = "kbq-calendarcell-disabled-a2a975";
|
|
8
8
|
const unavailable = "kbq-calendarcell-unavailable-a606f4";
|
|
9
|
+
const invalid = "kbq-calendarcell-invalid-02611e";
|
|
9
10
|
const s = {
|
|
10
11
|
base,
|
|
11
12
|
today,
|
|
@@ -14,7 +15,8 @@ const s = {
|
|
|
14
15
|
focusVisible,
|
|
15
16
|
selected,
|
|
16
17
|
disabled,
|
|
17
|
-
unavailable
|
|
18
|
+
unavailable,
|
|
19
|
+
invalid
|
|
18
20
|
};
|
|
19
21
|
export {
|
|
20
22
|
base,
|
|
@@ -22,6 +24,7 @@ export {
|
|
|
22
24
|
disabled,
|
|
23
25
|
focusVisible,
|
|
24
26
|
hovered,
|
|
27
|
+
invalid,
|
|
25
28
|
pressed,
|
|
26
29
|
selected,
|
|
27
30
|
today,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentRef, ReactElement, Ref } from 'react';
|
|
1
|
+
import type { ComponentRef, CSSProperties, ReactElement, Ref } from 'react';
|
|
2
2
|
import type { AriaCalendarProps, DateValue } from '@koobiq/react-primitives';
|
|
3
3
|
type CalendarPropMinValue<T extends DateValue> = AriaCalendarProps<T>['minValue'];
|
|
4
4
|
type CalendarPropMaxValue<T extends DateValue> = AriaCalendarProps<T>['maxValue'];
|
|
@@ -16,6 +16,8 @@ export type CalendarProps<T extends DateValue> = {
|
|
|
16
16
|
ref?: Ref<HTMLDivElement>;
|
|
17
17
|
/** Additional CSS-classes. */
|
|
18
18
|
className?: string;
|
|
19
|
+
/** Inline styles. */
|
|
20
|
+
style?: CSSProperties;
|
|
19
21
|
/** The minimum allowed date that a user may select. */
|
|
20
22
|
minValue?: CalendarPropMinValue<T>;
|
|
21
23
|
/** The maximum allowed date that a user may select. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import { type DateValue } from '@koobiq/react-primitives';
|
|
3
|
+
import type { DatePickerComponent, DatePickerProps, DatePickerRef } from './types';
|
|
4
|
+
export declare function DatePickerRender<T extends DateValue>(props: DatePickerProps<T>, ref: Ref<DatePickerRef>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const DatePicker: DatePickerComponent;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useRef } from "react";
|
|
4
|
+
import { mergeProps } from "@koobiq/react-core";
|
|
5
|
+
import { IconCalendarO16 } from "@koobiq/react-icons";
|
|
6
|
+
import { useDatePickerState, removeDataAttributes, useDatePicker } from "@koobiq/react-primitives";
|
|
7
|
+
import { PopoverInner } from "../Popover/PopoverInner.js";
|
|
8
|
+
import s from "./DatePicker.module.css.js";
|
|
9
|
+
import { DateInput } from "../DateInput/DateInput.js";
|
|
10
|
+
import { Calendar } from "../Calendar/Calendar.js";
|
|
11
|
+
import { IconButton } from "../IconButton/IconButton.js";
|
|
12
|
+
function DatePickerRender(props, ref) {
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const {
|
|
15
|
+
label,
|
|
16
|
+
style,
|
|
17
|
+
caption,
|
|
18
|
+
className,
|
|
19
|
+
slotProps,
|
|
20
|
+
fullWidth,
|
|
21
|
+
errorMessage,
|
|
22
|
+
startAddon,
|
|
23
|
+
endAddon,
|
|
24
|
+
"data-testid": testId
|
|
25
|
+
} = props;
|
|
26
|
+
const state = useDatePickerState(
|
|
27
|
+
removeDataAttributes({ ...props, description: caption })
|
|
28
|
+
);
|
|
29
|
+
const {
|
|
30
|
+
isInvalid,
|
|
31
|
+
groupProps,
|
|
32
|
+
labelProps,
|
|
33
|
+
fieldProps,
|
|
34
|
+
buttonProps,
|
|
35
|
+
dialogProps,
|
|
36
|
+
calendarProps: calendarPropsAria
|
|
37
|
+
} = useDatePicker(
|
|
38
|
+
removeDataAttributes({ ...props, description: caption }),
|
|
39
|
+
state,
|
|
40
|
+
anchorRef
|
|
41
|
+
);
|
|
42
|
+
const rootProps = mergeProps(
|
|
43
|
+
{
|
|
44
|
+
ref,
|
|
45
|
+
style,
|
|
46
|
+
label,
|
|
47
|
+
caption,
|
|
48
|
+
fullWidth,
|
|
49
|
+
className,
|
|
50
|
+
startAddon,
|
|
51
|
+
errorMessage,
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
slotProps: {
|
|
54
|
+
label: labelProps,
|
|
55
|
+
group: {
|
|
56
|
+
endAddon: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
+
endAddon,
|
|
58
|
+
/* @__PURE__ */ jsx(
|
|
59
|
+
IconButton,
|
|
60
|
+
{
|
|
61
|
+
variant: isInvalid ? "error" : "fade-contrast",
|
|
62
|
+
className: s.calendar,
|
|
63
|
+
...buttonProps,
|
|
64
|
+
children: /* @__PURE__ */ jsx(IconCalendarO16, {})
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
] }),
|
|
68
|
+
...groupProps,
|
|
69
|
+
ref: anchorRef
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
slotProps?.root,
|
|
74
|
+
fieldProps
|
|
75
|
+
);
|
|
76
|
+
const popoverProps = mergeProps(
|
|
77
|
+
{
|
|
78
|
+
state,
|
|
79
|
+
anchorRef,
|
|
80
|
+
offset: 4,
|
|
81
|
+
size: "auto",
|
|
82
|
+
hideArrow: true,
|
|
83
|
+
hideCloseButton: true,
|
|
84
|
+
placement: "bottom start",
|
|
85
|
+
slotProps: {
|
|
86
|
+
dialog: dialogProps
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
slotProps?.popover
|
|
90
|
+
);
|
|
91
|
+
const calendarProps = mergeProps(calendarPropsAria, slotProps?.calendar);
|
|
92
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
93
|
+
/* @__PURE__ */ jsx(DateInput, { ...rootProps }),
|
|
94
|
+
/* @__PURE__ */ jsx(PopoverInner, { ...popoverProps, children: /* @__PURE__ */ jsx(Calendar, { firstDayOfWeek: props.firstDayOfWeek, ...calendarProps }) })
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
const DatePicker = forwardRef(DatePickerRender);
|
|
98
|
+
export {
|
|
99
|
+
DatePicker,
|
|
100
|
+
DatePickerRender
|
|
101
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { AriaDatePickerProps, DateValue } from '@koobiq/react-primitives';
|
|
3
|
+
import type { CalendarProps } from '../Calendar';
|
|
4
|
+
import type { DateInputProps, DateInputRef } from '../DateInput';
|
|
5
|
+
import type { PopoverProps } from '../Popover';
|
|
6
|
+
export type DatePickerProps<T extends DateValue> = {
|
|
7
|
+
/**
|
|
8
|
+
* If true, the input will take up the full width of its container.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
/** The helper text content. */
|
|
13
|
+
caption?: ReactNode;
|
|
14
|
+
/** Addon placed before the children. */
|
|
15
|
+
startAddon?: ReactNode;
|
|
16
|
+
/** Addon placed after the children. */
|
|
17
|
+
endAddon?: ReactNode;
|
|
18
|
+
/** Additional CSS-classes. */
|
|
19
|
+
className?: string;
|
|
20
|
+
/** Inline styles. */
|
|
21
|
+
style?: CSSProperties;
|
|
22
|
+
/** Unique identifier for testing purposes. */
|
|
23
|
+
'data-testid'?: string | number;
|
|
24
|
+
/** Ref to the DateInput. */
|
|
25
|
+
ref?: Ref<DateInputRef>;
|
|
26
|
+
/** The props used for each slot inside. */
|
|
27
|
+
slotProps?: {
|
|
28
|
+
root?: DateInputProps<T>;
|
|
29
|
+
popover?: PopoverProps;
|
|
30
|
+
calendar?: CalendarProps<T>;
|
|
31
|
+
};
|
|
32
|
+
} & Omit<AriaDatePickerProps<T>, 'description' | 'validate' | 'validationBehavior' | 'validationState'>;
|
|
33
|
+
export type DatePickerComponent = <T extends DateValue>(props: DatePickerProps<T>) => ReactElement | null;
|
|
34
|
+
export type DatePickerRef = DateInputRef;
|
|
@@ -32,6 +32,7 @@ export * from './TagGroup';
|
|
|
32
32
|
export * from './Table';
|
|
33
33
|
export * from './Calendar';
|
|
34
34
|
export * from './DateInput';
|
|
35
|
+
export * from './DatePicker';
|
|
35
36
|
export * from './layout';
|
|
36
37
|
export { useListData, useDateFormatter, type DateFormatterOptions, } from '@koobiq/react-primitives';
|
|
37
38
|
export { useRouter, RouterProvider } from '@koobiq/react-primitives';
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ import { Table } from "./components/Table/Table.js";
|
|
|
75
75
|
import { Calendar } from "./components/Calendar/Calendar.js";
|
|
76
76
|
import { DateInput, DateInputRender } from "./components/DateInput/DateInput.js";
|
|
77
77
|
import { dateInputPropVariant } from "./components/DateInput/types.js";
|
|
78
|
+
import { DatePicker, DatePickerRender } from "./components/DatePicker/DatePicker.js";
|
|
78
79
|
import { flex, flexPropAlignItems, flexPropDirection, flexPropFlex, flexPropGap, flexPropJustifyContent, flexPropOrder, flexPropWrap } from "./components/layout/flex/flex.js";
|
|
79
80
|
import { spacing, spacingGap } from "./components/layout/spacing/spacing.js";
|
|
80
81
|
export {
|
|
@@ -91,6 +92,8 @@ export {
|
|
|
91
92
|
Container,
|
|
92
93
|
DateInput,
|
|
93
94
|
DateInputRender,
|
|
95
|
+
DatePicker,
|
|
96
|
+
DatePickerRender,
|
|
94
97
|
Divider,
|
|
95
98
|
FlexBox,
|
|
96
99
|
Grid,
|
package/dist/style.css
CHANGED
|
@@ -2335,7 +2335,7 @@
|
|
|
2335
2335
|
margin-block: var(--toggle-track-margin-block);
|
|
2336
2336
|
border-radius: var(--toggle-track-border-radius);
|
|
2337
2337
|
outline: 2px solid var(--toggle-track-outline-color);
|
|
2338
|
-
transition: background-color var(--kbq-transition-default), outline-color var(--kbq-transition-default);
|
|
2338
|
+
transition: border-color var(--kbq-transition-default), background-color var(--kbq-transition-default), outline-color var(--kbq-transition-default);
|
|
2339
2339
|
flex-shrink: 0;
|
|
2340
2340
|
position: relative;
|
|
2341
2341
|
}
|
|
@@ -2417,14 +2417,14 @@
|
|
|
2417
2417
|
}
|
|
2418
2418
|
|
|
2419
2419
|
.kbq-toggle-invalid-ae9ba4 {
|
|
2420
|
-
--toggle-track-bg-color: var(--kbq-
|
|
2420
|
+
--toggle-track-bg-color: var(--kbq-background-error-less);
|
|
2421
2421
|
--toggle-track-border-color: var(--kbq-line-error);
|
|
2422
2422
|
--toggle-thumb-bg-color: var(--kbq-icon-error);
|
|
2423
2423
|
}
|
|
2424
2424
|
|
|
2425
2425
|
.kbq-toggle-invalid-ae9ba4:where(.kbq-toggle-selected-0bb42c) {
|
|
2426
2426
|
--toggle-track-bg-color: var(--kbq-background-error);
|
|
2427
|
-
--toggle-track-border-color:
|
|
2427
|
+
--toggle-track-border-color: transparent;
|
|
2428
2428
|
--toggle-thumb-bg-color: var(--kbq-icon-white);
|
|
2429
2429
|
}
|
|
2430
2430
|
|
|
@@ -2436,7 +2436,7 @@
|
|
|
2436
2436
|
|
|
2437
2437
|
.kbq-toggle-invalid-ae9ba4:where(.kbq-toggle-hovered-d4d8d0.kbq-toggle-selected-0bb42c) {
|
|
2438
2438
|
--toggle-track-bg-color: var(--kbq-states-background-error-hover);
|
|
2439
|
-
--toggle-track-border-color:
|
|
2439
|
+
--toggle-track-border-color: transparent;
|
|
2440
2440
|
--toggle-thumb-bg-color: var(--kbq-icon-white);
|
|
2441
2441
|
}
|
|
2442
2442
|
|
|
@@ -2450,12 +2450,19 @@
|
|
|
2450
2450
|
}
|
|
2451
2451
|
|
|
2452
2452
|
.kbq-toggle-disabled-b31c64 {
|
|
2453
|
+
cursor: not-allowed;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
.kbq-toggle-disabled-b31c64:not(.kbq-toggle-selected-0bb42c) {
|
|
2453
2457
|
--toggle-track-border-color: var(--kbq-states-line-disabled);
|
|
2454
2458
|
--toggle-track-bg-color: var(--kbq-states-background-disabled);
|
|
2455
2459
|
--toggle-thumb-bg-color: var(--kbq-states-icon-disabled);
|
|
2456
|
-
--toggle-thumb-border-color: var(--kbq-states-icon-disabled);
|
|
2457
2460
|
--toggle-color: var(--kbq-states-foreground-disabled);
|
|
2458
|
-
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
.kbq-toggle-disabled-b31c64:where(.kbq-toggle-selected-0bb42c) {
|
|
2464
|
+
opacity: var(--kbq-opacity-disabled);
|
|
2465
|
+
display: flex;
|
|
2459
2466
|
}
|
|
2460
2467
|
.kbq-progressbar-824268 {
|
|
2461
2468
|
--progressbar-track-bg-color: var(--kbq-background-contrast-fade);
|
|
@@ -3765,6 +3772,11 @@
|
|
|
3765
3772
|
color: var(--kbq-states-foreground-disabled);
|
|
3766
3773
|
cursor: not-allowed;
|
|
3767
3774
|
}
|
|
3775
|
+
|
|
3776
|
+
.kbq-calendarcell-invalid-02611e {
|
|
3777
|
+
background-color: var(--kbq-background-error);
|
|
3778
|
+
color: var(--kbq-foreground-on-contrast);
|
|
3779
|
+
}
|
|
3768
3780
|
.kbq-dateinput-a4c39b {
|
|
3769
3781
|
min-inline-size: 150px;
|
|
3770
3782
|
}
|
|
@@ -3872,6 +3884,9 @@
|
|
|
3872
3884
|
.kbq-dateinputsegment-literal-d722fc:not(.kbq-dateinputsegment-hasValue-886d0f) {
|
|
3873
3885
|
color: var(--field-input-placeholder-color);
|
|
3874
3886
|
}
|
|
3887
|
+
.kbq-datepicker-calendar-25a0d7 {
|
|
3888
|
+
margin-inline-end: calc(-1 * var(--kbq-size-xxs));
|
|
3889
|
+
}
|
|
3875
3890
|
.kbq-spacing-mbs_0-be7021 {
|
|
3876
3891
|
margin-block-start: 0;
|
|
3877
3892
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.38",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@koobiq/design-tokens": "^3.
|
|
27
|
+
"@koobiq/design-tokens": "^3.14.0",
|
|
28
28
|
"@types/react-transition-group": "^4.4.12",
|
|
29
29
|
"react-transition-group": "^4.4.5",
|
|
30
|
-
"@koobiq/
|
|
31
|
-
"@koobiq/
|
|
32
|
-
"@koobiq/react-
|
|
33
|
-
"@koobiq/react-
|
|
30
|
+
"@koobiq/react-core": "0.0.1-beta.38",
|
|
31
|
+
"@koobiq/logger": "0.0.1-beta.38",
|
|
32
|
+
"@koobiq/react-icons": "0.0.1-beta.38",
|
|
33
|
+
"@koobiq/react-primitives": "0.0.1-beta.38"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@koobiq/design-tokens": "^3.
|
|
36
|
+
"@koobiq/design-tokens": "^3.14.0",
|
|
37
37
|
"react": "18.x || 19.x",
|
|
38
38
|
"react-dom": "18.x || 19.x"
|
|
39
39
|
},
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import { DatePicker } from './DatePicker';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: typeof DatePicker;
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: string;
|
|
8
|
-
};
|
|
9
|
-
argTypes: {};
|
|
10
|
-
};
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof meta>;
|
|
13
|
-
export declare const Base: Story;
|