laif-ds 0.2.45 → 0.2.47
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/_virtual/index2.js +5 -2
- package/dist/_virtual/index3.js +2 -5
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/agent-docs/components/AppForm.md +74 -12
- package/dist/components/ui/app-form.js +38 -36
- package/dist/components/ui/date-picker.js +6 -5
- package/dist/index.d.ts +6 -3
- package/dist/node_modules/date-fns/_lib/normalizeDates.js +5 -5
- package/dist/node_modules/date-fns/isSameWeek.js +15 -0
- package/dist/node_modules/date-fns/locale/it/_lib/formatDistance.js +71 -0
- package/dist/node_modules/date-fns/locale/it/_lib/formatLong.js +34 -0
- package/dist/node_modules/date-fns/locale/it/_lib/formatRelative.js +50 -0
- package/dist/node_modules/date-fns/locale/it/_lib/localize.js +147 -0
- package/dist/node_modules/date-fns/locale/it/_lib/match.js +111 -0
- package/dist/node_modules/date-fns/locale/it.js +22 -0
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
+
var r = t();
|
|
5
|
+
const m = /* @__PURE__ */ e(r);
|
|
3
6
|
export {
|
|
4
|
-
|
|
7
|
+
m as default
|
|
5
8
|
};
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
-
var r = t();
|
|
5
|
-
const m = /* @__PURE__ */ e(r);
|
|
2
|
+
var e = { exports: {} };
|
|
6
3
|
export {
|
|
7
|
-
|
|
4
|
+
e as __module
|
|
8
5
|
};
|
package/dist/_virtual/index6.js
CHANGED
package/dist/_virtual/index7.js
CHANGED
|
@@ -11,7 +11,7 @@ Dynamic form component that integrates with React Hook Form to provide a configu
|
|
|
11
11
|
### AppFormItem
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
interface AppFormItem {
|
|
14
|
+
export interface AppFormItem {
|
|
15
15
|
label: string; // Field label
|
|
16
16
|
component:
|
|
17
17
|
| "input"
|
|
@@ -24,6 +24,7 @@ interface AppFormItem {
|
|
|
24
24
|
| "switch"
|
|
25
25
|
| "slider"; // Field type
|
|
26
26
|
name: string; // Field name (used for form state and validation)
|
|
27
|
+
inputType?: string; // HTML input type for "input" component (e.g. "text", "email", "password", "number")
|
|
27
28
|
defaultValue?: string | boolean | number | string[] | Date | number[]; // Initial value
|
|
28
29
|
options?: AppSelectOption[]; // Options for select/multiselect/radio
|
|
29
30
|
disabled?: boolean; // Disables the field
|
|
@@ -36,18 +37,67 @@ interface AppFormItem {
|
|
|
36
37
|
}
|
|
37
38
|
```
|
|
38
39
|
|
|
40
|
+
### Submit Button Inside vs Outside
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { AppForm, Button } from "laif-ds";
|
|
44
|
+
import { useForm } from "react-hook-form";
|
|
45
|
+
|
|
46
|
+
export function SubmitInsideVsOutside() {
|
|
47
|
+
const formInside = useForm({ mode: "onChange" });
|
|
48
|
+
const formOutside = useForm({ mode: "onChange" });
|
|
49
|
+
|
|
50
|
+
const onSubmitInside = (data: any) => console.log("inside", data);
|
|
51
|
+
const onSubmitOutside = (data: any) => console.log("outside", data);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="grid grid-cols-2 gap-6">
|
|
55
|
+
<div>
|
|
56
|
+
{/* Internal submit button rendered by AppForm */}
|
|
57
|
+
<AppForm
|
|
58
|
+
form={formInside}
|
|
59
|
+
items={[{ label: "Name", component: "input", name: "name" }]}
|
|
60
|
+
onSubmit={onSubmitInside}
|
|
61
|
+
showSubmitButton
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
<div>
|
|
65
|
+
{/* External submit button managed outside */}
|
|
66
|
+
<AppForm
|
|
67
|
+
form={formOutside}
|
|
68
|
+
items={[{ label: "Name", component: "input", name: "name" }]}
|
|
69
|
+
onSubmit={onSubmitOutside}
|
|
70
|
+
/>
|
|
71
|
+
<div className="mt-4 flex justify-end">
|
|
72
|
+
<Button
|
|
73
|
+
type="button"
|
|
74
|
+
disabled={
|
|
75
|
+
!formOutside.formState.isValid || !formOutside.formState.isDirty
|
|
76
|
+
}
|
|
77
|
+
onClick={formOutside.handleSubmit(onSubmitOutside)}
|
|
78
|
+
>
|
|
79
|
+
Submit (external)
|
|
80
|
+
</Button>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
39
88
|
---
|
|
40
89
|
|
|
41
90
|
## Props
|
|
42
91
|
|
|
43
|
-
| Prop
|
|
44
|
-
|
|
|
45
|
-
| `items`
|
|
46
|
-
| `form`
|
|
47
|
-
| `cols`
|
|
48
|
-
| `submitText`
|
|
49
|
-
| `onSubmit`
|
|
50
|
-
| `isSubmitting`
|
|
92
|
+
| Prop | Type | Default | Description |
|
|
93
|
+
| ------------------ | --------------------- | ------------ | -------------------------------------------------------- |
|
|
94
|
+
| `items` | `AppFormItem[]` | **required** | Array of form field configurations |
|
|
95
|
+
| `form` | `UseFormReturn<any>` | **required** | React Hook Form instance |
|
|
96
|
+
| `cols` | `"1" \| "2" \| "3"` | `"2"` | Number of grid columns |
|
|
97
|
+
| `submitText` | `string` | `"Invia"` | Text for submit button |
|
|
98
|
+
| `onSubmit` | `(data: any) => void` | `undefined` | Form submission callback |
|
|
99
|
+
| `isSubmitting` | `boolean` | `false` | Shows loading state on submit button |
|
|
100
|
+
| `showSubmitButton` | `boolean` | `false` | Renders an internal submit button at the end of the form |
|
|
51
101
|
|
|
52
102
|
---
|
|
53
103
|
|
|
@@ -56,7 +106,7 @@ interface AppFormItem {
|
|
|
56
106
|
- **React Hook Form Integration**: Uses `Controller` from React Hook Form for each field
|
|
57
107
|
- **Validation Display**: Shows validation errors inline with each field
|
|
58
108
|
- **Grid Layout**: Automatically arranges fields in a responsive grid based on `cols` prop
|
|
59
|
-
- **Submit Button**:
|
|
109
|
+
- **Submit Button**: Rendered only when `showSubmitButton` is `true`. When shown, it is disabled when the form is invalid or pristine. Otherwise, manage submit externally with `form.handleSubmit(...)`.
|
|
60
110
|
- **Last Field Spanning**: The last field automatically spans full width
|
|
61
111
|
- **Error Highlighting**: Fields with errors get red border styling
|
|
62
112
|
|
|
@@ -65,30 +115,41 @@ interface AppFormItem {
|
|
|
65
115
|
## Field Types
|
|
66
116
|
|
|
67
117
|
### input
|
|
68
|
-
|
|
118
|
+
|
|
119
|
+
Standard text input field. When `component: "input"`, you can use the `inputType` property to control the underlying HTML input type (e.g. `"text"`, `"email"`, `"password"`, `"number"`, `"url"`).
|
|
120
|
+
|
|
121
|
+
For a complete showcase of different input types, see the Storybook story `UI/AppForm/DifferentInputTypes`.
|
|
69
122
|
|
|
70
123
|
### textarea
|
|
124
|
+
|
|
71
125
|
Multi-line text area
|
|
72
126
|
|
|
73
127
|
### select
|
|
128
|
+
|
|
74
129
|
Single selection dropdown using AppSelect
|
|
75
130
|
|
|
76
131
|
### multiselect
|
|
132
|
+
|
|
77
133
|
Multiple selection dropdown using AppSelect with `multiple` prop
|
|
78
134
|
|
|
79
135
|
### datepicker
|
|
136
|
+
|
|
80
137
|
Date picker component with optional range selection via `calendarRange`
|
|
81
138
|
|
|
82
139
|
### radio
|
|
140
|
+
|
|
83
141
|
Radio button group with options
|
|
84
142
|
|
|
85
143
|
### checkbox
|
|
144
|
+
|
|
86
145
|
Single checkbox with label
|
|
87
146
|
|
|
88
147
|
### switch
|
|
148
|
+
|
|
89
149
|
Toggle switch with label and optional caption
|
|
90
150
|
|
|
91
151
|
### slider
|
|
152
|
+
|
|
92
153
|
Range slider with min/max/step configuration
|
|
93
154
|
|
|
94
155
|
---
|
|
@@ -118,6 +179,7 @@ export function BasicForm() {
|
|
|
118
179
|
label: "Email",
|
|
119
180
|
component: "input",
|
|
120
181
|
name: "email",
|
|
182
|
+
inputType: "email",
|
|
121
183
|
placeholder: "Enter your email",
|
|
122
184
|
},
|
|
123
185
|
{
|
|
@@ -238,5 +300,5 @@ export function DateRangeForm() {
|
|
|
238
300
|
- **React Hook Form Required**: This component requires React Hook Form to be installed and configured
|
|
239
301
|
- **Validation**: Use React Hook Form's resolver (e.g., Zod, Yup) for validation
|
|
240
302
|
- **Grid Layout**: The grid uses Tailwind's grid system with `grid-cols-{n}` classes
|
|
241
|
-
- **Submit Button**:
|
|
303
|
+
- **Submit Button**: Use `showSubmitButton` to render the internal submit button at the end of the form, or provide your own external submit control.
|
|
242
304
|
- **Error Display**: Errors appear inline above each field and as border highlighting
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
3
3
|
import { cn as o } from "../../lib/utils.js";
|
|
4
|
-
import { Controller as
|
|
5
|
-
import { AppSelect as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { Checkbox as
|
|
8
|
-
import { DatePicker as
|
|
9
|
-
import { Input as
|
|
4
|
+
import { Controller as V } from "../../node_modules/react-hook-form/dist/index.esm.js";
|
|
5
|
+
import { AppSelect as v } from "./app-select.js";
|
|
6
|
+
import { Button as j } from "./button.js";
|
|
7
|
+
import { Checkbox as A } from "./checkbox.js";
|
|
8
|
+
import { DatePicker as F } from "./date-picker.js";
|
|
9
|
+
import { Input as I } from "./input.js";
|
|
10
10
|
import { Label as t } from "./label.js";
|
|
11
|
-
import { RadioGroup as
|
|
12
|
-
import { Slider as
|
|
11
|
+
import { RadioGroup as R, RadioGroupItem as B } from "./radio-group.js";
|
|
12
|
+
import { Slider as T } from "./slider.js";
|
|
13
13
|
import { Switch as $ } from "./switch.js";
|
|
14
14
|
import { Textarea as D } from "./textarea.js";
|
|
15
15
|
import { Typo as i } from "./typo.js";
|
|
16
|
-
const
|
|
17
|
-
items:
|
|
18
|
-
cols:
|
|
16
|
+
const X = ({
|
|
17
|
+
items: p,
|
|
18
|
+
cols: m = "2",
|
|
19
19
|
form: b,
|
|
20
20
|
submitText: g = "Invia",
|
|
21
21
|
onSubmit: x,
|
|
22
|
-
isSubmitting:
|
|
22
|
+
isSubmitting: h = !1,
|
|
23
|
+
showSubmitButton: C = !1
|
|
23
24
|
}) => {
|
|
24
25
|
const {
|
|
25
|
-
control:
|
|
26
|
-
handleSubmit:
|
|
27
|
-
formState: { errors:
|
|
28
|
-
} = b,
|
|
29
|
-
const c =
|
|
26
|
+
control: N,
|
|
27
|
+
handleSubmit: y,
|
|
28
|
+
formState: { errors: f, isValid: S, isDirty: k }
|
|
29
|
+
} = b, w = (e) => {
|
|
30
|
+
const c = f[e.name]?.message, d = c ? String(c) : void 0;
|
|
30
31
|
return /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
31
|
-
|
|
32
|
+
V,
|
|
32
33
|
{
|
|
33
34
|
name: e.name,
|
|
34
|
-
control:
|
|
35
|
+
control: N,
|
|
35
36
|
render: ({ field: r }) => {
|
|
36
37
|
const s = /* @__PURE__ */ l("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
37
38
|
/* @__PURE__ */ a(t, { children: e.label }),
|
|
@@ -42,9 +43,10 @@ const U = ({
|
|
|
42
43
|
return /* @__PURE__ */ l("div", { children: [
|
|
43
44
|
s,
|
|
44
45
|
/* @__PURE__ */ a(
|
|
45
|
-
|
|
46
|
+
I,
|
|
46
47
|
{
|
|
47
48
|
...r,
|
|
49
|
+
type: e.inputType,
|
|
48
50
|
placeholder: e.placeholder,
|
|
49
51
|
className: o(d && "border-d-destructive"),
|
|
50
52
|
disabled: e.disabled
|
|
@@ -68,7 +70,7 @@ const U = ({
|
|
|
68
70
|
return /* @__PURE__ */ l("div", { children: [
|
|
69
71
|
s,
|
|
70
72
|
/* @__PURE__ */ a(
|
|
71
|
-
|
|
73
|
+
R,
|
|
72
74
|
{
|
|
73
75
|
value: r.value != null ? String(r.value) : "",
|
|
74
76
|
onValueChange: (n) => r.onChange(n),
|
|
@@ -82,7 +84,7 @@ const U = ({
|
|
|
82
84
|
className: "flex items-center gap-2",
|
|
83
85
|
children: [
|
|
84
86
|
/* @__PURE__ */ a(
|
|
85
|
-
|
|
87
|
+
B,
|
|
86
88
|
{
|
|
87
89
|
id: u,
|
|
88
90
|
value: String(n.value),
|
|
@@ -112,7 +114,7 @@ const U = ({
|
|
|
112
114
|
return /* @__PURE__ */ l("div", { children: [
|
|
113
115
|
s,
|
|
114
116
|
/* @__PURE__ */ a(
|
|
115
|
-
|
|
117
|
+
v,
|
|
116
118
|
{
|
|
117
119
|
...r,
|
|
118
120
|
onValueChange: (n) => r.onChange(n),
|
|
@@ -126,7 +128,7 @@ const U = ({
|
|
|
126
128
|
return /* @__PURE__ */ l("div", { children: [
|
|
127
129
|
s,
|
|
128
130
|
/* @__PURE__ */ a(
|
|
129
|
-
|
|
131
|
+
v,
|
|
130
132
|
{
|
|
131
133
|
...r,
|
|
132
134
|
multiple: !0,
|
|
@@ -141,7 +143,7 @@ const U = ({
|
|
|
141
143
|
return /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
142
144
|
s,
|
|
143
145
|
/* @__PURE__ */ a(
|
|
144
|
-
|
|
146
|
+
F,
|
|
145
147
|
{
|
|
146
148
|
value: r.value,
|
|
147
149
|
onChange: e.disabled || e.calendarRange ? void 0 : (n) => r.onChange(n),
|
|
@@ -162,7 +164,7 @@ const U = ({
|
|
|
162
164
|
return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
|
|
163
165
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
|
|
164
166
|
/* @__PURE__ */ a(
|
|
165
|
-
|
|
167
|
+
A,
|
|
166
168
|
{
|
|
167
169
|
...r,
|
|
168
170
|
id: e.name,
|
|
@@ -223,7 +225,7 @@ const U = ({
|
|
|
223
225
|
return /* @__PURE__ */ l("div", { children: [
|
|
224
226
|
s,
|
|
225
227
|
/* @__PURE__ */ a(
|
|
226
|
-
|
|
228
|
+
T,
|
|
227
229
|
{
|
|
228
230
|
value: Array.isArray(r.value) ? r.value : [r.value || e.min || 0],
|
|
229
231
|
onValueChange: (n) => r.onChange(n[0]),
|
|
@@ -248,26 +250,26 @@ const U = ({
|
|
|
248
250
|
}
|
|
249
251
|
) });
|
|
250
252
|
};
|
|
251
|
-
return /* @__PURE__ */ l("form", { onSubmit:
|
|
252
|
-
/* @__PURE__ */ a("div", { className: o("grid gap-4", `grid-cols-${
|
|
253
|
+
return /* @__PURE__ */ l("form", { onSubmit: y((e) => x?.(e)), children: [
|
|
254
|
+
/* @__PURE__ */ a("div", { className: o("grid gap-4", `grid-cols-${m}`), children: p.map((e, c) => /* @__PURE__ */ a(
|
|
253
255
|
"div",
|
|
254
256
|
{
|
|
255
|
-
className: o(c ===
|
|
256
|
-
children:
|
|
257
|
+
className: o(c === p.length - 1 && "col-span-full"),
|
|
258
|
+
children: w(e)
|
|
257
259
|
},
|
|
258
260
|
e.name
|
|
259
261
|
)) }),
|
|
260
|
-
/* @__PURE__ */ a("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ a(
|
|
261
|
-
|
|
262
|
+
C && /* @__PURE__ */ a("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ a(
|
|
263
|
+
j,
|
|
262
264
|
{
|
|
263
265
|
type: "submit",
|
|
264
|
-
disabled: !
|
|
265
|
-
isLoading:
|
|
266
|
+
disabled: !S || !k || h,
|
|
267
|
+
isLoading: h,
|
|
266
268
|
children: g
|
|
267
269
|
}
|
|
268
270
|
) })
|
|
269
271
|
] });
|
|
270
272
|
};
|
|
271
273
|
export {
|
|
272
|
-
|
|
274
|
+
X as AppForm
|
|
273
275
|
};
|
|
@@ -7,9 +7,10 @@ import { Popover as I, PopoverTrigger as E, PopoverContent as R } from "./popove
|
|
|
7
7
|
import { cn as T } from "../../lib/utils.js";
|
|
8
8
|
import * as x from "react";
|
|
9
9
|
import { useEffect as V } from "react";
|
|
10
|
+
import { it as q } from "../../node_modules/date-fns/locale/it.js";
|
|
10
11
|
import { formatDate as m } from "../../node_modules/date-fns/format.js";
|
|
11
|
-
import { isSameDay as
|
|
12
|
-
function
|
|
12
|
+
import { isSameDay as A } from "../../node_modules/date-fns/isSameDay.js";
|
|
13
|
+
function X({
|
|
13
14
|
value: e,
|
|
14
15
|
onChange: c,
|
|
15
16
|
placeholder: b = "Seleziona data",
|
|
@@ -21,7 +22,7 @@ function U({
|
|
|
21
22
|
firstDate: a,
|
|
22
23
|
lastDate: p,
|
|
23
24
|
availableDates: l,
|
|
24
|
-
locale: C,
|
|
25
|
+
locale: C = q,
|
|
25
26
|
initialCalendarMonth: u,
|
|
26
27
|
customCalendarProps: P
|
|
27
28
|
}) {
|
|
@@ -33,7 +34,7 @@ function U({
|
|
|
33
34
|
let s = [];
|
|
34
35
|
return a && s.push({ before: a }), p && s.push({ after: p }), l?.length && s.push(
|
|
35
36
|
(n) => !l.some(
|
|
36
|
-
(M) =>
|
|
37
|
+
(M) => A(M, n)
|
|
37
38
|
)
|
|
38
39
|
), t && (s = [!0]), V(() => {
|
|
39
40
|
h(r), g(r || u);
|
|
@@ -88,5 +89,5 @@ function U({
|
|
|
88
89
|
] });
|
|
89
90
|
}
|
|
90
91
|
export {
|
|
91
|
-
|
|
92
|
+
X as DatePicker
|
|
92
93
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
9
9
|
import { ColumnDef } from '@tanstack/react-table';
|
|
10
10
|
import { Command as Command_2 } from 'cmdk';
|
|
11
|
+
import { ComponentProps } from 'react';
|
|
11
12
|
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu';
|
|
12
13
|
import { ControllerProps } from 'react-hook-form';
|
|
13
14
|
import { DayPicker } from 'react-day-picker';
|
|
@@ -146,12 +147,13 @@ declare interface AppEditorProps {
|
|
|
146
147
|
|
|
147
148
|
declare type AppEditorToolbar = "block-format" | "font-format" | "history";
|
|
148
149
|
|
|
149
|
-
export declare const AppForm: ({ items, cols, form, submitText, onSubmit, isSubmitting, }: AppFormProps) => JSX.Element;
|
|
150
|
+
export declare const AppForm: ({ items, cols, form, submitText, onSubmit, isSubmitting, showSubmitButton, }: AppFormProps) => JSX.Element;
|
|
150
151
|
|
|
151
|
-
declare interface AppFormItem {
|
|
152
|
+
export declare interface AppFormItem {
|
|
152
153
|
label: string;
|
|
153
154
|
component: "input" | "select" | "textarea" | "checkbox" | "multiselect" | "datepicker" | "radio" | "switch" | "slider";
|
|
154
155
|
name: string;
|
|
156
|
+
inputType?: ComponentProps<"input">["type"];
|
|
155
157
|
defaultValue?: string | boolean | number | string[] | Date | number[];
|
|
156
158
|
options?: AppSelectOption[];
|
|
157
159
|
disabled?: boolean;
|
|
@@ -164,12 +166,13 @@ declare interface AppFormItem {
|
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
declare interface AppFormProps {
|
|
167
|
-
cols?: "
|
|
169
|
+
cols?: "1" | "2" | "3";
|
|
168
170
|
items: AppFormItem[];
|
|
169
171
|
form: UseFormReturn<any>;
|
|
170
172
|
submitText?: string;
|
|
171
173
|
onSubmit?: (data: any) => void;
|
|
172
174
|
isSubmitting?: boolean;
|
|
175
|
+
showSubmitButton?: boolean;
|
|
173
176
|
}
|
|
174
177
|
|
|
175
178
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { constructFrom as e } from "../constructFrom.js";
|
|
3
|
-
function
|
|
4
|
-
const
|
|
3
|
+
function c(o, ...n) {
|
|
4
|
+
const t = e.bind(
|
|
5
5
|
null,
|
|
6
|
-
n.find((
|
|
6
|
+
o || n.find((r) => typeof r == "object")
|
|
7
7
|
);
|
|
8
|
-
return n.map(
|
|
8
|
+
return n.map(t);
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
|
-
|
|
11
|
+
c as normalizeDates
|
|
12
12
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { normalizeDates as f } from "./_lib/normalizeDates.js";
|
|
3
|
+
import { startOfWeek as r } from "./startOfWeek.js";
|
|
4
|
+
function o(t, a, e) {
|
|
5
|
+
const [i, m] = f(
|
|
6
|
+
e?.in,
|
|
7
|
+
t,
|
|
8
|
+
a
|
|
9
|
+
);
|
|
10
|
+
return +r(i, e) == +r(m, e);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
o as default,
|
|
14
|
+
o as isSameWeek
|
|
15
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const i = {
|
|
3
|
+
lessThanXSeconds: {
|
|
4
|
+
one: "meno di un secondo",
|
|
5
|
+
other: "meno di {{count}} secondi"
|
|
6
|
+
},
|
|
7
|
+
xSeconds: {
|
|
8
|
+
one: "un secondo",
|
|
9
|
+
other: "{{count}} secondi"
|
|
10
|
+
},
|
|
11
|
+
halfAMinute: "alcuni secondi",
|
|
12
|
+
lessThanXMinutes: {
|
|
13
|
+
one: "meno di un minuto",
|
|
14
|
+
other: "meno di {{count}} minuti"
|
|
15
|
+
},
|
|
16
|
+
xMinutes: {
|
|
17
|
+
one: "un minuto",
|
|
18
|
+
other: "{{count}} minuti"
|
|
19
|
+
},
|
|
20
|
+
aboutXHours: {
|
|
21
|
+
one: "circa un'ora",
|
|
22
|
+
other: "circa {{count}} ore"
|
|
23
|
+
},
|
|
24
|
+
xHours: {
|
|
25
|
+
one: "un'ora",
|
|
26
|
+
other: "{{count}} ore"
|
|
27
|
+
},
|
|
28
|
+
xDays: {
|
|
29
|
+
one: "un giorno",
|
|
30
|
+
other: "{{count}} giorni"
|
|
31
|
+
},
|
|
32
|
+
aboutXWeeks: {
|
|
33
|
+
one: "circa una settimana",
|
|
34
|
+
other: "circa {{count}} settimane"
|
|
35
|
+
},
|
|
36
|
+
xWeeks: {
|
|
37
|
+
one: "una settimana",
|
|
38
|
+
other: "{{count}} settimane"
|
|
39
|
+
},
|
|
40
|
+
aboutXMonths: {
|
|
41
|
+
one: "circa un mese",
|
|
42
|
+
other: "circa {{count}} mesi"
|
|
43
|
+
},
|
|
44
|
+
xMonths: {
|
|
45
|
+
one: "un mese",
|
|
46
|
+
other: "{{count}} mesi"
|
|
47
|
+
},
|
|
48
|
+
aboutXYears: {
|
|
49
|
+
one: "circa un anno",
|
|
50
|
+
other: "circa {{count}} anni"
|
|
51
|
+
},
|
|
52
|
+
xYears: {
|
|
53
|
+
one: "un anno",
|
|
54
|
+
other: "{{count}} anni"
|
|
55
|
+
},
|
|
56
|
+
overXYears: {
|
|
57
|
+
one: "più di un anno",
|
|
58
|
+
other: "più di {{count}} anni"
|
|
59
|
+
},
|
|
60
|
+
almostXYears: {
|
|
61
|
+
one: "quasi un anno",
|
|
62
|
+
other: "quasi {{count}} anni"
|
|
63
|
+
}
|
|
64
|
+
}, r = (a, t, o) => {
|
|
65
|
+
let n;
|
|
66
|
+
const e = i[a];
|
|
67
|
+
return typeof e == "string" ? n = e : t === 1 ? n = e.one : n = e.other.replace("{{count}}", t.toString()), o?.addSuffix ? o.comparison && o.comparison > 0 ? "tra " + n : n + " fa" : n;
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
r as formatDistance
|
|
71
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { buildFormatLongFn as t } from "../../_lib/buildFormatLongFn.js";
|
|
3
|
+
const m = {
|
|
4
|
+
full: "EEEE d MMMM y",
|
|
5
|
+
long: "d MMMM y",
|
|
6
|
+
medium: "d MMM y",
|
|
7
|
+
short: "dd/MM/y"
|
|
8
|
+
}, e = {
|
|
9
|
+
full: "HH:mm:ss zzzz",
|
|
10
|
+
long: "HH:mm:ss z",
|
|
11
|
+
medium: "HH:mm:ss",
|
|
12
|
+
short: "HH:mm"
|
|
13
|
+
}, d = {
|
|
14
|
+
full: "{{date}} {{time}}",
|
|
15
|
+
long: "{{date}} {{time}}",
|
|
16
|
+
medium: "{{date}} {{time}}",
|
|
17
|
+
short: "{{date}} {{time}}"
|
|
18
|
+
}, l = {
|
|
19
|
+
date: t({
|
|
20
|
+
formats: m,
|
|
21
|
+
defaultWidth: "full"
|
|
22
|
+
}),
|
|
23
|
+
time: t({
|
|
24
|
+
formats: e,
|
|
25
|
+
defaultWidth: "full"
|
|
26
|
+
}),
|
|
27
|
+
dateTime: t({
|
|
28
|
+
formats: d,
|
|
29
|
+
defaultWidth: "full"
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
l as formatLong
|
|
34
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isSameWeek as l } from "../../../isSameWeek.js";
|
|
3
|
+
const a = [
|
|
4
|
+
"domenica",
|
|
5
|
+
"lunedì",
|
|
6
|
+
"martedì",
|
|
7
|
+
"mercoledì",
|
|
8
|
+
"giovedì",
|
|
9
|
+
"venerdì",
|
|
10
|
+
"sabato"
|
|
11
|
+
];
|
|
12
|
+
function i(e) {
|
|
13
|
+
switch (e) {
|
|
14
|
+
case 0:
|
|
15
|
+
return "'domenica scorsa alle' p";
|
|
16
|
+
default:
|
|
17
|
+
return "'" + a[e] + " scorso alle' p";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function s(e) {
|
|
21
|
+
return "'" + a[e] + " alle' p";
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
switch (e) {
|
|
25
|
+
case 0:
|
|
26
|
+
return "'domenica prossima alle' p";
|
|
27
|
+
default:
|
|
28
|
+
return "'" + a[e] + " prossimo alle' p";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const u = {
|
|
32
|
+
lastWeek: (e, r, o) => {
|
|
33
|
+
const t = e.getDay();
|
|
34
|
+
return l(e, r, o) ? s(t) : i(t);
|
|
35
|
+
},
|
|
36
|
+
yesterday: "'ieri alle' p",
|
|
37
|
+
today: "'oggi alle' p",
|
|
38
|
+
tomorrow: "'domani alle' p",
|
|
39
|
+
nextWeek: (e, r, o) => {
|
|
40
|
+
const t = e.getDay();
|
|
41
|
+
return l(e, r, o) ? s(t) : c(t);
|
|
42
|
+
},
|
|
43
|
+
other: "P"
|
|
44
|
+
}, f = (e, r, o, t) => {
|
|
45
|
+
const n = u[e];
|
|
46
|
+
return typeof n == "function" ? n(r, o, t) : n;
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
f as formatRelative
|
|
50
|
+
};
|