@povio/ui 2.1.15 → 2.1.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/README.md CHANGED
@@ -29,6 +29,12 @@ Tailwind version 4 also defaults to `cursor: default` for buttons which differs
29
29
 
30
30
  This is required for buttons to behave as expected. It is based on [Tailwind Upgrade Guide](https://tailwindcss.com/docs/upgrade-guide#buttons-use-the-default-cursor).
31
31
 
32
+ In order for Tailwind to also compile classes for @povio/ui package, you need to include @source directive in Tailwind config.
33
+ In your globals.css add (make sure path is correct):
34
+ ```css
35
+ @source "../../node-modules/@povio/ui/dist";
36
+ ```
37
+
32
38
  ### React Aria
33
39
 
34
40
  We are using `react-aria-components` for our UI components including their plugin for Tailwind that makes classes for modifiers a bit shorter. As such, make sure to install and setup [`tailwindcss-react-aria-components`](https://www.npmjs.com/package/tailwindcss-react-aria-components)
@@ -8,7 +8,7 @@ import { TooltipWrapper } from "./TooltipWrapper.js";
8
8
  import { DateTimeUtils } from "./date-time.utils.js";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  import { clsx } from "clsx";
11
- import { useRef } from "react";
11
+ import { useImperativeHandle, useMemo, useRef } from "react";
12
12
  import { useDatePicker, useLocale } from "react-aria";
13
13
  import { mergeRefs } from "@react-aria/utils";
14
14
  import { Controller } from "react-hook-form";
@@ -32,6 +32,13 @@ var DatePickerBase = (props) => {
32
32
  headerClassName,
33
33
  errorClassName
34
34
  };
35
+ const datePickerInputRef = useRef(null);
36
+ const datePickerRef = useMemo(() => ({ get current() {
37
+ return datePickerInputRef.current?.getContainer?.() || null;
38
+ } }), []);
39
+ useImperativeHandle(ref, () => ({ clear: () => {
40
+ datePickerInputRef.current?.clear();
41
+ } }));
35
42
  const dialogState = useDatePickerState({
36
43
  ...rest,
37
44
  defaultValue: value || rest.defaultValue,
@@ -53,7 +60,6 @@ var DatePickerBase = (props) => {
53
60
  },
54
61
  shouldCloseOnSelect: false
55
62
  });
56
- const datePickerRef = useRef(null);
57
63
  const { groupProps, labelProps, fieldProps, buttonProps, dialogProps } = useDatePicker({
58
64
  ...rest,
59
65
  label,
@@ -105,7 +111,7 @@ var DatePickerBase = (props) => {
105
111
  className: clsx("relative inline-flex w-full flex-col text-left", className),
106
112
  tabIndex: as === "inline" ? -1 : void 0,
107
113
  children: [/* @__PURE__ */ jsx(DatePickerInput, {
108
- ref: mergeRefs(ref, datePickerRef),
114
+ ref: mergeRefs(ref, datePickerInputRef),
109
115
  as,
110
116
  groupProps,
111
117
  fieldProps: {
@@ -7,7 +7,7 @@ import { FormField } from "./FormField.js";
7
7
  import { TooltipWrapper } from "./TooltipWrapper.js";
8
8
  import { DateTimeUtils } from "./date-time.utils.js";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { useEffect, useRef } from "react";
10
+ import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
11
11
  import { useDatePicker, useLocale } from "react-aria";
12
12
  import { mergeRefs } from "@react-aria/utils";
13
13
  import { Controller } from "react-hook-form";
@@ -30,6 +30,13 @@ var DateTimePickerBase = (props) => {
30
30
  headerClassName,
31
31
  errorClassName
32
32
  };
33
+ const datePickerInputRef = useRef(null);
34
+ const datePickerRef = useMemo(() => ({ get current() {
35
+ return datePickerInputRef.current?.getContainer?.() || null;
36
+ } }), []);
37
+ useImperativeHandle(ref, () => ({ clear: () => {
38
+ datePickerInputRef.current?.clear();
39
+ } }));
33
40
  const dialogState = useDatePickerState({
34
41
  ...rest,
35
42
  defaultValue: value || rest.defaultValue,
@@ -54,7 +61,6 @@ var DateTimePickerBase = (props) => {
54
61
  granularity: "minute",
55
62
  hideTimeZone: true
56
63
  });
57
- const datePickerRef = useRef(null);
58
64
  const { groupProps, labelProps, fieldProps, buttonProps, dialogProps } = useDatePicker({
59
65
  ...rest,
60
66
  label,
@@ -110,13 +116,15 @@ var DateTimePickerBase = (props) => {
110
116
  return /* @__PURE__ */ jsx(TooltipWrapper, {
111
117
  as,
112
118
  error,
119
+ triggerTabIndex: as === "inline" ? -1 : void 0,
113
120
  children: /* @__PURE__ */ jsxs(FormField, {
114
121
  ...formFieldProps,
115
122
  as,
116
123
  labelProps,
117
124
  className: "relative inline-flex w-full flex-col text-left",
125
+ tabIndex: as === "inline" ? -1 : void 0,
118
126
  children: [/* @__PURE__ */ jsx(DatePickerInput, {
119
- ref: mergeRefs(ref, datePickerRef),
127
+ ref: mergeRefs(ref, datePickerInputRef),
120
128
  as,
121
129
  groupProps,
122
130
  fieldProps: {
@@ -180,12 +188,13 @@ const DateTimePicker = ({ fullIso = true,...props }) => {
180
188
  return /* @__PURE__ */ jsx(Controller, {
181
189
  control: formControl.control,
182
190
  name: formControl.name,
183
- render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
191
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
184
192
  ...innerProps,
185
193
  ref: mergeRefs(ref, field.ref),
186
194
  value: parseDateValue(field.value),
187
195
  onChange: (value) => field.onChange(formatDateValue(value)),
188
196
  onBlur: field.onBlur,
197
+ isDirty,
189
198
  isDisabled: field.disabled || props.isDisabled,
190
199
  error: props.error ?? error?.message
191
200
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.1.15",
3
+ "version": "2.1.16",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",